From b1cae00429c28ea3db6dd36ac58be5f298dd3dd3 Mon Sep 17 00:00:00 2001 From: Krzysztof Mazur Date: Thu, 23 Feb 2023 21:20:13 +0100 Subject: [PATCH 1/2] Fix CI by updating dependency versions --- patches/gcc-ar-ranlib.patch | 8 ++++---- platformio.ini | 13 +++++-------- scripts/apply_patches.py | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/patches/gcc-ar-ranlib.patch b/patches/gcc-ar-ranlib.patch index 648a24a..7bf02a4 100644 --- a/patches/gcc-ar-ranlib.patch +++ b/patches/gcc-ar-ranlib.patch @@ -1,10 +1,10 @@ diff --git a/builder/main.py b/builder/main.py -index 7802ec6..985ef81 100644 +index a6ca5b0..346d41f 100644 --- a/builder/main.py +++ b/builder/main.py -@@ -131,14 +131,14 @@ if mcu == "esp32c3": - env.Replace( - __get_board_f_flash=_get_board_f_flash, +@@ -203,14 +203,14 @@ env.Replace( + __get_board_flash_mode=_get_board_flash_mode, + __get_board_memory_type=_get_board_memory_type, - AR="%s-elf-ar" % toolchain_arch, + AR="%s-elf-gcc-ar" % toolchain_arch, diff --git a/platformio.ini b/platformio.ini index 507a8b7..c344ce0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,12 +15,8 @@ default_envs = esp32dev ; src_dir = ./src [env:esp32dev] -; 22 Dec 2021: #feature/arduino-idf-master is 33ff4132ef9a79be50552bd89e6fd44b9518643c -platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master -platform_packages = - ; use upstream Git version - ; 01 Jan 2022: #2.0.2 is caef4006af491130136b219c1205bdcf8f08bf2b - framework-arduino-esp32 @ https://github.com/espressif/arduino-esp32#2.0.2 +platform = espressif32 @ 5.3.0 +platform_packages = platformio/framework-arduinoespressif32@^3.20006.221224 board = esp32dev framework = arduino @@ -34,7 +30,8 @@ extra_scripts = pre:scripts/apply_patches.py ; Not using OTAs for now, so this can be used to increase the flash capacity -; board_build.partitions = no_ota.csv +; TODO - using LTO we used to fit without changing partitions, need to investiagte how to achieve that again +board_build.partitions = no_ota.csv build_flags = -DCORE_DEBUG_LEVEL=0 @@ -58,8 +55,8 @@ build_flags = -std=gnu++17 -Wall -Wextra - -flto + build_unflags = -std=gnu++11 ; re-enable lto - afaik it was only disabled because of https://github.com/espressif/esp-idf/issues/3989 diff --git a/scripts/apply_patches.py b/scripts/apply_patches.py index cd9ce84..bb8336f 100644 --- a/scripts/apply_patches.py +++ b/scripts/apply_patches.py @@ -17,7 +17,7 @@ # If the patching fails, you can change the platform package manually and create # a file called `.patching-done` to indicate that. For more details see: # https://github.com/krzmaz/LinakDeskEsp32Controller/issues/13 - if env.Execute("patch %s %s" % (original_file, patched_file)) != 0: + if env.Execute("patch --ignore-whitespace --fuzz 3 --binary %s %s" % (original_file, patched_file)) != 0: raise Exception("Problem while applying platform patches!\n\n" "See scripts/apply_patches.py for more details!\n") From 5d9f3fb64f169faaf3720d888be982b956af007a Mon Sep 17 00:00:00 2001 From: Krzysztof Mazur Date: Tue, 7 Mar 2023 21:54:36 +0100 Subject: [PATCH 2/2] Switch modifying the toolchain from patch to env variables --- patches/gcc-ar-ranlib.patch | 21 --------------------- platformio.ini | 2 +- scripts/apply_patches.py | 28 ---------------------------- scripts/gcc_toolchain.py | 6 ++++++ 4 files changed, 7 insertions(+), 50 deletions(-) delete mode 100644 patches/gcc-ar-ranlib.patch delete mode 100644 scripts/apply_patches.py create mode 100644 scripts/gcc_toolchain.py diff --git a/patches/gcc-ar-ranlib.patch b/patches/gcc-ar-ranlib.patch deleted file mode 100644 index 7bf02a4..0000000 --- a/patches/gcc-ar-ranlib.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/builder/main.py b/builder/main.py -index a6ca5b0..346d41f 100644 ---- a/builder/main.py -+++ b/builder/main.py -@@ -203,14 +203,14 @@ env.Replace( - __get_board_flash_mode=_get_board_flash_mode, - __get_board_memory_type=_get_board_memory_type, - -- AR="%s-elf-ar" % toolchain_arch, -+ AR="%s-elf-gcc-ar" % toolchain_arch, - AS="%s-elf-as" % toolchain_arch, - CC="%s-elf-gcc" % toolchain_arch, - CXX="%s-elf-g++" % toolchain_arch, - GDB="%s-elf-gdb" % toolchain_arch, - OBJCOPY=join( - platform.get_package_dir("tool-esptoolpy") or "", "esptool.py"), -- RANLIB="%s-elf-ranlib" % toolchain_arch, -+ RANLIB="%s-elf-gcc-ranlib" % toolchain_arch, - SIZETOOL="%s-elf-size" % toolchain_arch, - - ARFLAGS=["rc"], diff --git a/platformio.ini b/platformio.ini index c344ce0..2eac507 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,7 +27,7 @@ extra_scripts = scripts/extra_linker_flags.py ; fix the platform package to use gcc-ar and gcc-ranlib to enable lto linker plugin ; more detail: https://embeddedartistry.com/blog/2020/04/13/prefer-gcc-ar-to-ar-in-your-buildsystems/ - pre:scripts/apply_patches.py + pre:scripts/gcc_toolchain.py ; Not using OTAs for now, so this can be used to increase the flash capacity ; TODO - using LTO we used to fit without changing partitions, need to investiagte how to achieve that again diff --git a/scripts/apply_patches.py b/scripts/apply_patches.py deleted file mode 100644 index bb8336f..0000000 --- a/scripts/apply_patches.py +++ /dev/null @@ -1,28 +0,0 @@ - - -from os.path import join, isfile - -Import("env") - -PLATFORM_DIR = env.PioPlatform().get_dir() -patchflag_path = join(PLATFORM_DIR, ".patching-done") - -# patch file only if we didn't do it before -if not isfile(join(PLATFORM_DIR, ".patching-done")): - original_file = join(PLATFORM_DIR, "builder", "main.py") - patched_file = join("patches", "gcc-ar-ranlib.patch") - - assert isfile(original_file) and isfile(patched_file) - - # If the patching fails, you can change the platform package manually and create - # a file called `.patching-done` to indicate that. For more details see: - # https://github.com/krzmaz/LinakDeskEsp32Controller/issues/13 - if env.Execute("patch --ignore-whitespace --fuzz 3 --binary %s %s" % (original_file, patched_file)) != 0: - raise Exception("Problem while applying platform patches!\n\n" - "See scripts/apply_patches.py for more details!\n") - - def _touch(path): - with open(path, "w") as fp: - fp.write("") - - env.Execute(lambda *args, **kwargs: _touch(patchflag_path)) \ No newline at end of file diff --git a/scripts/gcc_toolchain.py b/scripts/gcc_toolchain.py new file mode 100644 index 0000000..b5b0676 --- /dev/null +++ b/scripts/gcc_toolchain.py @@ -0,0 +1,6 @@ +Import("env") + +env.Replace( + AR="xtensa-esp32-elf-gcc-ar", + RANLIB="xtensa-esp32-elf-gcc-ranlib" +) \ No newline at end of file