Skip to content

task-ble: hold NimBLE host lock around ble_hs_id_copy_addr (ESP-IDF v5.4+) - #1

Open
joalavedra wants to merge 1 commit into
firefly:mainfrom
joalavedra:fix/esp-idf-v5.4-build
Open

task-ble: hold NimBLE host lock around ble_hs_id_copy_addr (ESP-IDF v5.4+)#1
joalavedra wants to merge 1 commit into
firefly:mainfrom
joalavedra:fix/esp-idf-v5.4-build

Conversation

@joalavedra

Copy link
Copy Markdown

ESP-IDF v5.4 ships a NimBLE update where ble_hs_id_addr asserts ble_hs_locked_by_cur_task() under CONFIG_BT_NIMBLE_DEBUG=y. Calling ble_hs_id_copy_addr from onSync (the sync_cb) without explicitly holding the host lock now panics during NimBLE startup:

assert failed: ble_hs_id_addr ble_hs_id.c:295 (ble_hs_locked_by_cur_task())

(stack: ble_hs_pvcy_set_default_irkble_hs_startup_goble_hs_syncble_hs_start)

Older NimBLE was permissive for callers on the host task — the lock check is paranoid, the call itself is correct. The fix wraps it explicitly in ble_hs_lock()/ble_hs_unlock() so the assertion is satisfied. ble_hs_lock lives in NimBLE's private header (ble_hs_priv.h) so I forward-declare both rather than pulling the private include.

Affected: anyone building this component against ESP-IDF >= 5.4 with default NimBLE settings — including pixie-firmware itself.

Workaround for users on the current main: set CONFIG_BT_NIMBLE_DEBUG=n. The patch makes that workaround unnecessary.

Found while building pixie-agent-visualizer — a live AI-agent activity display on the Pixie.

ESP-IDF v5.4+ ships a NimBLE update whose ble_hs_id_addr asserts
ble_hs_locked_by_cur_task() under CONFIG_BT_NIMBLE_DEBUG=y. Calling
ble_hs_id_copy_addr from the sync_cb (as onSync does) without explicitly
holding the host lock now panics:

    assert failed: ble_hs_id_addr ble_hs_id.c:295 (ble_hs_locked_by_cur_task())

Wrap the call in ble_hs_lock()/ble_hs_unlock() and forward-declare both
from NimBLE's private header so we don't need to pull in ble_hs_priv.h.

Affected build: ESP-IDF >= 5.4 with default NimBLE debug settings.
Workaround for users on this commit: set CONFIG_BT_NIMBLE_DEBUG=n in
sdkconfig.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants