Files
Tasmota/platformio_override_sample.ini
joluxer ba88358ed6 ESP8266: fix heap metric functions and add OOM diagnostics (#24777)
* ESP8266: fix ESP_getMaxAllocHeap() and ESP_getHeapFragmentation()

Both functions returned wrong values: ESP_getMaxAllocHeap() returned
ESP.getFreeHeap() (total free, not largest contiguous block);
ESP_getHeapFragmentation() read ummHeapInfo.maxFreeContiguousBlocks,
which is only valid immediately after a umm_info() heap walk.

Fix: cache the result of umm_max_block_size() in ESP_UpdateHeapMetrics().
The cache is refreshed once per second when SetOption130 is active, and
on demand in CmndStatus() before Status 4 is output. Both getter functions
read the cached value; the call site overhead is a single integer read.

umm_max_block_size() is unconditionally available (UMM_INFO is hardcoded
in the Arduino ESP8266 umm_malloc_cfg.h), so no build flags are required.

Status 4 (StatusMEM) gains two ESP8266-specific fields: MaxFreeBlock (KB)
and Frag (%).

* ESP8266: add heap OOM diagnostics, Status 4 fields, Status 44 dump

OOM event monitoring (requires UMM_INLINE_METRICS or UMM_STATS_FULL):
- ESP_HeapOomCheck(): called once per second; logs the OOM counter delta
  when the counter changes ("OOM: count N (+M)")
- ESP_HeapOomTest(): logs current OOM count on demand

Status 4 (StatusMEM) gains additional ESP8266-specific fields when the
corresponding build flags are active:
- OomCount: cumulative out-of-memory events (UMM_INLINE_METRICS or
  UMM_STATS_FULL)
- HeapLwm (KB): heap low-watermark since boot (UMM_STATS_FULL)
- MaxAllocSz (bytes): peak single allocation size (UMM_STATS_FULL)

Status 44 (ESP8266-only diagnostic command):
- Triggers umm_info(nullptr, true) to print a full heap block map to
  the serial console
- Calls ESP_HeapOomTest() to log the current OOM count
- Returns {"Status44":{"HeapDump":"serial"}}
- Status 44 is accepted regardless of MAX_STATUS

Build flags UMM_STATS_FULL and UMM_INLINE_METRICS can be enabled via
platformio_override.ini build_flags; documented in
platformio_override_sample.ini.
2026-05-25 17:25:04 +02:00

135 lines
6.0 KiB
INI

; *** Example PlatformIO Project Configuration Override File ***
; *** Changes done here override settings in platformio.ini ***
;
; *****************************************************************
; *** to activate rename this file to platformio_override.ini ***
; *****************************************************************
;
; Please visit documentation for the options and examples
; http://docs.platformio.org/en/stable/projectconf.html
[platformio]
; Store Platformio platform and packages in project directory.
;core_dir = .platformio
; For unrelated compile errors with Windows it can help to shorten Platformio project path
;workspace_dir = c:\.pio
;extra_configs = platformio_tasmota_user_env.ini
; *** Build/upload environment
default_envs =
; *** Uncomment the line(s) below to select version(s)
tasmota
; tasmota-debug
; tasmota-minimal
; tasmota-lite
; tasmota-knx
; tasmota-sensors
; tasmota-display
; tasmota-zbbridge
; tasmota-ir
; tasmota32
; tasmota32solo1
; tasmota32s2
; tasmota32s2cdc
; tasmota32s3
; tasmota32c2
; tasmota32c3
; tasmota32c6
; tasmota32-zbbrdgpro
; tasmota32-bluetooth
; tasmota32-webcam
; tasmota32-knx
; tasmota32-lvgl
; tasmota32-ir
; tasmota32-nspanel
; tasmota32c3ser
; tasmota32c6ser
; tasmota32s3ser
[tasmota]
; *** Global build / unbuild compile time flags for ALL Tasmota / Tasmota32 [env]
;build_unflags =
;build_flags =
[env]
;build_unflags = ${common.build_unflags}
; -Wswitch-unreachable
;build_flags = ${common.build_flags}
; -DF_CRYSTAL=26000000
; -Wno-switch-unreachable
; *** Optional Debug messages
; -DDEBUG_TASMOTA_CORE
; -DDEBUG_TASMOTA_DRIVER
; -DDEBUG_TASMOTA_SENSOR
; *** ESP8266 heap debugging, activate as group
; -DUMM_STATS_FULL
; -DUMM_INLINE_METRICS
; Build variant 1MB = 1MB firmware no filesystem (default)
;board = ${common.board}
; Build variant 2MB = 1MB firmware, 1MB filesystem (most Shelly devices)
;board = esp8266_2M1M
; Build variant 4MB = 1MB firmware, 1MB OTA, 2MB filesystem (WEMOS D1 Mini, NodeMCU, Sonoff POW)
;board = esp8266_4M2M
;board_build.f_cpu = 160000000L
;board_build.f_flash = 40000000L
; *** Define serial port used for erasing/flashing/terminal
;upload_port = COM4
;monitor_port = COM4
lib_extra_dirs = ${library.lib_extra_dirs}
[env:tasmota32_base]
; Override settings for esp32, esp32s2, esp32s3, esp32c2 and esp32c3
; *** Uncomment next line ";" to enable development Tasmota Arduino IDF 53 based platform.
;platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF55_gcc152
;platform_packages = framework-arduinoespressif32 @
;build_unflags = ${esp32_defaults.build_unflags}
;build_flags = ${esp32_defaults.build_flags}
;board = esp32
;board_build.f_cpu = 240000000L
;board_build.f_flash = 40000000L
;board_build.flash_mode = qio
;board_build.flash_size = 8MB
;board_upload.maximum_size = 8388608
;board_upload.arduino.flash_extra_images =
;board_build.partitions = partitions/esp32_partition_app2944k_fs2M.csv
; *** Serial port used for erasing/flashing the ESP32
;upload_port = COM4
;monitor_port = COM4
;upload_speed = 115200
monitor_speed = 115200
;upload_resetmethod = ${common.upload_resetmethod}
lib_extra_dirs = ${library.lib_extra_dirs}
; *** ESP32 lib. ALWAYS needed for ESP32 !!!
lib/libesp32
; *** comment the following line if you dont use LVGL in a Tasmota32 build. Reduces compile time
lib/libesp32_lvgl
; *** uncomment the following line if you use Bluetooth or Apple Homekit in a Tasmota32 build. Reduces compile time
lib/libesp32_div
; *** uncomment the following line if you use Epaper driver epidy in your Tasmota32 build. Reduces compile time
; lib/libesp32_eink
[library]
shared_libdeps_dir = lib
; *** Library disable / enable for variant Tasmota(32). Disable reduces compile time
; *** !!! Disabling needed libs will generate compile errors !!!
; *** The resulting firmware will NOT be different if you leave all libs enabled
; *** Disabling by putting a ";" in front of the lib name
; *** If you dont know what it is all about, do not change
lib_extra_dirs =
; *** Only disabled for Tasmota minimal and Tasmota light. For all other variants needed!
lib/lib_basic
; **** I2C devices. Most sensors. Disable only if you dont have ANY I2C device enabled
lib/lib_i2c
; *** Displays. Disable if you dont have any Display activated
lib/lib_display
; *** Bear SSL and base64. Disable if you dont have SSL or TLS activated
lib/lib_ssl
; *** Audio needs a lot of time to compile. Mostly not used functions. Recommended to disable
lib/lib_audio
; *** RF 433 stuff (not RF Bridge). Recommended to disable
lib/lib_rf
; *** Mostly not used functions. Recommended to disable
lib/lib_div