Apalis TK1 watchdog does not disable when closing the file

I am trying to set up a watchdog. I’m using a slightly modified example from toradex :

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>

int main(void)
{
	int fd = open("/dev/watchdog0", O_WRONLY);
	int ret = 0;
	if (fd == -1) {
		perror("watchdog");
		exit(EXIT_FAILURE);
	}
    int i;
	for (i=0; i<10; i++) {
		ret = write(fd, "\0", 1);
		if (ret != 1) {
			ret = -1;
			break;
		}
		sleep(1);
	}
    printf("done. closing watchdog file\n");
	close(fd);
	return ret;
}

I am trying to make sure I can turn off the watchdog when no longer needed.

This is supposedly done by closing the watchdog file.

Still the system reboots after a few seconds (seems like around 40) when the program is done.

How can I actually disable the watchdog?

Hi sagism

Please refer to this article.

I read this article before implementing the above. Question still stands…

The article is very vague on the specifics of the TK1.

You need to either:

(a) If the TK1 supports “magic”, then write the special “V” character to the device before closing, to ensure that the watchdog does not reset the system.

or

(b) If your system is setup with “nowayout”, then set tegra_wdt.nowayout=0 on the boot command line.

Hi Jens

Your explication is correct. The behaviour of watchdog in linux is well described in the api documentation link text. Usually the toradex images are compiled with the Kernel option “WATCHDOG_NOWAYOUT”.

Thanks, how can I modify the boot command line?
I assume this would be done in uboot?
Which of the config params would I modify? (assuming booting from mmc),

Boot to uboot.
then type the follwoing:

setenv tegra_wdt.nowayout 0

saveenv

Then reboot.