west: runners: blackmagicprobe: flash hex_file

The cfg.elf_file is not signed, so `west flash` with a sysbuild will
not run the application if MCUboot image signature checking is on. Using
the cfg.hex_file for `bmp_flash` resolves since as the signed hex is
used when using sysbuild. Symbols are not required for flashing so the
switching from elf to hex is not an issue.

Signed-off-by: John Whittington <git@jbrengineering.co.uk>
diff --git a/scripts/west_commands/runners/blackmagicprobe.py b/scripts/west_commands/runners/blackmagicprobe.py
index 54fc22a..95cb6e2 100644
--- a/scripts/west_commands/runners/blackmagicprobe.py
+++ b/scripts/west_commands/runners/blackmagicprobe.py
@@ -116,6 +116,8 @@
         #
         # https://github.com/zephyrproject-rtos/zephyr/issues/50789
         self.elf_file = Path(cfg.elf_file).as_posix()
+        # hex_file for flash signed image
+        self.hex_file = Path(cfg.hex_file).as_posix()
         self.gdb_serial = blackmagicprobe_gdb_serial(gdb_serial)
         self.logger.info(f'using GDB serial: {self.gdb_serial}')
         if connect_rst:
@@ -150,8 +152,8 @@
                             help='Assert SRST during connect? (default: no)')
 
     def bmp_flash(self, command, **kwargs):
-        if self.elf_file is None:
-            raise ValueError('Cannot debug; elf file is missing')
+        if self.hex_file is None:
+            raise ValueError('Cannot flash; hex file is missing')
         command = (self.gdb +
                    ['-ex', "set confirm off",
                     '-ex', "target extended-remote {}".format(
@@ -159,7 +161,7 @@
                     self.connect_rst_enable_arg +
                    ['-ex', "monitor swdp_scan",
                     '-ex', "attach 1",
-                    '-ex', "load {}".format(self.elf_file),
+                    '-ex', "load {}".format(self.hex_file),
                     '-ex', "kill",
                     '-ex', "quit",
                     '-silent'])
diff --git a/scripts/west_commands/tests/test_blackmagicprobe.py b/scripts/west_commands/tests/test_blackmagicprobe.py
index 6e083d8..3ee50de 100644
--- a/scripts/west_commands/tests/test_blackmagicprobe.py
+++ b/scripts/west_commands/tests/test_blackmagicprobe.py
@@ -11,7 +11,7 @@
 
 from runners import blackmagicprobe
 from runners.blackmagicprobe import BlackMagicProbeRunner
-from conftest import RC_KERNEL_ELF, RC_GDB
+from conftest import RC_KERNEL_ELF, RC_KERNEL_HEX, RC_GDB
 import serial.tools.list_ports
 
 TEST_GDB_SERIAL = 'test-gdb-serial'
@@ -41,7 +41,7 @@
       '-ex', "target extended-remote {}".format(TEST_GDB_SERIAL),
       '-ex', "monitor swdp_scan",
       '-ex', "attach 1",
-      '-ex', "load {}".format(RC_KERNEL_ELF),
+      '-ex', "load {}".format(RC_KERNEL_HEX),
       '-ex', "kill",
       '-ex', "quit",
       '-silent'],),