Repository navigation
fix(i2s,rmt-rx,autoresearch): I2S loopback GREEN on WROOM bench (#3569) - #3571
Conversation
Bench milestone: runSingleTest {driver: I2S, 10 LEDs, ALL_ONES + 3 more
patterns} passes byte-exact on ESP32-WROOM COM11 (passedTests 4/4,
captureEvidenceBytes 120, rawEdges 256) — first wire-verified frame
from the modern classic-ESP32 I2S engine. RMT control also 4/4.
I2S driver (bench-derived corrections):
- Sample layout: I2S1 in tx_bits_mod=32 mono LCD mode emits only the
HIGH half-word of each 32-bit memory word — DATA_OUT(n) = memory bit
16+n, low 16 bits discarded. Found by bisection with the working RMT
RX (bits 8..23 → silent, 0..15 → silent, all-32 broadcast → signal).
Expansion now packs lanes at bits 16..31.
- Pixel clock derived from the channel's chipset timing (8 pulses /
bit period) instead of hardcoded 8 MHz — the hardcode gave a 1.0 µs
WS2812 bit (25% fast); wave8 LUT likewise built from the channel's
T1/T2/T3 so the wire waveform matches what the chipset (and the RX
decoder) expects. Lane 0's timing wins for multi-lane batches.
- tx_stop_en stays 0: bench-tested =1 latches the auto-stop at
tx_start (FIFO momentarily empty before DMA prefetch lands) and
nothing ever ships.
RMT RX (classic ESP32 one-shot chips):
- Clamp mBufferSize + the non-DMA bounce buffer to the hardware
one-shot capacity — callers pass edge_capacity ≈ 256k symbols and
the accumulation buffer grabbed 25% of free heap per capture arm,
cascading into the null-alloc StoreProhibited / LoadStoreAlignment
crash family once real capture data started flowing.
AutoResearch:
- Classic-ESP32 default bench pins 18/19 → 33/34 (GPIO34 input-only =
ideal RX; the physical COM11 harness is wired 33→34 — the 18/19 pair
was never connected, verified electrically). This also stops the
boot-time shared RX on a dead pin from hogging 4 RMT mem blocks.
- Edge diagnostic buffers: stack FixedVector → fl::vector (2 KB+ off
the loopTask peak).
- New peekMem RPC: read MMIO/SRAM words without resetting the chip
(esptool pokes reset the peripheral state under investigation) —
this is what pinpointed the DMA-completed-but-silent-pin state.
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 (9)
📝 WalkthroughWalkthroughThis PR updates AutoResearch example GPIO defaults to GPIO 33/34, adds a peekMem RPC diagnostic method, and switches diagnostic edge buffers to heap allocation. It also fixes ESP32 I2S1 driver behavior: derived pixel clock timing, disabled TX auto-stop, corrected wave8 32-bit sample bit packing (with updated tests), and non-DMA RMT RX buffer size clamping. ChangesAutoResearch example changes
ESP32 I2S1/RMT driver fixes
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant Host
participant AutoResearchRemoteControl
participant MemoryBus
Host->>AutoResearchRemoteControl: RPC "peekMem" {addr, count}
AutoResearchRemoteControl->>AutoResearchRemoteControl: validate addr alignment and count range
alt invalid args
AutoResearchRemoteControl-->>Host: {success:false, error:"InvalidArgs"}
else valid args
AutoResearchRemoteControl->>MemoryBus: read count 32-bit words from addr
MemoryBus-->>AutoResearchRemoteControl: values[]
AutoResearchRemoteControl-->>Host: {success:true, addr, values}
end
sequenceDiagram
participant ChannelEngineI2sEsp32Dev
participant ChannelData
participant I2sPeripheralEsp32DevEsp
ChannelEngineI2sEsp32Dev->>ChannelData: read total_period_ns() from active channel
ChannelEngineI2sEsp32Dev->>ChannelEngineI2sEsp32Dev: compute pixel_clk_hz = 8e9 / bit_period_ns
ChannelEngineI2sEsp32Dev->>I2sPeripheralEsp32DevEsp: initialize(clk=pixel_clk_hz)
ChannelEngineI2sEsp32Dev->>ChannelData: override wave8 LUT T1/T2/T3/RESET from channel timing
ChannelEngineI2sEsp32Dev->>ChannelEngineI2sEsp32Dev: rebuild mWave8ByteLut if timing changed
Possibly related issues
Possibly related PRs
✨ 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 |
…back GREEN (#3572) (#3573) Bench validation sweep on ESP32-WROOM COM11 (jumper GPIO33->34), all four channel drivers now pass byte-exact 10-LED loopback, 4/4 patterns: RMT, I2S, UART, SPI. UART (the one real bug, fixes #3572): buildWave10Lut best-fit rounding put WS2812B-V5's 1-symbol at 2 pulses (490 ns) — only 245 ns above the 0-symbol, inside real WS281x parts' sampling-threshold band and flapping the bench decoder's 500 ns threshold (wrong bytes / failed decodes). Enforce a 400 ns minimum absolute wire separation, widening T1H upward: V5 -> (1,3) = 245 vs 735 ns, matching the proven legacy WS2812 LUT shape. canRepresentTiming mirrors the bump (T1H tolerance widened by exactly the deliberate separation growth). Canonical WS2812 (1,3), SK6812 (1,4) and slow chipsets (WS2811-400, 500 ns pulses) unchanged. New unit test pins the V5 (1,3) shape. SPI needed no code change — its earlier bench crashes were the #3571 heap-exhaustion family. The driver is already async at the channel level (spi_device_queue_trans ISR-driven DMA + non-blocking poll()); the remaining #3179 scope (ISR-chunked ring-buffer streaming) is a peak-memory optimization, unchanged by this PR. Co-authored-by: Claude Fable 5 <[email protected]>
…#3576 Phase 3) (#3581) Classic ESP32's RMT receiver has no ping-pong and no DMA — captures are one-shot into channel RAM, ~256 symbols ≈ 10 WS2812 LEDs (#3571). This adds an I2S0-based oversampling backend that removes the ceiling: bench-verified byte-exact at 100 and 160 LEDs (16x the RMT limit). Backend (RxBackend::I2S_RX / RxDeviceType::I2S_RX, classic only): - I2S0 standard master-RX serial mode samples the RX pin (via the I2S0I_DATA_IN15 matrix signal — the classic SD-in quirk) at 16 MHz into a 16 KB circular DMA ring; CLZ-based run-length extraction on the draining task; 4-phase pair decode matching RMT semantics. - Packed level runs (4 bytes each) capped at 8000 (~165 LEDs, 32 KB) — sized against classic's free heap; unbounded storage OOM'd at 500. - Claims I2S0 through the cross-driver port-claim registry; begin() fails cleanly (fall back to RMT) when the second clockless bank or clocked-SPI owns the block. Bench-derived silicon findings (all encoded as comments): - The RX serial sampler clocks SD at the CLKM rate directly (80/clkm_div_num); rx_bck_div only shapes the unused BCK output. - Rates above ~16 MHz (clkm_div_num < 5) capture only zeros from real pads; the matrix-constant source still samples — input path ceiling. - rx_msb_shift=1 (Philips) required; PDM block forced off. - Bit order: bit31 of each 32-bit FIFO word is the earliest sample. - Per-bit extraction cannot keep up at 16 Msps (mid-frame gaps past ~50 LEDs) — CLZ word-run scanning fixes it. Plumbing: - RxChannel::begin() recreates the device when config.backend differs; a fresh default config silently reverted explicit backends to PLATFORM_DEFAULT/RMT. New RxChannel::backend() accessor; the AutoResearch capture path now carries it (root-cause fix). - runSingleTest gains an optional rxBackend param (RMT/ISR/I2S_RX). - g_i2s_rx_debug[] bench counters (peekMem-able, 32 bytes) kept for future bring-up. - fl/channels/README.md: RX capture backends section. Bench (WROOM COM11, GPIO33->34): I2S_RX byte-exact 4/4 at 10, 100 and 160 LEDs; regression I2S/I2S0/RMT/UART/SPI (RMT backend) 4/4 each. Host: 345/345, lint clean. Co-authored-by: Claude Fable 5 <[email protected]>
Bench milestone: the modern classic-ESP32 I2S engine passes byte-exact loopback on real hardware.
runSingleTest {driver: I2S, laneSizes: [10], pattern: ALL_ONES}on ESP32-WROOM COM11:passed: true, passedTests: 4/4, captureEvidenceBytes: 120, rawEdges: 256. RMT control also 4/4. This closes the wire-verification gap that #3569/#3568/#3515 Phase D were blocked on.Bench-derived driver corrections
tx_bits_mod=32mono LCD mode emits only the high half-word of each 32-bit memory word —DATA_OUT(n)= memory bit16+n; the low 16 bits are discarded. Found by bisection against a working RMT-RX loopback (lanes at bits 8..23 → silent; 0..15 → silent; all-32 broadcast → clean waveform). The expansion pass now packs the 16 lanes at bits 16..31.ChipsetTimingConfig(6.4 MHz for WS2812 — the previous 8 MHz hardcode gave a 1.0 µs bit, 25% out of spec), and the wave8 LUT is built from the channel's T1/T2/T3 so the wire waveform matches what the chipset and the RX decoder expect.tx_stop_enstays 0 — bench-tested=1latches the auto-stop attx_start(FIFO momentarily empty before DMA prefetch lands) and nothing ever ships.Crash-family fix (RMT RX heap)
Callers pass
edge_capacity ≈ 256k symbols; on one-shot chips (no RX ping-pong) the accumulation buffer grabbed 25% of free heap per capture arm for capacity that can never arrive — cascading into the null-alloc StoreProhibited / LoadStoreAlignment crashes once real capture data started flowing. Both the accumulation size and the non-DMA bounce buffer now clamp to the hardware one-shot capacity.AutoResearch bench plumbing
FixedVector→fl::vector.peekMemRPC — reads MMIO/SRAM without resetting the chip; this is what showed the DMA completing (out_eof/out_total_eofraw, EOF descriptor consumed, pin routed) while the pin stayed silent, isolating the fault to the sample-bit mapping.Verification
bash test --cpp --clean: 345/345.bash lint: clean.Related: #3569, #3568, #3526, #3515 Phase D.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes