[esp32_ble] Enable CONFIG_BT_RELEASE_IRAM on ESP32-C2#14109
Conversation
The ESP32-C2 has very limited RAM (~272KB) and BLE initialization fails with ESP_ERR_NO_MEM without this option. CONFIG_BT_RELEASE_IRAM frees ~21KB of IRAM by merging BT text/data/bss into heap, which is enough for BLE to work on the memory-constrained C2. Closes #13516 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
👋 Hi there! This PR modifies 1 file(s) with codeowners. @jesserockz, @Rapsssito - As codeowner(s) of the affected files, your review would be appreciated! 🙏 Note: Automatic review request may have failed, but you're still welcome to review. |
|
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#14109
components: [esp32_ble]
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 #14109 +/- ##
=======================================
Coverage 74.11% 74.11%
=======================================
Files 55 55
Lines 11590 11590
Branches 1578 1578
=======================================
Hits 8590 8590
Misses 2598 2598
Partials 402 402 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes BLE functionality on ESP32-C2 devices by automatically enabling the CONFIG_BT_RELEASE_IRAM sdkconfig option. The ESP32-C2 has limited RAM (~272KB), and without this option, esp_bt_controller_init fails with ESP_ERR_NO_MEM. The fix enables this option automatically during final validation when the ESP32-C2 variant is detected, eliminating the need for users to manually configure it.
Changes:
- Added automatic
CONFIG_BT_RELEASE_IRAMconfiguration for ESP32-C2 to free ~21KB of IRAM required for BLE operation - Added test coverage for ESP32-C2 BLE functionality
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/components/esp32_ble/test.esp32-c2-idf.yaml | New test file for ESP32-C2 BLE functionality following the established test pattern |
| esphome/components/esp32_ble/init.py | Added import of VARIANT_ESP32C2 constant and conditional sdkconfig option setting in final_validation |
Memory Impact AnalysisComponents:
This analysis runs automatically when components change. Memory usage is measured from a representative test configuration. |
|
thanks |
|
oops. I reset instead of pushing the CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT change on top |
CONFIG_BT_RELEASE_IRAM requires CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT to be disabled, otherwise ESP-IDF raises a compile-time error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
should have just let claude do it :) |
|
all good now |
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
What does this implement/fix?
Enable
CONFIG_BT_RELEASE_IRAMautomatically when BLE is used on ESP32-C2 variants.https://docs.espressif.com/projects/esp-idf/en/v5.2/esp32c2/api-guides/performance/ram-usage.html
The ESP32-C2 has very limited RAM (~272KB). Without this sdkconfig option,
esp_bt_controller_initfails withESP_ERR_NO_MEM, making BLE completely non-functional on C2 chips.On ESP32-C2, enabling
CONFIG_BT_RELEASE_IRAMdisablesCONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT, which changes the memory partitioning so IRAM and DRAM share space more flexibly. This gives the BT controller enough contiguous memory to initialize without OOM. The option also enables releasing ~21KB of BT IRAM viaesp_bt_mem_release()after Bluetooth is no longer needed, but ESPHome keeps BLE running continuously (for proxy, improv, etc.) so that function is never called. The benefit here is purely from the compile-time memory layout change.This is automatically applied during final validation when the ESP32-C2 variant is detected, so users no longer need to manually add it to their
sdkconfig_options.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: