Greetings,
I'm using NRF52840 with softdevice and nRF5_SDK_17.1.0 on NRF52 DK.
The shutdown_handler in my code is as follows:
bool shutdown_handler(nrf_pwr_mgmt_evt_t event)
{
uint32_t err_code;
NRF_LOG_INFO("Entered power manager handler.");
switch (event)
{
case NRF_PWR_MGMT_EVT_PREPARE_SYSOFF:
NRF_LOG_INFO("NRF_PWR_MGMT_EVT_PREPARE_SYSOFF");
err_code = bsp_buttons_disable();
APP_ERROR_CHECK(err_code);
break;
case NRF_PWR_MGMT_EVT_PREPARE_WAKEUP:
NRF_LOG_INFO("NRF_PWR_MGMT_EVT_PREPARE_WAKEUP");
err_code = bsp_buttons_disable();
// Suppress NRF_ERROR_NOT_SUPPORTED return code.
UNUSED_VARIABLE(err_code);
err_code = bsp_wakeup_button_enable(BTN0);
// Suppress NRF_ERROR_NOT_SUPPORTED return code.
UNUSED_VARIABLE(err_code);
break;
case NRF_PWR_MGMT_EVT_PREPARE_DFU:
err_code = sd_power_gpregret_clr(0, 0xffffffff);
VERIFY_SUCCESS(err_code);
err_code = sd_power_gpregret_set(0, 0xB1);
VERIFY_SUCCESS(err_code);
break;
case NRF_PWR_MGMT_EVT_PREPARE_RESET:
NRF_LOG_INFO("NRF_PWR_MGMT_EVT_PREPARE_RESET");
break;
}
NRF_LOG_FLUSH();
bsp_board_leds_off();
err_code = app_timer_stop_all();
APP_ERROR_CHECK(err_code);
return true;
}
/**@brief Register application shutdown handler with priority 0. */
NRF_PWR_MGMT_HANDLER_REGISTER(shutdown_handler, 0);
There is a secure bootloader from Nordic examples on my NRF52840 with the following configs set:
#define NRF_BL_DFU_ENTER_METHOD_PINRESET 1 #define NRF_BL_DFU_ENTER_METHOD_GPREGRET 1
But when I run the following command in my code, it just resets the device and does not enter the DFU mode. The only way to enter DFU is using the reset pin.
nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);
What is the problem and how can I resolve that?
Thanks in advance.