Browse Source

change: 如果启用了wdt,报错重启前每秒喂一次狗,不然idf5总是报没喂狗

Wendal Chen 3 years ago
parent
commit
cfb7819452
1 changed files with 13 additions and 0 deletions
  1. 13 0
      luat/modules/luat_main.c

+ 13 - 0
luat/modules/luat_main.c

@@ -21,6 +21,10 @@
 #include "luat_profiler.h"
 #endif
 
+#ifdef LUAT_USE_WDT
+#include "luat_wdt.h"
+#endif
+
 static int report (lua_State *L, int status);
 
 lua_State *L;
@@ -214,7 +218,16 @@ int luat_main (void) {
 #endif
   luat_main_call();
   LLOGE("Lua VM exit!! reboot in %dms", LUAT_EXIT_REBOOT_DELAY);
+#ifdef LUAT_USE_WDT
+  for (size_t i = 1; i < LUAT_EXIT_REBOOT_DELAY / 1000; i++)
+  {
+    luat_wdt_feed();
+    luat_timer_mdelay(1000);
+  }
+  luat_ota_reboot(1000);
+#else
   luat_ota_reboot(LUAT_EXIT_REBOOT_DELAY);
+#endif
   // 往下是肯定不会被执行的
   return 0;
 }