Previous minimums (10/8) were overly conservative. Most configs
register their actual needs via consume_sockets(), so the minimums
only need to cover unregistered components with modest headroom.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
get_socket_counts() now returns component detail strings alongside
counts so platforms can include them in their log messages. ESP32
INFO log now shows which components consume each socket type.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CONFIG_LWIP_MAX_SOCKETS is a single VFS socket pool shared by all
socket types. Listening sockets consume file descriptors too, so
they must be included in the total.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- OTA: note that active transfer uses a TCP PCB from general pool
- MIN_TCP_SOCKETS: update base count to api(3) after TCP_LISTEN split
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove SOCKET_TCP/SOCKET_UDP aliases, use SocketType.UDP everywhere
- Fix MEMP_NUM_NETCONN to include listening_tcp (listeners need netconns)
- Add comment on listening_tcp minimum (not all components register yet)
- Add comment on MAX_LISTENING_SOCKETS_TCP (BK-specific, RTL/LN use
MEMP_NUM_TCP_PCB_LISTEN directly)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Components now register their listening sockets explicitly instead of
relying on a hardcoded count. web_server_base registers the shared
HTTP listener (used by both web_server and captive_portal). The
libretiny lwIP config derives MEMP_NUM_TCP_PCB_LISTEN dynamically
from these registrations.
Also fixes captive_portal to correctly register its DNS socket as UDP
instead of TCP.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move MEM_LIBC_MALLOC=1 and MEMP_MEM_MALLOC=1 from BK72XX-only to all
LibreTiny platforms. All three SDKs (BK/RTL/LN) wire malloc to
FreeRTOS pvPortMalloc (thread-safe), and WiFi receive paths run in
task context.
Tested on RTL87xx (BW15): 84,184 B → 103,744 B free heap (~19.6KB
freed). OTA and web server confirmed working.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Allocate all MEMP pools (TCP PCBs, UDP PCBs, netconns, TCP segments,
pbufs, etc.) from the heap on demand instead of pre-allocated static
arrays. Saves ~20KB RAM on BK7231N (87,312 B free vs 67,144 B before).
Safe because the BK WiFi driver's receive path runs in task context
(core_thread pops from g_wifi_core.io_queue), not ISR context.
ESP32 and ESP8266 both ship with MEMP_MEM_MALLOC=1.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Listening sockets are already included in the TCP socket count from
component registrations (e.g. api registers 1 listening + 3 clients).
Remove the extra listening_tcp from MEMP_NUM_NETCONN to avoid
over-provisioning.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the dedicated lwIP heap (MEM_SIZE=16/32KB) with system malloc
on BK72XX, matching what LN882H and ESP8266 already do. The BK SDK's
malloc wraps FreeRTOS pvPortMalloc which is thread-safe.
This eliminates the dedicated pool bottleneck that caused OTA slowness
when MEM_SIZE was reduced to 5KB, and frees ~5.9KB heap on BK7231N
(61,264 B → 67,144 B).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
BK SDK has two plans: reduced (16KB) and default (32KB). Show both
in the docstring table for accuracy.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PBUF_POOL_SIZE=4 was the minimum to pass lwIP's sanity check but caused
pbuf exhaustion during concurrent connections (API + web_server + OTA),
resulting in dropped log messages.
Set to 10 to match the BK SDK default plan and ESP8266. RTL/LN already
default to 20 and need no override.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
BK SDK boards with CFG_LWIP_MEM_POLICY=LWIP_REDUCE_THE_PLAN (e.g. CB3S/
BK7231N) set PBUF_POOL_SIZE=3, which is too small for TCP_WND=4*MSS:
3*(1580-54)=4578 < 5840. Set PBUF_POOL_SIZE=4 on BK72XX so the lwIP
compile-time sanity check passes: 4*1526=6104 > 5840.
RTL(20) and LN(20) already have large enough PBUF pools.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>