瀏覽代碼

Reset watchdog in SD init to prevent reboot

If the watchdog is enabled and bootscreen + SD card checks take too long, Marlin may hang at boot time because of the reset loop. We have this happen all the time with the Anet board if no SD card is inserted.
Hans Raaf 7 年之前
父節點
當前提交
d29cc8f7bc
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10
    0
      Marlin/Sd2Card.cpp

+ 10
- 0
Marlin/Sd2Card.cpp 查看文件

@@ -31,6 +31,10 @@
31 31
 #if ENABLED(SDSUPPORT)
32 32
 #include "Sd2Card.h"
33 33
 
34
+#if ENABLED(USE_WATCHDOG)
35
+  #include "watchdog.h"
36
+#endif
37
+
34 38
 //------------------------------------------------------------------------------
35 39
 #if DISABLED(SOFTWARE_SPI)
36 40
   // functions for hardware SPI
@@ -299,6 +303,12 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
299 303
   uint16_t t0 = (uint16_t)millis();
300 304
   uint32_t arg;
301 305
 
306
+  // If init takes more than 4s it could trigger
307
+  // watchdog leading to a reboot loop.
308
+  #if ENABLED(USE_WATCHDOG)
309
+    watchdog_reset();
310
+  #endif
311
+
302 312
   // set pin modes
303 313
   pinMode(chipSelectPin_, OUTPUT);
304 314
   chipSelectHigh();

Loading…
取消
儲存