Hilscher Community Forum
Hardware watchdog in a container - Printable Version

+- Hilscher Community Forum (https://forum.hilscher.com)
+-- Forum: netPI 3 - Docker featuring Industrial Raspberry Pi 3 platform (https://forum.hilscher.com/forum-1.html)
+--- Forum: Hardware (https://forum.hilscher.com/forum-4.html)
+--- Thread: Hardware watchdog in a container (/thread-685.html)



Hardware watchdog in a container - Armin@netPI - January-7th-2021

The netPI CPU supports a hardware watchdog. Once triggered by software it monitors in a time frame of 10 seconds if it was retrigger again else it resets the CPU and forces a reboot of the device.

This behaviour is good for monitoring your netPI software if it is running stable. For example the Docker daemon or simply said if a container is running.

All you need to do is to deploy a container that has the host device "/dev/watchdog" mapped. With the mapping the device gets accessible in the container.

Mapping alone does not start the watchdog. This needs to be initialized by software and if started periodically retriggered.

Here is a a simple script you should run in the background in your container that triggers the watchdog every 5 seconds

Code:
#!/bin/bash
while [ true ]; do
    echo 1 > /dev/watchdog
    sleep 5
done

But please keep in mind once the watchdog is triggered it is active and in case stop the container for any reason your device will reset.

To disable the watchdog use the embedded console function of netPIs Docker web UI that allows you to enter the container, kill the watchdog calling bash script process first and then call

Code:
echo 'V' > /dev/watchdog

This will deactivate the watchdog until it is retriggered again.

Thx

Armin