west: runners: blackmagicprobe: elf_file fallback
Building the HEX file is optional (CONFIG_BUILD_OUTPUT_HEX), so `bmp_flash` will fallback to elf_file if missing. Additionally, to maintain section names the HEX is only used if it is signed. Signed-off-by: John Whittington <git@jbrengineering.co.uk>
This commit is contained in:
parent
10183797a1
commit
3f282da22d
2 changed files with 21 additions and 7 deletions
|
@ -116,8 +116,10 @@ class BlackMagicProbeRunner(ZephyrBinaryRunner):
|
||||||
#
|
#
|
||||||
# https://github.com/zephyrproject-rtos/zephyr/issues/50789
|
# https://github.com/zephyrproject-rtos/zephyr/issues/50789
|
||||||
self.elf_file = Path(cfg.elf_file).as_posix()
|
self.elf_file = Path(cfg.elf_file).as_posix()
|
||||||
# hex_file for flash signed image
|
if cfg.hex_file is not None:
|
||||||
self.hex_file = Path(cfg.hex_file).as_posix()
|
self.hex_file = Path(cfg.hex_file).as_posix()
|
||||||
|
else:
|
||||||
|
self.hex_file = None
|
||||||
self.gdb_serial = blackmagicprobe_gdb_serial(gdb_serial)
|
self.gdb_serial = blackmagicprobe_gdb_serial(gdb_serial)
|
||||||
self.logger.info(f'using GDB serial: {self.gdb_serial}')
|
self.logger.info(f'using GDB serial: {self.gdb_serial}')
|
||||||
if connect_rst:
|
if connect_rst:
|
||||||
|
@ -152,8 +154,20 @@ class BlackMagicProbeRunner(ZephyrBinaryRunner):
|
||||||
help='Assert SRST during connect? (default: no)')
|
help='Assert SRST during connect? (default: no)')
|
||||||
|
|
||||||
def bmp_flash(self, command, **kwargs):
|
def bmp_flash(self, command, **kwargs):
|
||||||
if self.hex_file is None:
|
# if hex file is present and signed, use it else use elf file
|
||||||
raise ValueError('Cannot flash; hex file is missing')
|
if self.hex_file:
|
||||||
|
split = self.hex_file.split('.')
|
||||||
|
# eg zephyr.signed.hex
|
||||||
|
if len(split) >= 3 and split[-2] == 'signed':
|
||||||
|
flash_file = self.hex_file
|
||||||
|
else:
|
||||||
|
flash_file = self.elf_file
|
||||||
|
else:
|
||||||
|
flash_file = self.elf_file
|
||||||
|
|
||||||
|
if flash_file is None:
|
||||||
|
raise ValueError('Cannot flash; elf file is missing')
|
||||||
|
|
||||||
command = (self.gdb +
|
command = (self.gdb +
|
||||||
['-ex', "set confirm off",
|
['-ex', "set confirm off",
|
||||||
'-ex', "target extended-remote {}".format(
|
'-ex', "target extended-remote {}".format(
|
||||||
|
@ -161,7 +175,7 @@ class BlackMagicProbeRunner(ZephyrBinaryRunner):
|
||||||
self.connect_rst_enable_arg +
|
self.connect_rst_enable_arg +
|
||||||
['-ex', "monitor swdp_scan",
|
['-ex', "monitor swdp_scan",
|
||||||
'-ex', "attach 1",
|
'-ex', "attach 1",
|
||||||
'-ex', "load {}".format(self.hex_file),
|
'-ex', "load {}".format(flash_file),
|
||||||
'-ex', "kill",
|
'-ex', "kill",
|
||||||
'-ex', "quit",
|
'-ex', "quit",
|
||||||
'-silent'])
|
'-silent'])
|
||||||
|
|
|
@ -11,7 +11,7 @@ import pytest
|
||||||
|
|
||||||
from runners import blackmagicprobe
|
from runners import blackmagicprobe
|
||||||
from runners.blackmagicprobe import BlackMagicProbeRunner
|
from runners.blackmagicprobe import BlackMagicProbeRunner
|
||||||
from conftest import RC_KERNEL_ELF, RC_KERNEL_HEX, RC_GDB
|
from conftest import RC_KERNEL_ELF, RC_GDB
|
||||||
import serial.tools.list_ports
|
import serial.tools.list_ports
|
||||||
|
|
||||||
TEST_GDB_SERIAL = 'test-gdb-serial'
|
TEST_GDB_SERIAL = 'test-gdb-serial'
|
||||||
|
@ -41,7 +41,7 @@ EXPECTED_COMMANDS = {
|
||||||
'-ex', "target extended-remote {}".format(TEST_GDB_SERIAL),
|
'-ex', "target extended-remote {}".format(TEST_GDB_SERIAL),
|
||||||
'-ex', "monitor swdp_scan",
|
'-ex', "monitor swdp_scan",
|
||||||
'-ex', "attach 1",
|
'-ex', "attach 1",
|
||||||
'-ex', "load {}".format(RC_KERNEL_HEX),
|
'-ex', "load {}".format(RC_KERNEL_ELF),
|
||||||
'-ex', "kill",
|
'-ex', "kill",
|
||||||
'-ex', "quit",
|
'-ex', "quit",
|
||||||
'-silent'],),
|
'-silent'],),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue