Skip to content

Commit

Permalink
west: prepend -c to openocd commands
Browse files Browse the repository at this point in the history
commit 0df4a53 changed the behavior of
how openocd commands are passed to openocd. We used to add -c to each
command, now the commands are being added without -c causing an error.

This adds "-c" to all commands instead of just passing a list.

Also fixes zephyrproject-rtos#20449.

Signed-off-by: Anas Nashif <[email protected]>
Signed-off-by: Martí Bolívar <[email protected]>
  • Loading branch information
nashif committed Nov 12, 2019
1 parent 1ae7ae8 commit c724033
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion boards/common/openocd-nrf5.board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set(pre_init_cmds
)

foreach(cmd ${pre_init_cmds})
board_runner_args(openocd --cmd-pre-init "-c ${cmd}")
board_runner_args(openocd --cmd-pre-init "${cmd}")
endforeach()

include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
36 changes: 31 additions & 5 deletions scripts/west_commands/runners/openocd.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,30 @@ def do_flash(self, **kwargs):
raise ValueError('Cannot flash; verify command is missing')

self.logger.info('Flashing file: {}'.format(self.hex_name))

pre_init_cmd = []
pre_load_cmd = []
post_verify_cmd = []
for i in self.pre_init:
pre_init_cmd.append("-c")
pre_init_cmd.append(i)

for i in self.pre_load:
pre_load_cmd.append("-c")
pre_load_cmd.append(i)

for i in self.post_verify:
post_verify_cmd.append("-c")
post_verify_cmd.append(i)

cmd = (self.openocd_cmd + self.cfg_cmd +
self.pre_init + ['-c', 'init',
pre_init_cmd + ['-c', 'init',
'-c', 'targets'] +
self.pre_load + ['-c', 'reset halt',
pre_load_cmd + ['-c', 'reset halt',
'-c', self.load_cmd + ' ' + self.hex_name,
'-c', 'reset halt'] +
['-c', self.verify_cmd + ' ' + self.hex_name] +
self.post_verify +
post_verify_cmd +
['-c', 'reset run',
'-c', 'shutdown'])
self.check_call(cmd)
Expand All @@ -136,11 +152,16 @@ def do_debug(self, **kwargs):
if self.elf_name is None:
raise ValueError('Cannot debug; no .elf specified')

pre_init_cmd = []
for i in self.pre_init:
pre_init_cmd.append("-c")
pre_init_cmd.append(i)

server_cmd = (self.openocd_cmd + self.cfg_cmd +
['-c', 'tcl_port {}'.format(self.tcl_port),
'-c', 'telnet_port {}'.format(self.telnet_port),
'-c', 'gdb_port {}'.format(self.gdb_port)] +
self.pre_init + ['-c', 'init',
pre_init_cmd + ['-c', 'init',
'-c', 'targets',
'-c', 'halt'])
gdb_cmd = (self.gdb_cmd + self.tui_arg +
Expand All @@ -150,11 +171,16 @@ def do_debug(self, **kwargs):
self.run_server_and_client(server_cmd, gdb_cmd)

def do_debugserver(self, **kwargs):
pre_init_cmd = []
for i in self.pre_init:
pre_init_cmd.append("-c")
pre_init_cmd.append(i)

cmd = (self.openocd_cmd + self.cfg_cmd +
['-c', 'tcl_port {}'.format(self.tcl_port),
'-c', 'telnet_port {}'.format(self.telnet_port),
'-c', 'gdb_port {}'.format(self.gdb_port)] +
self.pre_init + ['-c', 'init',
pre_init_cmd + ['-c', 'init',
'-c', 'targets',
'-c', 'reset halt'])
self.check_call(cmd)

0 comments on commit c724033

Please sign in to comment.