mirror of
https://github.com/wled/WLED.git
synced 2025-04-25 15:27:19 +00:00
Enable ESP watchdog by default
Use the ESP watchdog to detect hanging ESP and reset the firmware. Can be disable by defining WLED_WATCHDOG_TIMOUT 0 Default timeout is 3 seconds on ESP32 and 8 seconds on ESP2688
This commit is contained in:
parent
099d2fd03d
commit
213e3e998a
@ -276,6 +276,15 @@ void WLED::loop()
|
|||||||
loops++;
|
loops++;
|
||||||
#endif // WLED_DEBUG
|
#endif // WLED_DEBUG
|
||||||
toki.resetTick();
|
toki.resetTick();
|
||||||
|
|
||||||
|
#if WLED_WATCHDOG_TIMEOUT > 0
|
||||||
|
// we finished our mainloop, reset the watchdog timer
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
esp_task_wdt_reset();
|
||||||
|
#else
|
||||||
|
ESP.wdtFeed();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void WLED::setup()
|
void WLED::setup()
|
||||||
@ -302,6 +311,22 @@ void WLED::setup()
|
|||||||
DEBUG_PRINT(F("heap "));
|
DEBUG_PRINT(F("heap "));
|
||||||
DEBUG_PRINTLN(ESP.getFreeHeap());
|
DEBUG_PRINTLN(ESP.getFreeHeap());
|
||||||
|
|
||||||
|
#if WLED_WATCHDOG_TIMEOUT > 0
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
esp_err_t watchdog = esp_task_wdt_init(WLED_WATCHDOG_TIMEOUT, true);
|
||||||
|
DEBUG_PRINT(F("Enable watchdog "));
|
||||||
|
if (watchdog == ESP_OK) {
|
||||||
|
DEBUG_PRINTLN(F(" OK"));
|
||||||
|
} else {
|
||||||
|
DEBUG_PRINTLN(watchdog);
|
||||||
|
}
|
||||||
|
esp_task_wdt_add(NULL);
|
||||||
|
#else
|
||||||
|
// any timeout possible ?
|
||||||
|
ESP.wdtEnable(WLED_WATCHDOG_TIMEOUT * 1000);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
|
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
|
||||||
if (psramFound()) {
|
if (psramFound()) {
|
||||||
// GPIO16/GPIO17 reserved for SPI RAM
|
// GPIO16/GPIO17 reserved for SPI RAM
|
||||||
|
@ -49,6 +49,12 @@
|
|||||||
// filesystem specific debugging
|
// filesystem specific debugging
|
||||||
//#define WLED_DEBUG_FS
|
//#define WLED_DEBUG_FS
|
||||||
|
|
||||||
|
#ifndef WLED_WATCHDOG_TIMEOUT
|
||||||
|
// 3 seconds should be enough to detect a lockup
|
||||||
|
// define WLED_WATCHDOG_TIMEOUT=0 to disable watchdog
|
||||||
|
#define WLED_WATCHDOG_TIMEOUT 3
|
||||||
|
#endif
|
||||||
|
|
||||||
//optionally disable brownout detector on ESP32.
|
//optionally disable brownout detector on ESP32.
|
||||||
//This is generally a terrible idea, but improves boot success on boards with a 3.3v regulator + cap setup that can't provide 400mA peaks
|
//This is generally a terrible idea, but improves boot success on boards with a 3.3v regulator + cap setup that can't provide 400mA peaks
|
||||||
//#define WLED_DISABLE_BROWNOUT_DET
|
//#define WLED_DISABLE_BROWNOUT_DET
|
||||||
@ -78,6 +84,7 @@
|
|||||||
#else
|
#else
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "esp_task_wdt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "src/dependencies/network/Network.h"
|
#include "src/dependencies/network/Network.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user