mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
Prepare for ESP32 WDT (#21383)
* Prepare for ESP32 WDT * make `sleep()` reset WDT
This commit is contained in:
parent
15a5ef30c4
commit
2865630309
@ -36,6 +36,7 @@ build_flags = ${esp_defaults.build_flags}
|
||||
-Wl,--wrap=panicHandler -Wl,--wrap=xt_unhandled_exception
|
||||
-Wl,--wrap=_Z11analogWritehi ; `analogWrite(unsigned char, int)` use the Tasmota version of analogWrite for deeper integration and phase control
|
||||
-Wl,--wrap=ledcReadFreq ; `uint32_t ledcReadFreq(uint8_t chan)`
|
||||
-Wl,--wrap=delay ; void delay(uint32_t ms)
|
||||
lib_ignore =
|
||||
HTTPUpdateServer
|
||||
USB
|
||||
|
@ -1122,6 +1122,8 @@ https://rya.nc/tasmota-fingerprint.html"
|
||||
|
||||
#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 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
|
||||
|
||||
#ifdef SOC_TOUCH_VERSION_1 // ESP32
|
||||
|
@ -411,6 +411,10 @@ void setup(void) {
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
#endif // ESP32
|
||||
|
||||
#ifdef USE_ESP32_WDT
|
||||
enableLoopWDT(); // enabled WDT Watchdog on Arduino `loop()` - must return before 5s or called `feedLoopWDT();` - included in `yield()`
|
||||
#endif // USE_ESP32_WDT
|
||||
|
||||
RtcPreInit();
|
||||
SettingsInit();
|
||||
|
||||
|
@ -21,6 +21,30 @@ extern "C" {
|
||||
extern struct rst_info resetInfo;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* ESP32 Watchdog
|
||||
\*********************************************************************************************/
|
||||
#ifdef ESP32
|
||||
// Watchdog - yield() resets the watchdog
|
||||
#ifdef USE_ESP32_WDT
|
||||
|
||||
extern "C"
|
||||
void yield(void) {
|
||||
vPortYield(); // was originally in `__yield`
|
||||
feedLoopWDT();
|
||||
}
|
||||
|
||||
// patching delay(uint32_t ms)
|
||||
extern "C" void __real_delay(uint32_t ms);
|
||||
|
||||
extern "C" void __wrap_delay(uint32_t ms) {
|
||||
__real_delay(ms);
|
||||
feedLoopWDT();
|
||||
}
|
||||
|
||||
#endif // USE_ESP32_WDT
|
||||
#endif // ESP32
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Watchdog extension (https://github.com/esp8266/Arduino/issues/1532)
|
||||
\*********************************************************************************************/
|
||||
|
@ -110,6 +110,7 @@ void BrTimeoutStart(void) {
|
||||
if (0 == berry.timeout) {
|
||||
berry.timeout = 1; // rare case when value accidentally computes to zero
|
||||
}
|
||||
yield();
|
||||
}
|
||||
|
||||
void BrTimeoutYield(void) {
|
||||
|
@ -404,7 +404,8 @@ extern "C" {
|
||||
// ESP object
|
||||
int32_t l_yield(bvm *vm);
|
||||
int32_t l_yield(bvm *vm) {
|
||||
return be_call_c_func(vm, (void*) &BrTimeoutYield, NULL, "-");
|
||||
BrTimeoutYield();
|
||||
be_return_nil(vm);
|
||||
}
|
||||
|
||||
// Berry: tasmota.scale_uint(int * 5) -> int
|
||||
|
Loading…
x
Reference in New Issue
Block a user