Skip to content

Commit 7864df3

Browse files
committed
Allow overriding debug adapter speed using "debug_speed" option
1 parent 86ef82e commit 7864df3

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

builder/main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _jlink_cmd_script(env, source):
171171
UPLOADER="JLink.exe" if system() == "Windows" else "JLinkExe",
172172
UPLOADERFLAGS=[
173173
"-device", board.get("debug", {}).get("jlink_device"),
174-
"-speed", "4000",
174+
"-speed", env.GetProjectOption("debug_speed", "4000"),
175175
"-if", ("jtag" if upload_protocol == "jlink-jtag" else "swd"),
176176
"-autoconnect", "1",
177177
"-NoGui", "1"
@@ -278,6 +278,10 @@ def __configure_upload_port(env):
278278
]
279279
openocd_args.extend(
280280
debug_tools.get(upload_protocol).get("server").get("arguments", []))
281+
if env.GetProjectOption("debug_speed"):
282+
openocd_args.extend(
283+
["-c", "adapter speed %s" % env.GetProjectOption("debug_speed")]
284+
)
281285
openocd_args.extend([
282286
"-c", "program {$SOURCE} %s verify reset; shutdown;" %
283287
board.get("upload.offset_address", "")

platform.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import copy
1516
import json
1617
import os
1718

@@ -120,21 +121,21 @@ def _add_default_debug_tools(self, board):
120121
upload_protocols = board.manifest.get("upload", {}).get(
121122
"protocols", [])
122123
if "tools" not in debug:
123-
debug['tools'] = {}
124+
debug["tools"] = {}
124125

125126
# BlackMagic, J-Link, ST-Link
126127
for link in ("blackmagic", "jlink", "stlink", "cmsis-dap"):
127-
if link not in upload_protocols or link in debug['tools']:
128+
if link not in upload_protocols or link in debug["tools"]:
128129
continue
129130
if link == "blackmagic":
130-
debug['tools']['blackmagic'] = {
131+
debug["tools"]["blackmagic"] = {
131132
"hwids": [["0x1d50", "0x6018"]],
132133
"require_debug_port": True
133134
}
134135
elif link == "jlink":
135136
assert debug.get("jlink_device"), (
136137
"Missed J-Link Device ID for %s" % board.id)
137-
debug['tools'][link] = {
138+
debug["tools"][link] = {
138139
"server": {
139140
"package": "tool-jlink",
140141
"arguments": [
@@ -166,15 +167,31 @@ def _add_default_debug_tools(self, board):
166167
])
167168
server_args.extend(debug.get("openocd_extra_args", []))
168169

169-
debug['tools'][link] = {
170+
debug["tools"][link] = {
170171
"server": {
171172
"package": "tool-openocd",
172173
"executable": "bin/openocd",
173174
"arguments": server_args
174175
}
175176
}
176-
debug['tools'][link]['onboard'] = link in debug.get("onboard_tools", [])
177-
debug['tools'][link]['default'] = link in debug.get("default_tools", [])
177+
debug["tools"][link]["onboard"] = link in debug.get("onboard_tools", [])
178+
debug["tools"][link]["default"] = link in debug.get("default_tools", [])
178179

179-
board.manifest['debug'] = debug
180+
board.manifest["debug"] = debug
180181
return board
182+
183+
def configure_debug_options(self, initial_debug_options, ide_data):
184+
debug_options = copy.deepcopy(initial_debug_options)
185+
server_executable = debug_options["server"]["executable"].lower()
186+
adapter_speed = initial_debug_options.get("speed")
187+
if adapter_speed:
188+
if "openocd" in server_executable:
189+
debug_options["server"]["arguments"].extend(
190+
["-c", "adapter speed %s" % adapter_speed]
191+
)
192+
elif "jlink" in server_executable:
193+
debug_options["server"]["arguments"].extend(
194+
["-speed", adapter_speed]
195+
)
196+
197+
return debug_options

0 commit comments

Comments
 (0)