From 222b47627f9cce81733ed10c79d8beb4516266ef Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 31 Jul 2023 17:43:47 +0200 Subject: [PATCH] fix 4MB PIO script upload regression --- pio-tools/get_flash_size.py | 22 ++++++++++++---------- pio-tools/post_esp32.py | 7 ++++--- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pio-tools/get_flash_size.py b/pio-tools/get_flash_size.py index 7d1bf09f5..c0480d854 100644 --- a/pio-tools/get_flash_size.py +++ b/pio-tools/get_flash_size.py @@ -29,15 +29,17 @@ if "upload" in COMMAND_LINE_TARGETS: old_maximum_size = env.BoardConfig().get("upload.maximum_size") new_maximum_size = int(size.split("MB")[0]) * 0x100000 - extra_flags = env.BoardConfig().get("build.extra_flags").split(" ") - new_flags = "" - for flag in extra_flags: - if flag.startswith("-DESP32"): - flag = f"-DESP32_{size}" - new_flags += flag + " " - env.BoardConfig().update("build.extra_flags",new_flags) - env.BoardConfig().update("upload.flash_size",size) + if new_maximum_size > old_maximum_size: - env.BoardConfig().update("upload.maximum_size", new_maximum_size) + extra_flags = env.BoardConfig().get("build.extra_flags").split(" ") + new_flags = "" + for flag in extra_flags: + if flag.startswith("-DESP32"): + flag = f"-DESP32_{size}" + new_flags += flag + " " + env.BoardConfig().update("build.extra_flags",new_flags) + env.BoardConfig().update("upload.flash_size",size) - env.Replace(TASMOTA_flash_size=size) \ No newline at end of file + env.BoardConfig().update("upload.maximum_size", new_maximum_size) + + env.Replace(TASMOTA_flash_size=size) \ No newline at end of file diff --git a/pio-tools/post_esp32.py b/pio-tools/post_esp32.py index 33e9ffa7e..facff33e7 100644 --- a/pio-tools/post_esp32.py +++ b/pio-tools/post_esp32.py @@ -74,10 +74,11 @@ def patch_partitions_bin(size_string): def esp32_detect_flashsize(): if not "upload" in COMMAND_LINE_TARGETS: return "4MB",False - try: - return env.get("TASMOTA_flash_size"),True - except: + size = env.get("TASMOTA_flash_size") + if size == None: return "4MB",False + else: + return size,True def esp32_create_chip_string(chip): tasmota_platform = env.subst("$BUILD_DIR").split(os.path.sep)[-1]