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

WDT and Error Handler

This ticket started as a mail thread so I add it here so no data are missing:

============================================================================================================================ 

Yes I based my code from this sample code so I use the exact same steps and variables (5 seconds timeout). I do not use the wdt_feed() and it still works and I assume that if we do not feed the dog it will hang after 5 seconds. But it does not do that but I can see sporadic reboot within one hour.

For the callback issue I do use a debugger and it never enter the callback.

So having a WDT driver that do not needs feed, no working callback and sporadic restarts seems to be a broken implementation in Zephyr!

How can you fix this and when?

============================================================================================================================

Regarding the watchdog - there is a nice sample presenting how to use the API:

https://github.com/zephyrproject-rtos/zephyr/blob/master/samples/drivers/watchdog/src/main.c

Have you tried to follow this one?

Basically you need to call wdt_install_timeout(), then wdt_setup(), and then feed the watchdog with wdt_feed() within the time configured when installing the timeout.

And when checking if the watchdog callback function is called, remember that this function is called two cycles of the 32 kHz clock before the reset is done, so it is a very little time to do something. In case you’d want to set a breakpoint in this function, you’ll need to use the WDT_OPT_PAUSE_HALTED_BY_DBG option.

============================================================================================================================

I have two question regarding WTD and Error-handler.

  1. I have enabled WDT in Zephyr and implemented the setup and enable of the WDT and it seems to work, but …
    I do not use the wdt_feed() api but still it works but I could get sporadic restart within an hour a so. I also note that the callback function is not called when watchdog has expired.
  2. For the Error-Handler; And there are a lot of different fault handler for different failure and exceptions. And I want to enable reset when this happens. So is there any support for reset when we end up in any error handler?
Parents
  • 1.It's possible that the WDT is paused because the device is in sleep mode. That way it might take a long time for the WDT to time out.

    2. If the device doesn't reset already when it enters an error handler, then you can call NVIC_SystemReset() in all of the error handlers that you are using.

  • I just noted that #2 is already solved sins I ask this question 3 weeks ago. So we can skip this one.

    I will take a look at the sleep issue.

  • I see the issue here, some else have comment on this related to the last comment from me that was a request to change my code to something I already now will fail (explained above). I do not use this and was a request to show the code snippet on a change that Nordic (hakan) wanted to change that was wrong in my mind.

    I use wdt_setup(system_wdt_dev, WDT_OPT_PAUSE_IN_SLEEP) and have done this for all of my test.

    I only see one way forward and that is Nordic test the WDT in Zephyr and comeback when it is veryfied that it works and if so provide the solution for this.

    Here is some more info that was not part of the code snippet:

    #define SYSTEM_WDT_WINDOW_MAX 5000 // ms
    #define SYSTEM_WDT_WINDOW_MIN 0    // ms

  • I just read the thread again because I reference on older comments but they are gone. Have you deleted my old comments?

  • I do not use wdt_setup(system_wdt_dev, 0) I use wdt_setup(system_wdt_dev, WDT_OPT_PAUSE_IN_SLEEP).

    see commit :

    Even if I was clear how the configuration works you still want me to experiment with something that do not make sense. So I did test your suggestion and it fails because of my explanation above. The bit configuration are bitmask so the drivers knows what to configure. Bit 0 controls the sleep wdt and it should be set to 0. And this are done with wdt_setup(system_wdt_dev, WDT_OPT_PAUSE_IN_SLEEP). With your experiment it does not set anything (bit mask set 0 -> setting nothing). This means that wdt for sleep will be set too 1 (default configuration) so we will reboot every-time we going to sleep.

    So back to my OP question. Why do the system reboot within 2-4h?

  • So please try to setup watchdog with this option. If the problem will occurs after this change we try to prepare simple example together (extraction of affected code, based on zephyr and next one based on nrfx project to exclude influence of the zephyr RTOS) and pass it to Nordic engineers to look deply in peripheral's and CPU behaviour.

    jlz, please follow the advice above

Reply Children
No Data
Related