mirror of
https://github.com/arendst/Tasmota.git
synced 2026-07-27 20:05:46 +00:00
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