Skip to content

Commit 1be4025

Browse files
erwangokartben
authored andcommitted
scripts: runners: stm32cubeprogrammer: Review f/w selection algorithm
Aim is to avoid 2 issues: - Requesting --download-address to flash hex files - Flashing hex files (non signed) on N6 which works but doesn't allow persistent firmware Hence this changes binds --download-address with usage of .bin files. If --download-address was not provided, default to hex flashing. File existence done with isfile() will ensure the required file is available before flashing and report an error if this is not the case. Note: In specific N6 case, we're verifying zephyr.signed.bin is available instead of zephyr.bin. This is ensure since self.cfg.bin_file matches runners_yaml_props_target configuration (set to zephyr.signed.bin on STM32N6). Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
1 parent 3fa0cd5 commit 1be4025

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

scripts/west_commands/runners/stm32cubeprogrammer.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def do_add_parser(cls, parser):
169169
# is displayed when an invalid value is provided for this argument.
170170
type=functools.wraps(int)(lambda s: int(s, base=0)),
171171
required=False,
172-
help="Address where flashing should be done"
172+
help="Flashing location address. To be used only with .bin files"
173173
)
174174
parser.add_argument(
175175
"--download-modifiers",
@@ -271,15 +271,19 @@ def flash(self, **kwargs) -> None:
271271
if self._erase:
272272
self.check_call(cmd + ["--erase", "all"])
273273

274-
# flash image and run application
274+
# Define binary to be loaded
275275
if self._use_elf:
276+
# Use elf file if instructed to do so.
276277
dl_file = self.cfg.elf_file
277-
elif self.cfg.bin_file is not None and os.path.isfile(self.cfg.bin_file) and \
278-
"zephyr.signed" in self.cfg.bin_file:
278+
elif self.cfg.bin_file is not None and self._download_address is not None:
279+
# Use bin file if a binary is available and --download-address provided
279280
dl_file = self.cfg.bin_file
280-
elif self.cfg.hex_file is not None and os.path.isfile(self.cfg.hex_file):
281-
# --user-elf not used and no bin file given, default to hex
281+
elif self.cfg.hex_file is not None:
282+
# Neither --use-elf nor --download-address are present:
283+
# default to flashing using hex file.
282284
dl_file = self.cfg.hex_file
285+
286+
# Verify file configuration
283287
if dl_file is None:
284288
raise RuntimeError('cannot flash; no download file was specified')
285289
elif not os.path.isfile(dl_file):

0 commit comments

Comments
 (0)