Debug using MCUboot and app core

Hi,

I am using nRF5340 (CPUAPP) with MCUboot and Partition Manager (pm_static.yml, CONFIG_PARTITION_MANAGER_ENABLED=y).

Build and flash are successful, but during debug the CPU stops in the bootloader (address around 0x00008xxx) and does not reach my application main().

What is the correct way to debug the application when MCUboot is enabled?

Specifically:

  • How to make debugger directly run/jump to application?
  • Do I need special settings (reset type, run-to-main, etc.)?
  • Is there a recommended debug workflow for MCUboot + app?

Thanks!

  • Hi,

    Normally, it should not require any special considerations to debug the application while a bootloader is present. Does the application only fail to be reached when you are trying to debug the device?

    Best regards,

    Vidar

  • It fails to run even after flashing. I have identified a further issue and now have two cases:

    Case 1:

    mcuboot:
    address: 0x00000000
    size: 0x0000c000 # 48 KB Bootloader

    mcuboot_primary:
    address: 0x0000c000
    size: 0x00074000 # 464 KB Primary Slot
    region: flash_primary
    span: [mcuboot_pad, mcuboot_primary_app]

    mcuboot_pad:
    address: 0x0000c000
    size: 0x00000200 # 512 B

    mcuboot_primary_app:
    address: 0x0000c200
    size: 0x00073E00
    span: [app]

    app:
    address: 0x0000c200
    size: 0x00073E00

    mcuboot_secondary:
    address: 0x0200000
    size: 0x00040000
    region: external_flash

    settings_storage:
    address: 0x000f4000
    size: 0x00004000

    scratch:
    address: 0x000f8000
    size: 0x00008000

    When I build using pm_static.yml, I get the following error:

    ninja: error: '_sysbuild/mcuboot_primary_app_hex', needed by 'mcuboot_primary.hex', missing and no known rule to make it
    FATAL ERROR: command exited with status 1

    However, in partitions.yml, I see:

    app:
    address: 0xc200
    end_address: 0xf4000

    Case 2:

    mcuboot:
    address: 0x00000000
    size: 0x0000c000

    mcuboot_primary:
    address: 0x0000c000
    size: 0x00074000
    region: flash_primary
    span: [mcuboot_pad, mcuboot_primary_app]

    mcuboot_pad:
    address: 0x0000c000
    size: 0x00000200

    mcuboot_primary_app:
    address: 0x0000c200
    size: 0x00073E00

    mcuboot_secondary:
    address: 0x0200000
    size: 0x00040000
    region: external_flash

    settings_storage:
    address: 0x000f4000
    size: 0x00004000

    scratch:
    address: 0x000f8000
    size: 0x00008000

    In this case, I removed span: [app] and built the project successfully. However, in partitions.yml, I get:

    app:
    address: 0x80000
    end_address: 0xf4000
    region: flash_primary
    size: 0x74000

    and when we try to debug we get-

    Finished reading symbols from objdump: Time: 1371 ms Finished reading symbols from nm: Time: 1156 ms Output radix now set to decimal 10, hex a, octal 12. Input radix now set to decimal 10, hex a, octal 12. 0x000088b6 in ?? () Program stopped, probably due to a reset and/or halt issued by debugger

  • I am bit confused about why you are asking about how to debug the application when the program clearly hangs in the bootloader. Have you tried debugging the bootloader from Vs code with our nRF connect extension to see if you can locate where it is it hangs? I would also strongly recommend you enable logging in the boatloader if possible.

    I am also happy to debug the project here if you are able to provide a minimal project that will let me reproduce the problem on a nRF5340 DK board.

  • Hi, thanks for the reply.

    I just referred to the discussion  migrating app using mcuboot to NCS 3.2.3 - issue with MCUboot image IDs automatically assigned?   , and my issue is now resolved. I was migrating code from NCS 2.5.4 to 3.2.4, so there were significant differences.

Related