mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-27 13:56:24 +00:00
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.
This commit is contained in:
parent
7743849608
commit
d29cc8f7bc
@ -31,6 +31,10 @@
|
||||
#if ENABLED(SDSUPPORT)
|
||||
#include "Sd2Card.h"
|
||||
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
#include "watchdog.h"
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
#if DISABLED(SOFTWARE_SPI)
|
||||
// functions for hardware SPI
|
||||
@ -299,6 +303,12 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
|
||||
uint16_t t0 = (uint16_t)millis();
|
||||
uint32_t arg;
|
||||
|
||||
// If init takes more than 4s it could trigger
|
||||
// watchdog leading to a reboot loop.
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
watchdog_reset();
|
||||
#endif
|
||||
|
||||
// set pin modes
|
||||
pinMode(chipSelectPin_, OUTPUT);
|
||||
chipSelectHigh();
|
||||
|
Loading…
Reference in New Issue
Block a user