How to enable watchdog on mt7621 dts?

I use MT7621 soc and OpenWrt 22.03.4 linux kenrel 5.10.176, enabled internal HW watchdog, but at watchdog time out ,the system does not reboot and hangs. Why ?

dts as follow:

/dts-v1/;

#include "mt7621.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
        watchdog {
                compatible = "linux,wdt-gpio";
                gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
                hw_algo = "toggle";
                hw_margin_ms = <1000>;
                always-running = <1>;
                status = "okay";
        };
...
  }

Run sysupgrade, the terminal output:

Watchdog does not have CARDRESET support

dmesg search watchdog:

# dmesg | fgrep dog
[    2.643846] init: - watchdog -
[   17.230427] procd: - watchdog -
[   17.847738] procd: - watchdog -

search wdt, output nothing:

# dmesg | fgrep wdt

What SoC family do I find this SoC under or is this from Kernel?

My first thinking is still why the wdt hasn’t been included to begin with in the dtsi where it should be if it exist and actually do anything?

The dts is only for SoC device specific definition of function usage under a main dtsi.

What is your board model?

I use mt7621.dtsi as a base for board adaptation.

I don't see watchdog in MT7621.dti, is it not supported?

It's not a internal WDT of MT7621 SoC.

see:

1 Like

Then please show your .dts file.

The board dts as follow:

/dts-v1/;

#include "mt7621.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
        compatible = "mediatek,mt7621-soc";
        model = "strong-4g";

        memory@0 {
                device_type = "memory";
                reg = <0x0 0x10000000>;
        };

        chosen {
                bootargs = "console=ttyS0,115200";
        };

        leds {
                compatible = "gpio-leds";
        };

        keys {
                compatible = "gpio-keys";
                poll-interval = <20>;

                reset {
                        label = "reset";
                        gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
                        linux,code = <KEY_RESTART>;
                };
        };

        gpio_export {
                compatible = "gpio-export";
                #size-cells = <0>;
        };

        watchdog: watchdog {
                compatible = "linux,wdt-gpio";
                gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
                hw_algo = "toggle";
                hw_margin_ms = <1000>;
        };
};

&spi0 {
        status = "okay";

        m25p80@0 {
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <24000000>;

                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;

                        partition@0 {
                                label = "u-boot";
                                reg = <0x0 0x30000>;
                                read-only;
                        };

                        partition@30000 {
                                label = "u-boot-env";
                                reg = <0x30000 0x10000>;
                        };

                        factory: partition@40000 {
                                label = "factory";
                                reg = <0x40000 0x10000>;

                                compatible = "nvmem-cells";
                                #address-cells = <1>;
                                #size-cells = <1>;

                                eeprom_factory_8000: eeprom@8000 {
                                        reg = <0x8000 0x4da8>;
                                };

                                macaddr_factory_e000: macaddr@e000 {
                                        reg = <0xe000 0x6>;
                                };
                        };

                        partition@50000 {
                                compatible = "denx,uimage";
                                label = "firmware";
                                reg = <0x50000 0>;
                        };
                };
        };
};

&i2c {
        status = "okay";

        jxr160: rtc@32 {
                status = "okay";
                compatible = "jxr,jxr160";
                reg = <0x32>;
        };

        gpio_tca9539: gpio@20 {
                compatible = "nxp,pca9539";
                reg = <0x20>;

                interrupt-parent = <&gpio>;
                interrupts = <&gpio 0 GPIO_ACTIVE_LOW>;

                #gpio-cells = <2>;
                gpio-controller;
        };
};

&pcie {
        status = "okay";
};

&pcie0 {
        wifi@0,0 {
                compatible = "mediatek,mt76";
                reg = <0x0000 0 0 0 0>;
                ieee80211-freq-limit = <2400000 2500000>;
        };
};

&pcie1 {
        wifi@0,0 {
                compatible = "mediatek,mt76";
                reg = <0x0000 0 0 0 0>;
                nvmem-cells = <&eeprom_factory_8000>;
                nvmem-cell-names = "eeprom";
                ieee80211-freq-limit = <5000000 6000000>;
        };
};

&gmac0 {
        nvmem-cells = <&macaddr_factory_e000>;
        nvmem-cell-names = "mac-address";
};

&gmac1 {
        status = "okay";
        label = "wan";
        phy-handle = <&ethphy0>;

        nvmem-cells = <&macaddr_factory_e000>;
        nvmem-cell-names = "mac-address";
        mac-address-increment = <1>;
};

&mdio {
        ethphy0: ethernet-phy@0 {
                reg = <0>;
        };
};

&switch0 {
        status = "okay";

        ports {
                port@1 {
                        status = "okay";
                        label = "lan1";
                };

                port@2 {
                        status = "okay";
                        label = "lan2";
                };

                port@3 {
                        status = "okay";
                        label = "lan3";
                };

                port@4 {
                        status = "okay";
                        label = "lan4";
                };
        };
};

&state_default {
        gpio {
                groups = "jtag";
                function = "gpio";
        };
};

&xhci {
        status = "okay";
};

&sdhci {
        status = "okay";
};

&uartlite {
        status = "okay";
};

&uartlite2 {
        status = "okay";
};

&uartlite3 {
        status = "okay";
};

I found this MT7621 soc HW watchdog does not work? - #26 by suvine with a similar problem, the board use winbond W25Q256JVEIQ 32M nor flash, is it missing 3byte mode?

Run sysupgrade 1.bin, the serial port output:

# sysupgrade 1.bin
Wed Nov 22 10:17:13 CST 2023 upgrade: Commencing upgrade. Closing all shell sessions.
[  106.675281] device wlan0 left promiscuous mode
[  106.680030] br-lan: port 5(wlan0) entered disabled state
Watchdog handover: fd=3
- watchdog -
Watchdog does not have CARDRESET support
Wed Nov 22 10:17:15 CST 2023 upgrade: Sending TERM to remaining processes ...
Wed Nov 22 10:17:15 CST 2023 upgrade: Sending signal TERM to sleep (3946)
Wed Nov 22 10:17:19 CST 2023 upgrade: Sending KILL to remaining processes ...
[  117.662335] stage2 (4011): drop_caches: 3
Wed Nov 22 10:17:26 CST 2023 upgrade: Switching to ramdisk...
mount: mounting /dev/mtdblock6 on /overlay failed: Resource busy
[  122.098824] VFS: Busy inodes after unmount of jffs2. Self-destruct in 5 seconds.  Have a nice day...
Wed Nov 22 02:17:30 UTC 2023 upgrade: Performing system upgrade...
[  122.203143] do_stage2 (4011): drop_caches: 3
Unlocking firmware ...

Writing from <stdin> to firmware ...  [w][  131.413906] mt7530 mdio-bus:1f lan2: Link is Down
[  131.418745] br-lan: port 2(lan2) entered disabled state
Wed Nov 22 02:19:24 UTC 2023 upgrade: Upgrade completed
Wed Nov 22 02:19:25 UTC 2023 upgrade: Rebooting system...
umount: can't unmount /dev: Resource busy
umount: can't unmount /tmp: Resource [  237.310019] reboot: Restarting system
busy

After outputting reboot: Restarting system, the leds are off, but the board does not reboot/reset.

I'll fall back to an older version(kernel version is 4.4) of openwrt fireware, dmesg search wdt output:

# dmesg | fgrep wdt
[    0.237190] gpio-wdt watchdog: timer started
[   12.065895] mt7621_wdt 1e000100.wdt: reset enabled
[   12.071094] mt7621_wdt 1e000100.wdt: Initialized

search dog output:

# dmesg | fgrep dog
[    0.237190] gpio-wdt watchdog: timer started
[    2.340514] init: - watchdog -

Compare to the new openwrt firmware(How to enable watchdog on mt7621 dts? - #2 by cppcoffee), missing gpio-wdt outputs.

And run sysupgrade on older version of openwrt fireware output:

# sysupgrade -n /tmp/1.bin
killall: watchdog: no process killed
Sending TERM to remaining processes ... logd rpcd netifd odhcpd crond xl2tpd
[  952.996639] mt753x gsw: Port 2 Link is Down
Sending KILL to remaining processes ...

Switching to ramdisk...
Performing system upgrade...
Unlocking firmware ...

Writing from <stdin> to firmware ...
Upgrade completed
Rebooting system...
umount: can't unmount /dev: Device or resource busy
[ 1126.028779] watchdog watchdog0: wating for WDT reset!
[ 1131.028481] watchdog watchdog0: Timer expired. System will reboot soon!
[ 1131.035568] reboot: Restarting system

After outputting the reboot: Restarting system message, the board reboots correctly. Compare to the new openwrt firmware (How to enable watchdog on mt7621 dts? - #9 by cppcoffee), missing watchdog watchdog0 output.

Is the watchdog not loaded? Maybe the 5.10 kernel removed the debug output.

The mt7621 CONFIG_GPIO_WATCHDOG_ARCH_INITCALL is disabled, I try to enable it and
reflash fireware, the reboot issue is same.

Added broken-flash-reset into dts spi m25p80@0 node, and added wdt into gpio groups, the run led change the frequency to 200ms.

Brush to system, the run led blinks fast, running reboot command doesn't reset the board, same problem.

I pressed the reset button key and had the same problem。

--- ./target/linux/ramips/dts/mt7621_strong-4g.dts    2023-11-22 12:46:02.193255538 +0800
+++ /tmp/mt7621_stong-4g.dts 2023-11-22 12:36:23.179092699 +0800
@@ -78,7 +78,7 @@
                 compatible = "linux,wdt-gpio";
                 gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
                 hw_algo = "toggle";
-                hw_margin_ms = <1000>;
+                hw_margin_ms = <200>;
                 always-running;
         };
 };
@@ -95,7 +95,6 @@
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;
+                       broken-flash-reset;

                        partition@0 {
                                label = "u-boot";
@@ -259,7 +258,7 @@

 &state_default {
        gpio {
-               groups = "jtag";
+               groups = "jtag", "wdt";
                function = "gpio";
        };
 };

It's the board's hardware watchdog problem.

Thank you all.