Skip to content

Commit 46f2f8c

Browse files
mbolivar-nordicnashif
authored andcommitted
runners: fix openocd with --use-elf
There are use cases where --use-elf is given and the hex file does not exist. Handle them. Fixes: #31944 Signed-off-by: Martí Bolívar <[email protected]>
1 parent 9c55e2b commit 46f2f8c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/west_commands/runners/openocd.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def __init__(self, cfg, pre_init=None, pre_load=None,
4646
self.openocd_cmd = [cfg.openocd] + search_args
4747
# openocd doesn't cope with Windows path names, so convert
4848
# them to POSIX style just to be sure.
49-
self.hex_name = Path(cfg.hex_file).as_posix()
5049
self.elf_name = Path(cfg.elf_file).as_posix()
5150
self.pre_init = pre_init or []
5251
self.pre_load = pre_load or []
@@ -139,7 +138,11 @@ def do_flash(self, **kwargs):
139138
if self.verify_cmd is None:
140139
raise ValueError('Cannot flash; verify command is missing')
141140

142-
self.logger.info('Flashing file: {}'.format(self.hex_name))
141+
# openocd doesn't cope with Windows path names, so convert
142+
# them to POSIX style just to be sure.
143+
hex_name = Path(self.cfg.hex_file).as_posix()
144+
145+
self.logger.info('Flashing file: {}'.format(hex_name))
143146

144147
pre_init_cmd = []
145148
pre_load_cmd = []
@@ -160,9 +163,9 @@ def do_flash(self, **kwargs):
160163
pre_init_cmd + ['-c', 'init',
161164
'-c', 'targets'] +
162165
pre_load_cmd + ['-c', 'reset halt',
163-
'-c', self.load_cmd + ' ' + self.hex_name,
166+
'-c', self.load_cmd + ' ' + hex_name,
164167
'-c', 'reset halt'] +
165-
['-c', self.verify_cmd + ' ' + self.hex_name] +
168+
['-c', self.verify_cmd + ' ' + hex_name] +
166169
post_verify_cmd +
167170
['-c', 'reset run',
168171
'-c', 'shutdown'])

0 commit comments

Comments
 (0)