Enabled watchdog for ESP32 and variants (#21422)

* Enabled watchdog for ESP32 and variants

* Ensure compilation for sageboot

* Fix compilation

* Fix compilation for RISCV
This commit is contained in:
s-hadinger 2024-05-16 21:19:34 +02:00 committed by GitHub
parent 6ba59385d4
commit b9bd558abe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 26 additions and 7 deletions

View File

@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
## [14.0.0.1]
### Added
- Enabled watchdog for ESP32 and variants
### Breaking Changed

View File

@ -70,3 +70,10 @@
#define SPI_MOSI_DLEN_REG(x) SPI_MS_DLEN_REG(x)
#endif // TARGET
// This trick makes sure that 'lto' optimizer does not inline `delay()
// so we can override it with `-Wl,--wrap=delay` linker directive
#ifdef __cplusplus
extern "C"
#endif // _cplusplus
void delay(__UINT32_TYPE__ ms) __attribute__((noinline)) __attribute__ ((noclone));

View File

@ -392,7 +392,7 @@ size_t TasUpdateClass::writeStream(Stream &data) {
return written;
written += toRead;
delay(1); // Fix solo WDT
yield(); // Ensure WDT does not trigger
}
return written;
}

View File

@ -187,6 +187,8 @@
#define USE_WEBCLIENT
#define USE_WEBCLIENT_HTTPS
#undef USE_ESP32_WDT // disable watchdog on SAFEBOOT until more testing is done
#if CONFIG_IDF_TARGET_ESP32
#if CONFIG_FREERTOS_UNICORE
#undef USE_MQTT_TLS

View File

@ -1105,7 +1105,7 @@
#ifdef ESP32
// #define USE_ESP32_WDT // Enable Watchdog for ESP32, trigger a restart if loop has not responded for 5s, and if `yield();` was not called
#define USE_ESP32_WDT // Enable Watchdog for ESP32, trigger a restart if loop has not responded for 5s, and if `yield();` was not called
#define SET_ESP32_STACK_SIZE (8 * 1024) // Set the stack size for Tasmota. The default value is 8192 for Arduino, some builds might need to increase it

View File

@ -26,23 +26,27 @@ extern struct rst_info resetInfo;
\*********************************************************************************************/
#ifdef ESP32
// Watchdog - yield() resets the watchdog
#ifdef USE_ESP32_WDT
extern "C" void __yield(void); // original function from Arduino Core
extern "C"
void yield(void) {
vPortYield(); // was originally in `__yield`
__yield();
feedLoopWDT();
}
// patching delay(uint32_t ms)
extern "C" void __real_delay(uint32_t ms);
extern "C" void __real_delay(uint32_t ms); // original function from Arduino Core
extern "C" void __wrap_delay(uint32_t ms) {
#ifdef USE_ESP32_WDT
if (ms) { feedLoopWDT(); }
__real_delay(ms);
feedLoopWDT();
#else
__real_delay(ms);
#endif
}
#endif // USE_ESP32_WDT
#endif // ESP32
/*********************************************************************************************\

View File

@ -37,10 +37,15 @@ void CmndWDT(void)
}
// This will trigger the os watch after OSWATCH_RESET_TIME (=120) seconds
// or normal WDT on ESP32
void CmndBlockedLoop(void)
{
while (1) {
#ifdef ESP32
delay(10000); // 10s on ESP32 so that the normal WDT fires after 5s. There is no OSWATCH_RESET_TIME on ESP32
#else
delay(1000);
#endif
}
}

View File

@ -68,6 +68,7 @@ void lv_flush_callback(lv_display_t *disp, const lv_area_t *area, uint8_t *color
if (lvgl_glue->screenshot != nullptr) {
// save pixels to file
int32_t btw = (width * height * LV_COLOR_DEPTH + 7) / 8;
yield(); // ensure WDT does not fire
while (btw > 0) {
if (btw > 0) { // if we had a previous error (ex disk full) don't try to write anymore
int32_t ret = lvgl_glue->screenshot->write((const uint8_t*) color_p, btw);