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 TomWS,

    Thanks for your reply.

    Can you pls let me know where i need to use this,

    EXTERNAL_FLASH_ADDRESS=0x0A00000;

  • Hi TomWS, Thanks for your reply. Can you pls let me know where i need to use this, EXTERNAL_FLASH_ADDRESS=0x0A00000;

    I would have expected you to know this by now.  However, to answer your question, there are two places where this is relevant.  On the start of download where the DFU code gets the Bank1 start address:

    File: nrf_dfu_utils.c, nrf_dfu_bank1_start_addr()

    You need to return the synthetic address used to distinguish your external flash.

    And in your QSPI read & write functions where you need to strip off the upper bits of the synthetic address before using it.

    Note, as mentioned in an earlier reply (about 2 months ago), once you use a 'synthetic' address that is outside the range of the device flash, you need to modify the error checking in  nrf_dfu_cache_prepare() as in:

     

            //TWS: IGNORED! ASSERT(cache_address <= DFU_REGION_END(bootloader_start_addr));
            //TWS: REPLACED BELOW: cache_too_small = required_size > (DFU_REGION_END(bootloader_start_addr) - cache_address);
            cache_too_small = required_size > EXTERNAL_FLASH_SIZE;
            delete_more     = cache_too_small || single_bank; // Delete app or SoftDevice only if we need more room, or if single bank is requested.
    

  • Hi TomWS,

    Thanks for rour response.

    I have made modification according to your instruction. But it throws hardware error after the hash verification succeed.

    nrf_dfu_bank1_start_addr(void) will return return ALIGN_TO_PAGE(0x0A00000 + bank0_addr + s_dfu_settings.bank_0.image_size);

    ASSERT((cache_address & 0x000FFFFF) <= DFU_REGION_END(bootloader_start_addr));
    cache_too_small = required_size > (DFU_REGION_END(bootloader_start_addr) - (cache_address & 0x000FFFFF));
    delete_more = cache_too_small || single_bank; // Delete app or SoftDevice only if we need more room, or if single bank is requested.

    And strip off the upper bits of the synthetic address before using in QSPI read & write functions.

  • I'm not sure why you're getting a hardware fault, examining the stack might give you a clue.  However, I also don't know why you're modifying the bank1 start address.  ISTM that using the beginning of the QSPI memory should be sufficient.  What you store in QSPI flash doesn't have to have the same location as the firmware address.  Here is my dfu_bank1_start_addr():

    uint32_t nrf_dfu_bank1_start_addr(void)
    {
      if ((s_dfu_settings.bank_0.bank_code == NRF_DFU_BANK_VALID_APP) && s_dfu_settings.bank_0.image_size) { // is there an app already loaded?
        return EXTERNAL_FLASH_ADDRESS;  // yes, use external flash for bank1
      }    
      // no, use bank 0 for downloading
      uint32_t bank0_addr = nrf_dfu_bank0_start_addr();
      return ALIGN_TO_PAGE(bank0_addr + s_dfu_settings.bank_0.image_size);
    }
    

  • After the hash is verified successfully. Old setting are erased and new one written at 0x000FF000 and 0x000FE000. Then bootloader resets and check the backup settings which inturn throws ""Destination settings are identical to source, write not needed. Skipping".

    After that it goes to NMI_Handler Exception.

    But when i disable the External QSPI storage and work with standard bootloader code everything works fine, there is no NMI_Handler Exception.

    Pls help me to solve this issue.

Related