This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

DFU Bootloader Requires Reintialization of SD after Soft Reset

In the DFU code provided by nordic is explicitly states that.

"Soft reset from application must not reinitialize the SoftDevice."

In my application I do not have a button to force the device into DFU mode (inside the bootloader). I have implemented the jump from my application into the bootloader DFU using using the following code:

	err_code = sd_power_gpregret_clr(0xFF);
	APP_ERROR_CHECK(err_code);
	err_code = sd_power_gpregret_set(BOOTLOADER_DFU_START);
	APP_ERROR_CHECK(err_code);
	NVIC_SystemReset();

Basically, when a certain bluetooth write event is recieved by my application it executes the above code and sends the device into the bootloader where it starts the DFU service. However, I had to make a change to the bootloader to get it to work.

I had to explicitly reintialize the softdevice after my application performs a soft reset. That is accomplished using the following code.

else
{
    // If stack is present then continue initialization of bootloader.
    ble_stack_init(0x01);
    scheduler_init();
}

Previously the code read

else
{
    // If stack is present then continue initialization of bootloader.
    ble_stack_init(!app_reset);
    scheduler_init();
}

This confused me because the bootloader has a comment that explicitly says not to do this.

Am I doing something wrong should I not have to reintialize the softdevice? Everything is working i'm just curious why I had to violate the directions of the original bootloader.

Parents
  • Hi Lucas,

    Do you plan to keep bonding information when in DFU mode ? (to encrypt the link using the bond information that you used in the normal application ) If you don't plan to and just want to use DFU OTA without bonding, what you are doing now is just fine.

    What we plan when mentioned "Soft reset from application must not reinitialize the SoftDevice." was because of the implementation in the buttonless example (ble_app_hrs dfu example). That we don't do a full reset but only jump from application to the Bootloader, keeping the softdevice still initialized and that's why you should not do a softdevice initialize again when in bootloader. Please have a look at the bootloader_start() function in dfu_app_handler.c file in ble_app_hrs_with_dfu_experimental project.

    The reason we avoid a reset is to be able to pass bond information via RAM memory from application to bootloader.

Reply Children
No Data
Related