Skip to content

Commit c7e97bb

Browse files
tpamborfabiobaltieri
authored andcommitted
runners: probe-rs: Support debug and debugserver
Add support for west debug and west debugserver to the probe-rs runner. Signed-off-by: Tim Pambor <[email protected]>
1 parent 1fbfb1b commit c7e97bb

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

scripts/west_commands/runners/probe_rs.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55

66
from runners.core import RunnerCaps, ZephyrBinaryRunner
77

8+
DEFAULT_PROBE_RS_GDB_HOST = 'localhost'
9+
DEFAULT_PROBE_RS_GDB_PORT = 1337
810

911
class ProbeRsBinaryRunner(ZephyrBinaryRunner):
1012
'''Runner front-end for probe-rs.'''
1113

1214
def __init__(self, cfg, chip,
1315
probe_rs='probe-rs',
16+
gdb_host=DEFAULT_PROBE_RS_GDB_HOST,
17+
gdb_port=DEFAULT_PROBE_RS_GDB_PORT,
1418
dev_id=None,
1519
erase=False,
1620
tool_opt=None):
@@ -29,13 +33,17 @@ def __init__(self, cfg, chip,
2933

3034
self.elf_name = cfg.elf_file
3135

36+
self.gdb_cmd = cfg.gdb
37+
self.gdb_host = gdb_host
38+
self.gdb_port = gdb_port
39+
3240
@classmethod
3341
def name(cls):
3442
return 'probe-rs'
3543

3644
@classmethod
3745
def capabilities(cls):
38-
return RunnerCaps(commands={'flash'},
46+
return RunnerCaps(commands={'flash', 'debug', 'debugserver'},
3947
dev_id=True,
4048
erase=True,
4149
tool_opt=True)
@@ -46,6 +54,11 @@ def do_add_parser(cls, parser):
4654
help='chip name')
4755
parser.add_argument('--probe-rs', default='probe-rs',
4856
help='path to probe-rs tool, default is probe-rs')
57+
parser.add_argument('--gdb-host', default=DEFAULT_PROBE_RS_GDB_HOST,
58+
help=f'probe-rs gdb host, defaults to {DEFAULT_PROBE_RS_GDB_HOST}')
59+
parser.add_argument('--gdb-port', default=DEFAULT_PROBE_RS_GDB_PORT,
60+
help=f'probe-rs gdb port, defaults to {DEFAULT_PROBE_RS_GDB_PORT}')
61+
4962

5063
@classmethod
5164
def dev_id_help(cls) -> str:
@@ -68,6 +81,8 @@ def do_run(self, command, **kwargs):
6881
self.require(self.probe_rs)
6982
if command == 'flash':
7083
self.do_flash(**kwargs)
84+
elif command in ('debug', 'debugserver'):
85+
self.do_debug_debugserver(command, **kwargs)
7186

7287
def do_flash(self, **kwargs):
7388
download_args = []
@@ -80,3 +95,12 @@ def do_flash(self, **kwargs):
8095

8196
self.check_call([self.probe_rs, 'reset']
8297
+ self.args)
98+
99+
def do_debug_debugserver(self, command, **kwargs):
100+
debug_args = ['--gdb-connection-string', f"{self.gdb_host}:{self.gdb_port}"]
101+
if command == 'debug':
102+
debug_args += [self.elf_name]
103+
debug_args += ['--gdb', self.gdb_cmd]
104+
105+
self.check_call([self.probe_rs, 'gdb']
106+
+ self.args + debug_args)

0 commit comments

Comments
 (0)