Netcore OTA Update with Direct XIP mode

I have an nrf5340 device with the following requirements.

  • must switch application slots if image becomes corrupt
  • can only do OTA updates
  • must have the ability to upgrade the network core

In order to enable switching slots, we chose to use Direct XIP mode.  This has thrown the unwanted side effect getting caught in a boot loop when updating the network core. 

To reproduce,

  • bump up CONFIG_MCUBOOT_IMAGE_VERSION and rebuild the project
  • use mcumgr to send net_core_app_update.bin 
  • reset the board

The system ends up getting stuck in a boot loop, which sorta makes sense now that I know how direct XIP mode works.

*** Booting Zephyr OS build v3.3.99-ncs1 ***
I: Starting Direct-XIP bootloader
I: Primary   slot: version=0.0.0+0
I: Secondary slot: version=0.0.1+0
I: Image 0 loaded from the secondary slot
I: Bootloader chainload address offset: 0x80000
*** Booting Zephyr OS build v3.3.99-ncs1 ***
... etc etc 

I guess the question is it even possible to update the netcore OTA in Direct XIP mode?

  • For anyone attempting to do this, it is possible.

    With direct XIP mode, the update image must be stored in external flash.

    You will need a method to write the image file into external flash.  The file to use is build/zephyr/net_core_app_update.bin

    mcuboot locks the PCD ram permanently before booting.  This must be disabled.  Search through the bootloader code for the call to "pcd_lock_ram()" and comment it out, or you can modify that function to not lock the ram permanently

    To perform an update, the minimal steps from the application are

    • copy the net_core_app_update.bin file from external flash to the secondary slot
    • call pcd_network_core_update (see the bootloader loader.c file for example)
    • reboot the system

    The actual number of steps will vary depending on if you lock the ram, if you want to verify your images before/after transferring them, if you want to backup and restore the secondary firmware slot, and I'm sure that I'm missing steps.

    If you can avoid this, I recommend that you do.

Related