Hello,
In my application (using sdk 16.0.0) I have a bootloader that allows to upload a new firmware through either BLE or UART. The Bootloader is initialized as usual:
ret_val = nrf_bootloader_init(dfu_observer);
where:
static void dfu_observer(nrf_dfu_evt_type_t evt_type)
{
switch (evt_type)
{
.....
case NRF_DFU_EVT_DFU_STARTED:
sd_power_gpregret_set(0,0x4); // not correct but works!
bsp_board_led_on(BSP_BOARD_LED_0); // green
bsp_board_led_on(BSP_BOARD_LED_2); // red
break;
case NRF_DFU_EVT_OBJECT_RECEIVED: // DFU data object received
break;
case NRF_DFU_EVT_DFU_FAILED:
case NRF_DFU_EVT_DFU_ABORTED:
bsp_board_led_off(BSP_BOARD_LED_0); // green
bsp_board_led_on(BSP_BOARD_LED_2); // red
break;
case NRF_DFU_EVT_DFU_COMPLETED:
sd_power_gpregret_set(0,0x4); // set bit of GPREGRET register to remember DFU was ok after reset
bsp_board_led_on(BSP_BOARD_LED_0); // green
bsp_board_led_off(BSP_BOARD_LED_2); // red
break;
default:
break;
}
}
Now, what I would like to do is to write a bit of the GPREGRET register upon a successful DFU operation (NRF_DFU_EVT_DFU_COMPLETED) to notify the application that there has been a DFU after reset. However it looks like that state of the switch/case statement is never reached. The operations within the NRF_DFU_EVT_DFU_STARTED case (led blinking, GPREGRET writing) are instead executed, even though writing the register upon the "STARTED" event is not what I want as I am not sure at that point that the DFU operation will be successful.
Is there something I should do to enable the NRF_DFU_EVT_DFU_COMPLETED event to be processed? Is it possible that immediately after a successful DFU the bootloader resets and the new firmware is loaded, thus bypassing what is in that switch/case statement state? If so, what should I do to prevent an early reset?
Thanks.
Regards,
Stefano