|
|
@@ -1126,6 +1126,83 @@ static void mem_check(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//https://blog.csdn.net/weixin_47604497/article/details/136913868
|
|
|
+#include <linux/watchdog.h>
|
|
|
+static int wdog_fd=-1;
|
|
|
+static int wdog_is_en(void)
|
|
|
+{
|
|
|
+ GlobalDeviceManager *dm=&__globalDeviceManage;
|
|
|
+ MiscInfo_t *misc=&dm->_globalDevInfo.misc;
|
|
|
+
|
|
|
+ return misc->watchdog;
|
|
|
+}
|
|
|
+static int wdog_init(void)
|
|
|
+{
|
|
|
+ int r=0;
|
|
|
+
|
|
|
+ //if(wdog_is_en() == 0) {
|
|
|
+ char *path="/dev/watchdog";
|
|
|
+
|
|
|
+ if(wdog_fd<0) {
|
|
|
+ wdog_fd = open(path, O_RDWR); //O_WRONLY
|
|
|
+ log_d("wdog_fd = %d\n",wdog_fd);
|
|
|
+ if(wdog_fd<0) {
|
|
|
+ printf("___ %s open failed\n", path);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+#if (CHIP_TYPE == CHIP_T113s)
|
|
|
+ int i,option,timeout;
|
|
|
+ struct watchdog_info info;
|
|
|
+
|
|
|
+ option = WDIOS_DISABLECARD;
|
|
|
+ r = ioctl(wdog_fd, WDIOC_SETOPTIONS, &option);
|
|
|
+
|
|
|
+ r = ioctl(wdog_fd, WDIOC_GETSUPPORT, &info);
|
|
|
+ if(r<0) {
|
|
|
+ printf("___ %s getsupport failed\n", path);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ printf("___ watchdog options: 0x%x\n", info.options&WDIOC_SETTIMEOUT);
|
|
|
+
|
|
|
+ timeout = 40;
|
|
|
+ r = ioctl(wdog_fd, WDIOC_SETTIMEOUT, &timeout);
|
|
|
+ if(r) {
|
|
|
+ printf("______set__________ wdog set timeout: %d failed, errno: %d\n", timeout, errno);
|
|
|
+ }
|
|
|
+
|
|
|
+ option = WDIOS_ENABLECARD;
|
|
|
+ r = ioctl(wdog_fd, WDIOC_SETOPTIONS, &option);
|
|
|
+#endif
|
|
|
+// }
|
|
|
+
|
|
|
+ return r;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+static int wdog_feed(void)
|
|
|
+{
|
|
|
+ int r=0;
|
|
|
+
|
|
|
+ //if(wdog_is_en()) {
|
|
|
+ r = ioctl(wdog_fd, WDIOC_KEEPALIVE, 0);
|
|
|
+
|
|
|
+ //int t1=200,t2=0;
|
|
|
+ //r = ioctl(wdog_fd, WDIOC_SETTIMEOUT, &t1);
|
|
|
+ //printf("______set__________ wdog timeout: %d, errno: %d\n", r, errno);
|
|
|
+
|
|
|
+ //r = ioctl(wdog_fd, WDIOC_GETTIMEOUT, &t2);
|
|
|
+ //printf("________________ wdog timeout: %d\n", t2);
|
|
|
+ //}
|
|
|
+
|
|
|
+ return r;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
static void* polling_thread(void *arg)
|
|
|
@@ -1134,6 +1211,7 @@ static void* polling_thread(void *arg)
|
|
|
|
|
|
while(h->quit==0) {
|
|
|
mem_check();
|
|
|
+ wdog_feed();
|
|
|
sleep(1);
|
|
|
}
|
|
|
pthread_exit(NULL);
|
|
|
@@ -1143,6 +1221,7 @@ static void* polling_thread(void *arg)
|
|
|
int sys_init(void)
|
|
|
{
|
|
|
//userShellInit();
|
|
|
+ wdog_init();
|
|
|
initLogger();
|
|
|
lock_s_init();
|
|
|
|