- Check WDT module is enabled in kernel
In recent raspberry pi boards, the module for watchdog is
bcm2835_wdt
and it comes precompiled into kernel directly. So it doesn’t have to be enabled manually anymore and also it will not show when runninglsmod
.
To check if you have this module precompiled in kernel, you can run:
pi@raspberrypi:~ $ sudo cat /lib/modules/$(uname -r)/modules.builtin | grep wdt
kernel/drivers/watchdog/bcm2835_wdt.ko
pi@raspberrypi:~ $ sudo cat /var/log/kern.log* | grep watchdog
Oct 31 12:17:02 raspberrypi kernel: bcm2835-wdt bcm2835-wdt: Broadcom BCM2835 watchdog timer
First command checks if the module is compiled into the kernel while the second command checks if it is loaded at boot.
- Installing and enabling Watchdog (WDT) service
To enable watchdog you have to change the boot parameters by adding
dtparam=watchdog=on
in/boot/config.txt
. Also, install watchdog package and enable it to start at startup. Don’t forget to restart your RaspberryPi for these settings to come into effect.
pi@raspberrypi:~ $ sudo apt install watchdog
[... command output ...]
pi@raspberrypi:~ $ sudo systemctl enable watchdog
[... command output ...]
- Configure WDT service
The configuration file of watchdog can be tweaked in
/etc/watchdog.conf
. You can read the documentation for each setting in the file and adjust it as you like.
max-load-1 = 24
watchdog-device = /dev/watchdog
realtime = yes
priority = 1
- Test WDT service You can test the WDT working as expecting by simulating heavy load on your device. The following command runs a fork bomb and should create enough load for WDT to overflow. DANGER: THIS WILL REBOOT YOUR DEVICE.
# :(){ :|: & };: