Skip to content

refactor(rmt_rx): telemetry singleton + root-cause S3 DMA fallback (#3591) - #3600

Merged
zackees merged 1 commit into
masterfrom
fix/rmtrx-telemetry-singleton-dma-3591
Jul 5, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/rmtrx-telemetry-singleton-dma-3591

Conversation

@zackees

@zackees zackees commented Jul 5, 2026 •

Copy link
Copy Markdown
Member

Telemetry consolidation (addresses reviewer note on unconditional BSS globals)

The scattered g_rmtrx_* volatile globals are now fields of one RmtRxDebug struct reached via fl::Singleton<RmtRxDebug> — lazily constructed on first RX-channel creation, so no BSS is reserved unless a capture runs. The IRAM ISR reaches it through a cached member pointer (mDebug), which emits no absolute-address literal — so the telemetry is now IRAM-safe on Xtensa too, removing the #if defined(__riscv) gate #3596 needed after the l32r: literal placed after use link failure.

#3591 — S3 RMT-RX DMA "silent arm failure" root-caused

New begin_dbg + accumulating dma_tally + dma_fail_where telemetry read the DMA outcome despite suppressed logs. Verdict on S3: dma_tally = [requested=16, armedOK=0, fellback=0, armFail=16] — the shared DMA slot is granted (no TX contention), but the arm fails 100% at heap_caps_malloc (dma_fail_where=1). The 14336-symbol pool + matching user buffer needs ~112 KB contiguous DMA-internal RAM, unavailable under WiFi. begin() then retries non-DMA and every capture passes — the "failure" was a silent-but-correct memory-pressure fallback.

Latent bug fixed: the DMA user buffer was sized 14000 while the pool was 14336. If it ever allocated, the DMA engine would overrun it (bench-confirmed StoreProhibited/Cache-error when shrunk below the pool). User buffer now derives from the same kDmaRxSymbols constant as the pool.

The non-DMA ping-pong path (en_partial_rx) captures every S3 driver reliably; DMA offers only CPU offload here, so enabling it on S3 is deferred rather than forced with a fragile small pool.

Validation

WROOM RMT/I2S/UART 4/4, C6 SPI/UART 4/4, S3 UART/LCD_CLOCKLESS/LCD_SPI/RMT 4/4 (single-pass). Host 349/349, lint clean, esp32dev/c6/s3 compile clean.

Closes #3591.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved IR receiver stability by resizing and aligning the DMA capture buffer.
    • Reduced the chance of capture failures by hardening DMA allocation and fallback handling.
    • Improved diagnostic tracking for receive operations, including clearer capture counts and error reporting.

… root-cause S3 DMA fallback (#3591)

Telemetry
- The scattered `g_rmtrx_*` volatile globals (wait/max/first-symbols,
  callback raw-symbol probes) reserved BSS unconditionally. They are now
  fields of one `RmtRxDebug` struct reached via `fl::Singleton<RmtRxDebug>`
  — lazily constructed on first RX-channel creation, so nothing is
  reserved unless a capture actually runs.
- The ISR reaches the struct through a cached member pointer (mDebug)
  instead of a global symbol. A member deref emits no absolute-address
  literal, so the telemetry is now IRAM-safe on Xtensa too — this
  removes the `#if defined(__riscv)` gate that #3596 had to add after
  the "l32r: literal placed after use" link failure. Telemetry now works
  on every ESP32 variant.

#3591 — S3 RMT-RX DMA "silent arm failure" root-caused
- New begin()/arm telemetry (begin_dbg + accumulating dma_tally +
  dma_fail_where) let the bench read the DMA outcome despite suppressed
  logs. Verdict on ESP32-S3: dma_tally = [requested=16, armedOK=0,
  fellback=0, armFail=16] — the shared DMA slot IS granted (no TX
  contention), but the arm fails 100% at heap_caps_malloc
  (dma_fail_where=1). The 14336-symbol pool + a matching user buffer
  needs ~112 KB of contiguous DMA-internal RAM, unavailable once WiFi is
  up. begin() then retries non-DMA and every capture passes — the
  failure was purely a silent, correct memory-pressure fallback.
- Fixed a latent size MISMATCH exposed while investigating: the DMA user
  buffer was sized 14000 while the descriptor pool was 14336. If that
  buffer ever allocated, the DMA engine would write past it (bench
  confirmed: StoreProhibited/Cache-error crash when the buffer is
  shrunk below the pool). The user buffer is now derived from the same
  kDmaRxSymbols constant as the pool, so they can never diverge.

The non-DMA ping-pong path (en_partial_rx) captures every S3 driver's
frames reliably; DMA offers only CPU offload here, so enabling it on
S3 is deferred rather than forced with a fragile small pool.

Verified: WROOM RMT/I2S/UART 4/4, C6 SPI/UART 4/4, S3
UART/LCD_CLOCKLESS/LCD_SPI/RMT 4/4 (single-pass). Host 349/349, lint
clean, esp32dev/c6/s3 compile clean.

Co-Authored-By: Claude Fable 5 <[email protected]>
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jul 5, 2026
@zackees
zackees merged commit eac5bd6 into master Jul 5, 2026
10 checks passed
@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4cd44446-4440-430f-ab92-4c51c0da880a

📥 Commits

Reviewing files that changed from the base of the PR and between 217ca30 and 1fe697b.

📒 Files selected for processing (1)
  • src/platforms/esp/32/drivers/rmt_rx/rmt_rx_5/rmt_rx_channel_5.cpp.hpp

📝 Walkthrough

Walkthrough

Updates the ESP32 RMT RX RMT5 channel implementation to correctly size the DMA RX capture buffer against the descriptor pool size, and replaces fixed global bench telemetry arrays with a single lazily-constructed RmtRxDebug singleton recorded across begin, wait, arm, and ISR callback code paths.

Changes

RMT5 RX DMA Fix and Telemetry Refactor

Layer / File(s) Summary
RmtRxDebug singleton and member wiring
src/platforms/esp/32/drivers/rmt_rx/rmt_rx_5/rmt_rx_channel_5.cpp.hpp
Includes the singleton header, defines RmtRxDebug replacing g_rmtrx_* globals, and caches an mDebug member pointing to fl::Singleton<RmtRxDebug>::instance().
DMA RX buffer sizing fix
src/platforms/esp/32/drivers/rmt_rx/rmt_rx_5/rmt_rx_channel_5.cpp.hpp
Introduces kDmaRxSymbols = 14336 and makes DMA_BUFFER_SIZE equal the DMA descriptor pool size, removing the previous independent 14000 sizing; latches failure telemetry on allocation error.
beginImpl() stage and DMA tally telemetry
src/platforms/esp/32/drivers/rmt_rx/rmt_rx_5/rmt_rx_channel_5.cpp.hpp
Records begin_dbg[]/dma_tally[] codes for DMA request init, shared-slot fallback, channel-creation failure, enable/skip/arm failures, and success.
wait() exit-reason telemetry
src/platforms/esp/32/drivers/rmt_rx/rmt_rx_5/rmt_rx_channel_5.cpp.hpp
Records exit modes, symbol counts, callback counts, first raw symbols, and max symbol count via mDebug instead of removed globals.
startReceive() and ISR callback telemetry
src/platforms/esp/32/drivers/rmt_rx/rmt_rx_5/rmt_rx_channel_5.cpp.hpp
Latches DMA rejection telemetry on rmt_receive() failure and records per-callback raw-symbol data in the IRAM ISR via self->mDebug, removing the RISC-V-only global telemetry branch.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant App as beginImpl()
  participant Arm as allocateAndArm()
  participant Rx as startReceive()
  participant ISR as rxDoneCallback()
  participant Wait as wait()
  participant Dbg as RmtRxDebug (singleton)

  App->>Dbg: reset begin_dbg[], tally dma_tally[0]
  App->>Arm: allocate DMA buffer (kDmaRxSymbols)
  Arm->>Dbg: log begin_dbg[3], dma_fail_where on failure
  App->>Rx: startReceive()
  Rx->>Dbg: log dma_fail_where, dma_receive_err on failure
  ISR->>Dbg: log cb_raw_symbols, cb_first_raw
  Wait->>Dbg: log wait_dbg[], received symbols, max_symbols
  Dbg-->>App: telemetry available via mDebug
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rmtrx-telemetry-singleton-dma-3591

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ESP32-S3: SPI/UART/LCD_CLOCKLESS/LCD_SPI loopback captures fail to arm (wait=-1) while RMT passes 4/4 (#3576 Phase 9 audit)

1 participant