Watchdog resets board in spite of being fed

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, msg                                                                             
write_interval=5 # seconds                                                                                
echo("starting to feed...")                                                                               

for i in range(20):                                                                                   
echo("Done feeding watchdog")                                                                         
print "starting to sleep 100 seconds. watchdog should kick in soon"                                   
for count in range(1,100):                                                                            

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.

hi sagi

did you compile the kernel with CONFIG_WATCHDOG_NOWAYOUT flag. Check this community post for further information.

You need to do IOCTL, just doing writes to it won’t work.