在drivers/watchdog/s3c2410_wdt.c中进行修改:
- #define CONFIG_S3C2410_WATCHDOG_ATBOOT (1)
- #define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME (15)
注:
- #define CONFIG_S3C2410_WATCHDOG_ATBOOT (0)//系统启动时不开启看门狗
- #define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME (15)//复位时间
设置成系统启动就启动看门狗,并且看门狗到期时间为15s。这样系统复位后每15s系统就会复位一次,所以我们在用户空间进行喂狗,驱动中的那个中断函数是当看门狗作为定时器时用的,所以没有实现喂狗,所以只能在用户程序中喂狗,下面是源码:
- #include <stdio.h>
- #include <unistd.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <errno.h>
- #include <linux/watchdog.h>
- int main(int argc, char **argv){
- int fd;
- fd = open("/dev/watchdog",O_RDONLY);
- if(fd < 0){
- perror("/dev/watchdog");
- return -1;
- }
- for(;;){
- ioctl(fd, WDIOC_KEEPALIVE);
- sleep(3);
- }
- close(fd);
- return 0;
- }
