Skip to content

Commit 8d1b13f

Browse files
committed
Allow overriding debug adapter speed using "debug_speed" option
Resolve platformio#459, platformio#463
1 parent 01034c8 commit 8d1b13f

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

builder/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,10 @@ def __fetch_spiffs_size(target, source, env):
372372
openocd_args.extend(
373373
debug_tools.get(upload_protocol).get("server").get("arguments", []))
374374
openocd_args.extend([
375+
"-c", "adapter_khz %s" % env.GetProjectOption("debug_speed", "5000"),
375376
"-c",
376377
"program_esp {{$SOURCE}} %s verify" %
377-
board.get("upload.offset_address", "$ESP32_APP_OFFSET")
378+
board.get("upload.offset_address", "$ESP32_APP_OFFSET"),
378379
])
379380
for image in env.get("FLASH_EXTRA_IMAGES", []):
380381
openocd_args.extend([

platform.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ def _add_dynamic_options(self, board):
130130
if "openocd_target" in debug
131131
else ("board", debug.get("openocd_board"))
132132
),
133-
"-c",
134-
"adapter_khz %d" % debug.get("adapter_speed", 5000),
135133
]
136134

137135
debug["tools"][link] = {
@@ -164,15 +162,22 @@ def _add_dynamic_options(self, board):
164162
def configure_debug_options(self, initial_debug_options, ide_data):
165163
ide_extra_data = ide_data.get("extra", {})
166164
flash_images = ide_extra_data.get("flash_images", [])
165+
debug_options = copy.deepcopy(initial_debug_options)
166+
167+
if "openocd" in debug_options["server"].get("executable", ""):
168+
debug_options["server"]["arguments"].extend(
169+
["-c", "adapter_khz %s" % (initial_debug_options.get("speed") or "5000")]
170+
)
171+
167172
ignore_conds = [
168173
initial_debug_options["load_cmds"] != ["load"],
169174
not flash_images,
170175
not all([os.path.isfile(item["path"]) for item in flash_images]),
171176
]
177+
172178
if any(ignore_conds):
173-
return initial_debug_options
179+
return debug_options
174180

175-
debug_options = copy.deepcopy(initial_debug_options)
176181
load_cmds = [
177182
'monitor program_esp "{{{path}}}" {offset} verify'.format(
178183
path=fs.to_unix_path(item["path"]), offset=item["offset"]

0 commit comments

Comments
 (0)