Table of Contents

VIM2 Watchdog

Introduction

This page introduces the internal Watchdog. You will learn how to enable the watchdog and test it.

Enable Internal Watchdog

Watchdog is disabled by default, use the commands below to enable it.

Ubuntu 18.04

sudo ln -s  /lib/systemd/system/watchdog.service /etc/systemd/system/multi-user.target.wants/watchdog.service
sudo systemctl enable watchdog.service
sudo systemctl start watchdog.service

You need to create the service link manually, due to a Debian bug.

Ubuntu 20.04

sudo systemctl enable watchdog.service
sudo systemctl start watchdog.service

Check watchdog status:

khadas@Khadas:~$ systemctl status watchdog.service 
● watchdog.service - watchdog daemon
     Loaded: loaded (/lib/systemd/system/watchdog.service; enabled; vendor pres>
     Active: active (running) since Fri 2021-03-26 10:00:38 UTC; 15min ago
    Process: 3381 ExecStartPre=/bin/sh -c [ -z "${watchdog_module}" ] || [ "${w>
    Process: 3382 ExecStart=/bin/sh -c [ $run_watchdog != 1 ] || exec /usr/sbin>
   Main PID: 3385 (watchdog)
      Tasks: 1 (limit: 2932)
     Memory: 864.0K
     CGroup: /system.slice/watchdog.service
             └─3385 /usr/sbin/watchdog -s -v -c /etc/watchdog.conf
 
Mar 26 10:15:38 Khadas watchdog[3385]: still alive after 120 interval(s)
Mar 26 10:15:39 Khadas watchdog[3385]: still alive after 121 interval(s)
Mar 26 10:15:40 Khadas watchdog[3385]: still alive after 122 interval(s)
Mar 26 10:15:41 Khadas watchdog[3385]: still alive after 123 interval(s)
Mar 26 10:15:42 Khadas watchdog[3385]: still alive after 124 interval(s)
Mar 26 10:15:43 Khadas watchdog[3385]: still alive after 125 interval(s)
Mar 26 10:15:44 Khadas watchdog[3385]: still alive after 126 interval(s)
Mar 26 10:15:45 Khadas watchdog[3385]: still alive after 127 interval(s)
Mar 26 10:15:46 Khadas watchdog[3385]: still alive after 128 interval(s)
Mar 26 10:15:47 Khadas watchdog[3385]: still alive after 129 interval(s)
lines 1-21/21 (END) 

Test Internal Watchdog

Set Watchdog Timeout

The default timeout is 15 seconds, you can edit the file /etc/watchdog.conf to change the value watchdog-timeout.

Restart the watchdog service to take effect.

sudo systemctl restart watchdog

Run and Test

Trigger a Kernel crash.

echo 0 | sudo tee /sys/module/kernel/parameters/panic
echo c | sudo tee /proc/sysrq-trigger 

Kill the Watchdog daemon.

You can also kill the watchdog daemon to prevent an automatic restart after a Kernel crash.

$ sudo pkill -9 watchdog
$ sudo pkill -9 wd_keepalive
$
$
$ G12B:BL:6e7c85:2a3b91;FEAT:E0F83180:402000;POC:F;RCY:0;EMMC:0;READ:0;0.
bl2_stage_init 0x01
bl2_stage_init 0x81
hw id: 0x0000 - pwm id 0x01
bl2_stage_init 0xc1
bl2_stage_init 0x02
 
L0:00000000
L1:20000703
L2:00008067
L3:14000000
B2:00402000
B1:e0f83180
 
TE: 207260
 
BL2 Built : 15:22:05, Aug 28 2019. g12b g1bf2b53 - user@domain
...

If watchdog was setup successfully, the system will automatically reboot after the Kernel crash, in accordance with the timeout you have set above.

Disable Internal Watchdog

Disable the Watchdog daemon.

sudo systemctl disable watchdog
sudo reboot

Disable Watchdog driver [Optional].

You can also disable the watchdog driver. Edit /boot/env.txt and remove watchdog in the overlays node, then save and reboot the system.

2022/07/05 02:59 · frank