Skip to content

Commit 2061baf

Browse files
committed
Implement Platform::configure_debug_session interface (PlatformIO Core 5.2+)
1 parent 4f15087 commit 2061baf

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

platform.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,43 @@ def _add_dynamic_options(self, board):
161161
board.manifest["debug"] = debug
162162
return board
163163

164+
def configure_debug_session(self, debug_config):
165+
build_extra_data = debug_config.build_data.get("extra", {})
166+
flash_images = build_extra_data.get("flash_images", [])
167+
168+
if "openocd" in (debug_config.server or {}).get("executable", ""):
169+
debug_config.server["arguments"].extend(
170+
["-c", "adapter_khz %s" % (debug_config.speed or "5000")]
171+
)
172+
173+
ignore_conds = [
174+
debug_config.load_cmds != ["load"],
175+
not flash_images,
176+
not all([os.path.isfile(item["path"]) for item in flash_images]),
177+
]
178+
179+
if any(ignore_conds):
180+
return
181+
182+
load_cmds = [
183+
'monitor program_esp "{{{path}}}" {offset} verify'.format(
184+
path=fs.to_unix_path(item["path"]), offset=item["offset"]
185+
)
186+
for item in flash_images
187+
]
188+
load_cmds.append(
189+
'monitor program_esp "{%s.bin}" %s verify'
190+
% (
191+
fs.to_unix_path(debug_config.build_data["prog_path"][:-4]),
192+
build_extra_data.get("application_offset", "0x10000"),
193+
)
194+
)
195+
debug_config.load_cmds = load_cmds
196+
164197
def configure_debug_options(self, initial_debug_options, ide_data):
198+
"""
199+
Deprecated. Remove method when PlatformIO Core 5.2 is released
200+
"""
165201
ide_extra_data = ide_data.get("extra", {})
166202
flash_images = ide_extra_data.get("flash_images", [])
167203
debug_options = copy.deepcopy(initial_debug_options)

0 commit comments

Comments
 (0)