west debug does not work and corrupts flash contents in multi-domain-projects (with sysbuild)

Wheh I try to debug a multi-domain-image on an nrf5340 or 52840, I can debug the mcuboot domain just fine. But when I try to debug the app-domain (I tried this with the zephyr/samples/sysbuild/with_mcuboot sample), gdb complains that it cannot find the bounds of the current function.

But what's worse, it corrupts part of the flash, so that when I step though the mcuboot-domain after that (which still works), I can see mcuboot fail to find a bootable image. Clearly this should not happen, right?

This can be reproduced with any nrf5340 or nrf52840 and the aforementioned sample . I used the nrf52840 on an nrf9160dk and a custom nrf5340 board.

Parents
  • Hello,

    'west debug' will load the elf file, and the elf file is not signed, only the hex and bin files are signed. This is a limitation that should be addressed in the SDK. To work around this you can first flash the image(s) with 'west flash' then run 'west attach' to start your debug session.

    Best regards,

    Vidar

  • Hi Vidar,

    thanks for your answer! The flash/attach method works as you described.

    But I still don't entirely understand how loading an unsigned image into RAM can lead to corrupting the flash. I assumed 'west debug' was only loading the image into RAM, and not touching the flash at all. Am I wrong, and if so, could you elaborate what's actually happening?

    Regards,

    Alex.

  • Hi Alex,

    Good to hear! Maybe you're thinking of the debug symbols, which are loaded from the ELF file to be used by the debugger. The issue in this case is that 'west debug' is flashing the zephyr.elf file to your target, which does not contain the signature needed by the bootloader to boot the app.

    Note that you can get verbose output from west by prefixing the build target with -vvvv: 'west -vvvv debug' to see what it does.

Reply
  • Hi Alex,

    Good to hear! Maybe you're thinking of the debug symbols, which are loaded from the ELF file to be used by the debugger. The issue in this case is that 'west debug' is flashing the zephyr.elf file to your target, which does not contain the signature needed by the bootloader to boot the app.

    Note that you can get verbose output from west by prefixing the build target with -vvvv: 'west -vvvv debug' to see what it does.

Children
Related