Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Preserving reset reason with NRF bootloader (SDK15.2)

Hello,

My application, running on nRF52840 with SDK15.2, needs to detect the reset source from System OFF state. However, when using the BLE Secure DFU Bootloader, it always finds the RESETREAS register cleared to 0.

I tracked the problem to nrf_bootloader.c:231

nrf_power_resetreas_clear(NRF_POWER_RESETREAS_OFF_MASK);

Commenting out this line does fix my symptom, and my application is able to retrieve the reset reason once again with the bootloader present.

Since both the clear and the jump to the application happen in "nrf_bootloader_init()", I cannot simply save and restore the content of RESETREAS without modifying SDK files.

Is there a proper way to preserve the reset reason with the standard bootloader library?

Thanks in advance!

  • Hi Nathan,

    I don't think it will be a problem if you modify the SDK library as long as you do the clear in the application (main.c).

    Best Regards,

    Marjeris

  • Hello Nathan,

    What do you mean by saving and restoring the content of RESETREAS? To my understanding you cannot write back to RESETREAS, writing a '1' its what actually clears the register.....

    I am having the same issue as you describe, did you just left the line nrf_power_resetreas_clear(NRF_POWER_RESETREAS_OFF_MASK); commented out?

    Does anyone know why the NRF Bootloader clears the reset reason in the first place?

  • Hello Israel,

    Unless I'm mistaken, you can indeed read and write to the RESETREAS register. But this was not a solution to this problem.

    Here is the patch I applied:

    --- a/components/libraries/bootloader/nrf_bootloader.c	Tue Oct 30 13:29:35 2018 +0100
    +++ b/components/libraries/bootloader/nrf_bootloader.c	Tue Feb 05 18:06:54 2019 +0100
    @@ -228,7 +228,7 @@
         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);
    +        //nrf_power_resetreas_clear(NRF_POWER_RESETREAS_OFF_MASK);
             ret = false;
         }
         else if (NRF_BL_APP_CRC_CHECK_SKIPPED_ON_GPREGRET2 &&
    

    By reading then clearing it in the application, I have not encountered any side-effect since then.

  • Thanks for this post, it quickly help me locate the same issue.  Not sure if Nordic did some changes in the SDK (I'm using 15.3). That same line of code was on line 239 and was wrapped inside of an IF statement.  I was able to work around this issue without modifying the  SDK Files.  I just had to go into the sdk_config.h file and UNCHECK the "NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET" option (located under nRF_Bootloader>>nrf_bootloader - Bootloader settings>>Application integrity checks.

Related