Home>Posts>I/O Embedded & IoT, I/O HUB>How to Use the BeagleBone Black Watchdog Timer

How to Use the BeagleBone Black Watchdog Timer

By ·Categories: I/O Embedded & IoT, I/O HUB·Published On: August 28th, 2014·2.4 min read·

A watchdog timer (WDT) is used by a computer system to identify and recover from unexpected interruptions. Watchdog timers are especially important in remote and embedded applications. If the computer “hangs” or needs to be reset, a watchdog timer can be used to automate the recovery process, saving downtime and eliminating the need for the system to be constantly monitored by an operator.

As the BeagleBone Black begins to be more frequently deployed in commercial settings, ensuring reliable operation is paramount. Fortunately, the BeagleBone Black comes equipped with built-in watchdog timer functionality. Our new Inspire tutorial provides step by step instructions for accessing and activating the BeagleBone Black watchdog timer.

The BeagleBone Black has an embedded watchdog timer that can be very useful in providing a reset function.

A watchdog timer will:

  • Allow enough time for the system to boot before triggering a reset.
  • Needs to receive periodic signals from the critical program (I’m alive and well).
  • Reset the system, if the program becomes unresponsive (fails to report on time).

On the BeagleBone Black, the watchdog timer is activated by accessing the system device /dev/watchdog.

cat > /dev/watchdog

The watchdog function is initially activated by writing to /dev/watchdog.
This enables the watchdog, and it must now be periodically accessed. The initial period is about 60 seconds.

Your application program, should then access the watchdog timer to ensure that under normal operation the time interval is satisfied. Failing to write to the watchdog will cause a forced system reset. This is what we would like to happen if our program has become unresponsive.

Testing The Watchdog

To test the watchdog, simply write to the watchdog.

cat > /dev/watchdog

Wait about 60 seconds and your BeagleBone will reset and reboot.
On the other hand, if you issue the command again, before the timer has elapsed, the reset will be delayed further. These simple steps will help you test the watchdog timer.

NOTE: The watchdog is enabled once you FIRST write to /dev/watchdog, otherwise it is in-active.

Programming Hint

There are many approaches to implementing the watchdog ‘keep alive’ function. A simple method is to regularly issue a system command from the programming language chosen. Another method is to simply open the file ‘/dev/watchdog’ for writing.

This tutorial shows an example of  issuing a system command using bonescript (exec child process).
BoneScript also has a simple method to automatically run a program. In Bonescript, simply drop the program into the AUTORUN folder.

Similar execution of system functions exist for Python and C/C++. The implementation will vary based on the application needs.

A simple python example:

#!/usr/bin/env python

import time
import os

time.sleep(60)                  # Wait before starting
wd = open("/dev/watchdog", "w+")
while 1:

Is it time for you to implement your own watchdog timer application?


About the Author: Richard St-Pierre

Richard worked as the Senior Electrical Engineer at Logic Supply before relocating with his family in 2015. A general problem solver and well-known "Lab MacGyver", Richard is always on the lookout for creative approaches to design solutions and continues to explore new opportunities to build creative solutions to common challenges.
Follow OnLogic on LinkedIn

Leave A Comment


Have a project? Let's talk

More Articles


Learn the 5 ways Fanless Computers can help your business

Get the Whitepaper
View All Articles

OnLogic Industrial Computers

Discover OnLogic's multitude of industrial computers that will help you to advance your IoT project

Shop OnLogic

Learn more at OnLogic.com

OnLogic Industrial PCs: Designed to last. Built to order. Delivered in days. Visit our online store at OnLogic.com