How to use hardware watchdog in Ubuntu Core

Hardware watchdog is supported after snapd 2.34 or Core Image r5145.

A user can use the “snap set” command to config the watchdog parameters.

$ snap set core watchdog.runtime-timeout=1m
Set a timeout value in seconds (or in other time units if suffixed with “ms”, “min”, “h”, “d”, “w”). The watchdog hardware (/dev/watchdog) or the kernel option systemd.watchdog-device=) will be programmed to automatically reboot the system if it is not contacted within the specified timeout interval.

$ snap set core watchdog.shutdown-timeout=10m
It works as a safety net to ensure that the reboot takes place even if a clean reboot attempt times out. Note that the shutdown-timeout applies only to the second phase of the reboot, i.e. after all regular services are already terminated, and after the system and service manager process (PID 1) got replaced by the systemd-shutdown binary.

The function is implemented with systemd. The configuration can be validated in /etc/systemd/system.conf.d/10-snapd-watchdog.conf

1 Like

Dear chihchun:
The case you said is that snapd use the watchdog (indeed it’s support by systemd).
If a snap app want to use the hardware watchdog, what should we do ?

Best Regards

1 Like

Currently, there is a limitation on access to hardware watchdog from snap app. There is no security interface for /dev/watchdog yet.

Could you share a bit more the use case, why do you like to manage hw watchdog from an application? That will help the core team to justify the feature request.

1 Like

The update to watchdog timers with snap set do not reflect in the systemctl. Is this normal ?

$ systemctl show | grep -i watchdog
admin@FT8TB02:~$ sudo snap get core watchdog
Key                       Value
watchdog.runtime-timeout  2m

below command will show your current status of time out what you expect.

cat /etc/systemd/system.conf.d/10-snapd-watchdog.conf

Is the watchdog timer by default disabled.
On a system I had initially there were was no watchdog configuration:

admin@1TXPB02:~$ snap get core
Key Value
refresh {…}
seed {…}

Does this mean that in this case the watchdog is disabled?

I could however then set the configuration using
snap set core watchdog…

admin@1TXPB02:~$ snap set core watchdog.shutdown-timeout=10m
admin@1TXPB02:~$ snap get core watchdog.shutdown-timeout
admin@1TXPB02:~$ snap get core watchdog
Key Value
watchdog.shutdown-timeout 10m
admin@1TXPB02:~$ snap set core watchdog.runtime-timeout=1m
admin@1TXPB02:~$ snap get core watchdog
Key Value
watchdog.runtime-timeout 1m
watchdog.shutdown-timeout 10m
admin@1TXPB02:~$ snap get core watchdog
Key Value
watchdog.runtime-timeout 1m
watchdog.shutdown-timeout 10m

So does this mean it is now enabled and configured with the above values.

For Dell Products there is also a facility to configure a watchdog using the dcc (Dell Command Configure) tool:

sudo dcc.cctk --WatchdogTimer

Do the two mechanisms compliment each other? For example if I enable the timer using dcc.cctk and then set the timeouts using snap set core…

@chihchun ‘sanp set core watchdog.runtime-timeout’ is the setting the time value. But how to (who will) pet the watchdog within this time?