1 (edited by brna 2015-04-19 12:49:10)

Topic: Using the hardware watchdog on ar71XX

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

2 (edited by valentt 2015-04-28 09:45:16)

Re: Using the hardware watchdog on ar71XX

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

Re: Using the hardware watchdog on ar71XX

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 }'

Re: Using the hardware watchdog on ar71XX

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

Re: Using the hardware watchdog on ar71XX

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

Re: Using the hardware watchdog on ar71XX

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?

Re: Using the hardware watchdog on ar71XX

Looks like after this patch it is finally possible to take over manually tickling watchdog:
https://git.openwrt.org/?p=project/proc … 83073fabb1

8 (edited by valentt 2018-03-16 17:10:33)

Re: Using the hardware watchdog on ar71XX

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
}

Re: Using the hardware watchdog on ar71XX

I wrote a detailed blog post regarding how to use hardware watchdog and how to manually take control over it:
http://kernelreloaded.com/manually-cont … -watchdog/