nRF5340 Netcore firmware update using external flash

I am using NCS 1.7.0 and latest nRF5340 DK

I am trying to update netcore firmware using the process defined here: 
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.0/nrf/ug_nrf5340.html#fota-upgrades

I am able to update the appcore and netcore using the smp_svr sample as documented  here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/README.html#smp-svr-sample

I used west tool for building the smp_svr sample

`west build -b nrf5340dk_nrf5340_cpuapp -- -DCONFIG_BOOTLOADER_MCUBOOT=y -Dmcuboot_CONFIG_PCD=y -DOVERLAY_CONFIG=overlay-bt.conf`

I also enabled logging in hci_rpmsg and modified some dummy logging message to confirm that update has happened successfully in the netcore

This sample does not use QSPI external flash for the FOTA so i modified the sample to use external flash by adding an overlay and also CONFIG_NORDIC_QSPI_NOR=y.

This modified sample works for the updating application core but does not work for network core. I am able to upload the network core binary but once i issue image test and reset commands it takes sometime to reboot but still network core has the old firmware. 

I had to use the following configs in mcuboot child image configurations to come to this state:

```
CONFIG_PCD=y
CONFIG_PCD_APP=y
CONFIG_PCD_NET=y

# # CONFIG_UPDATEABLE_IMAGE_NUMBER=2
# # CONFIG_FLASH_SIMULATOR=y
# # CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
# # CONFIG_FLASH_SIMULATOR_STATS=n
# # CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_BOOT_SWAP_USING_SCRATCH=y

CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16
```

if i use the commented options above then during FOTA process device reboots continuously with a fatal error seen on network core.

I was facing a similar issue on my nRF5340 based product development (where i wanted to use CONFIG_BOOT_SWAP_USING_SCRATCH) and hence i thought it will work in devkit but i see the same issue here too on smp_svr sample application.

Kindly help me with this as I don't know what else is missing from my configurations that will enable me to update the network core using external flash QSPI.

Regards,

Dhananjay

  • Hello,

    The short answer is that you can't update the network core via QSPI out of the box. The reason for this is that the network core doesn't have access to the QSPI, and hence, it is not able to fetch the image from the external flash. However, if your application on the app_core can move the image from the QSPI into the flash, it will be possible to do what you describe. 

    Is there room in your flash to fit the network core update for the DFU?

    BR,

    Edvin

  • Hello Edvin,
          Thanks for the reply. Just to clarify few things

    • By QSPI do you mean External Flash?
    • By Flash, do you mean Internal code memory of the nRF53?

    I assumed MCUboot on the appcore takes care of informing netcore (via netboot and PCD) to indicate and moving new firmware update for netcore. is that right? or probably only indicate from your reply.

    We can allocate some internal flash memory on the appcore for this purpose which means we have to allocate around (256 KB - netboot size - PCD library size). If so, what should be done?

    If we do this we cannot use this code space on appcore in future right?

    Regards,

    DJ

  • Hello

    djgj said:
    • By QSPI do you mean External Flash?

    This sample does not use QSPI external flash for the FOTA so i modified the sample to use external flash by adding an overlay and also CONFIG_NORDIC_QSPI_NOR=y.

    Yes. Assuming your external flash is using QSPI for communication with the nRF. If you are talking about the external flash chip on the nRF5340 DK, then this is a QSPI flash chip.If you have some 3rd party external flash, then you need to see what interface/peripheral it uses to communicate with your nRF53, but QSPI is quite common.

    djgj said:
    • By Flash, do you mean Internal code memory of the nRF53?

    Yes. But looking further into this, I see that the way that the network core is being updated, the image is originally stored on the application core's flash, and then it is uploaded to the shared RAM by MCUBOOT. From there the network core will read it out, and update the network core. 

    When you attempted this, and it took a while before reverting back to the old FW. What do you observe? Do you see any logs from the network core? Or do you read out the network core after it has rebooted?

    Is there any way for me to replicate this on an nRF5240 DK? Can you send the project folder that you are using?

    BR,

    Edvin

  • Hello,

           Yes we are using QSPI flash in our product. And i used the QSPI in the nRF5340 DK too for reproducing this.

    So technically MCUboot can move the network core firmware from QSPI to shared SRAM and which can then be read by netcore? MCUboot already works fine for the appcore update with QSPI.

    When i updated the netcore, DK was unresponsive for 1 minute and then rebooted again. But when i checked the log it shows the old netcore logs only.. i have dummy print in my hci_rpmsg main.c where i can identify whether its old or new image.

    I have shared the project folder i used with nRF5340 DK here. This uses QSPI for firmware update process.smp_svr_with_qspi.zip

    1. Used west tool for building / flahsing the smp_svr sample to DK.
      • west build -b nrf5340dk_nrf5340_cpuapp -- -DCONFIG_BOOTLOADER_MCUBOOT=y -Dmcuboot_CONFIG_PCD=y -DOVERLAY_CONFIG=overlay-bt.conf
    2. Used this to load the binary image after building
      1. west flash --recover
    3. Then I change the dummy log print in hci_rpmsg main.c and build to identify it as newer binary image.
    4. Used mcumgr command line tools to update the image on appcore and netcore.
    5. Used 'build/zephyr/net_core_app_update.bin` to upload and test the FOTA on netcore.
    6. DK now tries to reboot for max 1 minute and when its booted i still see the image i flashed on step 2. (old log message)
    7. Unfortunately I don't see any logs from MCUboot even though i tried to enable all logs on it.

    Let me know if you are able to use this.

    Regards,

    DJ

  • Hello Edvin,
           Is there any update on this? were you able to use the sample provided?

    Regards,

    DJ

Related