mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 15:10:51 +00:00
ed289390df50082374f23ff20daa735bd075cdda
WiFi already had enable_on_boot + enable()/disable()/is_disabled() lifecycle, but enable_on_boot:false didn't actually save any memory. wifi_pre_setup_() called esp_wifi_init() and esp_netif_create_default_wifi_sta() unconditionally during setup(), which allocates ~15-30KB of DMA-capable internal SRAM (RX/TX buffers, driver state, PHY init). The flag only skipped esp_wifi_start() in the followup branch — the driver was already resident, just not associated. This commit splits wifi_pre_setup_() into two parts: - wifi_pre_setup_() (light, kept in setup() always): MAC setup, event group creation, WIFI_EVENT/IP_EVENT handler registration. No DMA allocation. - wifi_lazy_init_() (heavy, NEW): esp_netif_create_default_wifi_sta()/_ap(), esp_wifi_init(), esp_wifi_set_storage(). The DMA-allocating calls. Guarded by wifi_initialized_ flag for idempotency. setup() calls wifi_lazy_init_() only when enable_on_boot_=true. The else branch sets WIFI_COMPONENT_STATE_DISABLED without any heavy init — the dormant interface costs zero DMA-capable memory. enable() calls wifi_lazy_init_() before start(), so a runtime enable after boot-time disable does the heavy init on demand. Idempotent — subsequent enable/disable cycles don't re-allocate. disable() is unchanged — it stops wifi but doesn't deinit. A future "release_on_disable" variant could call esp_wifi_deinit() to actually free the memory at runtime, but that requires coordinating with consumers holding wifi-bound sockets and is out of scope here. ESP-IDF only. Other platforms (Arduino on ESP32, ESP8266) keep the existing behavior — their wifi_pre_setup_() lives in different per-platform files. Field-tested on ESP32-S3 with W5500 SPI ethernet + audio + bluetooth_proxy. Before Unit B+: ~14KB free internal during peak load, crash on W5500 SPI DMA buffer allocation. After Unit B+: ~32KB free internal, Min Free 78KB in some test configurations — sufficient headroom for the other DMA consumers (I2S audio, BT controller) to operate.
[esp32] Decouple esp-idf toolchain version check from PIO, honor framework source: override (#16516)
Description
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Readme
Multiple Licenses
393 MiB
Languages
C++
60.7%
Python
38.9%
C
0.3%
