[libretiny] Disable BLE stack on BK7231N to save ~21KB RAM - #13131
Conversation
|
To use the changes from this PR as an external component, add the following to your ESPHome configuration YAML file: external_components:
- source: github://pr#13131
components: [libretiny]
refresh: 1h(Added by the PR bot) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #13131 +/- ##
==========================================
- Coverage 73.76% 73.73% -0.03%
==========================================
Files 53 53
Lines 11329 11329
Branches 1538 1538
==========================================
- Hits 8357 8354 -3
- Misses 2572 2574 +2
- Partials 400 401 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Memory Impact AnalysisComponents:
This analysis runs automatically when components change. Memory usage is measured from a representative test configuration. |
|
memory impact is misleading because it doesn't build with bk7231n |
|
👋 Hi there! I've automatically requested reviews from codeowners based on the files changed in this PR. @kuba2k2 - You've been requested to review this PR as codeowner(s) of 1 file(s) that were modified. Thanks for your time! 🙏 |
There was a problem hiding this comment.
Pull request overview
This PR disables the BLE stack on BK7231N chips to save approximately 21KB of RAM and 200KB of Flash memory. Since ESPHome currently has no BLE support on LibreTiny platforms, the BLE stack is consuming resources unnecessarily. The change only applies to BK7231N because other BK72XX chips have a linker bug when BLE is disabled.
Changes:
- Adds SDK configuration option to disable BLE stack on BK7231N only
- Applies the configuration via PlatformIO's custom_options mechanism
- Includes detailed documentation explaining why this is BK7231N-specific
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Thanks |
What does this implement/fix?
Disables the BLE stack on BK7231N to save ~21KB RAM and ~200KB Flash.
ESPHome currently has no BLE support on LibreTiny platforms, so the BLE stack is pure waste. The Beken SDK unconditionally initializes it when
CFG_SUPPORT_BLE=1(the default), consuming significant RAM on memory-constrained devices.This can be flipped back on in a future PR when BLE support is added for BK7231N.
Before this change, users with typical configurations (WiFi, API, web_server, a few sensors) were seeing only ~10-13KB free heap at runtime, risking crashes under load. After this change, free heap increases to ~30KB+, providing a much safer margin.
Memory savings (BK7231N):
Why only BK7231N?
Other BK72XX chips (BK7231T, BK7251, BK7252) use BLE 4.2 which has a bug where the BLE library still links and references undefined symbols when
CFG_SUPPORT_BLE=0. BK7231N uses BLE 5.x which doesn't have this issue.Re-enabling BLE (for development/testing):
Users can override this default via platformio_options if needed:
Other SDK options (
CFG_TX_EVM_TEST,CFG_RX_SENSITIVITY_TEST,CFG_SUPPORT_BKREG,CFG_SUPPORT_OTA_HTTP,CFG_USE_SPI_SLAVE) were evaluated but provide no measurable benefit - the linker already strips unreferenced code via-gc-sections. Only BLE has an impact because its init code is called unconditionally.Types of changes
Related issue or feature (if applicable):
Pull request in esphome-docs with documentation (if applicable):
Test Environment
Example entry for
config.yaml:Checklist:
tests/folder).If user exposed functionality or configuration variables are added/changed: