Skip to content

Instantly share code, notes, and snippets.

@hsiboy
Created July 18, 2018 16:47
Show Gist options
  • Select an option

  • Save hsiboy/1701eb7ea8e803b4521d097e3d7a43d1 to your computer and use it in GitHub Desktop.

Select an option

Save hsiboy/1701eb7ea8e803b4521d097e3d7a43d1 to your computer and use it in GitHub Desktop.
Install watchdog service on raspberry pi - restart raspberry pi if x
# install the service
sudo modprobe bcm2708_wdog
echo "bcm2708_wdog" | sudo tee -a /etc/modules
sudo apt-get install watchdog
sudo update-rc.d watchdog defaults
# configure service
sudo vi /etc/watchdog.conf
# Uncomment the line that starts #watchdog-device to enable the watchdog daemon to use the watchdog device.
# Uncomment the line that says #max-load-1 = 24 to reboot the device if the load > 24 for 1 minute.
# A load of 25 of one minute means that you would have needed 25 Raspberry Pis to complete that task in 1 minute.
# start the service
sudo /etc/init.d/watchdog start
@cbrunnkvist
Copy link

cbrunnkvist commented Apr 29, 2024

N.b. either the bcm2708_wdog is no longer in recent Linux releases, or its module depends on your HW arch, and/or the module is compiled as BUILTIN nowadays rather than an external driver module - I'm honestly not really sure which at this time.

But in + summary, this works ouf of the box on a RPi 3b running Raspbian 12 (Bookworm):

conny@homebridge:~ $ sudo wdctl
Device:        /dev/watchdog0
Identity:      Broadcom BCM2835 Watchdog timer [version 0]
Timeout:       15 seconds
Timeleft:      14 seconds
Pre-timeout:    0 seconds
FLAG           DESCRIPTION               STATUS BOOT-STATUS
KEEPALIVEPING  Keep alive ping reply          1           0
MAGICCLOSE     Supports magic close char      0           0
SETTIMEOUT     Set timeout (in seconds)       0           0
conny@homebridge:~ $ ls -l /sys/class/watchdog/watchdog0/device/driver/
total 0
lrwxrwxrwx 1 root root    0 Apr 29 11:33 bcm2835-wdt -> ../../../../devices/platform/soc/3f100000.watchdog/bcm2835-wdt
--w------- 1 root root 4096 Apr 29 11:33 bind
--w------- 1 root root 4096 Apr 29 11:33 uevent
--w------- 1 root root 4096 Apr 29 11:33 unbind
conny@homebridge:~ $ modinfo bcm2835-wdt
name:           bcm2835_wdt
filename:       (builtin)
license:        GPL
file:           drivers/watchdog/bcm2835_wdt
description:    Driver for Broadcom BCM2835 watchdog timer
author:         Lubomir Rintel <[email protected]>
alias:          platform:bcm2835-wdt
parm:           heartbeat:Initial watchdog heartbeat in seconds (uint)
parm:           nowayout:Watchdog cannot be stopped once started (default=0) (bool)

UPDATE Alright, I think I got it working and the only thing I changed was, I uncommented/edited three lines in /etc/systemd/system.conf as below:

# in the "[Manager]" section:
RuntimeWatchdogSec=10
RebootWatchdogSec=10min
WatchdogDevice=/dev/watchdog0

WFM 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment