Hello,
We are using the nRF52840 with SDK 17.1.0, SoftDevice S140 v7.2.0, and the secure bootloader (nrf_bootloader.c).
Our application relies on reading NRF_POWER->RESETREAS & NRF_POWER_RESETREAS_OFF_MASK after boot to detect that the device woke from System OFF, so it can conditionally re-enter System OFF under certain conditions.
We noticed that when NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET is set to 1 (the default), the bootloader's crc_on_valid_app_required() function clears the OFF flag from RESETREAS before the application ever runs:
//nrf_bootloader.c
if (NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET &&
(nrf_power_resetreas_get() & NRF_POWER_RESETREAS_OFF_MASK))
{
nrf_power_resetreas_clear(NRF_POWER_RESETREAS_OFF_MASK);
ret = false;
}
This means by the time our application starts, the System OFF reset reason is already gone and we cannot detect the wakeup source.
Questions:
What is the rationale for clearing the OFF-reset reason flag here? Is it purely to ensure the CRC skip only applies once (i.e., the immediate boot after System OFF), or are there other implications?
If we set NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET to 0 so the flag is preserved for our application, the only effect should be that the bootloader will perform a full CRC check of the application on every System OFF wakeup. Are there any other side effects or risks we should be aware of?