Commit Graph
100 Commits
Author SHA1 Message Date
Zhou Xiao 327016d1a3 test(ble_log): add dedicated runtime dispatch test app
Extend the test peripheral with receipt timestamps and an auto-recycle
hook so runtime tests can observe handoff latency and sustain arrivals from
dispatch completion.

Add a standalone Unity app covering fixed first-submission deadlines,
callback-entry batch drain, shared ESP timer task fairness, periodic
timestamp light-sleep behavior, synchronous flush, dispatch latency,
deinit races, bounded inflight peaks, and timeout conversion at both
supported tick rates. Verify FIFO delivery and reject delayed-consumer and
extra-marker false positives.

Render BLE_LOG_RT_PERF lines in the performance log parser and
cross-reference the runtime and performance apps from their READMEs.
2026-08-27 16:16:38 +08:00
Zhou Xiao 620a3c90a9 refactor(ble_log): move runtime dispatch to esp_timer
Replace the dedicated BLE Log FreeRTOS task with a deferred esp_timer
batch dispatch. The first submission anchors a one-shot 1 ms deadline;
the callback drains the queue depth captured at entry and schedules the
next fixed defer only for arrivals left behind. Later submissions cannot
move the current deadline, and no fixed batch-size cap limits throughput.

Protect queue and timer lifetime with runtime references. Drain queued
submissions before ble_log_lbm_flush_all_trans waits for transport
ownership to return, so synchronous flush does not depend on the deferred
alarm firing.

Keep the defer alarm as a light-sleep wake source and select
ESP_TIMER_IN_IRAM. Timestamp synchronization uses the shared ESP timer task
with skipped unhandled events, so it neither wakes light sleep nor replays
missed periods. Retain legacy task and trigger symbols as hidden no-op
sdkconfig compatibility options.
2026-08-27 16:16:38 +08:00
Zhou Xiao 5d989c4ce8 test(ble_log): add on-target test app for the version info frame
New ble_log_test app captures the runtime hook output through the test
peripheral and validates the version info frame: source code, BLE Log
version, a hex-valid idf commit that must be non-zero, per-lib commit
fields non-zero exactly when the matching lib is linked, and chip
model/revision matching esp_chip_info(). The README carries the
generated empty Supported Targets table to match the build-test
manifest.

The test drives transports via sustained writes instead of
ble_log_flush(): the flush window disables the module, so hook frames
written during a flush would be dropped.

Also move .build-test-rules.yml from ble_log_perf_test/ to the
test_apps/ root (one manifest entry per app, as elsewhere in ESP-IDF).
Both apps stay disabled until BLE Log test runners are available.

Verified: full esp32c6 build of the app; the build-test checker's own
parsing logic confirms the README table matches the manifest.
2026-08-21 22:35:46 +08:00
Zhou Xiao 4dfb8568e7 feat(ble_log): report build, lib and chip versions in a version info frame
Replace the 2-byte BLE Log info record with a 58-byte version info
frame (BLE_LOG_VERSION 5 -> 6; the abandoned branch that claimed the
version-6 slot frees it, so the overall bump stays 5 -> 6):

- idf build commit (12 bytes), injected at build time by
  register_ble_log_idf_commit() next to the other register_* helpers;
  the git probe is only trusted when the IDF tree itself is a
  repo/worktree, since rev-parse walks up parent directories
- controller, btdm_common, BLE Mesh and BLE Audio lib commits (10
  bytes each, zero-padded), every getter guarded by the exact
  condition that links its lib, so configs without the lib leave the
  field zero (no link errors)
- chip model and revision from esp_chip_info() at runtime

Lib strings are copied NUL-safely instead of assuming a fixed hash
length; the mesh commit is the substring after the last space of
bt_mesh_v11_commit_str. Frame layout is pinned by a static assert.

Verified on target: esp32, esp32c3, esp32c5 and esp32h4 boards (the
h4 run covers controller + btdm_common + mesh in one build); the
audio-enabled build is blocked by pre-existing esp_ble_audio compile
errors on this base (audio symbol verified with nm instead).
2026-08-21 22:35:46 +08:00
Zhou Xiao afc12706a0 refactor(ble_log): simplify timestamp sync scheduling 2026-08-20 16:41:29 +08:00
Zhou Xiao 33cddfae15 refactor(ble_log): remove obsolete unit test hooks 2026-08-20 15:33:02 +08:00
Zhou Xiao 68ece6c8b6 refactor(ble_log): close the lifecycle gate before teardown
Introduce a seq_cst closing gate shared by the runtime and the LBM:
submitters increment the reference count before checking the inited
flag, and deinit closes the gate and waits for the count to drain
before deleting tasks, timers, queues, or buffers. A producer either
observes shutdown or its reference is visible to the wait, which makes
ble_log_deinit safe while write APIs are still active.

Submitters no longer block on the queue while holding a reference: a
timeout-0 send that cannot queue recycles the transport so its data
survives for the next flush.

Extract ble_log_ref_count_try_acquire/wait into the utility layer and
gate every LBM writer through ble_log_lbm_ref_acquire. ble_log_deinit
now closes the LBM gate first (ble_log_lbm_close) instead of clearing
the enable flag.
2026-08-19 23:17:46 +08:00
Zhou Xiao ccbc94cacc refactor(ble_log): decouple runtime submission ownership
Move transport ownership from the runtime to the LBM: submit and
recycle now hand the peripheral-owned flag explicitly instead of the
runtime reaching back into LBM buffers. The submit path never blocks
producers - a transport that cannot be queued is recycled immediately
so its data survives for the next flush.

Cross-context ownership accesses go through explicit atomic helpers:
release-store on recycle pairs with acquire-loads in the flush paths,
and the inflight high-water mark stays a relaxed CAS-max (a plain
volatile update races the runtime hook's statistics reads).
2026-08-19 23:15:07 +08:00
Zhou Xiao a855a19e53 feat(ble_log): add BLE log perf test app with test transport
Add a Unity-based perf test app under ble_log/test_apps with two
separate measurement purposes:

- throughput: multi-task (write_hex x3) + LL task/HCI + ISR + compressed
  writers under 2 Mbps / 20 Mbps link caps, measuring system-wide
  throughput only
- cycle: single-writer write_hex / write_hex_ll / compressed writes at
  link=0, measuring per-frame cycles; the compressed path is split into
  the encode phase and the write_hex phase via test-only counters in
  ble_log_compression.c

Add the test-only transport (CONFIG_BLE_LOG_PRPH_TEST) that models DMA
ownership transfer and link-rate backpressure.
2026-08-14 18:34:47 +08:00
Zhou Xiao 30f93c0bc5 refactor(bt/ble_log): share SPI master pin config with IOMUX fallback
Move the SPI2 bus, transfer-size and DMA-alignment constants shared by the
full-duplex DMA and half-duplex HD transports into
ble_log_prph_spi_common.h. Pin numbers stay Kconfig-driven but fall back to
the target's native SPI2 IOMUX pins when configured negative, and default to
-1 so both transports use the native pins out of the box; any GPIO number
still overrides.
2026-08-13 00:14:13 +08:00
Zhou Xiao 1831a49a26 feat(bt/ble_log): add SPI master half-duplex transport
Add BLE_LOG_PRPH_SPI_MASTER_HD, a half-duplex SPI2 transport built on the
HD DMA protocol (slave HD ver2). Reuses the SPI master pin config shared
with the full-duplex DMA transport; the HD device queue is sized 2x for
ping-pong so the next transaction is queued while the previous DMA runs.
2026-08-13 00:14:13 +08:00
Zhou Xiao 3fa1901e45 refactor(bt/ble_log): unify trans recycling and GDMA burst alignment
Extract ble_log_lbm_recycle_trans() so every transport (UART DMA, SPI DMA,
dummy) recycles owned trans through one path; the HD transport builds on it.

Also prepare buffers for GDMA weighted arbitration: align transport buffers
to the 32-byte burst size, and disable the UART data burst (UHCI enforces
burst-size alignment on uhci_transmit() once weighted arbitration is enabled,
and UART bandwidth is baud-rate limited anyway).
2026-08-13 00:14:13 +08:00
Zhou Xiao 08252a2dd5 fix(bt): initialize BLE Log in host-only mode 2026-08-12 18:50:08 +08:00
Zhou Xiao aa48bd8f47 fix(esp_timer): prevent restart expiry race 2026-07-27 15:33:44 +03:00
Zhou Xiao 2fa434eb50 fix(bt): keep BLE log ISR state in internal RAM 2026-07-21 16:27:39 +08:00
Zhou Xiao a2876d304e fix(ble_log): use BIT64 over BIT to support 64-bit IO setup 2026-07-02 11:26:11 +08:00
Zhou Xiao de87877f39 fix(ble): fix OpenCode BLE UART bridge plugin for v1.17+ compatibility
- Add type assertion for event.type to bypass strict TS compilation errors
- Accept both 'permission.asked' and 'permission.updated' event types
- Add normalizePermissionEvent() to handle internal vs SDK event property
  format differences (pattern vs patterns, type vs permission fields)
- Add RawPermissionEvent type for loose event property parsing
- Add troubleshooting section and subdirectory auto-loading note to README
2026-06-18 11:03:18 +08:00
Zhou Xiao 897f3b2af1 change(ble): [AUTO_MR] Update lib_esp32c2 to 750d4902 2026-06-12 12:00:54 +08:00
Zhou Xiao 226a0483b1 change(ble): [AUTO_MR] Update lib_esp32c6 to a6519790 2026-06-10 16:46:35 +08:00
Zhou Xiao a43358587c change(ble): [AUTO_MR] Update lib_esp32c5 to a6519790 2026-06-10 16:46:35 +08:00
Zhou Xiao 8a744e8e93 change(ble): [AUTO_MR] Update lib_esp32h2 to a6519790 2026-06-10 16:46:35 +08:00
Zhou Xiao 835c947761 Merge branch 'docs/ble-uart-tutorial' into 'master'
docs(ble): added ESP-BLE-UART OpenCode Companion Guide

See merge request espressif/esp-idf!48862
2026-06-05 20:17:23 +08:00
Zhou Xiao 926111e721 docs(ble): add ESP-BLE-UART companion guide
Move the OpenCode companion guide into the ble_uart_service example.

Add English and Chinese Markdown guides with image assets.

Keep ESP-BLE-UART naming consistent across the example and bridge tooling.
2026-06-05 19:01:00 +08:00
Zhou Xiao cce5bd6e51 change(ble_log): reverted default ble log buffer size to 2048 bytes 2026-05-29 16:32:02 +08:00
Zhou Xiao 725e9ee162 change(ble_log): move spi tx callback to flash when spi isr in iram disabled 2026-05-25 15:18:31 +08:00
Zhou Xiao 1be9cb193f change(ble): [AUTO_MR] Update lib_esp32c6 to 4adb29e0 2026-05-21 15:27:54 +08:00
Zhou Xiao edac0a5e14 change(ble): [AUTO_MR] Update lib_esp32c5 to 4adb29e0 2026-05-21 15:27:54 +08:00
Zhou Xiao 9ace4422d9 change(ble): [AUTO_MR] Update lib_esp32h2 to 4adb29e0 2026-05-21 15:27:54 +08:00
Zhou Xiao 19b09de9fe docs(ble): update bridge docs and troubleshooting 2026-05-09 16:13:08 +08:00
Zhou Xiao 38fad3e7cb fix(ble): handle notification setup failures 2026-05-09 16:13:05 +08:00
Zhou Xiao ddff80f413 fix(ble): remove BLE service UUID scan filter 2026-05-09 16:13:02 +08:00
Zhou Xiao ad7189e7dd fix(ble): handle permission reply fallbacks 2026-05-08 12:29:35 +08:00
Zhou Xiao fa8ca07e58 fix(ble): fixed edge case issues from ai reviewer 2026-05-08 12:02:14 +08:00
Zhou Xiao 956299d988 feat(tools): improve ble uart reconnect ux 2026-05-08 11:31:51 +08:00
Zhou Xiao 0b07f41e5a feat(tools): add opencode ble uart bridge demo 2026-05-08 11:31:51 +08:00
Zhou Xiao 5636a96a72 feat(ble): add BLE UART daemon notify API 2026-04-27 16:33:56 +08:00
Zhou Xiao e209dd1c9e docs(ble): document BLE UART bridge usage 2026-04-27 15:57:49 +08:00
Zhou Xiao 0dd9c29a28 feat(ble): wire BLE UART bridge CLI 2026-04-27 15:57:49 +08:00
Zhou Xiao 379dfec8d7 feat(ble): add BLE UART daemon RPC API 2026-04-27 15:57:49 +08:00
Zhou Xiao 7cce3dec88 feat(ble): add BLE UART bridge console 2026-04-27 15:57:49 +08:00
Zhou Xiao 1de9ccf2ba feat(ble): add BLE UART bridge core 2026-04-27 15:57:49 +08:00
Zhou Xiao 836f87cc4a change(ble_log): update ble log version to 5 for esp ble controller log encoding indication 2026-04-27 12:09:54 +08:00
Zhou Xiao fed69540fa change(gitlab): change tools/ble code owner to bluetooth 2026-04-23 18:03:53 +08:00
Zhou Xiao a9b93ca0e5 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.
2026-04-07 19:02:14 +08:00
Zhou Xiao 59536316c9 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)
2026-04-07 15:31:50 +08:00
Zhou Xiao 1275b78ad6 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)
2026-04-07 15:31:40 +08:00
Zhou Xiao 3f8cfc5b1d 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)
2026-04-07 15:31:32 +08:00
Zhou Xiao 92979706d7 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.
2026-04-07 15:15:31 +08:00
Zhou Xiao 205bc49fd6 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-03-24 15:42:03 +08:00
Zhou Xiao aec896b6b9 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-03-24 00:28:37 +08:00
Zhou Xiao c223a3f835 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-03-23 23:44:26 +08:00
Zhou Xiao 391f7b7d8a docs(ble_log_console): update user guides for new features and run/build scripts
- Recommend run.sh/run.bat as primary launch method with Launch Screen description
- Add build.sh/build.bat section for standalone executable packaging
- Document buffer utilization screen (m key) and two-table stats layout (d key)
- Update menuconfig path, status panel format, and Kconfig option names
- Remove obsolete textual ModuleNotFoundError troubleshooting
- Simplify manual configuration to single toggle (defaults cover most cases)
- Fix ESP32 -> ESP chip in introduction
2026-03-23 20:36:52 +08:00
Zhou Xiao b5b886fd1e 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-03-23 20:10:38 +08:00
Zhou Xiao 99212e7fc4 change(ble_log): update ble log module description 2026-03-23 19:54:42 +08:00
Zhou Xiao 1cc66e3888 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-03-23 19:39:41 +08:00
Zhou Xiao ca920a8e8f feat(ble_log_console): add buffer utilization tracker and display
Add BufUtilTracker to record per-LBM inflight peak data, wire it
through StatsAccumulator and StatsUpdated message for thread-safe
delivery to the UI. Buffer utilization is displayed in a dedicated
BufUtilScreen accessible via the 'm' keybinding, separate from
the frame stats screen ('d').

Also reject false INIT_DONE frames with version==0 caused by
misaligned data during parser sync, preventing spurious stats resets.
2026-03-23 18:29:37 +08:00
Zhou Xiao d9a4d15203 feat(ble_log_console): add BUF_UTIL internal frame decoding
Add BUF_UTIL=5 to InternalSource, BufUtilPool enum, BufUtilResult
TypedDict, BufUtilEntry dataclass, and name resolution helpers.
Add decode branch in internal_decoder with pool/index extraction
from the packed lbm_id field. Tests cover valid decode, pool/index
extraction, and truncated payload handling.
2026-03-23 18:28:29 +08:00
Zhou Xiao 257c4db455 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-03-23 18:28:14 +08:00
Zhou Xiao 75eef04a2c 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-03-23 16:33:06 +08:00
Zhou Xiao fdd282da91 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-03-23 16:32:49 +08:00
Zhou Xiao a51d879d1b feat(ble_log_console): add CLI entry point, build scripts, and docs
- Click-based CLI entry point (console.py) with --port, --baudrate,
  --log-dir options and interactive Launch Screen when --port omitted
- Deprecation warning for --output CLI flag
- 'ls' subcommand to list saved capture files
- PyInstaller build scripts (build.sh, build.bat, build_exe.py)
- Convenience run scripts (run.sh, run.bat)
- README rewrite with installation, usage, architecture docs, and
  troubleshooting guide
- User guides in English and Chinese
- Remove old single-file ble_log_console.py
- Register new scripts in executable-list.txt
2026-03-23 02:10:56 +08:00
Zhou Xiao 02f1960e56 feat(ble_log_console): add Textual frontend and app wiring
TUI frontend built on Textual with thread-safe backend integration:

- Launch screen with port/baud/log-dir selection and auto-refresh
- Log view with scrollable RichLog and color-coded write methods;
  Rich markup escaped to prevent crash on bracket characters
- Stats screen split into two tables by time base:
  - Firmware Counters (since chip init): Written and Buffer Loss
  - Console Measurements (since console start): Average Throughput
    and Peak Write — each with separate frames and bytes sub-columns
  - Column widths constrained with min_width/max_width for stable layout
  - Division-by-zero guard when peak window is zero
- Shortcut screen overlay
- Status panel with sync state, checksum mode, and transport metrics;
  speed display uses named UART_BITS_PER_BYTE constant
- Main app wiring: UART reader thread with threading.Lock for serial
  access, frame parser pipeline, stats emission via StatsUpdated
  messages (including funnel snapshots via public accessor for
  thread-safe delivery), BackendStopped message for disconnect
- BackendStopped posted on open_serial failure (prevents stuck status)
- Select.BLANK guard for baud rate in launch screen
- Explicit None guards replace asserts in backend worker
- Wall-clock burst tracking for REDIR frames (no chip-side timestamp)
- SN gap alerts (FrameLossDetected) and traffic spike notifications
2026-03-23 02:10:45 +08:00
Zhou Xiao 9046c77e52 feat(ble_log_console): add backend with frame parser, stats, and data models
Modular backend for the BLE log console rewrite:

- Frame parser with sync state machine and checksum auto-detection
  (4 modes: XOR/Sum x Full/Header-only); handles incomplete frames
  during re-sync search when previously synced
- Internal frame decoder (INIT_DONE, ENH_STAT, FLUSH, INFO)
- Data models: SourceCode, FrameByteCount, FunnelSnapshot, LossType
- Stats package with composition-root StatsAccumulator orchestrating:
  - TransportMetrics (RX bytes, lifetime-average throughput)
  - FirmwareLossTracker / FirmwareWrittenTracker (ENH_STAT deltas
    with first-report absolute value initialization)
  - SNGapTracker (sliding window reorder-tolerant SN gap detection)
  - PeakBurstTracker (per-source sliding window burst density)
  - TrafficSpikeDetector (wire utilization spike detection)
  - Wall-clock burst tracker for non-timestamped sources (REDIR)
- Torn-read guard on ENH_STAT reports (baudrate-based plausibility)
  with prev-state update on discard to prevent cascading drops
- Console-local metrics (TransportMetrics, PeakBurstTracker) preserved
  across INIT_DONE resets; only ENH_STAT-coupled components reset
- UART transport with port validation and exclusive serial access
- Comprehensive test suite (17 test files, 223 tests)
2026-03-23 02:10:29 +08:00
Zhou Xiao 42f2aeedb7 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-03-23 02:10:12 +08:00
Zhou Xiao a181fc156d 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-03-22 01:20:05 +08:00
Zhou Xiao 45a475a627 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-03-20 17:41:36 +08:00
Zhou Xiao 4d193873f1 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-03-20 17:21:33 +08:00
Zhou Xiao 3eb2f57605 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-03-20 17:05:17 +08:00
Zhou Xiao e2d38955de 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-03-20 16:36:10 +08:00
Zhou Xiao d51892380b 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-03-20 16:01:35 +08:00
Zhou Xiao 8fd5dbb730 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").
2026-03-04 10:54:48 +08:00
Zhou Xiao 54e5f358bf change(ble): [AUTO_MR] Update lib_esp32c6 to 17fdc66e 2026-01-16 12:51:46 +05:30
Zhou Xiao 7631a6f158 change(ble): [AUTO_MR] Update lib_esp32c5 to 17fdc66e 2026-01-16 12:51:46 +05:30
Zhou Xiao 57b4819474 change(ble): [AUTO_MR] Update lib_esp32h2 to 17fdc66e 2026-01-16 12:51:46 +05:30
Zhou Xiao 78594e0f6e fix(ble): fixed use-after-free in bluedroid attp 2026-01-14 15:45:10 +08:00
Zhou Xiao 52c2bd2dd6 feat(ble): added sdkconfig to control ble host side hci log 2026-01-13 17:52:05 +08:00
Zhou Xiao 82ee820cf8 feat(ble): support ll log payload length limit for ble log v2 2026-01-13 17:52:00 +08:00
Zhou Xiao 52754b1aa4 change(ble): optimized os_mbuf_copydata thread safety protection 2026-01-13 17:51:15 +08:00
Zhou Xiao 69522eaedb change(ble): [AUTO_MR] Update lib_esp32c6 to acf48208 2026-01-08 17:25:57 +08:00
Zhou Xiao d61e0bf975 change(ble): [AUTO_MR] Update lib_esp32c5 to acf48208 2026-01-08 17:25:57 +08:00
Zhou Xiao 32b41c88e0 change(ble): [AUTO_MR] Update lib_esp32h2 to acf48208 2026-01-08 17:25:57 +08:00
Zhou Xiao 69ec8bc962 fix(ble): fixed cache error risk in ble log module 2026-01-04 13:45:37 +08:00
Zhou Xiao fc09e0f2da feat(ble): provide isr dispatch method option for ble log ts 2026-01-04 13:44:56 +08:00
Zhou Xiao 7ebf1c8d15 change(ble): [AUTO_MR] Update lib_esp32c2 to 9f051857 2025-12-29 17:30:39 +08:00
Zhou Xiao d1a5804de9 fix(ble): add esp timer trigger back for timestamp synchronization 2025-12-29 16:59:55 +08:00
Zhou Xiao 2b9c7471d0 fix(ble): added null pointer check in ble log ts submodule 2025-12-23 11:12:20 +08:00
Zhou Xiao d1d07eb60a fix(ble): added missed ts sync reset 2025-12-23 11:12:20 +08:00
Zhou Xiao c604afa272 feat(ble): added xor checksum for integrity check performance optimization 2025-12-23 11:12:14 +08:00
Zhou Xiao bb2b2d34ca feat(ble): supported ble log v2 hci log for Bluedroid host 2025-12-22 18:30:04 +08:00
Zhou Xiao 92eb5a34ae feat(ble): supported ble log v2 hci log for NimBLE host 2025-12-22 18:29:27 +08:00
Zhou Xiao 069262e513 fix(ble): added missed spin lock initialization 2025-12-18 14:14:35 +08:00
Zhou Xiao c61b0bef64 Merge branch 'feat/update_libphy_for_c5_c61' into 'master'
feat(phy): update libphy to fix c5/c61 reset

Closes WIFIBUG-1548 and BT-4156

See merge request espressif/esp-idf!43853
2025-12-03 19:25:59 +08:00
Zhou Xiao 6924b8b372 feat(ble): enabled lc get time for ceva controller 2025-11-25 18:01:36 +08:00
Zhou Xiao dc4e41fab8 fix(ble): put ble_log_write_hex in iram to avoid cache error 2025-11-24 18:43:23 +08:00
Zhou Xiao 5286451f2e feat(phy): ESP32-C5 ECO2/ECO3 coex and ESP32-C6 track reset
* C5 phy_version: 1 107, 8c534c84, Nov 17 2025
* C6 phy_version: 343, b513b46, Nov 14 2025
2025-11-17 14:25:26 +08:00
Zhou Xiao 3e0d005987 fix(ble): increase default ble log stack size for xtensa chips 2025-11-11 17:07:42 +08:00
Zhou Xiao 4ce499148e change(ble): [AUTO_MR] updated rom linker script for ESP32-C2 2025-11-05 11:24:44 +08:00
Zhou Xiao 0be8704ba6 change(ble): [AUTO_MR] Update lib_esp32c2 to eb2959f9 2025-11-05 11:24:43 +08:00
Zhou Xiao b525e6555b feat(ble): make ble log task stack size configurable 2025-11-03 17:46:21 +08:00
Zhou Xiao 777f21783b fix(ble): fixed hci event log when link layer logging is disabled 2025-10-30 11:44:37 +08:00