Watchdog Timer on Jetson TX1 : How can I change the timeout value and kick WDT?

Hi.

I am trying to use watchdog timer on Jetson TX1.

Firstly, I tried following sample code after setup TX1 by JetPack for L4T 2.1, but it did not work.

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/watchdog.h>

int main (void) {
	int fd, ret;
	int timeout = 0;
 
	/* open WDT0 device (WDT0 enables itself automatically) */
	fd = open("/dev/watchdog0", O_RDWR);
	if(fd < 0) {
		fprintf(stderr, "Open watchdog device failed!\n");
		return -1;
	}
	/* WDT0 is counting now,check the default timeout value */
	ret = ioctl(fd, WDIOC_GETTIMEOUT, &timeout);
	if(ret) {
		fprintf(stderr, "Get watchdog timeout value failed!\n");
		return -1;
	}
	fprintf(stdout, "Watchdog timeout value: %d\n", timeout);
 
	/* set new timeout value 60s */
	/* Note the value should be within [5, 1000] */
	timeout = 60;
	ret = ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
	if(ret) {
		fprintf(stderr, "Set watchdog timeout value failed!\n");
		return -1;
	}
	fprintf(stdout, "New watchdog timeout value: %d\n", timeout);
 
	/*Kick WDT0, this should be running periodically */
	ret = ioctl(fd, WDIOC_KEEPALIVE, NULL);
	if(ret) {
		fprintf(stderr, "Kick watchdog failed!\n");
		return -1;
	}
}

Then, setup TX1 again by building the NVIDIA kernel according to “Tegra Linux Driver Package Development Guide”.
I set kernel configuration as follows:

CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_CORE=y
# CONFIG_WATCHDOG_NOWAYOUT is not set

#
# Watchdog Device Drivers
#
# CONFIG_SOFT_WATCHDOG is not set
CONFIG_SOFT_PLATFORM_WATCHDOG=y
CONFIG_TEGRA_WATCHDOG=y
CONFIG_MAX77620_WATCHDOG=y
# CONFIG_ALIM7101_WDT is not set
# CONFIG_I6300ESB_WDT is not set

#
# PCI-based Watchdog Cards
#
# CONFIG_PCIPCWATCHDOG is not set
# CONFIG_WDTPCI is not set

But, “WDIOC_GETTIMEOUT” and “WDIOC_SETTIMEOUT” shows error “operation not supported”.
And it seems that “WDIOC_KEEPALIVE” does not work, so TX1 reboot after 120 seconds.

I have tried changing kernel source (tegra_wdt.c) as follows:

-static int heartbeat = 120;
+static int heartbeat = 10;

The timout value does not change, either.

How can I change the timeout value and kick WDT?

The kernel version is 3.10.67, and it is able to kick and close WDT by the following way.

# tail -f /dev/watchdog0   // open wdt
# echo 1 > /dev/watchdog0  // kick wdt
# echo V > /dev/watchdog0  // close wdt

Can anyone help me?

Thanks.

Firstly, I tried following sample code after setup TX1 by JetPack for L4T 2.1, but it did not work.
What did you mean “it did not work”? What’s the message?

Regarding ioctl and watchdog timers, see also:
[url]https://devtalk.nvidia.com/default/topic/975935/jetson-tx1/how-can-i-change-the-timeout-value-and-kick-watchdog-on-jetson-tx1-/[/url]

Locked this thread out as the same issue is under discussing at [url]https://devtalk.nvidia.com/default/topic/975935/jetson-tx1/how-can-i-change-the-timeout-value-and-kick-watchdog-on-jetson-tx1-/[/url]