Commit Graph
272 Commits
Author SHA1 Message Date
Guo Zifan 0a2e3d0b0c feat(ble_log): Add frame check support for restart flow
(cherry picked from commit a81322a2ce)

Co-authored-by: guozifan <guozifan@espressif.com>
2026-06-24 11:25:24 +08:00
Zhi Wei Jian 9d61eddc3a fix(bt): fix BTC task and BLE mesh bluedroid adapter
(cherry picked from commit 678fb93245)

Co-authored-by: zhiweijian <zhiweijian@espressif.com>
2026-06-10 19:53:44 +08:00
Island f0d98bebfe Merge branch 'feat/ble-log-iram-optim_v5.3' into 'release/v5.3'
opt(bt): Move SPI Tx Callback to Flash When SPI ISR IN IRAM Disabled (5.3)

See merge request espressif/esp-idf!48921
2026-06-05 15:50:51 +08:00
luoxu aabd082b83 fix(bt): Normalize source paths for log compression pattern matching 2026-06-04 11:13:05 +08:00
ShenWeilong 7c16e210c7 change(bt): Separated bt/cmakelist to bt/controller/cmakelist and bt/porting/cmakelist 2026-06-04 11:13:05 +08:00
Zhou Xiao e11231d61c change(ble_log): reverted default ble log buffer size to 2048 bytes 2026-06-03 15:16:35 +08:00
Zhou Xiao f8ea60fe36 change(ble_log): move spi tx callback to flash when spi isr in iram disabled
(cherry picked from commit 725e9ee162)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2026-06-03 15:16:23 +08:00
Rahul Tank bf0964c613 fix(nimble): Add support for shorter connection intervals 2026-05-28 15:58:22 +05:30
Mayank Tyagi 0939fbdbfd feat(nimble): ADD BLE HCI logging support for ESP Insights 2026-05-20 13:44:11 +05:30
Zhang Hai Peng bab9c7e569 feat(ble): Support BLE critical logs
(cherry picked from commit 0af57d731c)

Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
2026-05-14 14:23:36 +08:00
zhiweijian 1c312d0b33 fix(ble): Fixed AI review bugs in bt common 2026-05-12 15:59:04 +08:00
Zhang Hai Peng fae52f14e8 feat(ble/blufi): Support setting BLE encryption for blufi
(cherry picked from commit 60a028fb17)

Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
2026-05-12 15:58:55 +08:00
Rahul Tank 93454c1da0 fix(nimble): cleanup: remove extraneous script file
Removed files that were unintentionally included in an earlier commit
2026-05-01 19:22:40 +05:30
Shen Wei LongandZhou Xiao df99116768 change(ble_log): update ble log version to 5 for esp ble controller log encoding indication
(cherry picked from commit 836f87cc4a)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2026-04-27 11:43:35 +00:00
Rahul Tank eac58ca641 Merge branch 'feat/nimble_logs_compression_v5.3' into 'release/v5.3'
feat(nimble): Support NimBLE log compression and decompression over SPI (v5.3)

See merge request espressif/esp-idf!46999
2026-04-22 08:34:06 +05:30
Rahul Tank 0eb2633ba0 fix(nimble): Fix Software ecc issue in tinycrpyt 2026-04-20 14:08:29 +05:30
Sahil Yadav 55cb8136c2 feat(nimble): Support NimBLE log compression and decompression over SPI 2026-04-19 09:50:59 +05:30
Rahul Tank 82caa79c0f fix(nimble): Address review comments for hidd / hidh code 2026-04-16 10:29:21 +05:30
Rahul Tank fd594b74b6 fix(nimble): Address review fixes for tinycrypt / and blufi code 2026-04-16 10:29:21 +05:30
Zhou Xiao 9a3b71f6cd fix(ble_log): ensure BLE Log IRAM functions are placed in IRAM on ESP32C2
On ESP32C2 with BT_CTRL_RUN_IN_FLASH_ONLY, the bt_default linker scheme
routes .iram1 sections to flash_text, causing BLE_LOG_IRAM_ATTR functions
to end up in flash instead of IRAM. Define a dedicated .ble_log_iram1
section for ESP32C2 and route it to iram0_bt_text unconditionally.


(cherry picked from commit a9b93ca0e5)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2026-04-14 13:13:47 +08:00
Zhou Xiao 6a16b680fc fix(ble_log): improve robustness with atomics, macro hygiene, and IRAM
- Use __atomic_fetch_add for stat_mgr counters to prevent lost updates
  under concurrent ISR/task access (H1)
- Use __atomic_load_n with ACQUIRE ordering for ref_count spin-loops (L1)
- Remove unnecessary BLE_LOG_IRAM_ATTR from ble_log_rt_task since it
  calls flash-resident functions and cannot run during flash ops (L3)
- Add parentheses to BLE_LOG_TRANS_FREE_SPACE and BLE_LOG_MAKE_FRAME_META
  macro parameters to prevent operator precedence bugs (M6)


(cherry picked from commit 59536316c9)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2026-04-14 13:13:47 +08:00
Zhou Xiao 1d755f5a8b fix(ble_log): fix deinit race and concurrent flush deadlock
- Reorder deinit: stop RT task before destroying peripheral driver to
  prevent sending transports to a NULL dev_handle on dual-core (H2)
- Drain remaining queue items in rt_deinit to clean up transport state
- Add atomic flush_in_progress guard to prevent two concurrent
  ble_log_flush() callers from deadlocking on ref_count spin-wait (H5)


(cherry picked from commit 1275b78ad6)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2026-04-14 13:13:46 +08:00
Zhou Xiao 15423ec16a fix(ble_log): fix crash and resource issues in peripheral drivers
- Handle scheduler-suspended and ISR context in UART redirect path
  to prevent xSemaphoreTake crash during light sleep (C1)
- Check uart_driver_install return value before setting inited flag (M1)
- Always clean up SPI device handle in deinit even if acquire_bus fails (M4)


(cherry picked from commit 3f8cfc5b1d)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2026-04-14 13:13:41 +08:00
Zhou Xiao c426736f4b fix(ble_log): handle scheduler-suspended state in ble_log_rt_queue_trans
During light sleep transitions, the FreeRTOS scheduler is suspended but
xPortInIsrContext() returns false, causing xQueueSend with portMAX_DELAY
to hit a configASSERT. Add a check for taskSCHEDULER_SUSPENDED and use
a non-blocking send with rollback on queue-full to avoid resource leaks.


(cherry picked from commit 92979706d7)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2026-04-14 13:13:40 +08:00
Zhou Xiao 24a45a173f fix(ble_log_console): exclude from idf-ci pytest collection to fix CI
idf-ci discovers pyproject.toml pytest config and runs a separate
collection pass with --target all, which finds 0 target tests and
raises RuntimeError. Add to .idf_ci.toml exclude_dirs instead of
deleting tests. Restore all 227 unit tests with lint/mypy fixes.
2026-04-07 13:15:03 +08:00
Zhou Xiao 907488e323 docs(ble_log): update README for multi-buffer transport and removed modules
Reflect changes from dev/ble-log-202603: ping-pong to multi-buffer
transport (4 buffers/LBM), renamed Kconfig options (LBM_TRANS_SIZE →
LBM_TRANS_BUF_SIZE with new defaults), always-enabled checksum and
enhanced statistics, UART redirection support, UHCI Out removal,
SPI Out deprecation, and updated memory estimation.
2026-04-07 13:13:51 +08:00
Zhou Xiao 39e0143bf8 feat(bt): add BT_LOG_CRITICAL_ONLY bandwidth-optimized log mode
Add Kconfig options for bandwidth-optimized logging via the BLE Log
Async Output system. When enabled, controller log levels default to 2
and host/mesh log encoding is auto-selected.

- BT_LOG_CRITICAL_ONLY parent: selects BLE_LOG_ENABLED + compression
- BT_LOG_CRITICAL_ONLY_CTRL: supports both NimBLE and non-NimBLE (C3)
  controllers with default level override
- BT_LOG_CRITICAL_ONLY_HOST: host-agnostic, selects compressed log
  for Bluedroid conditionally
- BT_LOG_CRITICAL_ONLY_MESH: placeholder for mesh log encoding
- Guards against BT_STACK_NO_LOG conflict
2026-04-07 13:13:47 +08:00
Zhou Xiao bf2422136d change(bt): consolidate BLE log Kconfig into common/Kconfig.in
Move per-chip BLE log Kconfig options (esp32c2/c5/c6/h2) into
components/bt/common/Kconfig.in for single-source-of-truth configuration.

Restructure menu as "BT Logs" with "Log Sources" sub-menu containing
controller log config options. Controller log output mode choice defaults
to BLE Log v2 when BLE_LOG_ENABLED, with legacy mode as deprecated
fallback. Migrate wrap_panic_handler and task_wdt_user_handler configs
as well since they depend on BT_LE_CONTROLLER_LOG_ENABLED.
2026-04-07 13:13:32 +08:00
Zhou Xiao cc75f2ac2f change(ble_log): update ble log module description 2026-04-07 13:13:07 +08:00
Zhou Xiao 9469209c2e feat(bt/ble_log): add cross-pool buffer fallback in LBM acquire
Replace the two-step acquire() + get_trans() flow with a unified
acquire_trans() that iterates all candidate pools. When a pool's
buffers are exhausted, the lock is released and the next pool is
tried, enabling load balancing across pools instead of only
resolving lock contention.
2026-04-07 13:13:03 +08:00
Zhou Xiao 184f5d2392 fix(bt/ble_log): use atomic_load for inflight_peak in buf_util report
Replace __atomic_exchange_n with __atomic_load_n in
ble_log_emit_buf_util() so inflight_peak reports the all-time peak
since init rather than resetting to zero after each report.
2026-04-07 13:12:49 +08:00
Zhou Xiao 7539bbff9d feat(ble_log): migrate from ping-pong to multi-buffer transport
Migrate all LBM, RT, and peripheral backend code from 2-buffer
ping-pong to 4-buffer transport with bitmask index arithmetic.

LBM changes:
- Init sets owner on each transport buffer
- get_trans/flush/dump use (idx+1) & (cnt-1) instead of !idx
- get_trans/flush use __atomic_load_n(ACQUIRE) for prph_owned
- New ble_log_write_buf_util() emits BUF_UTIL telemetry frames,
  exchange peak with 0 to avoid stale baseline after bursts

RT changes:
- Queue depth uses unified BLE_LOG_TRANS_TOTAL_CNT
- rt_queue_trans uses __atomic_store_n for prph_owned, tracks
  per-LBM inflight count and peak via lock-free CAS
- ISR path captures pxHigherPriorityTaskWoken and yields

Peripheral changes:
- All tx_done callbacks: decrement inflight before releasing
  prph_owned with __atomic_store_n(RELEASE)
- SPI/UART send_trans error paths: decrement inflight and
  release prph_owned to allow retry on next get_trans pass
- Dummy send_trans: recycle buffer immediately (pos=0, decrement
  inflight, release prph_owned) since no DMA hardware to wait for
- Redir LBM upgraded to 4-buffer with owner and reset support
- All peripherals implement ble_log_prph_reset_util_counters()
2026-04-07 13:12:45 +08:00
Zhou Xiao 1fefea44a3 feat(ble_log): define multi-buffer transport types and Kconfig
Replace ping-pong (2-buffer) transport constants with configurable
multi-buffer (4-buffer) types. Add buffer utilization reporting types,
unified queue depth derivation macros, and compile-time guards.

Rename Kconfig options to total-per-LBM semantics:
- BLE_LOG_LBM_TRANS_SIZE (512) -> BLE_LOG_LBM_TRANS_BUF_SIZE (2048)
- BLE_LOG_LBM_LL_TRANS_SIZE (1024) -> BLE_LOG_LBM_LL_TRANS_BUF_SIZE (2048)

Key type changes:
- ble_log_prph_trans_t: volatile bool -> plain bool (atomic ops used),
  add void *owner back-reference
- ble_log_lbm_t: trans array sized to BLE_LOG_TRANS_BUF_CNT (4),
  add trans_inflight and trans_inflight_peak counters
- BLE_LOG_TRANS_BUF_CNT replaces BLE_LOG_TRANS_PING_PONG_BUF_CNT
- New ble_log_buf_util_t for buffer utilization telemetry
- _Static_assert guards for divisibility, power-of-2, index limits
2026-04-07 13:12:39 +08:00
Zhou Xiao 888ed2ca70 feat(ble_log): consume frame_sn on loss path and bump BLE_LOG_VERSION
Add BLE_LOG_GET_FRAME_SN() on the buffer-full loss path so the SN
counter advances even when frames are dropped. This allows the console
to detect firmware-side buffer loss via SN gaps. Bump BLE_LOG_VERSION
to reflect the semantic change.
2026-04-07 13:10:37 +08:00
Zhou Xiao c79fba9a76 feat(bt/ble_log): implement UART redirection stream write
Introduce stream write API with deferred frame encapsulation for UART
redirection on port 0. Redirected data is now properly framed (header +
payload + checksum) instead of being sent as raw ASCII, preventing frame
parser sync oscillation on the receiver.

- Add stream_seal/stream_write/stream_flush in ble_log_lbm.c
- Add BLE_LOG_SRC_REDIR source and BLE_LOG_UART_REDIR_ENABLED gate
- Simplify redir_uart_tx_chars and timer callback to use stream API
- Flush pending stream data in ble_log_prph_deinit
- Make get_trans static (no external callers after refactor)
- Move UART wrap linker flags outside CONFIG_BT_ENABLED guard
- Default UART DMA peripheral when SOC_UHCI_SUPPORTED
- Default baud rate 921600 -> 3000000
2026-04-07 13:10:32 +08:00
Zhou Xiao f2669b3344 fix(bt/ble_log): fix flush timer callback in UART redirect module
Fix incorrect esp_timer callback signature, replace blocking mutex
with non-blocking trylock, add prph_inited guard, correct timer
period from 100us to 1s, and remove fragile idle-based flush logic.
2026-04-07 13:10:29 +08:00
Zhou Xiao 60d8948fef fix(bt/ble_log): use aligned counters in ble_log_stat_mgr_t
Replace embedded ble_log_enh_stat_t (packed wire struct) inside
ble_log_stat_mgr_t with flat uint32_t counters. Natural 4-byte
alignment ensures each load/store compiles to a single l32i/s32i
on Xtensa/RISC-V, making individual field access atomic without
locks.

Build the packed wire format on the stack inside a critical section
in ble_log_write_enh_stat() so the full snapshot is consistent.
2026-04-07 13:10:25 +08:00
Zhou Xiao 031c9bb374 change(bt/ble_log): make checksum and enhanced statistics always enabled
Remove CONFIG_BLE_LOG_PAYLOAD_CHECKSUM_ENABLED conditional compilation
-- payload checksum is always computed over the full frame.

Remove CONFIG_BLE_LOG_XOR_CHECKSUM_ENABLED conditional -- XOR checksum
is always used; delete the sum checksum dead code path.

Remove CONFIG_BLE_LOG_ENH_STAT_ENABLED conditional -- enhanced
statistics (frame/byte counters per source) are always active.

Remove incorrect select on choice symbol
BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 from BLE_LOG_IS_ESP_CONTROLLER.
2026-04-07 13:10:20 +08:00
Zhou Xiao 817fd9ea7a change(bt/ble_log): deprecate legacy SPI log output module
Move ble_log_spi_out.c and ble_log_spi_out.h into a deprecated/
subdirectory under components/bt/common/ble_log/. Extract all
BT_BLE_LOG_SPI_OUT_* Kconfig options into deprecated/Kconfig.in
with an if-block to reduce depends-on repetition, sourced from
ble_log/Kconfig.in inside a "Legacy SPI Log Output (Deprecated)"
menu. Add mutual exclusion with BLE_LOG_ENABLED so that the legacy
SPI Out and the new BLE Log Module cannot be enabled simultaneously.
Update CMakeLists.txt source path and add deprecated/include to
include dirs so existing callers are unaffected. The BLE Log
Module's SPI Master DMA peripheral transport is the replacement.
2026-04-07 13:10:16 +08:00
Zhou Xiao 374b9a4a63 change(bt/ble_log): remove BLE Log UHCI Out module
Delete ble_log_uhci_out.c and its header. Remove the UHCI Out source
from CMakeLists.txt and all BT_BLE_LOG_UHCI_OUT_* Kconfig options.
Remove per-chip BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED Kconfig and
all UHCI Out caller references in esp32c5/c6/h2 controller bt.c.
Update ble_log_console README to reference the new BLE Log Module
UART DMA config. The functionality is superseded by the BLE Log
Module's UART DMA peripheral transport.
2026-04-07 13:10:08 +08:00
zhiweijian bf804b2181 change(ble/bluedroid): Disable the built-in Bluedroid cryptographic implementation 2026-03-31 00:06:16 +08:00
ShenWeilong 790c71f79a change(bt): use BT_SMP_CRYPTO_STACK_MBEDTLS to select bt cryption lib 2026-03-31 00:06:16 +08:00
Jiang Jiang Jian 14cb9663f2 Merge branch 'fix/ble_hci_log_direction_v5.3' into 'release/v5.3'
feat(ble_log): encode HCI direction in ble_log pipeline (v5.3)

See merge request espressif/esp-idf!46300
2026-03-25 20:51:47 +08:00
Jiang Jiang Jian a50db17cc2 Merge branch 'feat/ble_bluedroid_log_full_compression_enable_v5.3' into 'release/v5.3'
feat(ble_mesh): enable log full compression function for bluedroid host (v5.3)

See merge request espressif/esp-idf!46153
2026-03-25 20:51:36 +08:00
Zhou Xiao 034342fd5e feat(ble_log): encode HCI direction in ble_log pipeline
Add ble_log_write_hci macro that encodes upstream/downstream direction
in MSB of HCI type byte. Update all 4 callsites (NimBLE + Bluedroid)
to use the new macro. Parser reads MSB to determine direction;
backward compatible (old firmware MSB=0 defaults to "sent").


(cherry picked from commit 8fd5dbb730)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2026-03-10 14:59:48 +08:00
Rahul Tank d24838f13d fix(blufi): Handle flattened ATT write payloads correctly in NimBLE BLUFI host 2026-03-04 11:47:25 +05:30
Luo Xu 0df48ce990 feat(ble): update log compression for bluedroid
(cherry picked from commit 05783fafd7)

Co-authored-by: luoxu <luoxu@espressif.com>
2026-03-02 09:43:17 +08:00
Luo Xu 381196774c feat(ble_mesh): enable log full compression function for bluedroid host
(cherry picked from commit 4cf88ce078)

Co-authored-by: luoxu <luoxu@espressif.com>
2026-03-02 09:43:17 +08:00
Rahul Tank 32cd231a95 fix(nimble): Bugfixes for various issues 2026-02-16 11:22:53 +05:30
luoxu 7aa71b48e5 feat(ble_mesh): update log compression for ble mesh lib 2026-02-06 11:14:07 +08:00