Debugging MCUboot

Hi,

I want to debug [i.e. attach to and single step] mcuboot [running as second stage bootloader] using Ozone and JLink.

I can connect to the board via the debugger and can debug for a while, but I never get to main().

I am probably doing it wrong, however my current approach fails with the verification of some required EXT_API functions fails, in particular the crypto libraries. I suppose I want to use these external APIs for crypto in mcuboot.

Well, my error is more of a hint than anything else. What I really want to know is:

What is the Nordic-recommended way to debug MCUBOOT with J-Link? 

Cheers,

Odd Rune

Vitalthings AS [Trondheim]

  • Well, to tie things up, I have solved it. 

    The basic gist of it is:
    * Flash the merged.hex from the west build.
    * Make sure to run b0 (wichever you use) before attempting to debug mcuboot. Essentially, the steps are:

    In the Ozone jdebug script:
    1. We do this by inspecting the b0 elf, finding the entry point and adding a step to _SetupTaget(), in our case
       Target.SetReg("PC", 0x10E0")
       Target.SetReg("SP", 0x20003208).
    2. Load the mcuboot ELF in Ozone using: File.open() in OnProjectLoad() to get access to the debug symbols.
    3. In TargetDownload():  Target.LoadMemory("/home/user/blah/build/merged.hex")


    In effect, this  flashes and runs b0 (entry point at 0x10E0), and hands things over to mcuboot; so that the external APIs are registered by b0 and accessible by mcuboot [used as the second stage bl].


    So that works.

    A second case I had was getting Segger RTT to work in mcuboot, but I've abandoned this for now as I can actually get step-debugging to work.

  • Hi Odd Rune,

    Glad to see you found a solution this quickly yourself. I've also explained this here in an older case of mine.

    Regards,

    Elfving

Related