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>
This commit is contained in:
parent
3fa0cd59b7
commit
1be4025550
1 changed files with 10 additions and 6 deletions
|
@ -169,7 +169,7 @@ class STM32CubeProgrammerBinaryRunner(ZephyrBinaryRunner):
|
|||
# is displayed when an invalid value is provided for this argument.
|
||||
type=functools.wraps(int)(lambda s: int(s, base=0)),
|
||||
required=False,
|
||||
help="Address where flashing should be done"
|
||||
help="Flashing location address. To be used only with .bin files"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--download-modifiers",
|
||||
|
@ -271,15 +271,19 @@ class STM32CubeProgrammerBinaryRunner(ZephyrBinaryRunner):
|
|||
if self._erase:
|
||||
self.check_call(cmd + ["--erase", "all"])
|
||||
|
||||
# flash image and run application
|
||||
# Define binary to be loaded
|
||||
if self._use_elf:
|
||||
# Use elf file if instructed to do so.
|
||||
dl_file = self.cfg.elf_file
|
||||
elif self.cfg.bin_file is not None and os.path.isfile(self.cfg.bin_file) and \
|
||||
"zephyr.signed" in self.cfg.bin_file:
|
||||
elif self.cfg.bin_file is not None and self._download_address is not None:
|
||||
# Use bin file if a binary is available and --download-address provided
|
||||
dl_file = self.cfg.bin_file
|
||||
elif self.cfg.hex_file is not None and os.path.isfile(self.cfg.hex_file):
|
||||
# --user-elf not used and no bin file given, default to hex
|
||||
elif self.cfg.hex_file is not None:
|
||||
# Neither --use-elf nor --download-address are present:
|
||||
# default to flashing using hex file.
|
||||
dl_file = self.cfg.hex_file
|
||||
|
||||
# Verify file configuration
|
||||
if dl_file is None:
|
||||
raise RuntimeError('cannot flash; no download file was specified')
|
||||
elif not os.path.isfile(dl_file):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue