From 9779079637f064aa0c356daad9b763480e4c867f Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 13 Feb 2024 15:55:20 +0100 Subject: [PATCH] Implement `board_img_freq` needed since the build recipe in Arduino has changed. https://github.com/espressif/arduino-esp32/blob/master/platform.txt#L159 --- builder/main.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/builder/main.py b/builder/main.py index 1f493503a..be3332752 100644 --- a/builder/main.py +++ b/builder/main.py @@ -59,6 +59,15 @@ def _get_board_memory_type(env): ) +def _get_board_img_freq(env): + board_config = env.BoardConfig() + img_freq = board_config.get("build.img_freq", "") + if img_freq =="": + img_freq = board_config.get("build.f_flash", "") + img_freq = str(img_freq).replace("L", "") + return str(int(int(img_freq) / 1000000)) + "m" + + def _get_board_f_flash(env): frequency = env.subst("$BOARD_F_FLASH") frequency = str(frequency).replace("L", "") @@ -225,6 +234,7 @@ def __fetch_fs_size(target, source, env): env.Replace( __get_board_boot_mode=_get_board_boot_mode, __get_board_f_flash=_get_board_f_flash, + __get_board_img_freq=_get_board_img_freq, __get_board_flash_mode=_get_board_flash_mode, __get_board_memory_type=_get_board_memory_type, @@ -296,7 +306,7 @@ def __fetch_fs_size(target, source, env): '"$PYTHONEXE" "$OBJCOPY"', "--chip", mcu, "elf2image", "--flash_mode", "${__get_board_flash_mode(__env__)}", - "--flash_freq", "${__get_board_f_flash(__env__)}", + "--flash_freq", "${__get_board_img_freq(__env__)}", "--flash_size", board.get("upload.flash_size", "4MB"), "-o", "$TARGET", "$SOURCES" ]), "Building $TARGET"), @@ -432,7 +442,7 @@ def __fetch_fs_size(target, source, env): "--after", board.get("upload.after_reset", "hard_reset"), "write_flash", "-z", "--flash_mode", "${__get_board_flash_mode(__env__)}", - "--flash_freq", "${__get_board_f_flash(__env__)}", + "--flash_freq", "${__get_board_img_freq(__env__)}", "--flash_size", board.get("upload.flash_size", "detect") ], UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS $ESP32_APP_OFFSET $SOURCE' @@ -450,7 +460,7 @@ def __fetch_fs_size(target, source, env): "--after", board.get("upload.after_reset", "hard_reset"), "write_flash", "-z", "--flash_mode", "${__get_board_flash_mode(__env__)}", - "--flash_freq", "${__get_board_f_flash(__env__)}", + "--flash_freq", "${__get_board_img_freq(__env__)}", "--flash_size", board.get("upload.flash_size", "detect"), "$FS_START" ],