krischaplin
Posts: 13
Joined: Fri Jan 13, 2012 1:52 pm

Watchdog timer - is 15 seconds the longest timeout?

Wed Jun 27, 2012 10:59 am

Hello All,

I have been using the Watchdog timer, however it appears that I can only program it at a maximum timeout value of 15 seconds. This is with the latest Debian distribution. Looking at the driver, this appears to be a hard maximum, however I cannot see mention of the Watchdog in the Broadcom documentation, so am unsure if this is a false limitation of the hardware, or indeed reality.

Has anyone used the watchdog with timeout of longer than 15 seconds? My C/Script combination has to spend a lot more CPU cycles than it should keeping the WDT happy, and a longer timout would be very welcome.

Best regards
Kris

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5537
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Watchdog timer - is 15 seconds the longest timeout?

Wed Jun 27, 2012 11:45 am

Looks like watchdog timeout register has 20 bits, and counts down every 16 microseconds. So limit is just under 16 seconds. And this is a hardware limit.
krischaplin wrote:My C/Script combination has to spend a lot more CPU cycles than it should keeping the WDT happy, and a longer timout would be very welcome.
Really? You are saying resetting the watchdog counter, say, once a second is wasting CPU cycles? Perhaps 0.001% of them...

krischaplin
Posts: 13
Joined: Fri Jan 13, 2012 1:52 pm

Re: Watchdog timer - is 15 seconds the longest timeout?

Wed Jun 27, 2012 12:05 pm

Hello Dom,

Thanks for the clarification. Can I ask where you found that? Perhaps I missed it in the documentation.

I'm implementing a system that will be remote/unattended, and I'm using a ping test to check for network connectivity. If the Pi cannot ping its gateway, I know network connectivity is somehow screwed, and expire the watchdog to reboot. As we know, ping can take some time to return - 10-15 seconds on a busy host is not out of the question.

I create two threads, one that keeps the watchdog timer happy with regular heartbeats, and the other that tests for ping response packets. On reception of a valid ping, a shared variable is updated between the two threads that resets a counter that would eventually decrement and stop the heartbeat process triggering the watchdog. This is a lot more overhead than I would want (call me mean!). If I could have set the granularity to say, 1 minute, or 10 minutes even, then I would be able to run a cron job to check for network connectivity, which would be much more simpler = lower risk of programming errors.

Thanks for the confirmation that this is a hardware limit. I'll consider my options.

Many thanks
Kris

mcgyver83
Posts: 361
Joined: Fri Oct 05, 2012 11:49 am

Re: Watchdog timer - is 15 seconds the longest timeout?

Mon Oct 22, 2012 12:23 pm

Hi, I'm looking for something that can reboot raspberry if lan connection fall down.
Watchdog can do this base on the ping.
I followed this article http://pi.gadgetoid.co.uk/post/001-who- ... he-watcher but I my rasp doesn't reboot after "fork bomb" (: (){ :|:& };:)
It still hungs and after a manual reboot it reboot itself after some seconds
How can I achieve my two targets (heartbeat and ping)?

embeddedsys
Posts: 7
Joined: Tue Nov 06, 2012 8:36 pm

Re: Watchdog timer - is 15 seconds the longest timeout?

Tue Nov 06, 2012 8:38 pm

I also need this

using wlan and if the wireless router reboots (it has dhcp and saved the pi mac into reservation pool) pi cannot get the connection live again even if i remove and reinsert the stick.

so this must be done !!


Return to “Troubleshooting”