Repository navigation
refactor(rmt_rx): telemetry singleton + root-cause S3 DMA fallback (#3591) - #3600
Merged
Merged
Conversation
… 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]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdates 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. ChangesRMT5 RX DMA Fix and Telemetry Refactor
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
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
This was referenced Jul 5, 2026
This was referenced Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Telemetry consolidation (addresses reviewer note on unconditional BSS globals)
The scattered
g_rmtrx_*volatile globals are now fields of oneRmtRxDebugstruct reached viafl::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 thel32r: literal placed after uselink failure.#3591 — S3 RMT-RX DMA "silent arm failure" root-caused
New
begin_dbg+ accumulatingdma_tally+dma_fail_wheretelemetry 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% atheap_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
14000while the pool was14336. 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 samekDmaRxSymbolsconstant 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