Watchdog timers on AM335x boards
From IGEP - ISEE Wiki
Contents
[hide]Watchdog timers on AM335x boards
![]() |
This is a work in progress article. Help other developers like you in the IGEP Community by improving it! |
Overview of this article
This article is meant to be a starting point for people to learn setup the watchdog timer on IGEP0033 AQUILA COM MODULE boards.
Feedback and Contributing
Creating articles in the wiki is a collaborative process, at any point, if you see a mistake you can contribute to this article.
Please, use the discussion tab for user comments. This is useful to separate page content and the discussion thereof and also, if you don't want to give normal users the right to edit the page but still want user contributed notes.
Editing permissions are restricted to registered users. Register in the main IGEP site and you will have single sign-on.
Consult the User's Guide for information on using the wiki software.
There is a set of Wiki contribution guidelines.
Aquila watchdog overview
There are 2 watchdog timers in the Aquila, inside the /dev/ directory:
- watchdog
- watchdog0
This watchdogs are special files which, when opened, count time while there's no writing on them. Whenever a process writes data on that files, they reset the timer. But if timer reaches the timeout value between writings, then watchdog forces the microcontroller to reboot, as it detects it as that process is freezing.
Watchdog timers under Linux kernel
The following documentation from kernel.org can give you more information about the watchdogs:
Compile the watchdog-simple.c source code with your board's compiler. This is the application we will use demonstrate the basical watchdog functionality.
With this tiny piece of software, we can enable, and tick the watchdog card. First, we will run it to see the typical behaviour:
$ watchdog-simple
As the program ticks the card (writes on it every 10 seconds), the watchdog observes normal activity and doesn't reset the board.
Now we will modify the code in order to avoid the ticking, and only enabling the watchdog to count. For that purpose, we will comment or erase all the code inside the while loop, obtaining an infinite loop that makes nothing (which simulates the system freezing).
$ watchdog-simple
After the timer reaches the timeout value, the board resets on itself.
Adding configuration parameters and flags
The watchdog can be configured by editing the underlying device parameters of special files. It can easily be implemented inside our simple test with ioctl().
For example, we can change the timeout value by adding the following lines to our main function, before the while loop:
int timeout = 45; ioctl(fd, WDIOC_SETTIMEOUT, &timeout); printf("The timeout was set to %d seconds\n", timeout);
Please, note that you may include some header files in order to compile the program succesfully:
#include <sys/ioctl.h> #include <linux/watchdog.h>
Note too that the timeout can be set to 60 seconds depending on the device's granularity.