AM335x PSP WDT Driver User Guide

= Introduction =

Software stability is a major issue on any platform. Anyone who uses software has probably experienced problems that crash the computer or program in question. This is also true of embedded programs, and in most cases there is no user around to reset the computer when things go wrong. That job is occupied by the watchdog timer. The watchdog timer is a 32 bit counter that resets the processor when it rolls over to zero. The processor can reset the counter or turn it off, but, correctly used, it will reset the processor in case of a code crash. To avoid getting reset, the program must reset the timer every so often.

= IP features =

2 instances: 1 System watchdog timer (used in Linux) and 1 Security watchdog timer


 * Free running 32-bit upward counter.
 * Programmable divider clock source (2n with n=[0:7])
 * On the fly read/write register (while counting)
 * Reset upon occurrence of a timer overflow condition

= Driver =

AM335x has a 32-bit watchdog timer which can be used to reset the hardware in case of a software fault. Once the /dev/watchdog is opened, it will reboot the system unless a user space daemon resets the timer at regular intervals within a certain timeout period. If watchdog device node is closed before timeout also reboot won't happen. The WDT driver is registered as a misc device. Default timeout of this driver is 60 seconds



= Configuration =

To enable/disable watchdog support, start the Linux Kernel Configuration tool:

$ make menuconfig Select Device Drivers from the main menu. ...   ...    Power management options ---&gt; [ ] Networking support ---&gt; Device Drivers ---&gt; ... Select Watchdog Timer Support as shown here: ...   ... &lt; &gt; Hardware Monitoring Support ---&gt; &lt; &gt; Generic Thermal sysfs driver ---&gt; [*] Watchdog Timer Support ---&gt; ... Select OMAP Watchdog as shown here: --- Watchdog Timer Support [ ] Disable watchdog shutdown on close &lt; &gt; Software watchdog ---&gt; &lt;*&gt; OMAP Watchdog ... Note: Watchdog timer is enabled by default in the am335x_evm_defconfig 

= Sample Applications =

This chapter describes the watchdog sample application provided along with the package. The source for this sample application is available in the Examples (wdt) directory of the Release Package folder.

1) Change the relative path of the kernel directory in the 'Makefile' as per your directory structure : KERNEL_DIR= &lt;insert relative path to the kernel&gt;
 * 1) Kernel base directory name with path

2) Compile the application using the 'make' command to obtain the executable :  $ make

3) Run the executable application (saWatchdog) on the EVM :

The application sets the watchdog reset time to 10 seconds by default (this can be changed in the source file as per the user's convenience). To test the watchdog's functionality, run the following two test cases on the EVM and check if the results are as expected. $ ./saWatchdog &lt;a value less than the watchdog reset time&gt;

(eg. $./saWatchdog 5)

$ ./saWatchdog &lt;a value greater than the watchdog reset time&gt; (eg. $./saWatchdog 12)

The application will keep writing values before the timeout in the first case, thus not restarting the system and keeping it going.

The application will get late in writing a value before the timeout in the second case, hence restarting the system.