LAN966x Watchdog
LAN966x Watchdog
Kernel configurations
Following kernel config options should be enabled to use LAN966x WDT:
-
CONFIG_DW_WATCHDOG
- Synopsys Watchdog driver config option.
Devicetree Configuration
To enable Watchdog timer, following configurations are required in device tree:
-
compatible
string must be set tosnps,dw-wdt
. -
reg
property must be set to<0xe0090000 0x1000>
. -
interrupts
property must be set with interrupt details as<GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>
.
Peripheral | Shared Peripheral Interrupt | CPU INTR |
---|---|---|
watchdog |
70 |
38 |
- Note
-
Shared peripheral interrupt lines start at index ID32. So, CPU INTR must be calculated as [Shared peripheral interrupt number - 32].
-
clocks
property must be set to<&nic_clk>
.
-
Example
Following example shows how a Watchdog timer should be defined in DT:
dtsi file:
watchdog: watchdog@e0090000 { compatible = "snps,dw-wdt"; reg = <0xe0090000 0x1000>; interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>; clocks = <&nic_clk>; status = "disabled"; };
dts file changes:
&watchdog { status = "okay"; };
UserSpace
Confirm instances are created
-
Check for
/dev/watchdog
. If this file is present, that means the watchdog kernel device driver is loaded.
Example on how to use
Run cat /dev/watchdog0
and you see linux reboots in 30-40secs.
# cat /dev/watchdog0 [ 7879.765752] watchdog: watchdog0: watchdog did not stop! # # # U-Boot 2019.04-linux4sam_6.2-icp (Sep 24 2021 - 09:49:43 +0200) CPU: SAMA7 Crystal frequency: 0 MHz CPU clock : 0 MHz Master clock : 0 MHz DRAM: 1 GiB MMC: sdhci-host@e0830000: 0, emmc@e0830000: 1 Loading Environment from SPI Flash... SF: Detected sst26vf016b with page size 256 Bytes, erase size 4 KiB, total 2 MiB OK In: serial Out: serial Err: serial Net: eth0: switch@0 Hit any key to stop autoboot: 0 m =>
Example using Busybox watchdog utility:
-
Configure buildroot and install Watchdog utility provided by Busybox.
-
The main watchdog configuration file is
/etc/watchdog.conf
.
# busybox | grep watchdog vconfig, vi, vlock, w, watch, watchdog, wc, wget, which, who, whoami, # # watchdog --help watchdog: unrecognized option `--help' watchdog version 5.16, usage: watchdog [options] options: -c | --config-file <file> specify location of config file -f | --force don't sanity-check config or use PID file -F | --foreground run in foreground -X | --loop-exit <number> run a fixed number of loops then exit -q | --no-action do not reboot or halt -b | --softboot soft-boot on error -s | --sync sync filesystem -v | --verbose verbose messages # ls -l /etc/watchdog.conf -rw-r--r-- 1 root root 6102 May 18 2022 /etc/watchdog.conf
Verify system reboot by running watchdog in background:
-
Add watchdog configurations to
/etc/watchdog.conf
file. -
Run command
watchdog -c /etc/watchdog.conf
. By default, Busybox watchdog command runs in background. -
Check for Hardware watchdog process ID.
-
Kill the watchdog process.
-
Verify that system is rebooted after
watchdog-timeout
value.
# cat /etc/watchdog.conf watchdog-device = /dev/watchdog watchdog-timeout = 20 log-dir = /var/log/watchdog file = /var/log/messages change = 1500 realtime = yes priority = 1 # # ps -ef | grep watchdog 22 root [watchdogd] 131 root grep watchdog # # # watchdog -c /etc/watchdog.conf # # # ps -ef | grep watchdog 22 root [watchdogd] 135 root watchdog -c /etc/watchdog.conf 140 root grep watchdog # # # uptime 00:09:09 up 9 min, load average: 0.00, 0.03, 0.03 # # # kill -9 135 ; uptime; tail -f /var/log/messages [ 580.280482] watchdog: watchdog0: watchdog did not stop! 00:09:40 up 9 min, load average: 0.00, 0.02, 0.03 Jan 1 00:08:36 buildroot daemon.info watchdog[135]: interface: no interface to check Jan 1 00:08:36 buildroot daemon.info watchdog[135]: temperature: no sensors to check Jan 1 00:08:36 buildroot daemon.info watchdog[135]: no test binary files Jan 1 00:08:36 buildroot daemon.info watchdog[135]: no repair binary files Jan 1 00:08:36 buildroot daemon.info watchdog[135]: error retry time-out = 60 seconds Jan 1 00:08:36 buildroot daemon.info watchdog[135]: repair attempts = 1 Jan 1 00:08:36 buildroot daemon.info watchdog[135]: alive=/dev/watchdog heartbeat=[none] to=root no_act=no force=no Jan 1 00:08:36 buildroot daemon.info watchdog[135]: watchdog now set to 20 seconds Jan 1 00:08:36 buildroot daemon.info watchdog[135]: hardware watchdog identity: Synopsys DesignWare Watchdog Jan 1 00:09:40 buildroot kern.crit kernel: [ 580.280482] watchdog: watchdog0: watchdog did not stop! U-Boot 2019.04-linux4sam_6.2-icp (Sep 24 2021 - 09:49:43 +0200) CPU: SAMA7 Crystal frequency: 0 MHz CPU clock : 0 MHz Master clock : 0 MHz DRAM: 1 GiB MMC: sdhci-host@e0830000: 0, emmc@e0830000: 1 Loading Environment from SPI Flash... SF: Detected sst26vf016b with page size 256 Bytes, erase size 4 KiB, total 2 MiB OK In: serial Out: serial Err: serial Net: eth0: switch@0 Hit any key to stop autoboot: 0 m =>
Verify system reboot by running watchdog in foreground:
-
Add watchdog configurations to
/etc/watchdog.conf
file. -
Run watchdog in foregroung using '-F' option in Busybox watchdog command as
watchdog -c /etc/watchdog.conf -F
. -
Press
CTRL + z
to suspend system. -
In this case, the Watchdog device is enabled but is no longer fed. After
watchdog-timeout
seconds, the system is reset by the Watchdog device.
# ls -l /dev/watchdog crw------- 1 root root 10, 130 Jan 1 00:00 /dev/watchdog # # uptime 00:04:29 up 4 min, load average: 0.02, 0.11, 0.06 # # # ps -ef | grep watchdog 22 root [watchdogd] 132 root grep watchdog # # cat /etc/watchdog.conf watchdog-device = /dev/watchdog watchdog-timeout = 20 log-dir = /var/log/watchdog file = /var/log/messages change = 10 realtime = yes priority = 1 # # watchdog -c /etc/watchdog.conf -F watchdog: starting daemon (5.16): watchdog: int=1s realtime=no sync=no load=0,0,0 soft=no watchdog: memory not checked watchdog: ping: no machine to check watchdog: file: /var/log/messages:10 watchdog: pidfile: no server process to check watchdog: interface: no interface to check watchdog: temperature: no sensors to check watchdog: no test binary files watchdog: no repair binary files watchdog: error retry time-out = 60 seconds watchdog: repair attempts = 1 watchdog: alive=/dev/watchdog heartbeat=[none] to=root no_act=no force=no watchdog: watchdog now set to 20 seconds watchdog: hardware watchdog identity: Synopsys DesignWare Watchdog watchdog: file /var/log/messages was not changed in 11 seconds (more than 10) watchdog: file /var/log/messages was not changed in 11 seconds (more than 10) watchdog: file /var/log/messages was not changed in 11 seconds (more than 10) ^Z[1]+ Stopped watchdog -c /etc/watchdog.conf -F # U-Boot 2019.04-linux4sam_6.2-icp (Sep 24 2021 - 09:49:43 +0200) CPU: SAMA7 Crystal frequency: 0 MHz CPU clock : 0 MHz Master clock : 0 MHz DRAM: 1 GiB MMC: sdhci-host@e0830000: 0, emmc@e0830000: 1 Loading Environment from SPI Flash... SF: Detected sst26vf016b with page size 256 Bytes, erase size 4 KiB, total 2 MiB OK In: serial Out: serial Err: serial Net: eth0: switch@0 Hit any key to stop autoboot: 0 m =>