Register the 2 UDP PCBs that lwIP allocates internally for DHCP and DNS
as a wifi.lwip_internal socket consumer, eliminating the magic +2 in
libretiny's MEMP_NUM_UDP_PCB calculation. Also corrects SDK default
values in the comparison table after line-by-line verification against
all three SDK source files.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The original table treated BK/RTL/LN SDK defaults as identical, but
they differ significantly:
- BK72XX: MEM_SIZE=32KB, TCP_SND_BUF=10×MSS — wildly oversized
- RTL87XX: MEM_SIZE=5KB, TCP_SND_BUF=5×MSS — already conservative
- LN882H: MEM_LIBC_MALLOC=1, TCP_SND_BUF=7×MSS — uses system heap
Setting MEM_SIZE=16KB on RTL87XX was an 11KB *increase* from its 5KB
SDK default, causing BD_RAM overflow on the mqtt test.
Fix: only set MEM_SIZE on BK72XX (where the 32KB→12KB reduction is
needed). RTL87XX keeps its SDK 5KB default, LN882H doesn't use it.
The comparison table is updated with accurate per-SDK columns.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Beken/RTL SDKs ship lwIP defaults tuned for a general-purpose WiFi
SoC: TCP_SND_BUF=10*MSS (14.6KB), MEM_SIZE=32KB, 12 TCP + 22 UDP
sockets. These waste significant RAM on memory-constrained chips.
ESPAsyncWebServer allocates malloc(tcp_sndbuf()) per response chunk,
and at 14.6KB this causes OOM on BK7231N.
This tunes lwIP to match ESP32/ESP8266 ranges:
- TCP_SND_BUF/TCP_WND: 4*MSS (was 10*MSS)
- MEM_SIZE: 12KB BK72XX / 16KB RTL,LN (was 32KB)
- Socket counts: dynamic from component registrations
- All derived pool sizes adjusted accordingly
Also splits socket consumer tracking into TCP/UDP, adds
get_socket_counts() API, and updates ESP32 to use it.
Closes https://github.com/esphome/esphome/issues/14095
- Change lookup function signatures from uint16_t to uint8_t since
indices are stored in uint8_t fields (max 255 per category)
- Use cpp_string_escape() for string table entries to prevent
compilation errors from special characters in user-provided strings
Replace uint32_t entity_string_packed_ with 3 separate uint8_t
fields (device_class_idx_, uom_idx_, icon_idx_) placed after the
1-byte EntityFlags struct. These fill the 3 padding bytes that
the compiler would insert anyway for alignment, saving 4 bytes
per entity with zero layout overhead.
The set_entity_strings(uint32_t) API is preserved — it unpacks
into the individual fields.
8 bits per field (max 255) is more than sufficient — even large
configs use fewer than 40 unique icons, 14 device classes, and
11 units of measurement. This frees up 8 bits in the packed
uint32_t for future use.
NumberTraits no longer needs get_device_class_ref() or
get_unit_of_measurement_ref() — no internal callers exist.
Callers should use number->get_device_class_ref() directly.
Eliminates offsetof warning on non-standard-layout type.
- Blobs now start directly with first string (no wasted \0 prefix)
- Lookup functions handle index 0 by pointing to trailing null of blob
- get_*_ref() simplified: just calls lookup, no separate empty check
- Removes EMPTY_REF constant and per-getter branch
- Replace DeferredStatement with FINAL-priority coroutine job
- Add named constants for bit shifts and max values
- Use _DC_SHIFT in packed calculation for consistency
- Restore Args docstring on _setup_entity_impl
The logger only writes to UART, never reads. Previously it used
tx_buffer_size (512 bytes) for both RX and TX buffers. Since ESP-IDF
requires rx_buffer_size > UART_HW_FIFO_LEN (128), use the minimum
of 129 bytes instead of 512, saving ~383 bytes of heap.
The logger only writes to UART, never reads. Previously it used
tx_buffer_size (512 bytes) for both RX and TX buffers. Since ESP-IDF
requires rx_buffer_size > UART_HW_FIFO_LEN (128), use the minimum
of 129 bytes instead of 512, saving ~383 bytes of heap.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Expose the scheduler's existing 64-bit millisecond tracking as a public
API and use it in the uptime sensors, replacing their manual rollover
handling.
Co-Authored-By: J. Nick Koston <nick@koston.org>
Tracks heap usage per component during both construction and setup() phases.
Logs deltas inline as components are registered and set up, then prints a
sorted summary after setup() completes. Storage is freed after the summary.
This is a diagnostic tool - not intended for production use. It was used to
discover the logger's unused UART event queue allocation (#14168).
The logger's uart_driver_install() was allocating a 10-item FreeRTOS
event queue but passing nullptr as the queue handle, meaning nothing
could ever read from it. Setting the queue size to 0 saves ~212 bytes
of heap.