Watchdog Timer

Hi,

I am playing with the Omap Watchdog timer - works great.

Currently I have to ping it to start the counter - which means that
the system has booted.
My goal is protection prior to root being mounted and the system
booting.

I am thinking it is easier to just make the initial state of the
watchdog on by default by changing the omap_wdt module in the kernel.
Has anyone done this? I can't see how to do it from looking at the
code.

Thanks,
CJ

Hi - anyone know if it is possible to change the initial state of the watchdog to on by default?
Perhaps in the kernel?

Cheers,
CJ

Anyone?

I wan to provide watchdog protection for the system assuming the
filesystem can't be mounted.
So could be from uboot.

If no one has done this .. maybe it is not essential for me either.

Cheers,
CJ

Hi CJ,

You can do it from U-Boot. Please see sections "16.4 Watchdog Timers"
and "16.5 Watchdog Timer Register Manual" of SPRUGN4F "AM/DM37x
Multimedia Device Technical Reference Manual" for BB-xM or SPRUF98M
"OMAP35x Applications Processor Technical Reference Manual" for all
other BBs. Also, there is a lot of examples in U-Boot sources how to
get access to the HW registers.

Cheers,
Max.

Hi,
can you explain how to use watchdog timer?

I have an application running on the beagleboard and I need the board
to reboot if application crash or close...

Thanks

Where can I find that manuals?

Well, I got the latest kernel sources from kernel.org and then looked in linux-2.6.37/Documentation/watchdog and there seems to be details on using the watchdog. I’m running a kernel that I compiled, and I explicitly enabled the omap watchdog.

sandisk4gb:~/src/linux-2.6.37/Documentation/watchdog/src$ ls -alF /dev/w*
crw-rw---- 1 root root 10, 130 Jan 17 22:47 /dev/watchdog

When I first ran one of the sample programs I got this on the console:

[125320.740692] omap_device: omap_wdt.-1: new worst case activate latency 0: 701904
Watchdog Ticking Away!

After my machine reset itself, I went and ran both of the following commands. Both resulted in the same warnings on the console, and the board rebooted as well, so obviously the disabling in the sample command is not working correctly.

/home/wim/src/linux-2.6.37/Documentation/watchdog/src # ./watchdog-test -e
Watchdog card enabled.
/home/wim/src/linux-2.6.37/Documentation/watchdog/src # ./watchdog-test -d
Watchdog card disabled.
/home/wim/src/linux-2.6.37/Documentation/watchdog/src #

[ 355.899108] omap_wdt: Unexpected close, not stopping!
[ 363.162719] omap_wdt: Unexpected close, not stopping!

Hi luca26,

OMAP3530: http://www.ti.com/litv/pdf/spruf98m
DM3730: http://www.ti.com/litv/pdf/sprugn4f

Cheers,
Max.

Thanks a lot!

Now I need help in using wdt.

As I said, I have an application that run in a beagleboard xm. I need
that if application crash, the beagleboard reboot.
I seen the example in the linux kernel documentation:
linux-2.6.37/Documentation/watchdog/src/watchdog-test.c .

Do I need to implement this code in my application to poll watchdog?
Is there another way to poll watchdog in the beagleboard?

Thanks

First off, I want to mention that I’ve compiled my kernel with the following options, and the watchdog is compiled in and not a module.

CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_NOWAYOUT=y

I found that if I did not use the second option, when my program exited abnormally, the watchdog file closed, and disabled itself. Maybe I was doing something wrong, but my solution was simply to increase the watchdog timer to 24 hours when I properly exit my program. I only properly exit my program when I’m running on my development platform. In normal operations the program gets started and runs forever.

Building on those sample programs you mention, My code looks like the following:

int WatchDog = open("/dev/watchdog", O_WRONLY);
if (WatchDog >= 0)
{
int WatchDogFlags = WDIOS_ENABLECARD;
int WatchDogTimeout = 45; // value that is not used, but simply different so that I can confirm the reading of the value below gets a value from the watchdog itself.
ioctl(WatchDog, WDIOC_SETOPTIONS, &WatchDogFlags);
cout << “Watchdog is enabled.” << endl;
ioctl(WatchDog, WDIOC_GETTIMEOUT, &WatchDogTimeout);
cout << “Watchdog timeout is " << WatchDogTimeout << " seconds.” << endl;
WatchDogTimeout = 120;
ioctl(WatchDog, WDIOC_SETTIMEOUT, &WatchDogTimeout);
cout << “Watchdog timeout was set to " << WatchDogTimeout << " seconds.” << endl;
}

// Here’s where I poll the watchdog inside my main processing loop.
int dummy;

if (WatchDog >= 0)
ioctl(WatchDog, WDIOC_KEEPALIVE, &dummy); // trigger the watchdog

if (WatchDog >= 0)
{
// set watchdog timeout to some very large number, in case the linux kernel does not allow the watchdog to be disabled once it’s been activated
// The LINUX kernel configration option is CONFIG_WATCHDOG_NOWAYOUT=y
// Ive decided that it’s a good thing to use, since otherwise if the program exits unexpectedly, the watchdog file gets closed and the watchdog will not reset the system.
int WatchDogTimeout = 86400; // 24 hours
ioctl(WatchDog, WDIOC_SETTIMEOUT, &WatchDogTimeout);
cout << “Watchdog timeout was set to " << WatchDogTimeout << " seconds.” << endl;
int WatchDogFlags = WDIOS_DISABLECARD;
ioctl(WatchDog, WDIOC_SETOPTIONS, &WatchDogFlags);
cout << “Watchdog is disabled.” << endl;
close(WatchDog);
}

Thanks Williams,
now it's more clear.
Tomorrow I'll check if the linux kernel in angostrom (downloaded from
http://narcissus.angstrom-distribution.org/) has the option
CONFIG_WATCHDOG_NOWAYOUT because I need the watchdog to be enabled
when my application crash.

Checking the kernel documentation (http://kernel.org/doc/Documentation/
watchdog/watchdog-parameters.txt) I've seen that omap_wdt driver
hasn't the parameter nowayout so it's impossible to change it's value
without re-compile kernel with that option but it's could be very
useful.

How can I check if my angstrom distribution has the option
CONFIG_WATCHDOG_NOWAYOUT enabled?

by checking config.gz?

Unfortunatelly my Angstrom (downloaded from narcissus) hasn't a
config.gz file .

Unfortunatelly my Angstrom (downloaded from narcissus) hasn't a
config.gz file .

Are you sure? I does have it over here.

I have the file too. Did you check here:

/proc/config.gz

Jake

Hi,

Still struggling finding out how to get the watchdog started in u-
boot.
Has anyone done this?

Cheers,
CJ

Thanks, I found it.

In my config file I have this:
CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_NOWAYOUT=y

so I think to be able to do as William said...

The watchdog in my beagleboard is started by the kernel because it has
included watchdog driver.
If you have the wdt driver as module (and you are using angstrom) you
can add it to /etc/modules .