This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

WDT & Bootloader

My application uses the WDT. In my application, I use a soft reset to enter the bootloader. Because the soft reset does not reset the WDT the program will reset while in the bootloader because of a watchdog timeout.

What is the best way to handle this issue? I see too options. Instead of performing a soft reset to enter the bootloader I could let the WDT in my application expire in order to perform a reset using a WATCHDOG reset. Alternatively I could add the watchdog service into the bootloader. I don't like that the watchdog is running during the initialization routines at the beginning of my application.Why does the softreset not reset the watchdog? Seems a bit odd.

Parents
  • Hi Lucas,

    I think the philosophy behind is that WDT should work in the way that when it started it can not be turned off. So the WDT can only be reset by itself or by a complete system reset (brown out, pin reset, systemOFF). When entering system OFF, the WDT register is retained but WDT is stopped.

    In this case, softreset is lower level that a Watchdog reset and it shouldn't reset the WDT.

    You are correct about the 2 solutions. I would personally choose to trigger system reset using WDT to start bootloader. In case you don't plan to do a reset when switching between application and Bootloader then you would need to handle the WDT in the bootloader.

Reply
  • Hi Lucas,

    I think the philosophy behind is that WDT should work in the way that when it started it can not be turned off. So the WDT can only be reset by itself or by a complete system reset (brown out, pin reset, systemOFF). When entering system OFF, the WDT register is retained but WDT is stopped.

    In this case, softreset is lower level that a Watchdog reset and it shouldn't reset the WDT.

    You are correct about the 2 solutions. I would personally choose to trigger system reset using WDT to start bootloader. In case you don't plan to do a reset when switching between application and Bootloader then you would need to handle the WDT in the bootloader.

Children
  • Hi Hung,

    Is there any reason why WDT reset wouldn't start the bootloader? In our setup, doing a soft reset causes the bootloader to start; but a WDT reset doesn't. GPREGRET register which is used to trigger the DFU mode is updated in both these resets. Have you tried entering the bootloader mode via WDT reset? Thanks.

  • @Shiva: As shown in the table at section 12.1.19 nRF51 Reference Manual, Watchdog reset will reset the retained register GPREGRET. That's why the bootloader didn't enter bootloader mode after WDT reset.

  • Thanks for the clarification, Hung. I figured as much after posting the comment. DFU sample code that Nordic provides by default uses GPREGRET to trigger the switch to OTA. If you could additionally clarify that we need to make use of application flash area to trigger the OTA switch if we want enter OTA mode via WDT reset, that would be great.

    What makes this complicated is that sf we already have a bootloader out there that uses GPREGRET to switch to OTA and doesn't already feed the WDT, then we can't release an application that starts using WDT now. Do you know if there is a way to achieve this?

  • Hi Shiva,

    One solution is to erase the BANK_VALID_APP flag in p_bootloader_settings->bank_0 in flash (have a look at bootloader_app_is_valid() function). By doing that and then do a WDT reset (or any reset), you will force the Bootloader to enter OTA mode. But the draw back is that there is no way to fallback to the original application.

Related