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!

Parents
  • 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?

Reply
  • 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?

Children
  • 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.

Related