Difference between revisions of "Example watchdog"
Line 1: | Line 1: | ||
{{todo|Buggy(01.03.14-11:32->JG+);(01.03.14-11:42->MD-);(02.04.14-19:30->MD)|Brian Serrano|project=oe 4,oe 5,bs,md,Buggy}} | {{todo|Buggy(01.03.14-11:32->JG+);(01.03.14-11:42->MD-);(02.04.14-19:30->MD)|Brian Serrano|project=oe 4,oe 5,bs,md,Buggy}} | ||
+ | |||
This is a guide to the <code>watchdog</code> C example project included in the EMAC OE SDK. | This is a guide to the <code>watchdog</code> C example project included in the EMAC OE SDK. | ||
− | |||
A '''watchdog timer''' (WDT) is a hardware circuit that can reset the computer system in case of a software fault. This is an example test for the Linux watchdog API. | A '''watchdog timer''' (WDT) is a hardware circuit that can reset the computer system in case of a software fault. This is an example test for the Linux watchdog API. | ||
− | + | For more information about the protocol see the following page: http://en.wikipedia.org/wiki/Watchdog_timer | |
− | For more information about the protocol see the following page:http://en.wikipedia.org/wiki/Watchdog_timer | ||
− | |||
The <code>watchdog</code> project builds one executable: <code>watchdog-test</code>. | The <code>watchdog</code> project builds one executable: <code>watchdog-test</code>. | ||
Line 42: | Line 40: | ||
Watchdog Ticking Away! | Watchdog Ticking Away! | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | Every second <code>watchdog-test</code> is sending an IOCTL to the watchdog driver, which in turn ticks <code>watchdog</code> to reset its internal timer so it doesn't timeout and trigger a system reset. | ||
− | + | Now we will stop interrupting <code>watchdog</code> and let it trigger a computer reset by pressing ''Ctrl+C''. | |
− | |||
− | |||
− | |||
− | Now we will stop interrupting <code>watchdog</code> and let it trigger a computer reset | ||
− | |||
− | |||
===Usage Example. Disabling <code>watchdog</code>=== | ===Usage Example. Disabling <code>watchdog</code>=== | ||
Line 60: | Line 53: | ||
'''NOTE: the ellipses starting off a sentence fragment is unacceptable. This needs to be worded nicely instead (for every fragment starting with an ellipses throughout this document).''' | '''NOTE: the ellipses starting off a sentence fragment is unacceptable. This needs to be worded nicely instead (for every fragment starting with an ellipses throughout this document).''' | ||
− | . | + | After running the <code>./watchdog-test -d</code> command, the program exits normally. |
===Usage Example. Enabling <code>watchdog</code>=== | ===Usage Example. Enabling <code>watchdog</code>=== | ||
Line 71: | Line 64: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | . | + | After running the <code>./watchdog-test -e</code> command, the system resets. |
===Usage Example. Setting <code>watchdog</code> timeout=== | ===Usage Example. Setting <code>watchdog</code> timeout=== | ||
Line 82: | Line 75: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | . | + | After running the <code>./watchdog-test -t</code> command, the program exits normally. Once it exits, 5 seconds will elapse, and then the system resets. |
==Summary== | ==Summary== |
Revision as of 17:05, 5 February 2014
This is a guide to the watchdog
C example project included in the EMAC OE SDK.
A watchdog timer (WDT) is a hardware circuit that can reset the computer system in case of a software fault. This is an example test for the Linux watchdog API.
For more information about the protocol see the following page: http://en.wikipedia.org/wiki/Watchdog_timer
The watchdog
project builds one executable: watchdog-test
.
Opening, Building and Uploading the Project Files
For information on opening the project from within Eclipse, please see Importing the EMAC OE SDK Projects with Eclipse. Then, follow Using the EMAC OE SDK Projects with Eclipse for information on how to build, upload and execute the example.
Alternatively, the Makefile
can be used with the make
command from the commandline to build and upload the example. For more information on this method, please see Using EMAC OE SDK Example Projects.
Usage and Behavior
A watchdog timer is a hardware circuit that can reset the computer system in case of a software fault. The watchdog-test
application can enable, disable, activate, configure and interrupt the watchdog timer.
Activating watchdog invokes system reset (after timeout) |
Hardware Requirements
watchdog
will run on any system for which it can be compiled and implements the standard Linux watchdog
API.
watchdog
Usage
./watchdog-test [-det]
- -d
- Disable watchdog.
- -e
- Enable watchdog.
- -t
- Set the watchdog timeout (to a value specified in code. Default is five seconds).
Usage Example. Activating watchdog
with a periodic interrupt
This will activate watchdog
and initiate a periodic interrupt to keep it from timing out.
root@emac-oe/tmp#:$ ./watchdog-test
Watchdog Ticking Away!
Every second watchdog-test
is sending an IOCTL to the watchdog driver, which in turn ticks watchdog
to reset its internal timer so it doesn't timeout and trigger a system reset.
Now we will stop interrupting watchdog
and let it trigger a computer reset by pressing Ctrl+C.
Usage Example. Disabling watchdog
root@emac-oe/tmp#:$ ./watchdog-test -d
Watchdog card disabled.
NOTE: the ellipses starting off a sentence fragment is unacceptable. This needs to be worded nicely instead (for every fragment starting with an ellipses throughout this document).
After running the ./watchdog-test -d
command, the program exits normally.
Usage Example. Enabling watchdog
This will enable and activate watchdog
but it won't perform a periodic timeout interrupt (see the first usage example, above). So when you run it the program activates watchdog
and then watchdog
resets the system.
root@emac-oe/tmp#:$ ./watchdog-test -e
Watchdog card enabled.
After running the ./watchdog-test -e
command, the system resets.
Usage Example. Setting watchdog
timeout
This will activate watchdog
and set it to timeout in 5 seconds.
root@emac-oe/tmp#:$ ./watchdog-test -t
Watchdog timeout set to 5 seconds!
After running the ./watchdog-test -t
command, the program exits normally. Once it exits, 5 seconds will elapse, and then the system resets.
Summary
The watchdog
C example project demonstrates how to use the watchdog timer. We provide examples of how to enable, disable, activate, configure and interrupt the watchdog
hardware circuit.
NOTE: At least give the reader an idea of why they may want to use this, and how to incorporate it into their system.