Skip to content

Commit 2ccfd22

Browse files
carlescuficfriedt
authored andcommitted
runners: pyocd: Convert to -i/--dev-id
Remove the previous pyocd-specific --board-id option and switch to the common -i/--dev-id one. Signed-off-by: Carles Cufi <[email protected]>
1 parent 285c2ca commit 2ccfd22

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

scripts/west_commands/runners/pyocd.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ class PyOcdBinaryRunner(ZephyrBinaryRunner):
1919

2020
def __init__(self, cfg, target,
2121
pyocd='pyocd',
22-
flash_addr=0x0, erase=False, flash_opts=None,
22+
dev_id=None, flash_addr=0x0, erase=False, flash_opts=None,
2323
gdb_port=DEFAULT_PYOCD_GDB_PORT,
2424
telnet_port=DEFAULT_PYOCD_TELNET_PORT, tui=False,
2525
pyocd_config=None,
26-
board_id=None, daparg=None, frequency=None, tool_opt=None):
26+
daparg=None, frequency=None, tool_opt=None):
2727
super().__init__(cfg)
2828

2929
default = path.join(cfg.board_dir, 'support', 'pyocd.yaml')
@@ -53,8 +53,8 @@ def __init__(self, cfg, target,
5353
self.pyocd_config_args = pyocd_config_args
5454

5555
board_args = []
56-
if board_id is not None:
57-
board_args = ['-u', board_id]
56+
if dev_id is not None:
57+
board_args = ['-u', dev_id]
5858
self.board_args = board_args
5959

6060
daparg_args = []
@@ -81,7 +81,12 @@ def name(cls):
8181
@classmethod
8282
def capabilities(cls):
8383
return RunnerCaps(commands={'flash', 'debug', 'debugserver', 'attach'},
84-
flash_addr=True, erase=True)
84+
dev_id=True, flash_addr=True, erase=True)
85+
86+
@classmethod
87+
def dev_id_help(cls) -> str:
88+
return '''Device identifier. Use it to select the probe's unique ID
89+
or substring thereof.'''
8590

8691
@classmethod
8792
def do_add_parser(cls, parser):
@@ -105,8 +110,8 @@ def do_add_parser(cls, parser):
105110
DEFAULT_PYOCD_TELNET_PORT))
106111
parser.add_argument('--tui', default=False, action='store_true',
107112
help='if given, GDB uses -tui')
108-
parser.add_argument('--board-id',
109-
help='ID of board to flash, default is to prompt')
113+
parser.add_argument('--board-id', dest='dev_id',
114+
help='Deprecated: use -i/--dev-id instead')
110115
parser.add_argument('--tool-opt',
111116
help='''Additional options for pyocd Commander,
112117
e.g. \'--script=user.py\' ''')
@@ -121,7 +126,7 @@ def do_create(cls, cfg, args):
121126
pyocd=args.pyocd,
122127
flash_addr=flash_addr, erase=args.erase, flash_opts=args.flash_opt,
123128
gdb_port=args.gdb_port, telnet_port=args.telnet_port, tui=args.tui,
124-
board_id=args.board_id, daparg=args.daparg,
129+
dev_id=args.dev_id, daparg=args.daparg,
125130
frequency=args.frequency,
126131
tool_opt=args.tool_opt)
127132

scripts/west_commands/tests/test_pyocd.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
TEST_PYOCD = 'test-pyocd'
2020
TEST_ADDR = 0xadd
21-
TEST_BOARD_ID = 'test-board-id'
21+
TEST_DEV_ID = 'test-dev-id'
2222
TEST_FREQUENCY = 'test-frequency'
2323
TEST_DAPARG = 'test-daparg'
2424
TEST_TARGET = 'test-target'
@@ -34,7 +34,7 @@
3434
'gdb_port': TEST_GDB_PORT,
3535
'telnet_port': TEST_TELNET_PORT,
3636
'tui': False,
37-
'board_id': TEST_BOARD_ID,
37+
'dev_id': TEST_DEV_ID,
3838
'frequency': TEST_FREQUENCY,
3939
'daparg': TEST_DAPARG,
4040
'tool_opt': TEST_TOOL_OPT,
@@ -49,7 +49,7 @@
4949
TEST_FLASH_OPTS] +
5050
['--gdb-port', str(TEST_GDB_PORT),
5151
'--telnet-port', str(TEST_TELNET_PORT),
52-
'--board-id', TEST_BOARD_ID,
52+
'--dev-id', TEST_DEV_ID,
5353
'--frequency', str(TEST_FREQUENCY),
5454
'--tool-opt', TEST_TOOL_OPT])
5555

@@ -71,7 +71,7 @@
7171
'flash',
7272
'-e', 'sector',
7373
'-a', hex(TEST_ADDR), '-da', TEST_DAPARG,
74-
'-t', TEST_TARGET, '-u', TEST_BOARD_ID,
74+
'-t', TEST_TARGET, '-u', TEST_DEV_ID,
7575
'-f', TEST_FREQUENCY,
7676
TEST_TOOL_OPT] +
7777
TEST_FLASH_OPTS +
@@ -86,7 +86,7 @@
8686
'-p', str(TEST_GDB_PORT),
8787
'-T', str(TEST_TELNET_PORT),
8888
'-t', TEST_TARGET,
89-
'-u', TEST_BOARD_ID,
89+
'-u', TEST_DEV_ID,
9090
'-f', TEST_FREQUENCY,
9191
TEST_TOOL_OPT]
9292
DEBUG_ALL_EXPECTED_CLIENT = [RC_GDB, RC_KERNEL_ELF,
@@ -112,7 +112,7 @@
112112
'-p', str(TEST_GDB_PORT),
113113
'-T', str(TEST_TELNET_PORT),
114114
'-t', TEST_TARGET,
115-
'-u', TEST_BOARD_ID,
115+
'-u', TEST_DEV_ID,
116116
'-f', TEST_FREQUENCY,
117117
TEST_TOOL_OPT]
118118
DEBUGSERVER_DEF_EXPECTED_CALL = ['pyocd',

0 commit comments

Comments
 (0)