Code: Select all
Linux jessie 4.9.24-v7+ #993 SMP Wed Apr 26 18:01:23 BST 2017 armv7l GNU/Linux
Code: Select all
ls -al /dev/watchdog*
0 crw------- 1 root root 10, 130 Aug 16 00:09 /dev/watchdog
0 crw------- 1 root root 252, 0 Aug 16 00:09 /dev/watchdog0
Code: Select all
Linux stretch 4.9.41+ #1023 Tue Aug 8 15:47:12 BST 2017 armv6l GNU/Linux
Code: Select all
ls -al /dev/watchdog*
0 crw------- 1 root root 10, 130 Aug 18 12:53 /dev/watchdog
0 crw------- 1 root root 252, 0 Aug 18 12:53 /dev/watchdog0
This is what I do and as far as I see it works:
Thank you epoch1970, after reading another gazillion posts (including some of yours), I think I have it working (on Jessie Lite) now. I'm getting some weirdness on Stretch Lite, but that maybe because I have tried so many things I have messed something else up! I'll reimage and try again over the weekend.epoch1970 wrote: ↑Fri Aug 18, 2017 2:00 pmThis is what I do and as far as I see it works:
- install raspbian lite,
- apt-get install watchdog
- edit /etc/default/watchdog and /etc/watchdog.conf
Edit: - Fiddle with the watchdog systemd unit, otherwise it doesn't start. I think this is still necessary. Last message here: https://bugs.launchpad.net/raspbian/+bug/1582707
- add some scripts if I want a custom test or repair policy. (I always want that, because the watchdog device has a timeout of 15secs on Pi and I don't want to run every test every 10 secs...)
Earlier, loading the relevant Linux module was necessary. Then it came compiled in the kernel, as you have noted. So no need to load anything.
Recently -AFAIK- an overlay was added but my guess is it allows to disable the hardware watchdog and it is enabled by default. I've never used this overlay.
I know systemd has some sort of feature they call watchdog. I suppose this is configured in systemd/system.conf. I've never used that either.
Code: Select all
1 sudo nano /boot/config.txt
Add the following to the end of the file:
dtparam=watchdog=on
2 sudo apt-get install watchdog chkconfig
3 sudo nano /etc/default/watchdog
Change to:
watchdog_module="bcm2835_wdt"
4 sudo nano /etc/watchdog.conf
Configure as required:
max-load-1 = 24
Enable device:
watchdog-device /dev/watchdog
Set the timeout:
watchdog-timeout = 14
5 sudo systemctl start watchdog
6 sudo systemctl -l status watchdog
Check for errors
7 sudo nano /lib/systemd/system/watchdog.service
Change to:
[Install]
WantedBy=default.target
9 sudo systemctl daemon-reload
10 sudo systemctl enable watchdog
11 sudo systemctl -l status watchdog
Code: Select all
● watchdog.service - watchdog daemon
Loaded: loaded (/lib/systemd/system/watchdog.service; enabled)
Active: active (running) since Fri 2017-08-18 15:10:05 BST; 6min ago
Main PID: 9609 (watchdog)
CGroup: /system.slice/watchdog.service
└─9609 /usr/sbin/watchdog
Aug 18 15:10:05 hassbian watchdog[9609]: int=1s realtime=yes sync=no soft=no mla=24 mem=0
Aug 18 15:10:05 hassbian watchdog[9609]: ping: no machine to check
Aug 18 15:10:05 hassbian watchdog[9609]: file: no file to check
Aug 18 15:10:05 hassbian watchdog[9609]: pidfile: no server process to check
Aug 18 15:10:05 hassbian watchdog[9609]: interface: no interface to check
Aug 18 15:10:05 hassbian watchdog[9609]: temperature: no sensors to check
Aug 18 15:10:05 hassbian watchdog[9609]: test=none(0) repair=none(0) alive=/dev/watchdog heartbeat=none to=root no_act=no force=no
Aug 18 15:10:05 hassbian watchdog[9609]: watchdog now set to 14 seconds
Aug 18 15:10:05 hassbian watchdog[9609]: hardware watchdog identity: Broadcom BCM2835 Watchdog timer
Aug 18 15:10:05 hassbian systemd[1]: Started watchdog daemon.
Code: Select all
#!/bin/bash
echo
echo "Setting up watchdog for Raspberry Pi..."
echo
if [ "$EUID" -ne 0 ]
then echo "Please run this script as root to properly setup watchdog."
echo
exit
fi
echo "Checking for watchdog parameter in boot config..."
echo
grep -q -F "dtparam=watchdog=on" /boot/config.txt || sudo sh -c 'echo "\n# activating the hardware watchdog\ndtparam=watchdog=on" >> /boot/config.txt'
echo "Installing watchdog service..."
echo
sudo apt-get install watchdog
echo
echo "Enabling watchdog max-load-1 for protection from system freeze..."
echo
sudo sed -i '/#max-load-1 /c\max-load-1 = 24' /etc/watchdog.conf
echo "Adding watchdog to the boot sequence..."
echo
sudo systemctl enable watchdog
echo
echo "Done! Watchdog should now be enabled."
echo
Code: Select all
Nov 2 16:34:10 rpi3 systemd[1]: Starting LSB: Start watchdog keepalive daemon...
Nov 2 16:34:10 rpi3 kernel: [ 0.806283] bcm2835-wdt 3f100000.watchdog: Broadcom BCM2835 watchdog timer
Nov 2 16:34:11 rpi3 systemd[1]: Started LSB: Start watchdog keepalive daemon.
Code: Select all
Linux rpi3b 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/Linux
Code: Select all
echo "RuntimeWatchdogSec=10" | sudo tee -a /etc/systemd/system.conf
echo "ShutdownWatchdogSec=10min" | sudo tee -a /etc/systemd/system.conf
cat /etc/systemd/system.conf | grep "Watchdog"
Code: Select all
[email protected]:~ $ journalctl -b | grep dog
Nov 03 18:16:43 rpi3b kernel: bcm2835-wdt 3f100000.watchdog: Broadcom BCM2835 watchdog timer
Nov 03 18:16:43 rpi3b systemd[1]: Hardware watchdog 'Broadcom BCM2835 Watchdog timer', version 0
Nov 03 18:16:43 rpi3b systemd[1]: Set hardware watchdog to 10s.
Code: Select all
while :
do
date
echo . > /dev/watchdog
sleep 14
done
in the meantime I experimented a little how to configure the watchdog timeout (on raspbian/stretch 4.9.59+)
Code: Select all
... bcm2835_wdt.heartbeat=10
VascoFerraz » Tue Jan 02, 2018 6:03 am
The following solution (thanks Paul) works on the RPi1 model B (BCM2835)?