I am feeding the hardware watchdog like so:
import sys
import time
from datetime import datetime
watchfile = open("/dev/watchdog0", "w")
def echo(msg):
print datetime.now(), msg
sys.stdout.flush()
write_interval=5 # seconds
echo("starting to feed...")
for i in range(20):
echo("Feeding")
watchfile.write("\0")
time.sleep(write_interval)
echo("Done feeding watchdog")
watchfile.write("V")
watchfile.close()
print "starting to sleep 100 seconds. watchdog should kick in soon"
for count in range(1,100):
echo("waiting")
time.sleep(1)
So I am effectively feeding the watchdog every 5 seconds, 20 times.
Yet the board resets before those 20 cycles end:
2018-03-11 09:00:31.733662 starting to feed...
2018-03-11 09:00:31.734115 Feeding
2018-03-11 09:00:36.739108 Feeding
2018-03-11 09:00:41.750901 Feeding
2018-03-11 09:00:46.773189 Feeding
2018-03-11 09:00:51.800117 Feeding
2018-03-11 09:00:56.806380 Feeding
2018-03-11 09:01:01.816076 Feeding
2018-03-11 09:01:06.836107 Feeding
2018-03-11 09:01:11.842025 Feeding
2018-03-11 09:01:16.845463 Feeding
2018-03-11 09:01:21.852083 Feeding
2018-03-11 09:01:26.864101 Feeding
2018-03-11 09:01:31.869663 Feeding
2018-03-11 09:01:36.876171 Feeding
dmesg | grep watchdog:
[ 4.762598] tegra_wdt tegra_wdt.0: last reset is due to watchdog timeout
[ 6.783728] last reset is due to watchdog timeout
So basically it seems like once the watchdog file is written to, I cannot stop it.
I have a similar C program built after the toradex sample code which exhibits the same behavior, the python version is just shorter.