Apart from pressing Button 4 or adding a DFU service to current running application. Is there any way to enter DFU mode from application?
Is it possible with nrfutil to move from application to DFU Mode, Update the image.
Apart from pressing Button 4 or adding a DFU service to current running application. Is there any way to enter DFU mode from application?
Is it possible with nrfutil to move from application to DFU Mode, Update the image.
Before resting to the bootloader mode, you should prepare the reset. Calling directly the NVIC_SystemReset();
method is not a good option IMO:
void reset_prepare(void) {
uint32_t err_code;
// Change a LED state
// Disconnect from BLE peer if connected
// If not connect, stop advertising if enabled
err_code = ble_conn_params_stop();
APP_ERROR_CHECK(err_code);
}
// Disable the SoftDevice and restart properly in bootloader mode
void bootloader_start() {
// A "simple" reset is not enough, the SD and IRQs must be disabled first
ble_dfu_evt_t evt;
memset(&evt, 0, sizeof(evt));
evt.ble_dfu_evt_type = BLE_DFU_START;
dfu_app_on_dfu_evt(&m_dfus, &evt);
}
In my case, I generate a ble_dfu_evt_t
event to restart properly in bootloader mode. I also use the reset_prepare
function to close a BLE connection or stop advertising before entering in bootloader mode.
Before resting to the bootloader mode, you should prepare the reset. Calling directly the NVIC_SystemReset();
method is not a good option IMO:
void reset_prepare(void) {
uint32_t err_code;
// Change a LED state
// Disconnect from BLE peer if connected
// If not connect, stop advertising if enabled
err_code = ble_conn_params_stop();
APP_ERROR_CHECK(err_code);
}
// Disable the SoftDevice and restart properly in bootloader mode
void bootloader_start() {
// A "simple" reset is not enough, the SD and IRQs must be disabled first
ble_dfu_evt_t evt;
memset(&evt, 0, sizeof(evt));
evt.ble_dfu_evt_type = BLE_DFU_START;
dfu_app_on_dfu_evt(&m_dfus, &evt);
}
In my case, I generate a ble_dfu_evt_t
event to restart properly in bootloader mode. I also use the reset_prepare
function to close a BLE connection or stop advertising before entering in bootloader mode.
Not sure I agree with that. It makes sense if you are doing the "soft reset" where you enter the bootloader by jumping into the bootloaders entry point instead of doing a chip reset. However, if you are doing a chip reset the stack is going to be coming up from scratch and any connection you had will be taken down by a connection supervisor timeout. Just seems like additional complexity if you are doing a chip reset.
Both approaches are possible. Depending on the BLE connection parameters, the timeout can be several seconds. I always prefer to correctly close a BLE connection.