Start of application takes ages after DFU process is complete

Hello,

in my application (SDK 16.0.0, nRF52840) I perform a DFU and successfully update the application firmware. However I have noticed that from the moment when the DFU is complete (i.e. the moment when the on_dfu_complete callback, defined in nrf_dfu_req_handler.c, is executed) to the moment when my application is active there is a huge time gap, about 15 seconds. Do you have any idea about the cause of this gap and how to reduce it? My guess is that there is either a coherence check on the new application before it is started, or a specific parameter that causes the delay in the sdk_config.h, which I am not aware of. My application occupies little less than half the available flash on the 52840.

Thank you.

Kind regards,

Stefano

  • Hello Stefano, 

    The activation delay is caused by the bootloader having to copy the FW image from bank 1 into bank 0. As can be seen from the Flash programming section of the PS, erasing one flash page takes ~85 ms, and the time to write one word is 41 us.

    If it is important to reduce this delay, you could consider configuring the bootloader so that it only perfom single bank updates (Dual-bank and single-bank updates) of the application, which means the application will be updated in-place.

    Kind regards,

    Vidar

  • Dear Vidar,

    Thank you for your quick answer. This can partially explain the large delay I observe. My application is exactly 409600, i.e. 100 pages, wide (the image we send is created in such a way to be always that size, and exactly half the available flash for dual update. I have verified in flash that after an update bank 1 starts immediately after the end of bank 0). So the time to erase and copy one page would be 85+(0,041*(4096/32)) ms=90 ms, and 9 seconds for 100 pages. Does any other potential source of delay to the start of application come to your mind?

    In addition to that, does this mean that when the on_dfu_complete is called the firmware has been copied into bank 1 but no validity check on it has been performed yet? What happens if there is a power cut during this validity check?

    Regards,

    Stefano

  • Dear Stefano,

    No problem. Regarding the calculation, there are 1024 words in a page, so I think it should be 85+(0,041*(4096/4)) = 127 ms. We also need to account for the time it takes to update the progress in  the BL settings page.

    nrf_bootloader_fw_activation.c->app_activate()->image_copy

    You can try increasing the NRF_BL_FW_COPY_PROGRESS_STORE_STEP value in sdk_config.h to see if that helps. This controls how frequent the settings page will be updated during the activation process.

    Regards,

    Vidar

  • Right, I mixed bits with bytes as for the word :) the numbers are getting close to what I see experimentally then. I will perform the test you suggest and let you know, but can you please confirm that the callback on_dfu_complete in nrf_dfu_req_handler.c is called before the new image is moved from bank 1 to bank 0? Cause otherwise there is smtg wrong in the way I do things.

    Thanks.

    Regards,

    Stefano

  • That can happen to the best of us Slight smile Yes, the bootloader is reset after the on_dfu_complete() callback has been invoked, and the image is copied from bank 1 to bank 0 on the subsequent startup.

    Regards,

    Vidar

Related