Watchdog

The RevPi Flat has two independent watchdogs. The first is part of the BCM2837 SoC, which is also used on the Raspberry Pi 3. The second is the Maxim MAX6370 external watchdog module.

BCM2837

The BCM2837 watchdog is the preferred watchdog because it behaves like other watchdogs under Linux. You can access it either via the device file /dev/watchdog0 or as a default watchdog via the device file /dev/watchdog.

MAX6370

The MAX6370 can be accessed via the device file /dev/watchdog1.

To activate it, GPIO4 must be set high once. It can no longer be deactivated via this GPIO, however. For activation via the command line, you can use the gpiod tool:

gpioset -m time -u 1000 pinctrl-bcm2835 4=1

gpiod package

The command “gpioset” is part of the gpiod package. If this is not installed, you can install it yourself with sudo apt install gpiod.

If you want to operate the GPIO from your application, the “libgpiod” is right for you. This also provides a Python interface.

You will need the following packages: libgpiod-dev libgpiod2 python3-libgpiod

The timeout of the MAX6370 is fixed at 60 seconds and cannot be changed.

Note: after the MAX6370 has been activated, you can only deactivate it by disconnecting the power supply. A restart/reset does not deactivate the watchdog. This means that a restart with an active watchdog must not take longer than 60 seconds. If this value is exceeded, the watchdog resets the hardware. The watchdog still remains active, even after this reset. The subsequent boot process must not take longer than 60 seconds until the watchdog is triggered.

Watchdog under Linux

There are several ways to use a watchdog under Linux. The RevPi image and Raspbian rely on “systemd”. This is therefore also the preferred method of using the watchdog. “systemd” can be used to trigger a hardware watchdog. Applications that are to be monitored by the watchdog are then monitored by “systemd”. This has the advantage that several applications can be monitored. Consequently, the entire system does not necessarily have to be restarted, but instead only the individual application.

Further documentation:

systemd for Administrators, Part XV – Watchdogs

Raspberry Pi forum: RPi3B+ and watchdog…