MCUBoot crash when using multi-image + swap + serial recovery

Hello,

I am encountering a crash in MCUBoot when using the following configuration:

  • MCUBoot as bootloader (SB_CONFIG_BOOTLOADER_MCUBOOT)
  • TFM configuration (build /ns board)
  • Multi-image update (SB_CONFIG_MCUBOOT_UPDATEABLE_IMAGES=2)
  • Swap mode (CONFIG_BOOT_SWAP_USING_MOVE)
  • Serial Recovery in USB ACM (CONFIG_BOOT_SERIAL_CDC_ACM)
  • Auterm sends a firmware or list images.

This issue seems to match an already-identified bug in upstream MCUBoot: https://github.com/mcu-tools/mcuboot/issues/2336

The version of MCUBoot included in the current nRF Connect SDK 3 .1.1 does not contain this fix, and the crash occurs on our side (a null pointer access).

Questions:

  • When does Nordic plan to integrate this upstream MCUBoot fix into the nRF Connect SDK?
  • Is there a known workaround recommended by Nordic until the fix is officially integrated?

Additional issue on the nRF5340 : sometime, the device freezes at startup when CONFIG_BOOT_SERIAL_WAIT_FOR_DFU is set. This behavior looks very similar to an older issue:
MCUBoot does not load application when using CONFIG_BOOT_SERIAL_WAIT_FOR_DFU .

Is this freeze a known issue ?

please find below logs when mcuboot freezes : 

nrf_usbd_common_disable () at ./src/nrf/zephyr/drivers/usb/common/nrf_usbd_common/nrf_usbd_common.c:1225
1225                    while (!NRF_USBD->EVENTS_ENDEPIN[0]) {
(gdb) bt
#0  nrf_usbd_common_disable ()
    at ./src/nrf/zephyr/drivers/usb/common/nrf_usbd_common/nrf_usbd_common.c:1225
#1  0x00006efe in usb_dc_detach ()
    at ./src/nrf/zephyr/drivers/usb/device/usb_dc_nrfx.c:1322
#2  0x00003b96 in usb_disable ()
    at ./src/nrf/zephyr/subsys/usb/device/usb_device.c:1358
#3  0x0000065c in do_boot (rsp=0x2000cf9c <z_main_stack+10172>)
    at ./src/nrf/bootloader/mcuboot/boot/zephyr/main.c:200
#4  main ()
    at ./src/nrf/bootloader/mcuboot/boot/zephyr/main.c:682
(gdb) 

Unplugging the USB cable doesn't solve the boot when we are frozen.

If USB cable is not present during boot : issue doesn't reproduce.

Best Regards,

Rémi Moessner

Parents Reply
  • Hello Vidar,

    Sorry, I didn't see your questions

    Is the problem that auterm is trying to mark the secondary slot as pending when the image was uploaded directly to the primary slot? Did you patch something around this code:  https://github.com/nrfconnect/sdk-mcuboot/commit/fac2cabe98d81b4416052990a22e9698d39267a3 ?

    The problem is that boot_serial code ignore that the PRIMARY slot has been written and set the SECONDARY slot as containing an update (and it is not the case ... as we wrote slot 0)

    my patch in boot_serial.c for this is : 

    @@ -648,7 +652,10 @@ bs_set(char *buf, int len)
                     if (rc == 0 && memcmp(hash, img_hash.value, sizeof(hash)) == 0) {
                         /* Hash matches, set this slot for test or confirmation */
                         found = true;
    -                    goto set_image_state;
    +                    if  (slot != BOOT_PRIMARY_SLOT)
    +                        goto set_image_state;
    +                    else
    +                        goto out;
                     }
                 }
             }

    ould you also say if you have made any changes to the bootloader in addition to the patch mentioned above? The developer was asking whether any of the clocks were stopped prior to this call as this could explain the issue.

    No clock modification, just my own modification for both issues i detected. Please find attached the full patch I used (it includes also the null ptr patch).

    boot_serial_nullptr_exception.patch

    Regards,

    Rémi

Children
Related