Commit Graph

5017 Commits

Author SHA1 Message Date
Jiang Jiang Jian
15085fd29c Merge branch 'bugfix/fix_some_bt_coex_bugs_v5.2' into 'release/v5.2'
fix(coex): fix some esp32 coexistence bugs (Backport v5.2)

See merge request espressif/esp-idf!47406
2026-04-12 14:56:36 +08:00
Island
10e699212d Merge branch 'change/ble_update_lib_20260409_v5.2' into 'release/v5.2'
change(ble): [AUTO_MR] 20260409 - Update ESP BLE Controller Lib (5.2)

See merge request espressif/esp-idf!47415
2026-04-10 15:43:22 +08:00
Island
8d2bfb58e4 Merge branch 'bugfix/fix_ble_pair_fail_v5.2' into 'release/v5.2'
fix(bt/bluedroid): fix BLE SMP pairing failure on BLE-only devices when using defalut param (5.2)

See merge request espressif/esp-idf!47397
2026-04-10 11:13:50 +08:00
Zhao Wei Liang
fcfeaaeb4a feat(ble): add adv tx options on ESP32-H2
(cherry picked from commit 8ef46541cd)

Co-authored-by: zhaoweiliang <zhaoweiliang@espressif.com>
2026-04-10 10:22:40 +08:00
Zhao Wei Liang
347a5a14dd feat(ble): add adv tx options on ESP32-C6
(cherry picked from commit e85bb5cca8)

Co-authored-by: zhaoweiliang <zhaoweiliang@espressif.com>
2026-04-10 10:22:40 +08:00
Zhao Wei Liang
437a32c9b1 change(ble): [AUTO_MR] Update lib_esp32c6 to c9fbba6f
(cherry picked from commit 24d0f0fad1)

Co-authored-by: zhaoweiliang <zhaoweiliang@espressif.com>
2026-04-10 10:22:40 +08:00
Zhao Wei Liang
9540ae562c change(ble): [AUTO_MR] Update lib_esp32h2 to c9fbba6f
(cherry picked from commit 9bfcc76221)

Co-authored-by: zhaoweiliang <zhaoweiliang@espressif.com>
2026-04-10 10:22:40 +08:00
linruihao
7e36a1ad5a fix(coex): fix some esp32 coexistence bugs
- fix ble scan may restart twice in coex scenarios
- fix bredr page/pscan coex request/release not match
- fix bredr incorrect inquiry length calculation
- update bredr page/inquiry pti
- add coex pti protection for entire page/inquiry event
2026-04-10 10:12:03 +08:00
Zhang Hai Peng
4e9392ecd8 fix(bt/bluedroid): fix BLE SMP pairing failure on BLE-only devices when using default param
(cherry picked from commit 74a053bd4e)

Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
2026-04-09 11:53:18 +08:00
Jin Cheng
50e3d7e488 fix(bt/bluedroid): moved L2CAP length check into start packets only 2026-04-08 20:42:41 +08:00
Jon Gilmore
811d0f4876 fix(bt/bluedroid): fix ACL reassembly dropping valid continuation fragments
The minimum length check in `reassemble_and_dispatch()` applied the START packet minimum (`HCI_ACL_PREAMBLE_SIZE + L2CAP_LENGTH_SIZE` = 8 bytes) to **all** ACL packets, including continuation fragments. Continuation fragments only carry the 4-byte ACL preamble (handle + length) with no L2CAP header, so small but valid continuations (5-7 bytes) were incorrectly rejected as "too short."

This caused the first L2CAP PDU in a rapid burst of BLE GATT indications to be silently dropped. The partial reassembly was orphaned, then discarded when the next indication's START fragment arrived, producing:

```
E BT_HCI: ACL packet too short (len=5)
W BT_HCI: reassemble_and_dispatch found unfinished packet for handle with start packet. Dropping old.
```

Parse the ACL preamble first (requires only 4 bytes) to determine the boundary flag, then apply the L2CAP length check only to START packets. Continuation packets are now accepted with the correct minimum of `HCI_ACL_PREAMBLE_SIZE` (4 bytes).

- ESP32-S3 connected to a BLE peripheral that fragments indications at 40 bytes per L2CAP PDU
- Peripheral sends 8+ indications within ~200ms (burst of state changes)
- The final continuation fragment of the first indication is small (5-6 bytes after type stripping)
- 100% reproducible on every burst; confirmed on ESP-IDF 5.5.3, 5.5.4, and 6.0.0

Verified on ESP32-S3 with a Sub-Zero wall oven (SO3050PESP, firmware 8.5):
- **Before fix:** First indication in every burst lost (ACL reassembly failure)
- **After fix:** All indications in burst delivered correctly, including when the final continuation fragment is 5-6 bytes

Closes https://github.com/espressif/esp-idf/issues/18414
2026-04-08 20:42:41 +08:00
Rahul Tank
bb79869454 Merge branch 'bugfix/fix_dtm_end_test_v5.2' into 'release/v5.2'
fix(nimble): Fix DTM test end packet count parsing (v5.2)

See merge request espressif/esp-idf!47335
2026-04-08 14:26:49 +05:30
Wang Meng Yang
bc2a328c96 Merge branch 'bugfix/btm_sec_free_dev_v5.2' into 'release/v5.2'
fix(bt): avoid deleting device record on partial transport cleanup(v5.2)

See merge request espressif/esp-idf!47310
2026-04-08 14:52:03 +08:00
Island
d4ce96fa47 Merge branch 'dev/ble-log-202603_v5.2' into 'release/v5.2'
dev: BLE Log 202603 (5.2)

See merge request espressif/esp-idf!47273
2026-04-08 10:32:35 +08:00
Rahul Tank
25cbc767e5 fix(nimble): Fix DTM test end packet count parsing 2026-04-07 15:47:06 +05:30
Jiang Jiang Jian
8602034bcf Merge branch 'bugfix/spp_deinit_v5.2' into 'release/v5.2'
fix(bt/bluedroid): flushed all the DM PM at the end of SPP deinit (v5.2)

See merge request espressif/esp-idf!47293
2026-04-07 14:34:37 +08:00
Island
52ad38feef Merge branch 'feat/use_common_config_to_sel_crypt_lib_v5.2' into 'release/v5.2'
Feat/use common config to sel crypt lib (v5.2)

See merge request espressif/esp-idf!46404
2026-04-07 12:12:03 +08:00
yangfeng
e7d5f1bbe8 fix(bt): avoid deleting device record on partial transport cleanup 2026-04-07 12:03:29 +08:00
Zhou Xiao
da207b1706 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 11:52:43 +08:00
Zhou Xiao
019ec12398 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 11:51:09 +08:00
Zhou Xiao
b5b54570b2 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 11:51:03 +08:00
Zhou Xiao
b03dce2530 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 11:50:49 +08:00
Zhou Xiao
5dade89132 change(ble_log): update ble log module description 2026-04-07 11:50:32 +08:00
Zhou Xiao
718561462c 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 11:50:25 +08:00
Zhou Xiao
c00bead568 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 11:49:58 +08:00
Zhou Xiao
bf6577ccf1 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 11:49:52 +08:00
Zhou Xiao
fcb4e4f77d 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 11:49:43 +08:00
Zhou Xiao
30ad222662 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 11:44:44 +08:00
Zhou Xiao
490acad912 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 11:44:38 +08:00
Zhou Xiao
24a368974e 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 11:44:32 +08:00
Zhou Xiao
992b2f75c5 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 11:44:26 +08:00
Zhou Xiao
812edd64c8 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 11:44:21 +08:00
Zhou Xiao
54a5fe04e6 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 11:44:14 +08:00
Zhou Xiao
1fee2c3a0f 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 11:43:22 +08:00
Jin Cheng
a8304b772f fix(bt/bluedroid): flushed all the DM PM at the end of SPP deinit 2026-04-07 09:15:20 +08:00
Island
8a289d2c78 Merge branch 'bugfix/fix_privacy_callback_trigger_multipe_times_v5.2' into 'release/v5.2'
Bugfix/fix privacy callback trigger multiple times (5.2)

See merge request espressif/esp-idf!47254
2026-04-03 20:35:52 +08:00
Zhi Wei Jian
1a532094a0 fix(ble/bluedroid): Fixed privacy callback triggering multiple times
(cherry picked from commit 5272b7e75b)

Co-authored-by: zhiweijian <zhiweijian@espressif.com>
2026-04-03 14:02:33 +08:00
Astha Verma
9fe3137223 fix(nimble): fix null dereference of ble_gatts_conn_aware_states after gatts stop 2026-04-03 09:48:41 +05:30
cjin
3f32fefaec feat(ble): supported ble mempool run time allocation for esp ip chips 2026-04-02 16:40:03 +08:00
Jin Chen
953692616a feat(ble): make env init function cuttable on ESP32-C2
(cherry picked from commit 5ec82368ba)

Co-authored-by: cjin <jinchen@espressif.com>
2026-04-02 16:36:22 +08:00
Jin Chen
2502afa094 change(ble): [AUTO_MR] Update lib_esp32h2 to 913c704d
(cherry picked from commit a8d705ff7a)

Co-authored-by: zhaoweiliang <zhaoweiliang@espressif.com>
2026-04-02 16:36:22 +08:00
Jin Chen
8e067d416f change(ble): [AUTO_MR] Update lib_esp32c2 to b8594335
(cherry picked from commit a2ef5c0ff9)

Co-authored-by: zhaoweiliang <zhaoweiliang@espressif.com>
2026-04-02 16:36:22 +08:00
Jin Chen
ef9c3a7972 change(ble): [AUTO_MR] Update lib_esp32c6 to 913c704d
(cherry picked from commit 06010a8b79)

Co-authored-by: zhaoweiliang <zhaoweiliang@espressif.com>
2026-04-02 16:36:22 +08:00
Wang Meng Yang
55e88b4e27 Merge branch 'bugfix/improve_spp_hid_v5.2' into 'release/v5.2'
fix(bt/bluedroid): fixed multiple high-severity issues from AI code review in SPP & HID (v5.2)

See merge request espressif/esp-idf!47148
2026-04-02 14:24:23 +08:00
Sumeet Singh
4c30f20afb feat(nimble): Update blecent example README.md with EATT documentation 2026-04-02 06:57:07 +05:30
Rahul Tank
e8e60bb6cf Merge branch 'bugfix/nimble_example_fixes_v5.2' into 'release/v5.2'
fix(nimble): Address nimble example issues (v5.2)

See merge request espressif/esp-idf!47075
2026-04-01 15:42:52 +05:30
Island
1e07f40a93 Merge branch 'bugfix/fix_some_bluedroid_bugs_260121_v5.2' into 'release/v5.2'
Bugfix/fix some bluedroid bugs 260121 (5.2)

See merge request espressif/esp-idf!46980
2026-04-01 11:45:16 +08:00
luoxu
99c115e259 remove(ble_mesh): deprecate the tinycrypt library within the Bluetooth Mesh component 2026-04-01 00:21:39 +08:00
zhiweijian
aada9ef228 change(ble/bluedroid): Disable the built-in Bluedroid cryptographic implementation 2026-04-01 00:21:39 +08:00
ShenWeilong
1286301e57 change(bt): use BT_SMP_CRYPTO_STACK_MBEDTLS to select bt cryption lib 2026-04-01 00:21:39 +08:00