Booting an application image without using DFU to transport

Hello Nordic Semi,

My Platform: nRF52840 + S140 SoftDevice + Secure Bootloader, SDK base v15.2 

I am working on a project requiring to transport application images to flash without using of the well established DFU/Mobile method. Images are transported via BLE connection during application runtime and written to flash using customized means. Assuming the whole application image is transported and written to free flash space, I need to then prepare the system to boot and run the new image. This requires some coordination with the bootloader settings configuration by the running application before restart.

Question: What are the specific steps necessary to inform/configure the bootloader to boot the newly written image?

- Edwin

  • Hello Vidar,

    Thanks for your guidance so far on the background DFU. I have integrated the app side 15.3 files needed to perform the settings write. I have left out nrf_dfu_transport, nrf_dfu_req_handler, nrf_dfu_validation and nrf_dfu_ver_validation and just want to directly mark everything in the s_dfu_settings struct necessary to have my secure bootloader detect, copy and boot the new image. 

    I have confirmed that app side DFU is initializing the settings structure ie:

    > Calling nrf_dfu_settings_init()...

    > Using settings page.

    > Copying forbidden parts from backup page.

    > Destination settings are identical to source, write not needed. Skipping.

    After transporting the init command data I copy to s_dfu_settings.init_command[] and confirm this array contains identical data.

    After transporting the new application image to the address given by nrf_dfu_bank1_start_addr() and confirming this exists in flash I then mark s_dfu_settings.bank_current = NRF_DFU_CURRENT_BANK_1.

    Finally I’m calling nrf_dfu_settings_write_and_backup() to apply the updates.

    So far so good but some questions:

    1. What other members of s_dfu_settings need updating in preparation for reboot?

    2. Can I simply induce a reset after completing the settings write (ie: sd_nvic_SystemReset()) or is marking the general purpose retention register needed in advance of reset?

    -Edwin

  • Hi Edwin,

    You can see which fields the application is allowed to change in this post:  RE: App-based DFU, changing bank#1 address? . However, I believe it's only .bank_current and .init_command that are required. 

    elange said:
    2. Can I simply induce a reset after completing the settings write (ie: sd_nvic_SystemReset()) or is marking the general purpose retention register needed in advance of reset?

    You only need a reset. When the NRF_DFU_CURRENT_BANK_1 flag is set, the bootloader will enter the postvalidation function which should verify the image uploaded by the application, and then activate it. 

    Vidar

  • Thanks Vidar, based on other discussion the parameters in s_dfu_settings.progress needed for post validation after reset are:

    • progress.command_size
    • progress.command_offset

    This in addition to the bank_current setting did the trick. I see new image being rebooted now!

Related