By default the watchdog is disabled at boot time by AT91Bootstrap. To enable it you have to recompile AT91Bootstrap after have disabled this flag:
[ ] Disable Watchdog
To know how to compile AT91Bootstrap follow the tutorials on this link.
To change the default flag value use the make menuconfig command.
This is the Kernel flag to enable inside the Kernel configuration.
Device Drivers --->
[*] Watchdog Timer Support --->
<*> AT91SAM9X / AT91CAP9 watchdog
To know how to change the kernel configuration and compile it to generate the bootable class='acmetable' zImage follow this tutorials this link.
Add to board xxxx.dts these lines inside the apb section:
ahb {
apb {
...
<b>
watchdog@fffffe40 {
compatible = "atmel,at91sam9260-wdt";
reg = <0xfffffe40 0x10>;
timeout-sec = <30>;
status = "okay";
};
</b>
...
};
};
Setting the parameter timeout-sec as you like.
To know how to compile the Device Tree file follow the tutorials on how to cross compile the Linux Kernel on this link.
If everything is going well you will see this message on the debug port during the bootstrap:
at91sam9_wdt: enabled (heartbeat=30 sec, nowayout=0)
or from the command line:
root@arietta:~# dmesg | grep "wdt"
[ 5.375000] at91sam9_wdt: enabled (heartbeat=30 sec, nowayout=0)
a device node called /dev/watchdog exists on the rootfs:
root@arietta:~# ls /dev/watchdog
/dev/watchdog
Now simply try the watchdog by typing and wait 30 sec doing nothing...
# echo "hello" > /dev/watchdog
watchdog watchdog0: watchdog did not stop!
After 30 secs the board will restart.
at91sam9_wdt: I will reset your machine !
Writing something on /dev/watchdog you have armed the watchdog timer and after the first write you have to write on it before 30 sec to avoid the restart.
More info about the watchdog under Linux is available on this link: