west: openocd: support pre init command option
With ST boards it is possible to specify the board ID when flashing using openocd. This is very useful when having multiple devices connected. This change allows us to address a device directly: west flash -- --cmd-pre-init "hla_serial 066BFF535254887767174558" This needs to be called before init, hence the new option. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
842e1d4dd1
commit
b61f86d2c0
1 changed files with 13 additions and 3 deletions
|
@ -17,7 +17,8 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
|
|||
'''Runner front-end for openocd.'''
|
||||
|
||||
def __init__(self, cfg,
|
||||
pre_cmd=None, load_cmd=None, verify_cmd=None, post_cmd=None,
|
||||
pre_init_cmd=None, pre_cmd=None, load_cmd=None, verify_cmd=None,
|
||||
post_cmd=None,
|
||||
tui=None, config=None,
|
||||
tcl_port=DEFAULT_OPENOCD_TCL_PORT,
|
||||
telnet_port=DEFAULT_OPENOCD_TELNET_PORT,
|
||||
|
@ -38,6 +39,7 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
|
|||
self.elf_name = cfg.elf_file
|
||||
self.load_cmd = load_cmd
|
||||
self.verify_cmd = verify_cmd
|
||||
self.pre_init_cmd = pre_init_cmd
|
||||
self.pre_cmd = pre_cmd
|
||||
self.post_cmd = post_cmd
|
||||
self.tcl_port = tcl_port
|
||||
|
@ -55,6 +57,8 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
|
|||
parser.add_argument('--config',
|
||||
help='if given, override default config file')
|
||||
# Options for flashing:
|
||||
parser.add_argument('--cmd-pre-init',
|
||||
help='Command to run before calling init')
|
||||
parser.add_argument('--cmd-pre-load',
|
||||
help='Command to run before flashing')
|
||||
parser.add_argument('--cmd-load',
|
||||
|
@ -80,6 +84,7 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
|
|||
def create(cls, cfg, args):
|
||||
return OpenOcdBinaryRunner(
|
||||
cfg,
|
||||
pre_init_cmd=args.cmd_pre_init,
|
||||
pre_cmd=args.cmd_pre_load, load_cmd=args.cmd_load,
|
||||
verify_cmd=args.cmd_verify, post_cmd=args.cmd_post_verify,
|
||||
tui=args.tui, config=args.config,
|
||||
|
@ -109,14 +114,19 @@ class OpenOcdBinaryRunner(ZephyrBinaryRunner):
|
|||
if self.pre_cmd is not None:
|
||||
pre_cmd = ['-c', self.pre_cmd]
|
||||
|
||||
pre_init_cmd = []
|
||||
if self.pre_init_cmd is not None:
|
||||
pre_init_cmd = ['-c', self.pre_init_cmd]
|
||||
|
||||
post_cmd = []
|
||||
if self.post_cmd is not None:
|
||||
post_cmd = ['-c', self.post_cmd]
|
||||
|
||||
self.logger.info('Flashing file: {}'.format(self.hex_name))
|
||||
cmd = (self.openocd_cmd +
|
||||
['-f', self.openocd_config,
|
||||
'-c', 'init',
|
||||
['-f', self.openocd_config] +
|
||||
pre_init_cmd +
|
||||
['-c', 'init',
|
||||
'-c', 'targets'] +
|
||||
pre_cmd +
|
||||
['-c', 'reset halt',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue