Track Bluedroid linker wraps and their upstream fixes

Open
#205 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
c, cmake, cpp

Research direction

This is a tracking list rather than a single change. Start with one wrap, such as the l2cble_init_direct_conn entry in esp32_ble_tracker/bluedroid_stubs.cpp and DIRECT_CONN_FIX_VERSIONS in esp32_ble_tracker/__init__.py, and check which ESP-IDF versions carry the upstream fix. Done means the version bound is set and the wrap is removed once no supported version needs it, with the checkbox ticked here.

Written by the indexing model from the issue text.

Description

Summary

ESPHome works around several Bluedroid (ESP-IDF Bluetooth host) bugs with linker wraps (-Wl,--wrap) instead of patching ESP-IDF. Each wrap should be dropped once ESPHome uses an ESP-IDF release with the upstream fix. This issue tracks every wrap, its upstream issue or PR, and when it can go.

Wraps

  • esphome/esphome#19375 [esp32_ble_tracker] Guard Bluedroid against stale queued connection requests
    • Wraps l2cble_init_direct_conn (esp32_ble_tracker/bluedroid_stubs.cpp).
    • Upstream: espressif/esp-idf#18336 (issue, open). Fixed by espressif/esp-idf@82e71c1767, tagged in 5.2.8, 5.3.6, 5.5.6, 6.0.3, 6.1.1 and from 6.2.0; the 5.4 branch has it but no tag yet (5.4.4 predates it).
    • Already gated by version (DIRECT_CONN_FIX_VERSIONS in esp32_ble_tracker/__init__.py): add each branch as it is tagged, remove the wrap once ESPHome's ESP-IDF versions all have it.
    • Next step: the table still lacks 5.5.6 and 6.1.1, so the wrap is still added on those releases even though they have the fix.
  • esphome/esphome#22081 [esp32_ble] Parse Bluedroid hex strings without sscanf
    • Wraps btc_config_get_bin and string_to_bdaddr (esp32_ble/bluedroid_hex_wraps.cpp). Not a bug: keeps newlib's scanf engine (about 16 KB) out of the firmware.
    • Upstream: espressif/esp-idf#19235 (PR, open).
    • Added below ESP-IDF 6.0 on variants without sscanf in ROM, and on every variant from ESP-IDF 6.0 (esphome/esphome#22805, merged: picolibc's scanf engine is in flash there too).
  • esphome/esphome#22559 [esp32_ble] Keep bond keys when a bonded device re-encrypts on ESP-IDF 5.5.6
    • Wraps smp_check_auth_req and btm_sec_clear_ble_keys (esp32_ble/bluedroid_bond_keys.c).
    • Upstream: espressif/esp-idf#19322 (PR, open).
    • Added for ESP-IDF 5.5.6 up to 6.0, and from 6.1.1 (esphome/esphome#22806, merged: 6.1.1 has the same change).
  • esphome/esphome#22576 [esp32_ble] Sort GATT discovery responses by handle for ESP-IDF 5.5.6 and 6.0.3
    • Wraps gatt_client_handle_server_rsp (esp32_ble/bluedroid_gattc_order.cpp).
    • Upstream: none filed yet. ESP-IDF 5.5.6 and 6.0.3 added a check that ends GATT discovery when a peer lists handles out of order, which earlier releases, Android and BlueZ accept.
    • Added for 5.5.6 up to 6.0, for 6.0.3 up to 6.1, and from 6.1.1 (esphome/esphome#22806 left out 6.1.0, which does not have the check).
  • esphome/esphome#22670 [esp32_ble] Stop Bluedroid re-running a failed queued MTU or execute write request
    • Wraps bta_gattc_cfg_mtu, bta_gattc_execute, GATTC_ConfigureMTU and GATTC_ExecuteWrite (esp32_ble/bluedroid_gattc_queue.c). Fixes esphome/esphome#17954.
    • Upstream: espressif/esp-idf#19336 (PR, open). The bug is still on ESP-IDF master.
    • Added for every ESP-IDF version.

Process

  • When a wrap is added, list it here with its upstream issue or PR, or file one.
  • When an ESP-IDF release with the fix is adopted, give the wrap an upper version bound, then remove it once no supported version needs it, and tick it here.
  • Wraps that need Bluedroid's private headers (bluedroid_headers_cmake) only run on the native ESP-IDF toolchain and not on Windows hosts; PlatformIO builds keep the ESP-IDF behaviour.
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from esphome/backlog

All issues in esphome/backlog

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.