OFF CHIP OTA UPDATE using external flash

I am working on this project off chip ota update on nRF5_SDK  using ecample/thread/dfu

by now, i have done changes in these functions on_data_obj_create_request() and on_data_obj_write_request(). initially these functions were erasing and writing data in internal flash which I changed to qspi functions like nrf_drv_qspi_erase() and nrf_drv_qspi_write(). and it works perfectly.

Later i changed functions for hash verification which is also working but i am not sure about what should be the next step so that bootloader changes the earlier application with the new firmware image.

  • Bank 1 is the temporary address where the app was initially supposed to be downloaded, but I changed it to external flash.

    Bank 0 is the address in the internal flash where the app runs after the download completes. In the bootloader, we erase the old image from bank 0 and replace it with bank 1 (in this case, external flash) after performing a CRC check.

  • Yes, but you are not showing how you adapted the copy function to read the image from external flash.

  • i have changed the image_copy function and in logs i can see it is working and writes my image completely

    after this i have shared a code snippet of image_copy() inside that i have changed this

    // Flash one page

    uint32_t m_buffer_rx[bytes];

    if(nrf_drv_qspi_read(m_buffer_rx, bytes,firmware_flash_addr ) != NRFX_SUCCESS)
    {
    NRF_LOG_INFO("Failed read application for bootloader reset in Ext Flash.\r\n");
    }
    else
    {
    NRF_LOG_INFO("Succsessfully read application for bootloader reset from: 0x%lX\r\n",firmware_flash_addr);
    WAIT_FOR_PERIPH();
    NRF_LOG_DEBUG("Copying 0x%x to 0x%x, size: 0x%x", src_addr, dst_addr, bytes);
    ret_val = nrf_dfu_flash_store(dst_addr,
    (uint32_t *)m_buffer_rx,
    ALIGN_NUM(sizeof(uint32_t), bytes),
    NULL);
    }

    and code which was earlier copying the image is here:


    //NRF_LOG_DEBUG("Copying 0x%x to 0x%x, size: 0x%x", src_addr, dst_addr, bytes);
    //ret_val = nrf_dfu_flash_store(dst_addr,
    // (uint32_t *)src_addr,
    // ALIGN_NUM(sizeof(uint32_t), bytes),
    // NULL);

  • It looks like you are using the QSPI flash API correctly. Could you please read out the image stored in the QSPI flash and compare it to the image stored in Bank 1 to see if they match?

  • To read from the external flash, a specific command is required by the nrfprog tool. Unfortunately, while retrieving data from the external flash, this command appends the address to each line, thereby impeding the direct comparison between the data retrieved from the internal and external flash sources.

    Furthermore, regarding the progress of the DFU process, I'd like to inform you that we have reached the final stages:

    1. The application has been successfully downloaded to the external flash.
    2. Hash verification has been completed without any issues.
    3. DFU bank 1 has been appropriately configured.
    4. The bootloader has been reset as per the protocol.
    5. The bootloader is effectively replacing the entire code from the external flash to the internal flash.
    6. Upon replacement, a CRC computation over the image in the internal flash is conducted. However, this step encounters failure, and despite diligent efforts, the root cause behind this failure remains elusive.
Related