From e767ac07033151a897f38cd6d4be888068126354 Mon Sep 17 00:00:00 2001 From: Andrej Butok Date: Fri, 26 Jul 2024 15:31:03 +0200 Subject: [PATCH] runners: jlink: Add support for .elf files to the jlink flash command The .bin & .hex build output is optional and can be disabled by CONFIG_BUILD_OUTPUT_BIN/HEX. Add support for the mandatory .elf build output to the jlink runner flash command. Signed-off-by: Andrej Butok --- scripts/west_commands/runners/jlink.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/west_commands/runners/jlink.py b/scripts/west_commands/runners/jlink.py index 5670cd374c8..fd4022db03b 100644 --- a/scripts/west_commands/runners/jlink.py +++ b/scripts/west_commands/runners/jlink.py @@ -320,10 +320,12 @@ class JLinkBinaryRunner(ZephyrBinaryRunner): raise ValueError(err) else: - # use hex or bin file provided by the buildsystem, preferring .hex over .bin + # Use hex, bin or elf file provided by the buildsystem. + # Preferring .hex over .bin and .elf if self.hex_name is not None and os.path.isfile(self.hex_name): flash_file = self.hex_name flash_cmd = f'loadfile "{self.hex_name}"' + # Preferring .bin over .elf elif self.bin_name is not None and os.path.isfile(self.bin_name): if self.dt_flash: flash_addr = self.flash_address_from_build_conf(self.build_conf) @@ -331,9 +333,12 @@ class JLinkBinaryRunner(ZephyrBinaryRunner): flash_addr = 0 flash_file = self.bin_name flash_cmd = f'loadfile "{self.bin_name}" 0x{flash_addr:x}' + elif self.elf_name is not None and os.path.isfile(self.elf_name): + flash_file = self.elf_name + flash_cmd = f'loadfile "{self.elf_name}"' else: - err = 'Cannot flash; no hex ({}) or bin ({}) files found.' - raise ValueError(err.format(self.hex_name, self.bin_name)) + err = 'Cannot flash; no hex ({}), bin ({}) or elf ({}) files found.' + raise ValueError(err.format(self.hex_name, self.bin_name, self.elf_name)) # Flash the selected build artifact lines.append(flash_cmd)