Raspberry - Watchdog for Raspbian Stretch 10

A watchdog timer is a special kind of timer commonly found on embedded systems that is used to detect when the running software is hung up on some task. The watchdog timer is basically a countdown timer that counts from some initial value down to zero. When zero is reached, the watchdog timer understands that the system is hung up and resets it. Therefore, the running software must periodically update the watchdog timer with a new value to stop it from reaching zero and causing a reset. When the running software is locked up doing a certain task and cannot update the watchdog timer, the timer will inevitably reach zero and a reset will occur.

Luckily for us, the Broadcom BCM2835 SoC on the Raspberry Pi comes with a hardware-based watchdog timer that can do just that. You will find this specially useful if you have a Raspberry Pi in a remote location and the operating system hangs and there's no one around to reboot it.

Installing the Watchdog

sudo apt-get install watchdog
sudo update-rc.d watchdog enable

Watchdog configuration

sudo apt-get install watchdog chkconfig
sudo chkconfig watchdog on
sudo /etc/init.d/watchdog start

Then open the configuration file:

sudo nano /etc/watchdog.conf

Uncomment the following lines:

watchdog-device = /dev/watchdog
interval = 4
realtime = yes
priority = 1

Save it. In the file /etc/systemd/system.conf, uncomment this line:


Kernel configuration

Create the following new file:

sudo nano /etc/modprobe.d/bcm2835_wdt.conf

Add these new lines:

alias char-major-10-130 bcm2835_wdt
alias char-major-10-131 bcm2835_wdt

Save this file. Then, in the file /etc/modules, add this line:


And start the new kernel probe:

sudo modprobe bcm2835_wdt
sudo service watchdog restart

Testing the configuration

Start the following forkbomb to check if the watchdog gets launched:

:(){ :|:& };:

The raspberry should eventually restart in 3-4 minutes at most.


BCM2835 data sheets

ARM Processor data sheet

Mirror from

Framboise314 - Watchdog pour mon Raspberry Pi - https://www.framboise314.fr/watchdog-pour-mon-raspberry-pi/

Previous Post Next Post