Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

DFU with external QSPI memory

Hi,

   I am working on project, in which we using nordic nRF52840 chip. We need to flash the app+SD+BL image file in external QSPI memory.

After prevalidation, the DFU controller starts to send flash image package, we need to receive this and need to save in external QSPI memory. Once the postvalidation is successful, then read all the flash image package stored in external QSPI memory and write it to internal flash memory.

For that we use secure bootloader example code as reference file. I need to know where i need to modify the secure bootloader code.

I noticed that after prevalidation, the flash is erased in on_data_obj_create_request() function in nrf_dfu_req_handler.c file, and flash is written in on_data_obj_write_request() under the same c file. Is that right?

Thanks & Regards

Mohammad Gouse

  • Hi Mohammad, 

    You are correct, the flash erased when the object is created and it's write when there is a NRF_DFU_OP_OBJECT_WRITE command.

    You then need to modify the functions inside nrf_bootloader_fw_activation.c ( app_activate, sd_activate,bl_activate) to use the image in QSPI to replace the app/bootloader/softdevice in the internal flash. 

    The biggest challenge I can find here is on how you replace the bootloader itself. Currently we call nrf_dfu_mbr_copy_bl() to replace the bootloader. This function uses the MBR (SD_MBR_COMMAND_COPY_BL) to replace the bootloader. The MBR expecting the bootloader image to be at a location in flash not in the QSPI flash. 

    You may need to write your code to copy the bootloader image into internal flash first. And then call nrf_dfu_mbr_copy_bl() to replace the bootloader. 

  • Hi Hung Bui,

      Thanks for your response. 

    As per your suggestion we planned to keep the bootloader inside the flash memory.

    After prevaalidation, the SD+App will be loaded to QSPI external memory and after the post validation I need to occupy it from QSPI external memory to internal flash memory.

    I am having nRF5280-DK which has QSPI memory(MX25R6435F with 1MB Flash size), i need to implement with this QSPI chip.

    As per you documents app_activate is called, when new app is present in Bank 1. 

    But in my task, after pre validation, i need to receive the image file from the DFU Controller and save it in QSPI memory. For QSPI task i will use the following function provided in qspi example (SDK).

     nrf_drv_qspi_write(m_buffer_tx, QSPI_TEST_DATA_SIZE, 0);

     nrf_drv_qspi_read(m_buffer_rx, QSPI_TEST_DATA_SIZE, 0);

     nrf_drv_qspi_erase(NRF_QSPI_ERASE_LEN_64KB, 0);

  • Hi Mohammad, 

    The writing to flash is handled inside on_data_obj_write_request(), you can modify nrf_dfu_flash_store() to use your qspi function instead of writing to the internal flash that fstorage does. 

  • @Mohammad, can you comment on your progress on this?  I'm planning on doing something similar (using SPI flash rather than QSPI) and I am glad you're leading the way on this! :-)  If possible, can you briefly enumerate which files (and functions) you've needed to modify/replace to accomplish this?

  • Hi TomWs,

       I have not completed this task and also i was busy with another task. I will let you know after i sucessfully complete it. But you can start with the above steps described.

Related