From 2b00a809c827a84cfc261ed674b8c0154115414a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 21 Feb 2026 14:42:30 -0600 Subject: [PATCH] [libretiny] Fix BK72XX lwIP sanity check for reduced-plan boards 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 --- esphome/components/libretiny/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/esphome/components/libretiny/__init__.py b/esphome/components/libretiny/__init__.py index aeb29668f8..02c4aad03d 100644 --- a/esphome/components/libretiny/__init__.py +++ b/esphome/components/libretiny/__init__.py @@ -373,6 +373,11 @@ def _configure_lwip(config: dict) -> None: # LN882H uses MEM_LIBC_MALLOC=1 (system heap), so MEM_SIZE is irrelevant. if CORE.is_bk72xx: lwip_opts.append("MEM_SIZE=5120") # BK SDK: 32,768, RTL SDK: 5,120 + # PBUF_POOL_SIZE: BK SDK "reduced plan" sets this to only 3, which is + # too small for TCP_WND=4×MSS (5840 > 3*1526=4578). Set to 4 so the + # lwIP sanity check passes: 4*1526=6104 > 5840. + # RTL(20) and LN(20) are already large enough. + lwip_opts.append("PBUF_POOL_SIZE=4") cg.add_platformio_option("custom_options.lwip", lwip_opts)