We're no longer updating This wiki!!

This is an old revision of the document!


Watchdog on Linux/Ubuntu

Background

Watchdog timers are commonly found in embedded systems and other computer-controlled equipment where humans cannot easily access the equipment or would be unable to react to faults in a timely manner. In such systems, the computer cannot depend on a human to reboot it if it hangs; it must be self-reliant.

Odroid C1/C1+ support watchdog driver aml_wdt to control the PMU.

Test Watchdog module

Watchdog driver aml_wdt is configurable for Odroid C1/C1+.

Kernel Changes Need to make this working.

You probably need to recompile the kernel with this changes.

diff --git a/drivers/amlogic/watchdog/aml_wdt.c b/drivers/amlogic/watchdog/aml_wdt.c
index e7b34b5..4ac15df 100644
--- a/drivers/amlogic/watchdog/aml_wdt.c
+++ b/drivers/amlogic/watchdog/aml_wdt.c
@@ -102,7 +102,7 @@ static void boot_moniter_work(struct work_struct *work)
 }

 static const struct watchdog_info aml_wdt_info = {
-       .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+       .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
        .identity = "aml Watchdog",
 };

diff --git a/include/linux/amlogic/aml_wdt.h b/include/linux/amlogic/aml_wdt.h
index 08c12ab..e1f7c4a 100644
--- a/include/linux/amlogic/aml_wdt.h
+++ b/include/linux/amlogic/aml_wdt.h
@@ -44,19 +44,19 @@ struct aml_wdt_dev {
 #define AML_WDT_ENABLED (aml_read_reg32(P_WATCHDOG_TC)&(1 << WATCHDOG_ENABLE_BIT))
 static inline void disable_watchdog(void)
 {
-       printk(KERN_INFO "** disable watchdog\n");
+       pr_emerg("** disable watchdog\n");
        aml_write_reg32(P_WATCHDOG_RESET, 0);
        aml_clr_reg32_mask(P_WATCHDOG_TC,(1 << WATCHDOG_ENABLE_BIT));
 }
 static inline void enable_watchdog(unsigned int timeout)
 {
-       printk(KERN_INFO "** enable watchdog\n");
+       pr_emerg("** enable watchdog\n");
        aml_write_reg32(P_WATCHDOG_RESET, 0);
        aml_write_reg32(P_WATCHDOG_TC, 1 << WATCHDOG_ENABLE_BIT |(timeout|WATCHDOG_COUNT_MASK));
 }
 static inline void reset_watchdog(void)
 {
-       printk(KERN_DEBUG"** reset watchdog\n");
+       pr_info("** reset watchdog\n");
        aml_write_reg32(P_WATCHDOG_RESET, 0);
 }
 #ifdef CONFIG_AML_WDT

You should be able to see /dev/watchdog and /dev/watchdog0 device files being created.

odroid@odroid:~$ ls -la /dev/watchdog*
crw------- 1 root root  10, 130 Oct 30 17:28 /dev/watchdog
crw------- 1 root root 250,   0 Oct 30 17:28 /dev/watchdog0
odroid@odroid:~$

Watchdog daemon will trigger and reboot if we access the device file manually.

# cat /dev/watchdog
[ 7639.726211] watchdog watchdog0: watchdog did not stop!

To manually stop watchdog to reboot.

# echo V > /dev/watchdog

Install Watchdog daemon

To install watchdog daemon

sudo apt-get install watchdog

Create dir for watchdog logs files

sudo mkdir -p /var/log/watchdog

Watchdog demon configuration files

You need to edit the /etc/watchdog.conf file to un-comment and so actually use the /dev/watchdog device access to the module. Otherwise the watchdog will not use the hardware and rely only on its internal code to soft-reboot a broken machine.

$ cat /etc/watchdog.conf
#ping                   = 172.31.14.1
#ping                   = 172.26.1.255
#interface              = eth0
#file                   = /var/log/messages
#change                 = 1407

# Uncomment to enable test. Setting one of these values to '0' disables it.
# These values will hopefully never reboot your machine during normal use
# (if your machine is really hung, the loadavg will go much higher than 25)
#max-load-1             = 24
#max-load-5             = 18
#max-load-15            = 12

# Note that this is the number of pages!
# To get the real size, check how large the pagesize is on your machine.
#min-memory             = 1

#repair-binary          = /usr/sbin/repair
#repair-timeout         =
#test-binary            =
#test-timeout           =

watchdog-device = /dev/watchdog

# Defaults compiled into the binary
#temperature-device     =
#max-temperature        = 120

# Defaults compiled into the binary
admin                   = root
interval                = 1
logtick                = 1
log-dir         = /var/log/watchdog

# This greatly decreases the chance that watchdog won't be scheduled before
# your machine is really loaded
realtime                = yes
priority                = 1

# Check if rsyslogd is still running by enabling the following line
pidfile         = /var/run/rsyslogd.pid

# set watchdog timer
watchdog-timeout        = 15

For more configuration please follow link below. http://www.sat.dundee.ac.uk/psc/watchdog/watchdog-configure.html

Start Watchdog Service and Verify

root@odroid:~# service watchdog status
 * watchdog is running
root@odroid:~#

Once the watchdog demon is configures then it tries to continuously try to reset the watchdog timer.

Another way to test watchdog device is working under watchdog demon.

root@odroid:~#
root@odroid:~# pkill -9 watchdog
root@odroid:~# [ 2452.972630@0] watchdog watchdog0: watchdog did not stop!
    QA5:A;SVN:B72;POC:17F;STS:0;BOOT:0;INIT:10;BOOT:1;INIT:0;READ:0;CHECK:0;PASS:1;

    ----------------------------------------------------------------------
    Welcome to Hardkernel's ODROID-C... (Built at 19:33:00 Dec 8 2014) *
    ----------------------------------------------------------------------
    CPU : AMLogic S805
    MEM : 1024MB (DDR3@792MHz)
    BID : HKC1310001
    S/N : HKC11122F37DF492
    0x0000009f
    check SD_boot_type:0x1 card_type:0x1
    Loading U-boot...success.
en/c1_watchdog_timer.1446524195.txt.gz · Last modified: 2015/11/03 12:46 by moon.linux
CC Attribution-Share Alike 3.0 Unported
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0