Browse Source

Prevent SD access from resetting ESP32 (#16690)

pull/1/head
felixstorm 5 years ago
committed by Scott Lahteine
parent
commit
e4eaf32b4d
  1. 10
      Marlin/src/sd/SdVolume.cpp

10
Marlin/src/sd/SdVolume.cpp

@ -291,6 +291,16 @@ int32_t SdVolume::freeClusterCount() {
for (uint16_t i = 0; i < n; i++) for (uint16_t i = 0; i < n; i++)
if (cacheBuffer_.fat32[i] == 0) free++; if (cacheBuffer_.fat32[i] == 0) free++;
} }
#ifdef ESP32
// Needed to reset the idle task watchdog timer on ESP32 as reading the complete FAT may easily
// block for 10+ seconds. yield() is insufficient since it blocks lower prio tasks (e.g., idle).
static millis_t nextTaskTime = 0;
const millis_t ms = millis();
if (ELAPSED(ms, nextTaskTime) {
vTaskDelay(1); // delay 1 tick (Minimum. Usually 10 or 1 ms depending on skdconfig.h)
nextTaskTime = ms + 1000; // tickle the task manager again in 1 second
}
#endif // ESP32
} }
return free; return free;
} }

Loading…
Cancel
Save