nRF5340 Firmware Update from external NOR QSPI flash

Hi

I have gone through the following link and I have working firmware OTA update with BLE SMP.
https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/ncs-dfu#http_dfu_ext_flash

But my device design also has a cloud connection via nRF9160. Following is the complete connection diagram.

Cloud<==HTTPS==> nRF9160 <== UART ==> nRF5340 <== QSPI ==> NOR flash

My requirement is to receive the firmware update file via HTTPS to nRF9160 and it will be transmitted to nRF5340 and eventually will be written in NOR flash.

external_flash:
  address: 0x0
  end_address: 0x200000
  region: external_flash
  size: 0x200000

mcuboot_secondary:
  address: 0x00000
  device: mx25r16
  end_address: 0xf4000
  region: external_flash
  size: 0xf4000

littlefs_storage:
  address: 0x100000
  device: mx25r16
  region: external_flash
  size: 0x200000

My understanding is I will need to enable the QSPI flash access in Mcuboot by adding following lines to the file "/child_image/mcuboot/prj.conf"

# SPI Flash
CONFIG_SPI=y
CONFIG_NORDIC_QSPI_NOR=y

Then write the firmware update file "app_update.bin" in the external NOR flash partition "mcuboot_secondary". File packets will be received over UART and then written via flash write operation. Once file write is complete I will need to restart the SOC.
Is my understanding correct? Also, will I need to update any other flag or message to start firmware update on reboot?

Many Thanks

  • Dilawar Ali said:
    I still need assistance to enable netcore image update as well.

    There are some known issues with NSIB(secure boot)+MCUBOOT and incompatible with multi image DFU on nRF53, that are getting fixed in the upcoming NCS v2.3.0 release. Relevant PR: https://github.com/nrfconnect/sdk-nrf/pull/9169/files#diff-3618c46f4d0a530f32e99d83263fe217269f73f927f5c110f8aed6db3b8800db

  • After a whole lot of trial and error, I managed to get my firmware to compile with the two-stage bootloader + network core update + mcuboot_secondary on external flash.

    First, I copied partitions.yml into pm_static_<custom-board-name>_cpuapp.yml, and added this to the end:

    mcuboot_primary_1:
      address: 0x0
      device: flash_ctrl
      end_address: 0x40000
      region: ram_flash
      size: 0x40000
    mcuboot_secondary_1:
      address: 0xce000
      device: MX25R64
      end_address: 0x10e000
      region: external_flash
      size: 0x40000
    ram_flash:
      address: 0x40000
      end_address: 0x40000
      region: ram_flash
      size: 0x0

    I added these flags to my prj.conf:

    CONFIG_NRF53_UPGRADE_NETWORK_CORE=y
    CONFIG_BOOT_IMAGE_ACCESS_HOOKS=y
    CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
    CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=y
    
    CONFIG_SECURE_BOOT=y

    I added these flags to my mcuboot.conf:

    CONFIG_PCD_APP=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

    For some reason, setting CONFIG_BOOT_UPGRADE_ONLY=n makes it explode with the error 'PM_MCUBOOT_PRIMARY_1_ADDRESS' undeclared. If someone knows why this is happening, I'm all ears.

    In a nutshell, I'm pretty sure this is what you have to do to make it work:

    • DO NOT name the static partition file pm_static.yml, name it pm_static_<boardname>_cpuapp.yml
    • CONFIG_BOOT_UPGRADE_ONLY must be set to 'y' for some reason
    • Set ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS to import the flash simulator into your device tree

    Now to see if it actually runs.

Related