Martin's corner on the web

Putting Raspberry Pi’s hardware watchdog to work

As I continue my quest for reliability of my Raspberry Pi computer, I stumbled upon something interesting that I didn’t know existed – hardware watchdog for Raspberry Pi. For those hearing this term for the first time, a watchdog is a hardware timer that needs to be regularly restarted in software. Failing to restart it means the computer is crashed and will result in a system restart.

So following the instructions, I have installed watchdog for my Pi:

Install watchdog

sudo apt-get install watchdog

Uncomment the following line in /etc/watchdog.conf

watchdog-device = /dev/watchdog

Edit /etc/modules

sudo editor /etc/modules

And add the following:

# hardware watchdog
bcm2708_wdog

Run the following command to activate the module and service:

sudo modprobe bcm2708_wdog
sudo service watchdog restart

I hope this helps improve the overall reliability of my Raspberry Pi computer.

5 thoughts on “Putting Raspberry Pi’s hardware watchdog to work

  1. Phil

    Hi Martin,
    That looks very interesting, I look forward to hearing how it works out. I’m curious as to what reliability problems you have with your Pi? I’ve just checked mine and its been up now for 38 days without any problems. Like you, I have moved the rootfs to an external usb ‘stick’ though I did this mainly for increased capacity. I have the Pi connected to my lan and also I have a wifi dongle setup in adhoc mode so I can shutdown the modem/router overnight, but still access emoncms if I want to. I power it with a 12v deep cycle battery that is permanently connected to an ‘intelligent’ (motorcycle) charger.

    1. Martin Post author

      I think my problems were caused by the unexpected power outages; I only moved the rootfs to external drive couple days ago, so that will probably make a difference too. The watchdog solution is just another “measure” to ensure the thing runs stable. Your setup looks much less prone to such failrues, so no surprise that you run that long..

  2. PeterN

    Hi Martin,
    Thanks – this should greatly enhance performance of RPi. I have a few configured as emoncms, xbian and camera which have all needed reboot at one stage.

    Got this after final step – is this ok?
    pi@raspberrypi ~ $ sudo service watchdog restart
    [FAIL] Restarting watchdog: Stopping watchdog daemon… failed!
    [ ok ting watchdog daemon….

    Thanks

    Peter

  3. PeterN

    Ran last two steps together and looks better. No idea why but hope it helps.

    pi@raspberrypi ~ $ sudo nano /etc/watchdog.conf
    pi@raspberrypi ~ $ sudo editor /etc/modules
    pi@raspberrypi ~ $ sudo modprobe bcm2708_wdog
    pi@raspberrypi ~ $ sudo service watchdog restart
    [FAIL] Restarting watchdog: Stopping watchdog daemon… failed!
    [ ok ting watchdog daemon….
    pi@raspberrypi ~ $ ^C
    pi@raspberrypi ~ $ sudo modprobe bcm2708_wdog ; sudo service watchdog restart
    [….] Restarting watchdog: Stopping watchdog daemon… Starting watchdog daemon[ o.
    pi@raspberrypi ~ $ ^C

  4. PeterN

    Looking at it again it probably obvious that restart failed first time as it wasn’t running.