5
5
6
6
from runners .core import RunnerCaps , ZephyrBinaryRunner
7
7
8
+ DEFAULT_PROBE_RS_GDB_HOST = 'localhost'
9
+ DEFAULT_PROBE_RS_GDB_PORT = 1337
8
10
9
11
class ProbeRsBinaryRunner (ZephyrBinaryRunner ):
10
12
'''Runner front-end for probe-rs.'''
11
13
12
14
def __init__ (self , cfg , chip ,
13
15
probe_rs = 'probe-rs' ,
16
+ gdb_host = DEFAULT_PROBE_RS_GDB_HOST ,
17
+ gdb_port = DEFAULT_PROBE_RS_GDB_PORT ,
14
18
dev_id = None ,
15
19
erase = False ,
16
20
tool_opt = None ):
@@ -29,13 +33,17 @@ def __init__(self, cfg, chip,
29
33
30
34
self .elf_name = cfg .elf_file
31
35
36
+ self .gdb_cmd = cfg .gdb
37
+ self .gdb_host = gdb_host
38
+ self .gdb_port = gdb_port
39
+
32
40
@classmethod
33
41
def name (cls ):
34
42
return 'probe-rs'
35
43
36
44
@classmethod
37
45
def capabilities (cls ):
38
- return RunnerCaps (commands = {'flash' },
46
+ return RunnerCaps (commands = {'flash' , 'debug' , 'debugserver' },
39
47
dev_id = True ,
40
48
erase = True ,
41
49
tool_opt = True )
@@ -46,6 +54,11 @@ def do_add_parser(cls, parser):
46
54
help = 'chip name' )
47
55
parser .add_argument ('--probe-rs' , default = 'probe-rs' ,
48
56
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
+
49
62
50
63
@classmethod
51
64
def dev_id_help (cls ) -> str :
@@ -68,6 +81,8 @@ def do_run(self, command, **kwargs):
68
81
self .require (self .probe_rs )
69
82
if command == 'flash' :
70
83
self .do_flash (** kwargs )
84
+ elif command in ('debug' , 'debugserver' ):
85
+ self .do_debug_debugserver (command , ** kwargs )
71
86
72
87
def do_flash (self , ** kwargs ):
73
88
download_args = []
@@ -80,3 +95,12 @@ def do_flash(self, **kwargs):
80
95
81
96
self .check_call ([self .probe_rs , 'reset' ]
82
97
+ 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