From 5bd7342ff434fc30498ab31b438073f7eb4f9218 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 20 Oct 2025 15:19:06 -1000 Subject: [PATCH] wip --- .../components/esp8266/testing_mode.py.script | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/esphome/components/esp8266/testing_mode.py.script b/esphome/components/esp8266/testing_mode.py.script index 0b59c2e000..b1e476ca29 100644 --- a/esphome/components/esp8266/testing_mode.py.script +++ b/esphome/components/esp8266/testing_mode.py.script @@ -105,30 +105,31 @@ if testing_mode: # Create custom linker script immediately (before linker command is built) build_dir = env.subst("$BUILD_DIR") ldscript = env.GetProjectOption("board_build.ldscript", "") + assert ldscript, "No linker script configured in board_build.ldscript" - if ldscript: - framework_dir = env.PioPlatform().get_package_dir("framework-arduinoespressif8266") - if framework_dir: - sdk_ld = os.path.join(framework_dir, "tools", "sdk", "ld", ldscript) - custom_ld = os.path.join(build_dir, f"testing_{ldscript}") + framework_dir = env.PioPlatform().get_package_dir("framework-arduinoespressif8266") + assert framework_dir is not None, "Could not find framework-arduinoespressif8266 package" - if os.path.exists(sdk_ld) and not os.path.exists(custom_ld): - # Read and patch the SDK linker script - with open(sdk_ld, "r") as f: - content = f.read() + sdk_ld = os.path.join(framework_dir, "tools", "sdk", "ld", ldscript) + custom_ld = os.path.join(build_dir, f"testing_{ldscript}") - patched_content = apply_memory_patches(content) + if os.path.exists(sdk_ld) and not os.path.exists(custom_ld): + # Read and patch the SDK linker script + with open(sdk_ld, "r") as f: + content = f.read() - # Write custom linker script - with open(custom_ld, "w") as f: - f.write(patched_content) + patched_content = apply_memory_patches(content) - print(f"ESPHome: Created custom linker script: {custom_ld}") + # Write custom linker script + with open(custom_ld, "w") as f: + f.write(patched_content) - # Tell the linker to use our custom script - if os.path.exists(custom_ld): - env.Replace(LDSCRIPT_PATH=custom_ld) - print(f"ESPHome: Using custom linker script with patched memory limits") + print(f"ESPHome: Created custom linker script: {custom_ld}") + + # Tell the linker to use our custom script + assert os.path.exists(custom_ld), f"Custom linker script not found: {custom_ld}" + env.Replace(LDSCRIPT_PATH=custom_ld) + print(f"ESPHome: Using custom linker script with patched memory limits") # Hook to patch local.eagle.app.v6.common.ld after it's created env.AddPreAction("$BUILD_DIR/${PROGNAME}.elf", patch_local_linker_script)