Files
Tasmota/pio-tools
the-way-of-A-WildandGitHub 86bc033c86 Neutralize lwIP SNTP client to prevent heap drain on WiFi reconnects (#24593)
The ESP8266 SDK automatically invokes sntp_init() via
netif_sta_status_callback on every WiFi reconnect. This results in repeated
allocations of UDP PCBs (udp_new()), leading to heap exhaustion and
potential lwIP timeout list corruption due to unmatched sntp_stop() calls.

Tasmota does not use the lwIP SNTP client and relies solely on WifiGetNtp()
for time synchronization. To avoid unnecessary resource usage, wrap and
neutralize sntp_init() and sntp_stop() with no-op implementations.

This prevents UDP PCB allocations and avoids issues caused by repeated
initialization during reconnect cycles.

Additionally, a PlatformIO post-build script has been added to validate
that the linker wraps are correctly applied. The script runs after ELF
generation and uses xtensa-lx106-elf-nm to inspect symbols, ensuring that
the __wrap_sntp_init and __wrap_sntp_stop functions are present in the
final firmware. If the wrappers are missing, the build fails.

Confirmed via firmware disassembly:
- Single call site in netif_sta_status_callback
- Requires linker wraps: --wrap=sntp_init,--wrap=sntp_stop

Fixes: #24566
2026-03-26 10:42:02 +01:00
..
2025-08-20 21:51:23 +02:00
2023-10-26 18:04:34 +02:00
2026-02-13 11:24:01 +01:00
2026-02-13 11:24:01 +01:00
2025-08-21 21:24:26 +02:00
2026-02-13 11:24:01 +01:00
2025-12-24 15:06:28 +01:00