Repository navigation
feat: fix #2254 SPI long-strip bug + enable RMT RX DMA streaming - #2300
Conversation
Non-DMA ESP-IDF RMT RX fires its ISR exactly once per receive op, so a single rmt_receive() tops out at one mem-block fill (~4096 symbols, ≈170 WS2812B LEDs). Any autoresearch test on strips longer than that silently truncated to this cap — hiding real driver bugs past the boundary (see issue #2254). With ESP-IDF 5.3+ en_partial_rx and flags.with_dma=true, the receiver fires the ISR on every DRAM ping-pong fill. Each callback we copy the chunk into an accumulation buffer before the next DMA fill overwrites it, extending capture to the full buffer size. This lands the full plumbing for that path as an opt-in RxConfig::use_dma flag, defaulting off for compatibility: 1. RxConfig::use_dma — new opt-in field. 2. RmtRxChannelImpl::begin() rebuilds the ESP-IDF channel when the flag toggles (ESP-IDF bakes with_dma at rmt_new_rx_channel() time). 3. allocateRx() is called with use_dma=mUseDma so the memory manager routes the allocation through DRAM instead of the dedicated on-chip RX pool (which is only 192 words on ESP32-S3 — too small for the 1024-symbol mem_block_symbols DMA mode needs). 4. allocateDMA() acquires the single shared DMA slot on ESP32-S3. Graceful fallback to non-DMA mode when the slot is already held. 5. mem_block_symbols: 64 (non-DMA, hardware block) vs 1024 (DMA, DRAM ping-pong size). 1024 fits comfortably in internal SRAM and lets ESP-IDF accept the 1024-symbol user buffer rmt_receive() validates against capacity. 6. DMA ping-pong buffer allocated via heap_caps_malloc(DMA|INTERNAL) — fl::vector's default allocator can land in PSRAM on S3, which ESP-IDF rejects with "user buffer not in the internal RAM". 7. ISR (rxDoneCallback) now handles skip_signals inline in streaming mode: entire-chunk skips are dropped without terminating the receive op, partial skips advance past the skipped prefix and accumulate the tail. Non-DMA path still uses the legacy handleSkipPhase() wrapper. 8. begin() bypasses the synchronous handleSkipPhase() when mUseDma is set — the streaming ISR does it. Autoresearch harness opts in for all non-RMT driver tests (SPI, PARLIO, I2S, UART, LCD_*) where the TX path doesn't use RMT, so no shared-DMA contention. RMT loopback continues to use non-DMA mode. Expected end-state on ESP32-S3: `bash autoresearch --spi --strip-sizes 550` captures the full 13,200 symbols across ~13 partial-rx callbacks and the LED comparator verifies all 550 LEDs. See issue #2254. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
With mem_block_symbols == user_buffer_size (both 1024), ESP-IDF treats rmt_receive() as single-shot — ISR fires once, captures one fill, sets is_last=true. That's why the previous commit still capped at 4096 symbols (= 512 bytes decoded) for the 550-LED SPI test. Set mem_block_symbols = 256 so ESP-IDF sees user_buffer / mem_block = 4 and engages true ping-pong streaming: ISR fires every 256-symbol fill, accumulation copies each chunk, stream continues until the receiver detects idle (signal_range_max_ns). Also add visible FL_WARN telemetry of symbols/callbacks after wait() so regressions on long streams are diagnosable. See issue #2254. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Previous run with user_buf=1024 / mem_block_symbols=256 reported symbols=4096 callbacks=8 — partial_rx IS firing (8× ping-pong halves at 512 symbols each), but the stream stopped after 4 full-buffer fills. ESP-IDF isn't wrapping the user buffer indefinitely. Try a bigger user buffer (16384 symbols = 64 KB DMA|INTERNAL) so one rmt_receive() covers ~680 WS2812B LEDs. Keep mem_block_symbols=256 so partial callbacks still fire frequently during the fill. See issue #2254. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
When allocateAndArm() fails (e.g., rmt_receive rejects the buffer size as exceeding DMA capacity), begin() was tearing down the ESP-IDF channel but leaking both the DMA slot and the memory-manager registration. Subsequent begin() attempts then saw the DMA slot already held and fell back to non-DMA mode until the RxDevice was destroyed — defeating the streaming path permanently. Also resize user buffer to 4096 symbols + mem_block_symbols=1024 (4× ratio) so rmt_receive() accepts the request. See issue #2254. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Deep-dive testing on ESP32-S3 found that rmt_receive() caps the user buffer at 1024 symbols absolute (4 KB) regardless of mem_block_symbols ratio. Combined with ESP-IDF's 4× internal wrap during partial-rx streaming, total capture per rmt_receive() is 4096 symbols — identical to non-DMA single-shot mode. DMA streaming alone does NOT extend capture length on this chip. Extending capture past ~170 LEDs requires task-side re-submission of rmt_receive() when one completes, which is a bigger refactor (needs a dedicated RX task, notification from ISR on is_last, re-arm with minimal inter-receive gap). Not wired up in this branch. Keep the DMA infrastructure (RxConfig::use_dma, channel rebuild on toggle, memory-manager integration, DRAM-backed ping-pong buffer, in-stream skip_signals filter) as groundwork for that future change, but default the autoresearch harness opt-in to false since DMA mode alone offers no capture-length benefit today. Shrink DMA buffer to 1024 symbols (the maximum ESP-IDF accepts on S3) with mem_block_symbols=256 — if use_dma is enabled by hand, this config at least doesn't crash. See issue #2254. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Deep ESP-IDF source dive (rmt_rx.c:210-211, v5.5) revealed the real
cap formula:
num_dma_nodes = max(2, mem_block_symbols * 4 / 4095 + 1)
user_buffer_cap_bytes = num_dma_nodes * 4092
All my previous attempts used mem_block_symbols in [64, 1024], which
gave num_dma_nodes=2 and a cap of 8184 bytes = 2046 symbols. That's
why every buffer > 1024 symbols was rejected with "buffer size
exceeds DMA capacity".
Setting mem_block_symbols=14336 yields num_dma_nodes=14 and a
57288-byte cap — enough for a single rmt_receive() to capture 14000
symbols = ~583 WS2812B LEDs. No ISR re-submission needed. The
existing partial-rx ISR streams ~1023-symbol chunks into the
accumulation buffer across 14 callbacks, then is_last fires cleanly.
Memory cost: 14336 × 4 = 56 KB internal-RAM DMA descriptor buffer +
56 KB user buffer (heap_caps_malloc DMA|INTERNAL) = 112 KB. ESP32-S3
has ~320 KB internal SRAM available, so ~35% — acceptable for a
single-channel autoresearch test where no RMT TX is active.
Autoresearch opts in for non-RMT drivers (SPI, PARLIO, I2S, UART,
LCD_*). RMT loopback stays non-DMA to avoid contention for S3's
single shared DMA slot.
Credits: expert-rmt5-agent + general-purpose agent dove into the
ESP-IDF source and identified the DMA-node formula as the actual
gate. See issue #2254.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Root cause of issue #2254 Issue 2 on ESP32-S3: the SPI channel driver double-buffered 4 KB staging chunks, queued one SPI transaction at a time, and advanced the pipeline only when poll() ran. At wave8 encoding (24 bytes/LED), 4 KB = 170 LEDs per chunk. Any strip longer than that was split into multiple transactions with inter-chunk gaps dependent on poll() cadence. For WS2812B, any gap > 50 µs causes a reset latch. In a system where poll() can be preempted by WiFi/websocket tasks (MoonLight scenario), gaps easily exceed that, latching the first chunk's LEDs and leaving the tail dark — exactly the "LEDs not showing the right output" bug @ewowi reported. Bump staging_size to 16384 bytes in both the initial setup and the reinit paths. ESP-IDF's SPI DMA descriptor chain then produces continuous output for a single queued transaction covering up to ~680 LEDs. For strips longer than that, chunks still exist but the vast majority of real-world use cases fit in one transaction. Memory cost: 2 × 16 KB (double-buffer) = 32 KB internal SRAM per channel, up from 8 KB. Acceptable on ESP32-S3's 320 KB internal pool. Discovered while investigating the RMT RX capture limit — the RX wasn't at fault, the TX was. RX consistently reported 4096 symbols captured regardless of strip length from 100 to 550 LEDs, pointing at a fixed-size TX artifact. Tracing the SPI pipeline confirmed the 4 KB staging boundary. See issue #2254. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughDMA streaming mode support is added to ESP32 RMT RX devices via a new Changes
Sequence Diagram(s)sequenceDiagram
participant Init as Initialization
participant RMT as RMT RX Channel
participant DMA as DMA Manager
participant Buffer as Buffer Mgmt
participant ISR as ISR Handler
Init->>RMT: begin() with use_dma=true
RMT->>RMT: Check if use_dma changed
alt use_dma Changed
RMT->>RMT: Rebuild RMT channel
end
RMT->>DMA: Acquire shared DMA slot
alt DMA Slot Available
DMA-->>RMT: Slot granted
RMT->>Buffer: Allocate DRAM-backed DMA buffer
Buffer-->>RMT: Buffer ready
RMT->>RMT: Configure with_dma flag
else DMA Slot Unavailable
DMA-->>RMT: Fallback to non-DMA
RMT->>RMT: Disable use_dma & with_dma
end
RMT->>RMT: Start receive (DMA or legacy buffer)
note over ISR: During Reception
ISR->>ISR: Compute in-chunk skip offset (DMA mode)
ISR->>ISR: Drop fully-skipped chunks
ISR->>Buffer: Copy non-skipped tail to accumulator
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp (1)
1502-1561:⚠️ Potential issue | 🟡 MinorThree-way skip logic is correct — but the zero-symbol success case deserves stronger feedback.
The split (whole-chunk-dropped / partial-skip-straddle / no-skip) is sound. When
mSkipCounter >= received_count, the early return at line 1531 guarantees thatreceived_countis strictly greater thanmSkipCounterwhen you reach line 1550, making the subtraction safe.The case you flagged is valid: when
is_lastis set with the entire chunk inside the skip window (lines 1542–1546),mReceiveDoneis set to true butmSymbolsReceivedremains 0. Thewait()loop then exits immediately and returnsSUCCESSwith zero symbols. While the telemetry log at line 46 will showsymbols=0, returningSUCCESSwith no data is misleading — it signals completion without indicating that the transmission was entirely filtered away. If a caller configuredskip_signals ≥ total_expected_symbols, they'll getSUCCESSbut zero bytes on decode, which reads as normal completion rather than misconfiguration. Adding an explicit check inwait()or raising an error for the zero-symbol case would make this failure mode harder to miss.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp` around lines 1502 - 1561, The ISR can set mReceiveDone when an entire chunk was skipped (rxDoneCallback) leaving mSymbolsReceived==0 which makes wait() return SUCCESS with zero data; update the receive-completion semantics so zero-symbol completion is reported as an error: add a check in wait() that if mReceiveDone (or the completion flag set by rxDoneCallback) and mSymbolsReceived == 0 then return a failure status (or set a dedicated mReceiveError/mReceiveDoneError flag that wait() checks) instead of SUCCESS; alternatively, set that error flag inside rxDoneCallback when data->flags.is_last && mSymbolsReceived == 0 so wait() can propagate an error to callers. Ensure you reference rxDoneCallback, mReceiveDone, mSymbolsReceived and wait() when making the change.
🧹 Nitpick comments (5)
src/platforms/esp/32/drivers/spi/channel_driver_spi.cpp.hpp (1)
849-951: Fix looks correct; consider deduplicating the magic number and updating the stale 4KB comment.The 16 KB staging size is correctly mirrored in both
reinitSpiHardware(Line 856) andcreateChannel(Line 951), andbus_config.max_transfer_szis set accordingly in both paths, so ESP-IDF will allocate enough DMA descriptors to cover the full transaction. Math checks out: 16384 / 24 ≈ 682 WS2812B LEDs per transaction.Two small follow-ups that would harden maintenance:
- Extract the value into a single
constexpr(e.g.kSpiStagingBytes) shared betweenreinitSpiHardwareandcreateChannel, so the two call sites can never drift. If these ever disagree, the reinit path would silently configuremax_transfer_szinconsistently with the actual allocated staging buffers.- The comment at Line 1081 still says "Allocate staging buffers (4KB each, double-buffered)" — update it to reflect 16 KB (32 KB total per channel) to avoid misleading future readers, especially since the per-channel SRAM footprint is now a non-trivial part of the budget called out in the PR description.
Proposed change
- // Allocate staging buffers (4KB each, double-buffered) + // Allocate staging buffers (16 KB each, double-buffered → 32 KB per channel). + // Size chosen to fit ~680 WS2812B LEDs of wave8 output in a single SPI DMA + // transaction (see `#2254`). Internal SRAM + DMA-capable is required because + // PSRAM is not DMA-safe for SPI TX on ESP32-S3.And, e.g., at namespace scope:
+/// SPI staging buffer size (bytes). Double-buffered → 2× this per channel. +/// Sized to cover one wave8 transaction for ~680 WS2812B LEDs without chunking. +constexpr size_t kSpiStagingBytes = 16384;then replace both
const size_t staging_size = 16384;locals withkSpiStagingBytes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/platforms/esp/32/drivers/spi/channel_driver_spi.cpp.hpp` around lines 849 - 951, Both reinitSpiHardware and createChannel use the magic staging_size = 16384 value and the comment about "4KB" is stale; extract the staging size into a single constexpr (e.g. kSpiStagingBytes) at namespace scope and replace the local const size_t staging_size = 16384 in reinitSpiHardware and createChannel with that constant, and update the comment near the staging-buffer allocation (previously "4KB each, double-buffered") to reflect 16 KB (32 KB total per-channel) so the docs and both uses cannot drift.src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp (4)
1642-1643:mCallbackCountcomment flags this as temporary instrumentation.The member comment
// Debug: Count ISR callbacks (TEMP - for testing en_partial_rx)suggests this field was added for diagnosis and is not intended to stay. If you want to keep it (it is useful for thewait()telemetry), consider removing the "TEMP" marker so future maintainers don't prune it thinking it was a leftover. Alternatively, gate it behindFASTLED_RX_LOG_ENABLEDalongside the telemetryFL_WARNnoted on line 945.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp` around lines 1642 - 1643, The field volatile u32 mCallbackCount is marked as temporary instrumentation; either remove the "TEMP" marker in the comment if you intend to keep this telemetry for wait()/ISR callback counting, or conditionally compile and log it under the existing FASTLED_RX_LOG_ENABLED flag (same mechanism used for FL_WARN telemetry) so it isn't treated as throwaway debug code; update the comment to reflect permanence if kept, or wrap its use and any diagnostic references in the FASTLED_RX_LOG_ENABLED guard and ensure related logging uses FL_WARN as the other telemetry does.
1249-1295: DMA buffer allocation is sized and capped correctly.
heap_caps_malloc(..., MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL)is the right call for ESP32-S3 (forces internal SRAM, rejects PSRAM) and the reuse logic (free+realloc only when current capacity is insufficient) is efficient across repeatedbegin()calls.Minor nit: the zero-fill loop at lines 1286-1288 could be a
memset(mDmaCapableBuffer, 0, bytes)— slightly clearer intent and lets the compiler emit a block clear. Not worth blocking on.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp` around lines 1249 - 1295, The DMA buffer zero-fill loop in allocateAndArm() currently writes zeros element-by-element to mDmaCapableBuffer; replace that manual loop with a single memset(mDmaCapableBuffer, 0, bytes) after allocation (use the same bytes variable computed as hw_buffer_size * sizeof(RmtSymbol)) to make intent clearer and allow the compiler to optimize the block clear; keep the existing allocation/free/reuse logic around mDmaCapableBuffer and mDmaCapableBufferSize unchanged.
795-805: Silentuse_dmadowngrade — consider exposing state back to caller.If
RmtMemoryManager::allocateDMA()fails (another RMT channel holds the shared slot),mUseDmais mutated tofalsehere butconfig.use_dmaon the caller side still readstrue. Callers inspectingRxConfigafterbegin()will think DMA is active when it isn't, and the~4096single-fill cap re-appears silently on long strips — exactly the failure mode#2254is trying to fix.The
FL_WARNat line 798 is good, but for callers with long strips this fallback quietly re-introduces the bug. Options:
- Return
falsefrombegin()whenconfig.use_dma=trueand the slot can't be acquired (force the caller to handle it).- Or expose the effective state via a new accessor (e.g.,
bool isDmaActive() const).Not a blocker — the current behavior is defensible (best-effort capture) and the warning makes it diagnosable — but worth considering before release.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp` around lines 795 - 805, The code currently flips mUseDma to false when RmtMemoryManager::allocateDMA(...) fails but leaves the caller's RxConfig::use_dma (and hence external expectations) unchanged; update begin() to either propagate the failure by returning false when config.use_dma was requested but allocateDMA failed, or keep the current best-effort behavior while exposing the effective state by adding an accessor (e.g., bool isDmaActive() const) and ensuring mDmaAllocated/mUseDma and rx_config.use_dma are synchronized before returning so callers can reliably detect whether DMA is actually active; reference mUseDma, mDmaAllocated, RmtMemoryManager::allocateDMA, rx_config, and begin() when making the change.
940-949: Per-wait()FL_WARN telemetry will flood logs in production.This was previously
FL_LOG_RX(gated byFASTLED_RX_LOG_ENABLED) and has been promoted toFL_WARN, which is unconditional. Every successfulwait()call now emits a warning line. Given the comment acknowledges this as temporary diagnostic telemetry for#2254, consider gating it so downstream users don't see diagnostic output on every frame.♻️ Suggested gating
- // Visible (non-FL_DBG) telemetry: lets us see whether en_partial_rx - // is actually firing multiple callbacks per transmission on long - // streams. mCallbackCount == 1 on a long-stream capture indicates - // ESP-IDF ended the receive after one fill (likely due to idle - // timeout from signal_range_max_ns). See issue `#2254`. - FL_WARN("[RMT RX] wait(): symbols=" << mSymbolsReceived - << " callbacks=" << mCallbackCount - << " use_dma=" - << (mUseDma ? "true" : "false")); + // Diagnostic telemetry for en_partial_rx / issue `#2254` — gate + // behind FASTLED_RX_LOG_ENABLED so production captures stay quiet. + FL_LOG_RX("[RMT RX] wait(): symbols=" << mSymbolsReceived + << " callbacks=" << mCallbackCount + << " use_dma=" + << (mUseDma ? "true" : "false"));The similar "DMA streaming mode requested"
FL_WARNat line 754 fires once perbegin(), which is tolerable, but the same gating argument applies there.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp` around lines 940 - 949, The FL_WARN in RmtRxChannel::wait() is unconditionally logging per-frame telemetry (mSymbolsReceived, mCallbackCount, mUseDma) and will flood production logs; change this to the gated RX logging used previously (e.g., FL_LOG_RX / FL_DBG or wrap the FL_WARN call in an `#if` FASTLED_RX_LOG_ENABLED / if(FASTLED_RX_LOG_ENABLED) guard) so the telemetry only appears when FASTLED_RX_LOG_ENABLED is enabled; also apply the same gating to the one-time "DMA streaming mode requested" message emitted in begin() (the message near the "DMA streaming mode requested" code) to keep that diagnostic under the same log gate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp`:
- Around line 1502-1561: The ISR can set mReceiveDone when an entire chunk was
skipped (rxDoneCallback) leaving mSymbolsReceived==0 which makes wait() return
SUCCESS with zero data; update the receive-completion semantics so zero-symbol
completion is reported as an error: add a check in wait() that if mReceiveDone
(or the completion flag set by rxDoneCallback) and mSymbolsReceived == 0 then
return a failure status (or set a dedicated mReceiveError/mReceiveDoneError flag
that wait() checks) instead of SUCCESS; alternatively, set that error flag
inside rxDoneCallback when data->flags.is_last && mSymbolsReceived == 0 so
wait() can propagate an error to callers. Ensure you reference rxDoneCallback,
mReceiveDone, mSymbolsReceived and wait() when making the change.
---
Nitpick comments:
In `@src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp`:
- Around line 1642-1643: The field volatile u32 mCallbackCount is marked as
temporary instrumentation; either remove the "TEMP" marker in the comment if you
intend to keep this telemetry for wait()/ISR callback counting, or conditionally
compile and log it under the existing FASTLED_RX_LOG_ENABLED flag (same
mechanism used for FL_WARN telemetry) so it isn't treated as throwaway debug
code; update the comment to reflect permanence if kept, or wrap its use and any
diagnostic references in the FASTLED_RX_LOG_ENABLED guard and ensure related
logging uses FL_WARN as the other telemetry does.
- Around line 1249-1295: The DMA buffer zero-fill loop in allocateAndArm()
currently writes zeros element-by-element to mDmaCapableBuffer; replace that
manual loop with a single memset(mDmaCapableBuffer, 0, bytes) after allocation
(use the same bytes variable computed as hw_buffer_size * sizeof(RmtSymbol)) to
make intent clearer and allow the compiler to optimize the block clear; keep the
existing allocation/free/reuse logic around mDmaCapableBuffer and
mDmaCapableBufferSize unchanged.
- Around line 795-805: The code currently flips mUseDma to false when
RmtMemoryManager::allocateDMA(...) fails but leaves the caller's
RxConfig::use_dma (and hence external expectations) unchanged; update begin() to
either propagate the failure by returning false when config.use_dma was
requested but allocateDMA failed, or keep the current best-effort behavior while
exposing the effective state by adding an accessor (e.g., bool isDmaActive()
const) and ensuring mDmaAllocated/mUseDma and rx_config.use_dma are synchronized
before returning so callers can reliably detect whether DMA is actually active;
reference mUseDma, mDmaAllocated, RmtMemoryManager::allocateDMA, rx_config, and
begin() when making the change.
- Around line 940-949: The FL_WARN in RmtRxChannel::wait() is unconditionally
logging per-frame telemetry (mSymbolsReceived, mCallbackCount, mUseDma) and will
flood production logs; change this to the gated RX logging used previously
(e.g., FL_LOG_RX / FL_DBG or wrap the FL_WARN call in an `#if`
FASTLED_RX_LOG_ENABLED / if(FASTLED_RX_LOG_ENABLED) guard) so the telemetry only
appears when FASTLED_RX_LOG_ENABLED is enabled; also apply the same gating to
the one-time "DMA streaming mode requested" message emitted in begin() (the
message near the "DMA streaming mode requested" code) to keep that diagnostic
under the same log gate.
In `@src/platforms/esp/32/drivers/spi/channel_driver_spi.cpp.hpp`:
- Around line 849-951: Both reinitSpiHardware and createChannel use the magic
staging_size = 16384 value and the comment about "4KB" is stale; extract the
staging size into a single constexpr (e.g. kSpiStagingBytes) at namespace scope
and replace the local const size_t staging_size = 16384 in reinitSpiHardware and
createChannel with that constant, and update the comment near the staging-buffer
allocation (previously "4KB each, double-buffered") to reflect 16 KB (32 KB
total per-channel) so the docs and both uses cannot drift.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c1162186-5985-45b6-9574-adedc35e67ff
📒 Files selected for processing (4)
examples/AutoResearch/AutoResearchTest.cppsrc/fl/rx_device.hsrc/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hppsrc/platforms/esp/32/drivers/spi/channel_driver_spi.cpp.hpp
📊 Header Compilation PerformanceTotal Time: 1184.41ms Top 5 Slowest Headers
Warnings
Full Report |
`ci/ci-cppcheck.py` shells out to `pio check`, which requires a fully
populated PlatformIO project tree. Boards now compiled by fbuild don't
get their partition CSVs (e.g. `huge_app.csv`) written into the PIO
project dir, so `pio check` fails in CMake configure:
Missing partition table file `.../.build/pio/esp32c2/huge_app.csv`
UserSideException: Processing esp32c2 ...
This has kept esp32c2 red on master since #2292 (2026-04-18) and blocks
PR #2300.
Short-term: detect fbuild output presence by testing
`.build/.fbuild/build/<env>/release/` (the fbuild artifact dir returned
by `PioCompiler._artifacts_dir` in `ci/compiler/pio.py`). When that
directory exists for the target board, skip `pio check` with a visible
SKIP notice and return 0 rather than fail CI.
This accepts a temporary cppcheck-coverage gap on fbuild-default boards
(esp32c2 today, s3/c3/c6 on deck) until the proper clang-tool-chain-bin
integration lands — tracked by:
- #2301 — fbuild cppcheck support
- #2302 — esp32c2 CI regression (closed by this commit)
- #2303 — umbrella: clang-tool-chain-bin for IWYU + cppcheck +
other linting tools
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…CI (#2305) `ci/ci-cppcheck.py` shells out to `pio check`, which requires a fully populated PlatformIO project tree. Boards now compiled by fbuild don't get their partition CSVs (e.g. `huge_app.csv`) written into the PIO project dir, so `pio check` fails in CMake configure: Missing partition table file `.../.build/pio/esp32c2/huge_app.csv` UserSideException: Processing esp32c2 ... This has kept esp32c2 red on master since #2292 (2026-04-18) and blocks PR #2300. Short-term: detect fbuild output presence by testing `.build/.fbuild/build/<env>/release/` (the fbuild artifact dir returned by `PioCompiler._artifacts_dir` in `ci/compiler/pio.py`). When that directory exists for the target board, skip `pio check` with a visible SKIP notice and return 0 rather than fail CI. This accepts a temporary cppcheck-coverage gap on fbuild-default boards (esp32c2 today, s3/c3/c6 on deck) until the proper clang-tool-chain-bin integration lands — tracked by: - #2301 — fbuild cppcheck support - #2302 — esp32c2 CI regression (closed by this commit) - #2303 — umbrella: clang-tool-chain-bin for IWYU + cppcheck + other linting tools Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Fixes two root causes together that land as the total fix for issue #2254 Issue 2 (ESP32-S3 SPI driver "black frame between displays" on long strips):
Bug 1 — SPI TX staging buffer too small (the user-facing bug)
channel_driver_spi.cpp.hpphardcodedstaging_size = 4096bytes. With wave8 encoding at 24 bytes/LED, each SPI transaction held exactly 170 LEDs. Longer strips were split across multiplespi_device_queue_trans()calls advanced by the poll() loop. When poll() was preempted (WiFi, websockets, etc.), the SPI line idled long enough for WS2812B to latch → first 170 LEDs locked in the first frame, the rest went to a second partial frame that overwrote them. This is the symptom @ewowi videoed at https://github.com/user-attachments/assets/afe42d51-a635-42a4-a838-bca5b56bfdf9.Fix:
staging_size = 16384bytes. ESP-IDF's SPI DMA descriptor chain now produces continuous output for up to ~680 LEDs in a single queued transaction — no poll()-dependent gap between chunks.Bug 2 — RMT RX user buffer artificially capped (autoresearch harness limit)
Blocked me from seeing Bug 1. ESP-IDF 5.5 caps
rmt_receive()user buffers atnum_dma_nodes × 4092bytes wherenum_dma_nodes = max(2, mem_block_symbols × 4 / 4095 + 1)(rmt_rx.c:210-211and the check at:380-381). With our defaultmem_block_symbols=64that's 8184 bytes = 2046 symbols max.Fix: opt-in DMA RX via
RxConfig::use_dma. Channel is rebuilt when the flag toggles (ESP-IDF bakesflags.with_dmaat creation time).mem_block_symbols=14336yields 14 DMA nodes and a ~60 KB cap. ISR-sideskip_signalsfilter (drops skip chunks inline during partial-rx streaming — no synchronous pre-capture drain). DRAM-backed ping-pong buffer viaheap_caps_malloc(DMA|INTERNAL)because ESP-IDF rejects PSRAM buffers for DMA.Test plan
On the ESP32-S3 attached here,
bash autoresearch --spi --strip-sizes 550:bytes_captured=512, Errors: 0/550 (100.0%)— false-positive PASS, only first 170 LEDs were ever actually verified due to RX cap + silent truncation[RMT RX] wait(): symbols=13200 callbacks=15 use_dma=true; bytes_captured=1650; [Run 1/2] PASS | Errors: 0/550 (100.0%)— genuine PASS with all 550 LEDs byte-for-byte verified across 2 frames (frameCount=2 from feat(autoresearch): add --frames N multi-frame capture #2293 confirms no second-frame degradation).Memory impact
mem_block_symbols=14336DMA descriptor buffer + 56 KB DRAM user buffer. Only allocated whenRxConfig::use_dma = true. Autoresearch harness opts in for non-RMT TX paths.Files touched
src/platforms/esp/32/drivers/spi/channel_driver_spi.cpp.hpp— staging_size bump (the ESP32-S3: I2S driver starves websockets, SPI output incorrect, Audio driver FPS impact #2254 user-facing fix).src/fl/rx_device.h— newRxConfig::use_dmafield.src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp— DMA path: channel rebuild, allocateDMA integration, DRAM buffer, streaming ISR skip, telemetry.examples/AutoResearch/AutoResearchTest.cpp— opt-in DMA RX for non-RMT drivers.Related
--frames N— confirms no second-frame degradation once TX is continuous).🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Tests