Replacing watchdog shell script with device tree node

Hi :slight_smile:

(Regarding this PR)

The Yuncore AX835 has a watchdog IC connected to GPIO7 (of the MT7981B SoC) that needs to be toggled every second - otherwise the device is reset after 5 minutes.

The stock firmware exposes the watchdog GPIO as a LED called hwwatchdog.
Using the LED, a shell script like this prevents the reboots:
while true; do sleep 1; echo 1 > brightness; sleep 1; echo 0 > brightness; done

For the PR, I want to use the device tree to trigger the watchdog:

	watchdog {
		compatible = "linux,wdt-gpio";
		gpios = <&pio 7 GPIO_ACTIVE_LOW>;
		hw_algo = "toggle";
		hw_margin_ms = <1000>;
		always-running;
	};

There is a second watchdog in /dev but it doesn't prevent the reboots.
Does it still need a userspace component. Am I missing something else?

My current theory is that this new watchdog "pushes" the platform watchdog from /dev/watchdog to /dev/watchdog0 and that the platform watchdog causes the reset while procd toggles the always-on watchdog (procd only supports one watchdog).
I don't know how to test that though. Writing to either watchdog using echo 1 > .. fails with 'Resource busy..'.

kind regards!

My previous line of thought has proven to be faulty.
Even without the added watchdog definition, there are two watchdog devices: /dev/watchdog and /dev/watchdog0. Since there's only one watchdog in the device tree, I assume they belong together.

On the PR, there's now a LED.
Another user also wasn't able to get the watchdog running using gpio-wdt and they offered this solution:

		led_hwwatchdog {
			label = "hwwatchdog";
			gpios = <&pio 7 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "timer";
			led-pattern = <1000>, <1000>;
		};