From 56ce44b7ca1a8c284adfb940e457e4dd919616b0 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 17:40:59 +0000 Subject: [PATCH] Flash with program_esp on the first debug session too configure_debug_session switched the GDB load to program_esp only when every flash image already existed. `pio debug` configures the session before it builds the firmware, so on the first session of a clean build the bootloader and partition table were missing and GDB fell back to `load`. For ESP-IDF images that writes the new ELF sections into flash through the mapping of the application already there and leaves an image that no longer matches its checksum: on an ESP32-S31 the chip then reset in a loop and never reached app_main. The images are build outputs that exist by the time GDB runs the load commands, so stop requiring them up front. Sessions started on an already built project were not affected. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TyrpBtw45nhJDbpwhXbBbd --- platform.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform.py b/platform.py index fe4f8ecae..b90069485 100644 --- a/platform.py +++ b/platform.py @@ -286,10 +286,12 @@ def configure_debug_session(self, debug_config): ["-c", "adapter speed %s" % (debug_config.speed or "5000")] ) + # The images may not exist yet: `pio debug` configures the session + # before building them, and falling back to GDB `load` would write + # the new sections over the application already in flash ignore_conds = [ debug_config.load_cmds != ["load"], not flash_images, - not all([os.path.isfile(item["path"]) for item in flash_images]), ] if any(ignore_conds):