Hardware Watchdog
From OpenTom
Excerpt from the 2.4.x sourcecode how to use the watchdog:
Create the proper device 'mknod /dev/watchdog c 246 0' Set watchdog timeout with ioctl on /dev/watchdog (IOW_WD_SET_TIME, in seconds) Kick the watchdog within the set time using IOW_WD_KICK (NULL argument)
Source is in the kernel 2.4 trunk ..../drivers/Barcelona/Watchdog/
Note that in the 2.6.x kernel there is no port of the Barcelona Watchdog driver, since it already provides a generic s3c2410 watchdog driver. Of course the userspace is not compatible, since the TTGO driver authors apparently didn't know the generic watchdog api.
[edit]
Sample Code
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/watchdog.h>
#include <errno.h>
#include <string.h>
int main(int argc, char* argv[])
{
int fd;
if((fd = open("/dev/watchdog", O_RDWR | O_NOCTTY)) < 0) {
fprintf(stderr, "could not open watchdog: %s", strerror(errno));
return 1;
}
if(daemonize() < 0) {
fprintf(stderr, "could not daemonize: %s", strerror(errno));
return 1;
}
while(1) {
write(fd, "\0", 1);
sleep(15);
}
}

