west: openocd: Allow to specify FTDI instance by its serial number
To be used in setups with multiple boards attached to the same one host we need to have an ability to specify precisely which JTAG probe to use for a particular board. This is done by passing "ftdi_serial XXX" command to OpenOCD. And the serial ("XXX") is supposed to be passed from higher level, typically via west's options. And exactly for that we add another "openocd" runner option "--serial=XXX" which sets a Tcl's "_ZEPHYR_BOARD_SERIAL" variable that later gets passed to OpenOCD's "ftdi_serial" command. See more discussions on the matter here: https://github.com/zephyrproject-rtos/zephyr/issues/22543 Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
This commit is contained in:
parent
3b60f09583
commit
5a4237ed3b
1 changed files with 7 additions and 4 deletions
|
@ -18,7 +18,7 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
|
|||
|
||||
def __init__(self, cfg, pre_init=None, pre_load=None,
|
||||
load_cmd=None, verify_cmd=None, post_verify=None,
|
||||
tui=None, config=None,
|
||||
tui=None, config=None, serial=None,
|
||||
tcl_port=DEFAULT_OPENOCD_TCL_PORT,
|
||||
telnet_port=DEFAULT_OPENOCD_TELNET_PORT,
|
||||
gdb_port=DEFAULT_OPENOCD_GDB_PORT):
|
||||
|
@ -50,6 +50,7 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
|
|||
self.gdb_port = gdb_port
|
||||
self.gdb_cmd = [cfg.gdb] if cfg.gdb else None
|
||||
self.tui_arg = ['-tui'] if tui else []
|
||||
self.serial = ['-c set _ZEPHYR_BOARD_SERIAL ' + serial] if serial else []
|
||||
|
||||
@classmethod
|
||||
def name(cls):
|
||||
|
@ -59,6 +60,8 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
|
|||
def do_add_parser(cls, parser):
|
||||
parser.add_argument('--config',
|
||||
help='if given, override default config file')
|
||||
parser.add_argument('--serial', default="",
|
||||
help='if given, selects FTDI instance by its serial number, defaults to empty')
|
||||
# Options for flashing:
|
||||
parser.add_argument('--cmd-pre-init', action='append',
|
||||
help='''Command to run before calling init;
|
||||
|
@ -93,7 +96,7 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
|
|||
pre_init=args.cmd_pre_init,
|
||||
pre_load=args.cmd_pre_load, load_cmd=args.cmd_load,
|
||||
verify_cmd=args.cmd_verify, post_verify=args.cmd_post_verify,
|
||||
tui=args.tui, config=args.config,
|
||||
tui=args.tui, config=args.config, serial=args.serial,
|
||||
tcl_port=args.tcl_port, telnet_port=args.telnet_port,
|
||||
gdb_port=args.gdb_port)
|
||||
|
||||
|
@ -138,7 +141,7 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
|
|||
post_verify_cmd.append("-c")
|
||||
post_verify_cmd.append(i)
|
||||
|
||||
cmd = (self.openocd_cmd + self.cfg_cmd +
|
||||
cmd = (self.openocd_cmd + self.serial + self.cfg_cmd +
|
||||
pre_init_cmd + ['-c', 'init',
|
||||
'-c', 'targets'] +
|
||||
pre_load_cmd + ['-c', 'reset halt',
|
||||
|
@ -161,7 +164,7 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
|
|||
pre_init_cmd.append("-c")
|
||||
pre_init_cmd.append(i)
|
||||
|
||||
server_cmd = (self.openocd_cmd + self.cfg_cmd +
|
||||
server_cmd = (self.openocd_cmd + self.serial + self.cfg_cmd +
|
||||
['-c', 'tcl_port {}'.format(self.tcl_port),
|
||||
'-c', 'telnet_port {}'.format(self.telnet_port),
|
||||
'-c', 'gdb_port {}'.format(self.gdb_port)] +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue