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.