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 <tim.pambor@codewrights.de>
This commit is contained in:
Tim Pambor 2025-07-21 13:57:28 +02:00 committed by Fabio Baltieri
parent 1fbfb1bd9a
commit c7e97bb5f8

View File

@ -5,12 +5,16 @@
from runners.core import RunnerCaps, ZephyrBinaryRunner
DEFAULT_PROBE_RS_GDB_HOST = 'localhost'
DEFAULT_PROBE_RS_GDB_PORT = 1337
class ProbeRsBinaryRunner(ZephyrBinaryRunner):
'''Runner front-end for probe-rs.'''
def __init__(self, cfg, chip,
probe_rs='probe-rs',
gdb_host=DEFAULT_PROBE_RS_GDB_HOST,
gdb_port=DEFAULT_PROBE_RS_GDB_PORT,
dev_id=None,
erase=False,
tool_opt=None):
@ -29,13 +33,17 @@ class ProbeRsBinaryRunner(ZephyrBinaryRunner):
self.elf_name = cfg.elf_file
self.gdb_cmd = cfg.gdb
self.gdb_host = gdb_host
self.gdb_port = gdb_port
@classmethod
def name(cls):
return 'probe-rs'
@classmethod
def capabilities(cls):
return RunnerCaps(commands={'flash'},
return RunnerCaps(commands={'flash', 'debug', 'debugserver'},
dev_id=True,
erase=True,
tool_opt=True)
@ -46,6 +54,11 @@ class ProbeRsBinaryRunner(ZephyrBinaryRunner):
help='chip name')
parser.add_argument('--probe-rs', default='probe-rs',
help='path to probe-rs tool, default is probe-rs')
parser.add_argument('--gdb-host', default=DEFAULT_PROBE_RS_GDB_HOST,
help=f'probe-rs gdb host, defaults to {DEFAULT_PROBE_RS_GDB_HOST}')
parser.add_argument('--gdb-port', default=DEFAULT_PROBE_RS_GDB_PORT,
help=f'probe-rs gdb port, defaults to {DEFAULT_PROBE_RS_GDB_PORT}')
@classmethod
def dev_id_help(cls) -> str:
@ -68,6 +81,8 @@ class ProbeRsBinaryRunner(ZephyrBinaryRunner):
self.require(self.probe_rs)
if command == 'flash':
self.do_flash(**kwargs)
elif command in ('debug', 'debugserver'):
self.do_debug_debugserver(command, **kwargs)
def do_flash(self, **kwargs):
download_args = []
@ -80,3 +95,12 @@ class ProbeRsBinaryRunner(ZephyrBinaryRunner):
self.check_call([self.probe_rs, 'reset']
+ self.args)
def do_debug_debugserver(self, command, **kwargs):
debug_args = ['--gdb-connection-string', f"{self.gdb_host}:{self.gdb_port}"]
if command == 'debug':
debug_args += [self.elf_name]
debug_args += ['--gdb', self.gdb_cmd]
self.check_call([self.probe_rs, 'gdb']
+ self.args + debug_args)