OpenWrt Forum Archive

Topic: Using the hardware watchdog on ar71XX

The content of this topic has been archived on 6 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'm trying to find a way to use the hardware watchdog with tl-wr703n / gl-inet / carambola routers, a way to powercycle the device if it doesn't respond for a certain time.
I found links listed below and ended up with a fact that procd has replaced busybox-watchdog,but that info didn't lead me further.
Can you help?

    http://lxr.free-electrons.com/source/dr … th79_wdt.c
    http://trac.gateworks.com/wiki/watchdog
    http://trac.gateworks.com/wiki/gsc#GSCDrivers
    https://forum.openwrt.org/viewtopic.php?id=10554
    http://lxr.mein.io/source/procd/watchdog.h
    https://dev.openwrt.org/changeset/37106
    https://dev.openwrt.org/ticket/11722

Thanks!

Edit:
This works perfectly on raspbian, this is what i need on ar71xx: http://blog.ricardoarturocabral.com/201 … ng-on.html

(Last edited by brna on 19 Apr 2015, 12:49)

Interesting idea, let's see if this is possible to do on AR9331... I'll investigate also and share my findings.

(Last edited by valentt on 28 Apr 2015, 09:45)

Thanks to Jow on IRC here is what I found out. Watchdog is running by default now and it is controlled by ubus daemon.

You can query watchdog status by issuing this command:

ubus call system watchdog

to stop watchdog:
ubus call system watchdog '{ "stop": true }'

to start watchdog:
ubus call system watchdog '{ "stop": false }'

To manually take over control of watchdog stop ubus from controlling it and just trigger it by writing anything to /dev/watchdog every 10 seconds.

Here is watchdog api documentation:
https://lxr.missinglinkelectronics.com/ … og-api.txt

Wow, that's great!
Well done Valentt and Jow, tnx!

this is exactly what i'm looking for. you say simply "stop ubus from controlling it". how do you do this?

i found a page (http://trac.gateworks.com/wiki/watchdog) which shows how to stop ubus from petting the watchdog (ubus call system watchdog '{ "stop": true }' ). i haven't been able to write to /dev/watchdog when i do this, however. i get "device busy" error. because i can't write to that dev, the unit will reboot in 30 seconds (or the timeout time).

how do you disable ubus/procd from maintaining a lock on /dev/watchdog?

first step is to enable magicclose feature of watchdog, this releases procd lock of /dev/watchdog when it is stopped.

if you just try to stop watchdog then you are still not allowed to "tickle" /dev/watchdog and after 30 seconds device just reboots:

root@OpenWrt:~# ubus call system watchdog '{"stop": true}'
{
        "status": "stopped",
        "timeout": 30,
        "frequency": 5,
        "magicclose": false
}
root@OpenWrt:~# echo 1 > /dev/watchdog 
-ash: can't create /dev/watchdog: Resource busy

But if you first enable magicclose then you can tickle watchdog manually:

root@OpenWrt:~# ubus call system watchdog '{"magicclose": true}'                                                                                                                                                     
{                                                                                                                                                                                                                    
        "status": "running",                                                                                                                                                                                         
        "timeout": 30,                                                                                                                                                                                               
        "frequency": 5,                                                                                                                                                                                              
        "magicclose": true                                                                                                                                                                                           
}

root@OpenWrt:~# ubus call system watchdog '{"stop": true}'
{
        "status": "offline",
        "timeout": 0,
        "frequency": 0,
        "magicclose": true
}
root@OpenWrt:~# echo 1 > /dev/watchdog 

and you can return watchdog control back to procd:

root@OpenWrt:~# ubus call system watchdog '{"stop": false}'
{
        "status": "running",
        "timeout": 30,
        "frequency": 5,
        "magicclose": true
}

(Last edited by valentt on 16 Mar 2018, 17:10)

The discussion might have continued from here.