From 456e0f2679cbf88ecda82f1425eea63fd3350e95 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 7 Feb 2026 18:37:32 -0600 Subject: [PATCH 1/3] revert this after https://github.com/libretiny-eu/libretiny/pull/361 --- .clang-tidy.hash | 2 +- esphome/components/libretiny/__init__.py | 25 +++++++++++++----------- platformio.ini | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.clang-tidy.hash b/.clang-tidy.hash index e3c1f2e30b..f62d6a02ad 100644 --- a/.clang-tidy.hash +++ b/.clang-tidy.hash @@ -1 +1 @@ -bb17a9237b701c18a0ec885a709409305d2b777e9d4a3cf49b2e71e2144b3fe0 +08deb6f9a4fca320183b1f5fed24db904fcd68d13d47a35e89bbe8f05d68091e diff --git a/esphome/components/libretiny/__init__.py b/esphome/components/libretiny/__init__.py index 5ae1118fa2..7cd1dc545f 100644 --- a/esphome/components/libretiny/__init__.py +++ b/esphome/components/libretiny/__init__.py @@ -33,6 +33,9 @@ from .const import ( CONF_UART_PORT, FAMILIES, FAMILY_BK7231N, + FAMILY_BK7231Q, + FAMILY_BK7231T, + FAMILY_BK7251, FAMILY_COMPONENT, FAMILY_FRIENDLY, FAMILY_RTL8710B, @@ -52,19 +55,14 @@ CODEOWNERS = ["@kuba2k2"] AUTO_LOAD = ["preferences"] IS_TARGET_PLATFORM = True -# BK7231N SDK options to disable unused features. +# BK72XX SDK options to disable unused features. # Disabling BLE saves ~21KB RAM and ~200KB Flash because BLE init code is # called unconditionally by the SDK. ESPHome doesn't use BLE on LibreTiny. # -# This only works on BK7231N (BLE 5.x). Other BK72XX chips using BLE 4.2 -# (BK7231T, BK7231Q, BK7251; BK7252 boards use the BK7251 family) have a bug -# where the BLE library still links and references undefined symbols when -# CFG_SUPPORT_BLE=0. -# # Other options like CFG_TX_EVM_TEST, CFG_RX_SENSITIVITY_TEST, CFG_SUPPORT_BKREG, # CFG_SUPPORT_OTA_HTTP, and CFG_USE_SPI_SLAVE were evaluated but provide no # NOLINT # measurable benefit - the linker already strips unreferenced code via -gc-sections. -_BK7231N_SYS_CONFIG_OPTIONS = [ +_BK72XX_SYS_CONFIG_OPTIONS = [ "CFG_SUPPORT_BLE=0", ] @@ -197,11 +195,11 @@ ARDUINO_VERSIONS = { "dev": (cv.Version(1, 12, 0), "https://github.com/libretiny-eu/libretiny.git"), "latest": ( cv.Version(1, 12, 0), - "https://github.com/bdraco/libretiny.git#7f52d41", + "https://github.com/bdraco/libretiny.git#39f407a", ), "recommended": ( cv.Version(1, 12, 0), - "https://github.com/bdraco/libretiny.git#7f52d41", + "https://github.com/bdraco/libretiny.git#39f407a", ), } @@ -385,9 +383,14 @@ async def component_to_code(config): cg.add_platformio_option("custom_fw_version", __version__) # Apply chip-specific SDK options to save RAM/Flash - if config[CONF_FAMILY] == FAMILY_BK7231N: + if config[CONF_FAMILY] in ( + FAMILY_BK7231N, + FAMILY_BK7231Q, + FAMILY_BK7231T, + FAMILY_BK7251, + ): cg.add_platformio_option( - "custom_options.sys_config#h", _BK7231N_SYS_CONFIG_OPTIONS + "custom_options.sys_config#h", _BK72XX_SYS_CONFIG_OPTIONS ) # Disable LWIP statistics to save RAM - not needed in production diff --git a/platformio.ini b/platformio.ini index 349bdc4341..2bfe9f89e9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -214,7 +214,7 @@ build_unflags = [common:libretiny-arduino] extends = common:arduino # TODO: Revert to v1.12.0 tag once https://github.com/libretiny-eu/libretiny/pull/361 is released -platform = https://github.com/bdraco/libretiny.git#7f52d41 +platform = https://github.com/bdraco/libretiny.git#39f407a framework = arduino lib_compat_mode = soft lib_deps = From d73384ae46999b99b852b2f9f691b7d9dc86001d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 7 Feb 2026 19:07:15 -0600 Subject: [PATCH 2/3] revert this after https://github.com/libretiny-eu/libretiny/pull/361 --- esphome/components/libretiny/__init__.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/esphome/components/libretiny/__init__.py b/esphome/components/libretiny/__init__.py index 7cd1dc545f..6898f6c897 100644 --- a/esphome/components/libretiny/__init__.py +++ b/esphome/components/libretiny/__init__.py @@ -33,9 +33,6 @@ from .const import ( CONF_UART_PORT, FAMILIES, FAMILY_BK7231N, - FAMILY_BK7231Q, - FAMILY_BK7231T, - FAMILY_BK7251, FAMILY_COMPONENT, FAMILY_FRIENDLY, FAMILY_RTL8710B, @@ -55,14 +52,20 @@ CODEOWNERS = ["@kuba2k2"] AUTO_LOAD = ["preferences"] IS_TARGET_PLATFORM = True -# BK72XX SDK options to disable unused features. +# BK7231N SDK options to disable unused features. # Disabling BLE saves ~21KB RAM and ~200KB Flash because BLE init code is # called unconditionally by the SDK. ESPHome doesn't use BLE on LibreTiny. # +# This only works on BK7231N (BLE 5.x). Other BK72XX chips using BLE 4.2 +# (BK7231T, BK7231Q, BK7251) cannot disable BLE via custom_options because +# the LibreTiny builder reads CFG_SUPPORT_BLE from the sys_config file at +# build-script time to decide which sources to compile - the custom_options +# override only affects C preprocessor defines, not the builder's Python logic. +# # Other options like CFG_TX_EVM_TEST, CFG_RX_SENSITIVITY_TEST, CFG_SUPPORT_BKREG, # CFG_SUPPORT_OTA_HTTP, and CFG_USE_SPI_SLAVE were evaluated but provide no # NOLINT # measurable benefit - the linker already strips unreferenced code via -gc-sections. -_BK72XX_SYS_CONFIG_OPTIONS = [ +_BK7231N_SYS_CONFIG_OPTIONS = [ "CFG_SUPPORT_BLE=0", ] @@ -383,14 +386,9 @@ async def component_to_code(config): cg.add_platformio_option("custom_fw_version", __version__) # Apply chip-specific SDK options to save RAM/Flash - if config[CONF_FAMILY] in ( - FAMILY_BK7231N, - FAMILY_BK7231Q, - FAMILY_BK7231T, - FAMILY_BK7251, - ): + if config[CONF_FAMILY] == FAMILY_BK7231N: cg.add_platformio_option( - "custom_options.sys_config#h", _BK72XX_SYS_CONFIG_OPTIONS + "custom_options.sys_config#h", _BK7231N_SYS_CONFIG_OPTIONS ) # Disable LWIP statistics to save RAM - not needed in production From 2eac6b06b7333b482888f28972b525e409fc57f7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 8 Feb 2026 10:28:14 -0600 Subject: [PATCH 3/3] revert workarounds now that libretiny v1.12.1 is released --- .clang-tidy.hash | 2 +- esphome/components/libretiny/__init__.py | 18 ++++++++---------- platformio.ini | 3 +-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.clang-tidy.hash b/.clang-tidy.hash index f62d6a02ad..f9de2bc05d 100644 --- a/.clang-tidy.hash +++ b/.clang-tidy.hash @@ -1 +1 @@ -08deb6f9a4fca320183b1f5fed24db904fcd68d13d47a35e89bbe8f05d68091e +0f2b9a65dce7c59289d3aeb40936360a62a7be937b585147b45bb1509eaafb36 diff --git a/esphome/components/libretiny/__init__.py b/esphome/components/libretiny/__init__.py index 6898f6c897..01445da7ee 100644 --- a/esphome/components/libretiny/__init__.py +++ b/esphome/components/libretiny/__init__.py @@ -57,10 +57,9 @@ IS_TARGET_PLATFORM = True # called unconditionally by the SDK. ESPHome doesn't use BLE on LibreTiny. # # This only works on BK7231N (BLE 5.x). Other BK72XX chips using BLE 4.2 -# (BK7231T, BK7231Q, BK7251) cannot disable BLE via custom_options because -# the LibreTiny builder reads CFG_SUPPORT_BLE from the sys_config file at -# build-script time to decide which sources to compile - the custom_options -# override only affects C preprocessor defines, not the builder's Python logic. +# (BK7231T, BK7231Q, BK7251; BK7252 boards use the BK7251 family) have a bug +# where the BLE library still links and references undefined symbols when +# CFG_SUPPORT_BLE=0. # # Other options like CFG_TX_EVM_TEST, CFG_RX_SENSITIVITY_TEST, CFG_SUPPORT_BKREG, # CFG_SUPPORT_OTA_HTTP, and CFG_USE_SPI_SLAVE were evaluated but provide no # NOLINT @@ -193,16 +192,15 @@ def _notify_old_style(config): # The dev and latest branches will be at *least* this version, which is what matters. # Use GitHub releases directly to avoid PlatformIO moderation delays. -# TODO: Revert to v1.12.0 tag once https://github.com/libretiny-eu/libretiny/pull/361 is released ARDUINO_VERSIONS = { - "dev": (cv.Version(1, 12, 0), "https://github.com/libretiny-eu/libretiny.git"), + "dev": (cv.Version(1, 12, 1), "https://github.com/libretiny-eu/libretiny.git"), "latest": ( - cv.Version(1, 12, 0), - "https://github.com/bdraco/libretiny.git#39f407a", + cv.Version(1, 12, 1), + "https://github.com/libretiny-eu/libretiny.git#v1.12.1", ), "recommended": ( - cv.Version(1, 12, 0), - "https://github.com/bdraco/libretiny.git#39f407a", + cv.Version(1, 12, 1), + "https://github.com/libretiny-eu/libretiny.git#v1.12.1", ), } diff --git a/platformio.ini b/platformio.ini index 2bfe9f89e9..ada900ffb2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -213,8 +213,7 @@ build_unflags = ; This are common settings for the LibreTiny (all variants) using Arduino. [common:libretiny-arduino] extends = common:arduino -# TODO: Revert to v1.12.0 tag once https://github.com/libretiny-eu/libretiny/pull/361 is released -platform = https://github.com/bdraco/libretiny.git#39f407a +platform = https://github.com/libretiny-eu/libretiny.git#v1.12.1 framework = arduino lib_compat_mode = soft lib_deps =