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.pdfSomeone (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=104I compiled that utility--here's the source and executable:
http://plugnacious.org/sheevaplug/devmem2It 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.
#!/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