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

  • nRF5340 QSPI peripheral is designed to support NOR flash. NAND flash is a different animal. Is it a typo?

  • Sorry for the typing error. Flash is NOR (MX25R1635)

  • Hi,

    Yes, your understanding seems correct. Note that this scheme is not officially fully supported yet, but there is a PR here that adds support for this:

    https://github.com/nrfconnect/sdk-nrf/pull/8839

  • I facing the following error while compiling the source code. I am not sure what setting I need to update. 

    C:/Users/Dilawar_Ali/ncs/v2.1.2/nrf/modules/mcuboot/hooks/nrf53_hooks.c: In function 'boot_read_image_header_hook':
    C:\Users\Dilawar_Ali\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:28:28: error: 'PM_MCUBOOT_PRIMARY_1_ADDRESS' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ADDRESS'?
       28 |   img_head->ih_load_addr = PM_MCUBOOT_PRIMARY_1_ADDRESS;
          |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |                            PM_MCUBOOT_PRIMARY_ADDRESS
    C:\Users\Dilawar_Ali\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:28:28: note: each undeclared identifier is reported only once for each function it appears in
    C:\Users\Dilawar_Ali\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:29:27: error: 'PM_CPUNET_APP_SIZE' undeclared (first use in this function)
       29 |   img_head->ih_img_size = PM_CPUNET_APP_SIZE;
          |                           ^~~~~~~~~~~~~~~~~~
    In file included from C:\Users\Dilawar_Ali\ncs\v2.1.2\zephyr\include\zephyr\toolchain\gcc.h:88,
                     from C:\Users\Dilawar_Ali\ncs\v2.1.2\zephyr\include\zephyr\toolchain.h:50,
                     from C:\Users\Dilawar_Ali\ncs\v2.1.2\zephyr\include\zephyr\sys\__assert.h:11,
                     from C:\Users\Dilawar_Ali\ncs\v2.1.2\zephyr\lib\libc\minimal\include\assert.h:11,
                     from C:\Users\Dilawar_Ali\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:7:
    C:/Users/Dilawar_Ali/ncs/v2.1.2/nrf/modules/mcuboot/hooks/nrf53_hooks.c: In function 'network_core_update':
    C:\Users\Dilawar_Ali\ncs\v2.1.2\zephyr\include\zephyr\device.h:96:39: error: '__device_dts_ord_DT_N_NODELABEL_PM_MCUBOOT_PRIMARY_1_DEV_ORD' undeclared (first use in this function)
       96 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)
          |                                       ^~~~~~~~~
    C:\Users\Dilawar_Ali\ncs\v2.1.2\zephyr\include\zephyr\device.h:276:37: note: in expansion of macro 'DEVICE_NAME_GET'
      276 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_NAME(node_id))
          |                                     ^~~~~~~~~~~~~~~
    C:\Users\Dilawar_Ali\ncs\v2.1.2\zephyr\include\zephyr\device.h:296:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
      296 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
          |                                  ^~~~~~~~~~~~~~~~~~
    C:\Users\Dilawar_Ali\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:85:19: note: in expansion of macro 'DEVICE_DT_GET'
       85 |  mock_flash_dev = DEVICE_DT_GET(DT_NODELABEL(PM_MCUBOOT_PRIMARY_1_DEV));
          |                   ^~~~~~~~~~~~~
    C:\Users\Dilawar_Ali\ncs\v2.1.2\nrf\modules\mcuboot\hooks\nrf53_hooks.c:98:20: error: 'PM_CPUNET_B0N_ADDRESS' undeclared (first use in this function)
       98 |   if (reset_addr > PM_CPUNET_B0N_ADDRESS) {
          |                    ^~~~~~~~~~~~~~~~~~~~~
    [171/289] Building C object zephyr/drivers/pinctrl/CMakeFiles/drivers__pinctrl.dir/pinctrl_nrf.c.obj
    [172/289] Building C object modules/nrf/lib/fatal_error/CMakeFiles/..__nrf__lib__fatal_error.dir/fatal_error.c.obj
    [173/289] Linking C static library zephyr\drivers\flash\libdrivers__flash.a
    [174/289] Building C object modules/nrf/subsys/fw_info/CMakeFiles/..__nrf__subsys__fw_info.dir/fw_info.c.obj
    [175/289] Building C object modules/nrf/drivers/hw_cc310/CMakeFiles/..__nrf__drivers__hw_cc310.dir/hw_cc310.c.obj
    [176/289] Building C object modules/mbedtls/CMakeFiles/modules__mbedtls.dir/zephyr_init.c.obj
    [177/289] Linking C static library zephyr\drivers\serial\libdrivers__serial.a
    [178/289] Building C object modules/mbedtls/CMakeFiles/modules__mbedtls.dir/C_/Users/Dilawar_Ali/ncs/v2.1.2/modules/crypto/mbedtls/library/aes.c.obj
    [179/289] Linking C static library zephyr\drivers\timer\libdrivers__timer.a
    ninja: build stopped: subcommand failed.
    [341/382] Linking C executable zephyr\zephyr_pre0.elf
    
    [345/382] Linking C executable zephyr\zephyr_pre1.elf

  • Do you have CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY set to y?

Related