Browse Source

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 years ago
parent
commit
d29cc8f7bc
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      Marlin/Sd2Card.cpp

+ 10
- 0
Marlin/Sd2Card.cpp View File

@@ -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…
Cancel
Save