LAN969x Watchdog
2. Kernel configurations
Following kernel config options should be enabled to use LAN969x WDT:
-
CONFIG_DW_WATCHDOG- Synopsys Watchdog driver config option.
3. Devicetree Configuration
To enable the Watchdog timer, following configurations are required in device tree:
-
compatiblestring must be set tosnps,dw-wdt. -
regproperty must be set to<0xe0090000 0x1000>. -
interruptsproperty must be set with interrupt details as<GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>.
| Peripheral | Shared Peripheral Interrupt | CPU INTR |
|---|---|---|
watchdog |
68 |
36 |
- Note
-
Shared peripheral interrupt lines start at index ID32. So, CPU INTR must be calculated as [Shared peripheral interrupt number - 32].
-
clocksproperty must be set to<&fabric_clk>.
-
4. 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 36 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&fabric_clk>;
};
4.1. UserSpace
4.1.1. Confirm instances are created
-
Check for
/dev/watchdog. If this file is present, that means the watchdog kernel device driver is loaded.
4.1.2. Direct activation of the watchdog
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 2023.04 (Nov 07 2023 - 14:41:53 +0100) CPU: ARM A53 Model: lan969x ev23x71a (pcb8398) DRAM: 896 MiB (effective 897.9 MiB) Core: 27 devices, 16 uclasses, devicetree: fit MMC: emmc@e0830000: 0 Loading Environment from MMC... OK In: serial Out: serial Err: serial Net: eth0: switch@0 Hit any key to stop autoboot: 0
4.1.3. Using the 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
4.1.4. Running the watchdog in the background
-
Add watchdog configurations to
/etc/watchdog.conffile. -
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-timeoutvalue.
# 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 # watchdog -c /etc/watchdog.conf # ps -ef | grep watchdog 28 root [watchdogd] 477 root watchdog -c /etc/watchdog.conf 481 root grep watchdog # kill -9 477 ; uptime ; tail -f /var/log/messages [ 2933.075931] watchdog: watchdog0: watchdog did not stop! 00:48:53 up 48 min, load average: 0.00, 0.00, 0.00 Jan 1 00:48:38 vcoreiii daemon.info watchdog[477]: interface: no interface to check Jan 1 00:48:38 vcoreiii daemon.info watchdog[477]: temperature: no sensors to check Jan 1 00:48:38 vcoreiii daemon.info watchdog[477]: no test binary files Jan 1 00:48:38 vcoreiii daemon.info watchdog[477]: no repair binary files Jan 1 00:48:38 vcoreiii daemon.info watchdog[477]: error retry time-out = 60 seconds Jan 1 00:48:38 vcoreiii daemon.info watchdog[477]: repair attempts = 1 Jan 1 00:48:38 vcoreiii daemon.info watchdog[477]: alive=/dev/watchdog heartbeat=[none] to=root no_act=no force=no Jan 1 00:48:38 vcoreiii daemon.info watchdog[477]: watchdog now set to 20 seconds Jan 1 00:48:38 vcoreiii daemon.info watchdog[477]: hardware watchdog identity: Synopsys DesignWare Watchdog Jan 1 00:48:53 vcoreiii kern.crit kernel: [ 2933.075931] watchdog: watchdog0: watchdog did not stop! NOTICE: Booting Trusted Firmware ...More trace... U-Boot 2023.04 (Nov 07 2023 - 14:41:53 +0100) CPU: ARM A53 Model: lan969x ev23x71a (pcb8398) DRAM: 896 MiB (effective 897.9 MiB) Core: 27 devices, 16 uclasses, devicetree: fit MMC: emmc@e0830000: 0 Loading Environment from MMC... OK In: serial Out: serial Err: serial Net: eth0: switch@0 Hit any key to stop autoboot: 0
4.1.5. Running the watchdog in the foreground
-
Add watchdog configurations to the
/etc/watchdog.conffile. -
Run the watchdog in foreground using the '-F' option.
-
Press
CTRL + zto suspend the watchdog process. -
In this case, the watchdog device is enabled but is no longer fed. After
watchdog-timeoutseconds, the system is reset by the Watchdog device.
# watchdog -c /etc/watchdog.conf -F watchdog: starting daemon (5.16): watchdog: int=1s realtime=yes sync=no load=0,0,0 soft=no watchdog: memory not checked watchdog: ping: no machine to check watchdog: file: /var/log/messages:1500 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 [1]+ Stopped watchdog -c /etc/watchdog.conf -F # NOTICE: Booting Trusted Firmware ...More traces... NOTICE: Direct boot of BL33 binary image U-Boot 2023.04 (Nov 07 2023 - 14:41:53 +0100) CPU: ARM A53 Model: lan969x ev23x71a (pcb8398) DRAM: 896 MiB (effective 897.9 MiB) Core: 27 devices, 16 uclasses, devicetree: fit MMC: emmc@e0830000: 0 Loading Environment from MMC... OK In: serial Out: serial Err: serial Net: eth0: switch@0 Hit any key to stop autoboot: 0