Compare commits

...

3 Commits

Author SHA1 Message Date
J. Nick Koston
06c5b06f74 [esp32_ble] Work around gatt_main.c compile bug and add IDF to Arduino platformio.ini
Always enable CONFIG_BT_GATTS_ENABLE to work around an ESP-IDF 5.5.2.260206
bug in gatt_main.c where GATT_TRACE_DEBUG references 'msg_len' outside the
GATTS_INCLUDED/GATTC_INCLUDED preprocessor guard, causing a compile error
when both are disabled.

Also add framework-espidf to the Arduino platform_packages in platformio.ini
since Arduino builds use ESP-IDF as a component (framework = arduino, espidf).
2026-02-09 08:52:42 -06:00
J. Nick Koston
c4a5df08c6 [esp32] Fix P4 linker mismatch and pass release to Arduino IDF path
The ESP-IDF 5.5.2.260206 release changed the default of
ESP32P4_SELECTS_REV_LESS_V3 from y to n. PlatformIO always uses
sections.ld.in (for rev <3) rather than sections.rev3.ld.in
(for rev >=3), causing a linker script mismatch with the generated
memory.ld. Restore the previous default until PlatformIO handles
this properly.

Also centralize the ESP-IDF release lookup into
_format_framework_espidf_version so both the IDF and Arduino
code paths use the same release.
2026-02-09 08:05:21 -06:00
J. Nick Koston
5e50716deb [esp32] Bump ESP-IDF 5.5.2 to release 260206
The base ESP-IDF 5.5.2 release contains a broken BT controller
binary (libbtdm_app.a) that causes BLE scanning to silently die
after hours/days with a HCI command timeout (opcode 0x200c).

pioarduino's v5.5.2.260206 release includes the upstream fix
from espressif/esp32-bt-lib commit 06dc4667 which fixes the
BLE enable scan timeout and crash in btdm_controller_task.

Fixes https://github.com/esphome/esphome/issues/13560
2026-02-09 07:10:26 -06:00
4 changed files with 31 additions and 11 deletions

View File

@@ -1 +1 @@
37ec8d5a343c8d0a485fd2118cbdabcbccd7b9bca197e4a392be75087974dced
7b63ea33897064554efa88382ff41c34a55ea58e1161667093b97d8427f7f957

View File

@@ -612,9 +612,13 @@ def _format_framework_arduino_version(ver: cv.Version) -> str:
return f"{ARDUINO_FRAMEWORK_PKG}@https://github.com/espressif/arduino-esp32/releases/download/{ver}/{filename}"
def _format_framework_espidf_version(ver: cv.Version, release: str) -> str:
def _format_framework_espidf_version(
ver: cv.Version, release: str | None = None
) -> str:
# format the given espidf (https://github.com/pioarduino/esp-idf/releases) version to
# a PIO platformio/framework-espidf value
if release is None:
release = ESP_IDF_RELEASE_LOOKUP.get(ver)
if ver == cv.Version(5, 4, 3) or ver >= cv.Version(5, 5, 1):
ext = "tar.xz"
else:
@@ -689,6 +693,9 @@ ESP_IDF_FRAMEWORK_VERSION_LOOKUP = {
"latest": cv.Version(5, 5, 2),
"dev": cv.Version(5, 5, 2),
}
ESP_IDF_RELEASE_LOOKUP: dict[cv.Version, str] = {
cv.Version(5, 5, 2): "260206",
}
ESP_IDF_PLATFORM_VERSION_LOOKUP = {
cv.Version(5, 5, 2): cv.Version(55, 3, 36),
cv.Version(5, 5, 1): cv.Version(55, 3, 31, "2"),
@@ -750,9 +757,10 @@ def _check_versions(config):
raise cv.Invalid("Only ESP-IDF 5.0+ is supported.")
recommended_version = ESP_IDF_FRAMEWORK_VERSION_LOOKUP["recommended"]
platform_lookup = ESP_IDF_PLATFORM_VERSION_LOOKUP.get(version)
release = value.get(CONF_RELEASE, ESP_IDF_RELEASE_LOOKUP.get(version))
value[CONF_SOURCE] = value.get(
CONF_SOURCE,
_format_framework_espidf_version(version, value.get(CONF_RELEASE, None)),
_format_framework_espidf_version(version, release),
)
if _is_framework_url(value[CONF_SOURCE]):
value[CONF_SOURCE] = f"pioarduino/framework-espidf@{value[CONF_SOURCE]}"
@@ -1464,7 +1472,7 @@ async def to_code(config):
if (idf_ver := ARDUINO_IDF_VERSION_LOOKUP.get(framework_ver)) is not None:
cg.add_platformio_option(
"platform_packages",
[_format_framework_espidf_version(idf_ver, None)],
[_format_framework_espidf_version(idf_ver)],
)
# Use stub package to skip downloading precompiled libs
stubs_dir = CORE.relative_build_path("arduino_libs_stub")
@@ -1508,6 +1516,14 @@ async def to_code(config):
f"CONFIG_ESPTOOLPY_FLASHSIZE_{config[CONF_FLASH_SIZE]}", True
)
# ESP32-P4: The ESP-IDF 5.5.2.260206 release changed the default of
# ESP32P4_SELECTS_REV_LESS_V3 from y to n. PlatformIO always uses
# sections.ld.in (for rev <3) rather than sections.rev3.ld.in (for rev >=3),
# causing a linker script mismatch with the generated memory.ld.
# Restore the previous default until PlatformIO handles this properly.
if variant == VARIANT_ESP32P4:
add_idf_sdkconfig_option("CONFIG_ESP32P4_SELECTS_REV_LESS_V3", True)
# Set minimum chip revision for ESP32 variant
# Setting this to 3.0 or higher reduces flash size by excluding workaround code,
# and for PSRAM users saves significant IRAM by keeping C library functions in ROM.

View File

@@ -403,18 +403,21 @@ def final_validation(config):
add_idf_sdkconfig_option("CONFIG_ESP_HOSTED_ENABLE_BT_BLUEDROID", True)
add_idf_sdkconfig_option("CONFIG_ESP_HOSTED_BLUEDROID_HCI_VHCI", True)
# Check if BLE Server is needed
has_ble_server = "esp32_ble_server" in full_config
# Check if BLE Client is needed (via esp32_ble_tracker or esp32_ble_client)
has_ble_client = (
"esp32_ble_tracker" in full_config or "esp32_ble_client" in full_config
)
# ESP-IDF BLE stack requires GATT Server to be enabled when GATT Client is enabled
# This is an internal dependency in the Bluedroid stack (tested ESP-IDF 5.4.2-5.5.1)
# Always enable GATTS: ESP-IDF 5.5.2.260206 has a bug in gatt_main.c where a
# GATT_TRACE_DEBUG references 'msg_len' outside the GATTS_INCLUDED/GATTC_INCLUDED
# guard, causing a compile error when both are disabled.
# Additionally, when GATT Client is enabled, GATT Server must also be enabled
# as an internal dependency in the Bluedroid stack.
# See: https://github.com/espressif/esp-idf/issues/17724
add_idf_sdkconfig_option("CONFIG_BT_GATTS_ENABLE", has_ble_server or has_ble_client)
# TODO: Revert to conditional once the gatt_main.c bug is fixed upstream:
# has_ble_server = "esp32_ble_server" in full_config
# add_idf_sdkconfig_option("CONFIG_BT_GATTS_ENABLE", has_ble_server or has_ble_client)
add_idf_sdkconfig_option("CONFIG_BT_GATTS_ENABLE", True)
add_idf_sdkconfig_option("CONFIG_BT_GATTC_ENABLE", has_ble_client)
# Handle max_connections: check for deprecated location in esp32_ble_tracker

View File

@@ -136,6 +136,7 @@ extends = common:arduino
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.36/platform-espressif32.zip
platform_packages =
pioarduino/framework-arduinoespressif32@https://github.com/espressif/arduino-esp32/releases/download/3.3.6/esp32-core-3.3.6.tar.xz
pioarduino/framework-espidf@https://github.com/pioarduino/esp-idf/releases/download/v5.5.2.260206/esp-idf-v5.5.2.tar.xz
framework = arduino, espidf ; Arduino as an ESP-IDF component
lib_deps =
@@ -170,7 +171,7 @@ extra_scripts = post:esphome/components/esp32/post_build.py.script
extends = common:idf
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.36/platform-espressif32.zip
platform_packages =
pioarduino/framework-espidf@https://github.com/pioarduino/esp-idf/releases/download/v5.5.2/esp-idf-v5.5.2.tar.xz
pioarduino/framework-espidf@https://github.com/pioarduino/esp-idf/releases/download/v5.5.2.260206/esp-idf-v5.5.2.tar.xz
framework = espidf
lib_deps =