Thursday 1 May 2014

Enabling the watchdog on a Raspberry Pi (Raspbian)

I have a Raspberry Pi that's connected to a PICAXE which listens for sensor data that's being broadcast from a couple of nodes in my house (one measures mains power consumption, two others measure ambient temperature). In summer the Raspberry Pi gets a bit warm and randomly locks up, so I've enabled the hardware watchdog to automatically reboot it if the system locks up.

A hardware watchdog is usually a watchdog timer: a register which is hooked up to a clock and when either the register overflows or hits zero it triggers a hardware reset. Your system writes to the register periodically to stop it triggering the hardware reset. If for some reason you stopped writing to the register, something went wrong and the system resets.

Here are some short notes on how to enable the onboard watchdog on the Raspberry Pi:

Run the following command to attempt loading the watchdog kernel module:
sudo modprobe bcm2708_wdog

Now run "lsmod" and look for the line in bold below:

Module Size Used by
bcm2708_wdog 3537 0


This verifies that the watchdog module was loaded successfully. Now edit /etc/modules and add bcm2708_wdog to load the module on boot by running the following command:
sudo echo bcm2708_wdog >> /etc/modules

Install the watchdog package:
sudo apt-get install watchdog

Configure starting the watchdog daemon on boot:
sudo update-rc.d watchdog defaults
sudo chkconfig watchdog on

Edit the watchdog daemon's configuration files and tell it to use the watchdog device. Change the line:
#watchdog-device = /dev/watchdog
to
watchdog-device = /dev/watchdog

Start the watchdog:
/etc/init.d/watchdog start


No comments:

Post a Comment