Skip to content

Commit 4619379

Browse files
authored
🐛 Prevent watchdog for slow ESP3D commands (#28739)
1 parent 8a1f01c commit 4619379

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎Marlin/src/HAL/ESP32/HAL.cpp‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <esp_adc_cal.h>
2929
#include <HardwareSerial.h>
3030

31-
#if ENABLED(USE_ESP32_TASK_WDT)
31+
#if ANY(USE_ESP32_TASK_WDT, USE_WATCHDOG)
3232
#include <esp_task_wdt.h>
3333
#endif
3434

@@ -93,7 +93,12 @@ struct {
9393

9494
bool wifi_custom_command(char * const command_ptr) {
9595
#if ENABLED(ESP3D_WIFISUPPORT)
96-
return esp3dlib.parse(command_ptr);
96+
// ESP3D commands such as a WiFi scan or a file system format can take longer
97+
// than the watchdog timeout, and can't refresh the watchdog themselves.
98+
TERN_(USE_WATCHDOG, esp_task_wdt_delete(nullptr));
99+
const bool handled = esp3dlib.parse(command_ptr);
100+
TERN_(USE_WATCHDOG, esp_task_wdt_add(nullptr));
101+
return handled;
97102
#else
98103
UNUSED(command_ptr);
99104
return false;
@@ -184,8 +189,6 @@ int MarlinHAL::freeMemory() { return ESP.getFreeHeap(); }
184189

185190
#if ENABLED(USE_WATCHDOG)
186191

187-
#include <esp_task_wdt.h>
188-
189192
#define WDT_TIMEOUT_S TERN(WATCHDOG_DURATION_8S, 8, 4) // 4 or 8 second timeout
190193

191194
void watchdogSetup() {

0 commit comments

Comments
 (0)