• Home
  • Help
  • Search
  • Login
  • Register
Pages: [1]
Author Topic: Watchdog timer  (Read 4559 times)
jmknapp
Newbie
*

Karma: 0
Posts: 45



View Profile
« on: July 01, 2009, 04:05:52 AM »

Someone was telling me the Plug has a built-in hardware watchdog timer, but I've found no evidence of it.  Does anyone else know anything about this?

I did some poking around (ha ha) and found that there is indeed a watchdog timer on the processor chip, accessible via memory-mapped I/O.

According to the processor user manual, the following three registers are needed to implement a watchdog reset:

1) CPUWDTimer, offset 0x20324 [table 109, p. 258], which decrements every processor clock, max value 0xffffffff (32 bits), which is about 20 seconds
2) Timers Control register, offset 0x20300 [table 103, p. 256], where bit 4 (CPUWDTimerEn) controls whether the wd timer stops counting when it reaches 0
3) RSTOUTn Mask Register, offset 0x20108 [table 95, p. 252], where bit 1 (WDRstOutEn) enables a reset to occur when the wd timer decrements to zero

the user manual is here: http://www.embeddedarm.com/documentation/third-party/MV88F5182-usermanual.pdf

Someone (tmk) in this forum posted a utility (c code) to read and write memory locations from user space:

http://openplug.org/plugforum/index.php?topic=104

I compiled that utility--here's the source and executable: http://plugnacious.org/sheevaplug/devmem2

It works great to test out the wd timer. First off, the offsets above have to be applied to a base address, which tmk found to be 0xf1000000 at least in his case, & I found it's the case on my plug too. To cut to the chase:

This command shows the wd timer value:

# ./devmem2 0xf1020324 w
/dev/mem opened.
Memory mapped at address 0x40020000.
Value at address 0xF1020324 (0x40020324): 0x7FFFFFFF

So that defaults to 0x7fffffff and it's not counting down. Setting the timer enable bit will start the countdown:

# ./devmem2 0xf1020300 w 0x17

That sets the timer wd enable bit 0x10 (along with 0x7 set by default)

Now executing "./devmem2 0xf1020324 w" will show the timer counting down until it hits zero and stops (about 10 seconds). Luckily the wd reset isn't enabled yet. Starting from 0xffffffff affords about 20 seconds before the timer expires:

# ./devmem2 0xf1020324 w 0xffffffff

To cause a reset on timer expiration:

# ./devmem2 0xf1020108 w 0x2

Believe me, it will reset the sheevaplug when the timer expires, or immediately if the timer is already zero!

So anyway, a quick-and-dirty watchdog timer could be made from this code, say, resetting the timer every 5 seconds.

Code:
#!/bin/ksh
./devmem2 0xf1020324 w 0xffffffff > /dev/null 2>&1
./devmem2 0xf1020300 w 0x17 > /dev/null 2>&1
./devmem2 0xf1020108 w 0x2 > /dev/null 2>&1

while :
do
        ./devmem2 0xf1020324 w 0xffffffff > /dev/null 2>&1
        sleep 5
done

Obviously one could get a bit fancier and more robust than that!

Joe


Logged

cbxbiker61
Global Moderator
Sr. Member
*****

Karma: 38
Posts: 497


View Profile
« Reply #1 on: July 01, 2009, 04:18:15 PM »

I slammed together support for a real watchdog driver named kirkwood_wdt in my 2.6.30 distribution.  A patch is in /2.6.30/patches

http://plugcomputer.org/plugforum/index.php?topic=449.0

Logged

jmknapp
Newbie
*

Karma: 0
Posts: 45



View Profile
« Reply #2 on: July 01, 2009, 06:03:21 PM »

I slammed together support for a real watchdog driver named kirkwood_wdt in my 2.6.30 distribution.  A patch is in /2.6.30/patches

http://plugcomputer.org/plugforum/index.php?topic=449.0


Good slamming... I checked it out and it works fine.

Joe
Logged

restamp
Global Moderator
Sr. Member
*****

Karma: 4
Posts: 273


View Profile
« Reply #3 on: July 01, 2009, 07:02:18 PM »

I would concur that a kernel solution is ultimately the only way to go, but if anyone needs a user-level implementation in the interim, here is a link to the source I threw together for my Plug.  It has been running for 24 hours here without any problems:

http://cboh.org/SheevaPlug/hw-wdt.c
http://cboh.org/SheevaPlug/etc-init.d-hw-wdt.sh

Enjoy.
Logged

jmknapp
Newbie
*

Karma: 0
Posts: 45



View Profile
« Reply #4 on: July 02, 2009, 03:52:04 AM »

I would concur that a kernel solution is ultimately the only way to go, but if anyone needs a user-level implementation in the interim, here is a link to the source I threw together for my Plug. 

Works fine for me too & it has the simplicity of just dropping it in without a kernel upgrade. After all, the kernel method requires a user-level service routine anyway.

Joe
Logged

e-squizo
Newbie
*

Karma: 3
Posts: 22


View Profile
« Reply #5 on: March 11, 2010, 03:15:23 PM »

I slammed together support for a real watchdog driver named kirkwood_wdt in my 2.6.30 distribution.  A patch is in /2.6.30/patches

Did you ever submit this module to the mainline kernel? I'm surprised something so useful isn't there yet...
Logged

cbxbiker61
Global Moderator
Sr. Member
*****

Karma: 38
Posts: 497


View Profile
« Reply #6 on: March 11, 2010, 04:42:07 PM »

[Did you ever submit this module to the mainline kernel? I'm surprised something so useful isn't there yet...

The official watchdog module on sheeva is orion_wdt.  I can't remember when they slipped it in, but it's been there for quite a while.
Logged

e-squizo
Newbie
*

Karma: 3
Posts: 22


View Profile
« Reply #7 on: March 12, 2010, 06:59:08 PM »

The official watchdog module on sheeva is orion_wdt.

Awesome. Thanks.
Logged

Pages: [1]
Print
Jump to: