Watchdog Timer

1,811 views
Skip to first unread message

CJNZ

unread,
Jan 6, 2011, 7:58:34 PM1/6/11
to Beagle Board
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

CJNZ

unread,
Jan 9, 2011, 6:39:28 PM1/9/11
to beagl...@googlegroups.com
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

CJNZ

unread,
Jan 16, 2011, 7:13:43 PM1/16/11
to Beagle Board
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

Max Galemin

unread,
Jan 16, 2011, 11:09:08 PM1/16/11
to Beagle Board
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.

luca26

unread,
Jan 20, 2011, 1:06:41 PM1/20/11
to Beagle Board
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

luca26

unread,
Jan 20, 2011, 1:07:33 PM1/20/11
to Beagle Board
Where can I find that manuals?

William C Bonner

unread,
Jan 20, 2011, 5:19:13 PM1/20/11
to beagl...@googlegroups.com
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!


--
You received this message because you are subscribed to the Google Groups "Beagle Board" group.
To post to this group, send email to beagl...@googlegroups.com.
To unsubscribe from this group, send email to beagleboard...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/beagleboard?hl=en.


Max Galemin

unread,
Jan 20, 2011, 6:40:47 PM1/20/11
to Beagle Board
Hi luca26,

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


Cheers,
Max.

luca26

unread,
Jan 21, 2011, 8:08:28 AM1/21/11
to Beagle Board
Thanks a lot!

luca26

unread,
Jan 22, 2011, 8:43:54 AM1/22/11
to Beagle Board
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

William C Bonner

unread,
Jan 22, 2011, 3:19:16 PM1/22/11
to beagl...@googlegroups.com
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);
}


luca26

unread,
Jan 23, 2011, 5:13:11 AM1/23/11
to Beagle Board
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.
> > beagleboard...@googlegroups.com<beagleboard%2Bunsu...@googlegroups.com>
> > .

luca26

unread,
Jan 23, 2011, 5:38:27 AM1/23/11
to Beagle Board
How can I check if my angstrom distribution has the option
CONFIG_WATCHDOG_NOWAYOUT enabled?

Koen Kooi

unread,
Jan 23, 2011, 5:51:31 AM1/23/11
to beagl...@googlegroups.com
by checking config.gz?

Op 23 jan 2011, om 11:38 heeft luca26 het volgende geschreven:

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

> --
> You received this message because you are subscribed to the Google Groups "Beagle Board" group.
> To post to this group, send email to beagl...@googlegroups.com.

> To unsubscribe from this group, send email to beagleboard...@googlegroups.com.

luca26

unread,
Jan 23, 2011, 6:19:17 AM1/23/11
to Beagle Board
Unfortunatelly my Angstrom (downloaded from narcissus) hasn't a
config.gz file .

Koen Kooi

unread,
Jan 23, 2011, 6:53:54 AM1/23/11
to beagl...@googlegroups.com

Op 23 jan 2011, om 12:19 heeft luca26 het volgende geschreven:

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

Are you sure? I does have it over here.

Jake

unread,
Jan 23, 2011, 9:30:50 AM1/23/11
to beagl...@googlegroups.com
I have the file too.  Did you check here:

/proc/config.gz

Jake

CJNZ

unread,
Jan 23, 2011, 9:33:39 PM1/23/11
to Beagle Board
Hi,

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

Cheers,
CJ

luca26

unread,
Jan 24, 2011, 2:51:59 AM1/24/11
to Beagle Board
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...

luca26

unread,
Jan 24, 2011, 2:54:37 AM1/24/11
to Beagle Board
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 .

CJNZ

unread,
Jan 24, 2011, 4:05:57 PM1/24/11
to Beagle Board
Hi Luca26,

I have it compiled into the kernel.
It doesn't start on boot.. shall I make it a module and then that will
work?

Cheers,
CJ

William C Bonner

unread,
Jan 24, 2011, 10:00:30 PM1/24/11
to beagl...@googlegroups.com
In my short experience with using the linux watchdog, the watchdog does not come up in a state until an external program has opened the watchdog file.

After the file has been opened by a program, the watchdog has to be triggered regularly or the system will be reset. If the kernel has the NOWAYOUT option set, then once the watchdog is first opened, you'll have to keep triggering the watchdog forever, but it seems that you can trigger it from multiple programs, as long as they have permission to open the /dev/watchdog file.

I would bet that you could write a simple shell script to open the watchdog.

cat /dev/watchdog

would open it from the command line with its default parameters, and then your machine would probably reset 60 seconds later, assuming that you don't do something else to trigger the watchdog.

Wim.

luca26

unread,
Jan 25, 2011, 2:31:58 AM1/25/11
to Beagle Board
Hi Cjnz,
what do you mean with "it doesn't start" ?
Have you got the file /dev/watchdog ?

luca26

unread,
Jan 25, 2011, 3:34:41 AM1/25/11
to Beagle Board
Now I tried the watchdog as said before.

int watchdog_fd = open("/dev/watchdog", O_WRONLY); \\open the
watchdog file
if (watchdog_fd >= 0)
{
int flags_abilitazione_wd = WDIOS_ENABLECARD;
ioctl(watchdog_fd, WDIOC_SETOPTIONS,
&flags_abilitazione_wd); \\enable the watchdog
int watchdog_timeout = 20; //20 secondi prima
riavviare la scheda
ioctl(watchdog_fd, WDIOC_SETTIMEOUT,
&watchdog_timeout); \\ set 20 sec timeout
}

after that I don't write the WDIOC_KEEPALIVE so I expect my board to
reboot after 20 second but it only halt and doesn't restart.

What do you think about?

luca26

unread,
Jan 25, 2011, 4:17:02 AM1/25/11
to Beagle Board
I tried the same watchdog in beagleboard c4 and xm.
It works fine in the c4 (it reboot correctly when the timeout
occurs) .
In the Xm the board only halt and doesn't reboot.

I'm using the same Angstrom downloaded from http://www.angstrom-distribution.org/narcissus/
.

luca26

unread,
Jan 25, 2011, 2:47:33 PM1/25/11
to Beagle Board
does someone used watchdog successfully with BB xM ?

luca26

unread,
Feb 17, 2011, 1:15:17 PM2/17/11
to Beagle Board
I try again....

Does someone used watchdog successfully with BB xM ?

I can't use it. After WD timeout, the BB xM halt but doesn't reboot.
It works fine with BB C4 .

psa

unread,
Nov 4, 2011, 5:51:58 AM11/4/11
to beagl...@googlegroups.com
Currently, I have the same problem with DM3730 and TPS65950 (on BB-xM). Have-you solve it?
Thanks in advance.
Pierre

Reply all
Reply to author
Forward
0 new messages