From fe61e4eacd28ecfae1ed09dfbf55bb99394aafd6 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 29 Jul 2025 14:18:40 +1200 Subject: [PATCH] [esp32] Fix post build --- esphome/components/esp32/post_build.py.script | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/esphome/components/esp32/post_build.py.script b/esphome/components/esp32/post_build.py.script index 6e0e439011..98320ee2d3 100644 --- a/esphome/components/esp32/post_build.py.script +++ b/esphome/components/esp32/post_build.py.script @@ -51,9 +51,12 @@ def merge_factory_bin(source, target, env): continue file_path = pathlib.Path(str(fname)) if file_path.exists(): - sections.append((addr, str(file_path))) + sections.append((addr, file_path)) else: print(f"Info: {file_path.name} not found — skipping") + if sections: + # Append main firmware to sections + sections.append(("0x10000", firmware_path)) # 3. Final fallback: guess standard image locations if not sections: @@ -66,7 +69,7 @@ def merge_factory_bin(source, target, env): ] for addr, file_path in guesses: if file_path.exists(): - sections.append((addr, str(file_path))) + sections.append((addr, file_path)) else: print(f"Info: {file_path.name} not found — skipping") @@ -77,20 +80,19 @@ def merge_factory_bin(source, target, env): output_path = firmware_path.with_suffix(".factory.bin") cmd = [ + f'"{env.subst("$PYTHONEXE")}"', "-m", "esptool", "--chip", chip, "merge_bin", "--flash_size", flash_size, "--output", str(output_path) ] for addr, file_path in sections: - cmd += [addr, file_path] + cmd += [addr, str(file_path)] + print(f"Merging binaries into {output_path}") result = env.Execute( - env.VerboseAction( - f"{env.subst('$PYTHONEXE')} -m esptool " + " ".join(cmd), - "Merging binaries with esptool" - ) + env.VerboseAction(" ".join(cmd), "Merging binaries with esptool") ) if result == 0: