From 5f002dc4673f5233aa0166244617d7efdf8cc12a Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Mon, 3 Jan 2022 18:52:30 +0100 Subject: [PATCH] Set ESP32 stack size with ``#define SET_ESP32_STACK_SIZE``, added ``StackLowMark`` metrics --- CHANGELOG.md | 1 + tasmota/i18n.h | 1 + tasmota/my_user_config.h | 2 ++ tasmota/support_command.ino | 4 ++-- tasmota/support_esp.ino | 6 ++++++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 960b7f5f7..73cdab574 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. ### Changed - PubSubClient library from v2.8.12 to v2.8.13 - From Semantic Versioning (SemVer) to Calendar Versioning (CalVer) +- Set ESP32 stack size with ``#define SET_ESP32_STACK_SIZE``, added ``StackLowMark`` metrics ### Fixed - Intermittent exceptions and heap corruption due to PubSubClient library buffer overflow (#13700) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index 508cd0c29..0af945eb0 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -143,6 +143,7 @@ #define D_JSON_PROBETEMPERATURE "ProbeTemperature" #define D_JSON_PROGRAMFLASHSIZE "ProgramFlashSize" #define D_JSON_PROGRAMSIZE "ProgramSize" +#define D_JSON_STACKLOWMARK "StackLowMark" #define D_JSON_PSRMAXMEMORY "PsrMax" #define D_JSON_PSRFREEMEMORY "PsrFree" #define D_JSON_PUMP "Pumped" diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index c5f6d3c04..1cf048513 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -974,6 +974,8 @@ #ifdef ESP32 +#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 + //#define USE_SONOFF_SPM // Add support for ESP32 based Sonoff Smart Stackable Power Meter(+6k3 code) #ifdef USE_SONOFF_SPM #define USE_ETHERNET diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index f3261c095..d7bd08e30 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -545,7 +545,7 @@ void CmndStatus(void) if ((0 == payload) || (4 == payload)) { Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS4_MEMORY "\":{\"" D_JSON_PROGRAMSIZE "\":%d,\"" D_JSON_FREEMEMORY "\":%d,\"" D_JSON_HEAPSIZE "\":%d,\"" #ifdef ESP32 - D_JSON_PSRMAXMEMORY "\":%d,\"" D_JSON_PSRFREEMEMORY "\":%d,\"" + D_JSON_STACKLOWMARK "\":%d,\"" D_JSON_PSRMAXMEMORY "\":%d,\"" D_JSON_PSRFREEMEMORY "\":%d,\"" #endif // ESP32 D_JSON_PROGRAMFLASHSIZE "\":%d,\"" D_JSON_FLASHSIZE "\":%d" #ifdef ESP8266 @@ -554,7 +554,7 @@ void CmndStatus(void) ",\"FlashFrequency\":%d,\"" D_JSON_FLASHMODE "\":%d"), ESP_getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP_getFreeHeap1024(), #ifdef ESP32 - ESP.getPsramSize()/1024, ESP.getFreePsram()/1024, + uxTaskGetStackHighWaterMark(nullptr) / 1024, ESP.getPsramSize()/1024, ESP.getFreePsram()/1024, #endif // ESP32 ESP.getFlashChipSize()/1024, ESP.getFlashChipRealSize()/1024 #ifdef ESP8266 diff --git a/tasmota/support_esp.ino b/tasmota/support_esp.ino index 27a00e108..e3a3ba943 100644 --- a/tasmota/support_esp.ino +++ b/tasmota/support_esp.ino @@ -135,6 +135,12 @@ String GetDeviceHardware(void) { #include "rom/rtc.h" #endif +// Set the Stacksize for Arduino core. Default is 8192, some builds may need a bigger one +size_t getArduinoLoopTaskStackSize(void) { + return SET_ESP32_STACK_SIZE; +} + + #include bool NvmLoad(const char *sNvsName, const char *sName, void *pSettings, unsigned nSettingsLen) {