diff --git a/platform.py b/platform.py index e6cfd4c..65e6505 100644 --- a/platform.py +++ b/platform.py @@ -161,7 +161,43 @@ class Espressif32Platform(PlatformBase): board.manifest["debug"] = debug return board + def configure_debug_session(self, debug_config): + build_extra_data = debug_config.build_data.get("extra", {}) + flash_images = build_extra_data.get("flash_images", []) + + if "openocd" in (debug_config.server or {}).get("executable", ""): + debug_config.server["arguments"].extend( + ["-c", "adapter_khz %s" % (debug_config.speed or "5000")] + ) + + 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): + return + + load_cmds = [ + 'monitor program_esp "{{{path}}}" {offset} verify'.format( + path=fs.to_unix_path(item["path"]), offset=item["offset"] + ) + for item in flash_images + ] + load_cmds.append( + 'monitor program_esp "{%s.bin}" %s verify' + % ( + fs.to_unix_path(debug_config.build_data["prog_path"][:-4]), + build_extra_data.get("application_offset", "0x10000"), + ) + ) + debug_config.load_cmds = load_cmds + def configure_debug_options(self, initial_debug_options, ide_data): + """ + Deprecated. Remove method when PlatformIO Core 5.2 is released + """ ide_extra_data = ide_data.get("extra", {}) flash_images = ide_extra_data.get("flash_images", []) debug_options = copy.deepcopy(initial_debug_options)