Mcuboot failing to load SMP SVR application on nRF5340 DK

Hi,

I'm trying to follow the MCUBoot + SMP SVR example on this page: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/README.html#smp-svr-sample

MCUBoot flashes just fine, but when I try to flash the signed binary of the SMP SVR application, MCUBoot only sees zeroes in the application header. I've added some debugging in MCUBoot so I can monitor why it's failing when trying to load the SMP SVR application:

*** Booting Zephyr OS build zephyr-v3.1.0-678-gd0a788669e15 ***
I: Starting bootloader
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
W: Failed reading image headers; Image=0
E: MAB boot_is_header_valid -- header magic (0x00000000) doesn't match (0x96f3b83d)
E: MAB boot_is_header_valid -- header magic (0x00000000) doesn't match (0x96f3b83d)
E: MAB boot_validate_slot -- boot_is_header_valid result = 0
E: MAB boot_validate_slot -- fih_not_eq result = 1
E: Image in the primary slot is not valid!
E: Unable to find bootable image

Can you advise on what could be the issue?

This is on an nRF5340 DK.

  • Hi

    When flashing the application first time to the nRF5340, use:

    west build -p -b nrf5340dk_nrf5340_cpuapp
    west flash

    This will flash the merged file.

    When performing DFU to SMP Server over serial, I recommend using mcumgr as explained in the SMP Server sample, but with app_update.bin, as mentioned in Using MCUboot in nRF Connect SDK:

    sudo mcumgr <connection string> image upload build/zephyr/app_update.bin

    Des it work when you do this?

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    Thanks for your response. Will the first command that you posted:

    west build -p -b nrf5340dk_nrf5340_cpuapp

    build both MCUBoot and the SMP Server application into a single binary? Don't I have to specify the actual project to build in the west invocation:

    west build -p -b <board_name> <path to project>?

  • Hi

    mablabs said:

    Will the first command that you posted:

    west build -p -b nrf5340dk_nrf5340_cpuapp

    build both MCUBoot and the SMP Server application into a single binary

    Yes, MCUBoot will be build as a child image to your application. See Bootloaders and Device Firmware Updates for a good explanation of bootloaders.

    When you program your board with the debugger, hex files are usually used.
    The binary files used for MCUBoot is for use for the DFU tools: typically sent over UART or Bluetooth Low Energy.
    For more information about our build system and which files are generated, see Build and configuration system.

    mablabs said:
    Don't I have to specify the actual project to build in the west invocation:

    west build -p -b <board_name> <path to project>?

    By default, `west build` will build for the current folder.(path is "./") Meaning that you only need the path if you build from another location.
    It is up to you where you want to build from really.

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    Thanks for the clarification. However, when I try to run the following commands:

    west build -b nrf5340dk_nrf5340_cpuapp  zephyr/samples/subsys/mgmt/mcumgr/smp_svr/ -- -DOVERLAY_CONFIG='overlay-serial.conf;overlay-fs.conf;overlay-shell-mgmt.conf'
    
    west flash

    I still get the following error from the bootloader, when it goes to boot:

    *** Booting Zephyr OS build zephyr-v3.1.0-678-gd0a788669e15  ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    W: Failed reading image headers; Image=0
    E: MAB boot_is_header_valid -- header magic (0x00000000) doesn't match (0x96f3b83d)
    E: MAB boot_is_header_valid -- header magic (0x00000000) doesn't match (0x96f3b83d)
    E: MAB boot_validate_slot -- boot_is_header_valid result = 0
    E: MAB boot_validate_slot -- fih_not_eq result = 1
    E: Image in the primary slot is not valid!
    E: Unable to find bootable image
    

    Please advise on what could be happening. Very much appreciate your help.

  • Hi,

    I believe I have figured out my issue. It looks like my environment wasn't configured correctly, and instead of using the nRF Connect SDK, VS Code was using a separate Zephyr installation. When I started from scratch on another PC using nRF Connect SDK, everything works as expected and the SMP Server app works (and I can see the bootloader logs indicating it's successfully loading).

Related