Repository navigation
Description
Summary
Continuing from #2254 (Issue 2: SPI driver — incorrect LED output). On ESP32-S3, the SPI LED driver exhibits a two-frame degeneration pattern: the first frame renders (mostly) correctly, then a black / corrupted frame appears between displays, and the cycle repeats. Current bash autoresearch --spi does not catch this because it only captures and verifies a single FastLED.show() call per test case.
This is a big problem — the most common real-world usage pattern for the SPI driver is a steady show() loop, and that is exactly the pattern we are not testing.
Repro (hardware required)
- Board: ESP32-S3 (attached here)
- Driver: SPI (APA102 / HD107 / SK9822 style)
- Symptom: first frame looks OK on an oscilloscope / logic analyzer / LED strip; the next frame clocks out as all-zeros (or a degraded pattern) so the strip flashes black; the frame after that recovers, and the cycle repeats. Visible as a visible flicker / black-frame interstitial on any long
show()loop. - Video evidence from ESP32-S3: I2S driver starves websockets, SPI output incorrect, Audio driver FPS impact #2254: https://github.com/user-attachments/assets/afe42d51-a635-42a4-a838-bca5b56bfdf9
Why the existing autoresearch tool misses this
Reviewed examples/AutoResearch/AutoResearchTest.cpp in the capture() function (around lines 376–391). For non-RMT drivers (PARLIO, SPI, UART, I2S) the flow is:
rx_channel->begin(rx_config); // arm RX once
FastLED.show(); // TX frame #1
FastLED.wait(TX_WAIT_TIMEOUT_MS);
rx_channel->wait(rx_wait_ms); // decode single capture
One FastLED.show(). One decode. No concept of frame N vs. frame N+1. A driver that emits a correct frame #1 and a zeroed frame #2 is scored PASS today.
The runTest / runSingleTest RPC handlers (driver_sweep.py, AutoResearchRemote.cpp) inherit the same single-frame assumption — iterations=1 is the default and each iteration currently re-runs an independent capture rather than capturing consecutive back-to-back frames from a sustained show() loop.
What we need the autoresearch tool to do
Extend the capture pipeline so that a single test case can capture two (or N) consecutive frames from the same armed RX session and verify each of them independently. Concretely:
1. New capture mode: multi-frame continuous capture
- Arm RX once with a buffer large enough for N frames plus inter-frame gaps.
- Call
FastLED.show()N times in a row (N ≥ 2) without re-arming RX between shows. - Rely on the existing gap-tolerance logic (already bumped to 100 µs for SPI) to segment the edge stream into frame boundaries.
- Decode the stream into N frame buffers, not one.
- Compare every frame against the expected pattern — all must pass for the test to pass.
2. New test pattern: second-frame degradation detector
Dedicated check that succeeds only if frame #2 is byte-identical (within tolerance) to frame #1 when the same CRGB buffer is shown twice. Failure modes we want to catch:
- All-zero second frame ("black frame between displays" — the current SPI bug).
- Partial second frame (DMA truncation / premature end).
- Corrupted second frame (buffer reuse / overwrite during DMA).
- Shifted second frame (clock/latch misalignment across frame boundary).
Each of these should produce a distinct, named failure class in the JSON-RPC result so the agent can distinguish "SPI driver zeroes the buffer after first show" from "SPI driver truncates DMA".
3. RPC surface changes
Add to the existing runSingleTest / runTest config:
{
\"driver\": \"SPI\",
\"laneSizes\": [100],
\"pattern\": \"MSB_LSB_A\",
\"frameCount\": 2, // NEW: consecutive frames in one capture (default 1)
\"frameComparison\": \"identical\" // NEW: \"identical\" | \"independent\" | \"none\"
}Result stream should report per-frame pass/fail:
{
\"type\": \"test_complete\",
\"passed\": false,
\"frames\": [
{\"index\": 0, \"passed\": true, \"mismatchedLeds\": 0},
{\"index\": 1, \"passed\": false, \"mismatchedLeds\": 100, \"failureClass\": \"all_zero\"}
]
}4. Promote SPI to a first-class autoresearch attribute
Since we have an ESP32-S3 attached and SPI is already a top-level flag (--spi), make the SPI sweep run multi-frame by default on ESP32-S3:
bash autoresearch --spion esp32s3 → runs withframeCount=2andframeComparison=\"identical\".- Add a regression test case specifically named
spi_second_frame_regressionto the sweep matrix inci/autoresearch/driver_sweep.py. - Add
--frames N/--frames-compare MODECLI flags tobash autoresearchso other drivers (PARLIO, I2S) can opt into multi-frame testing once the plumbing exists.
Implementation sketch
Files to touch:
examples/AutoResearch/AutoResearchTest.cpp—capture()grows aframe_countparameter; the gap_tolerance / edge decoder splits multi-frame edge streams.examples/AutoResearch/AutoResearchRemote.cpp—runSingleTest/runTestJSON handler acceptsframeCountandframeComparison.ci/autoresearch/driver_sweep.py— test matrix gains a multi-frame row for SPI; result printer handles per-frame failure arrays.autoresearch(bash wrapper) +ci/autoresearch/args.py— new--frames/--frames-compareflags; defaultframes=2when driver is SPI.agents/docs/hardware-autoresearch.md— document the new flags and the second-frame failure classes.
Acceptance criteria
-
bash autoresearch --spion ESP32-S3 detects the current "black frame between displays" bug without any code changes to the SPI driver (i.e., it reproduces the failure that ESP32-S3: I2S driver starves websockets, SPI output incorrect, Audio driver FPS impact #2254's video shows, as a hard FAIL in the sweep). - After the driver is fixed, the same command passes cleanly with both frames matching.
- Running with
--frames 2on RMT (known-good driver) passes — proving the capture pipeline itself doesn't false-positive. - Failure class in the RPC result matches the visual symptom (
all_zerofor the current SPI bug).
Related
- ESP32-S3: I2S driver starves websockets, SPI output incorrect, Audio driver FPS impact #2254 — parent issue (ESP32-S3 SPI + I2S + audio driver problems)
- fix(esp32): resolve SPI/LCD_SPI buffer growth failure on channel reuse #2251 — SPI buffer growth on channel reuse (partial fix, didn't resolve second-frame)
- FastLED Channels API #2167 — original Channels API discussion
Environment
- Board: ESP32-S3 (attached)
- FastLED: master as of 2026-04-17
- Discovered while reproducing ESP32-S3: I2S driver starves websockets, SPI output incorrect, Audio driver FPS impact #2254 locally
Activity
feat(autoresearch): add --frames N multi-frame capture
feat(autoresearch): add --frames N multi-frame capture (#2293)
zackees commentedon Apr 18, 2026
Completed across two merged PRs:
--frames Nmulti-frame capture +frameCountRPC parameter torunSingleTest. Harness can now detect two-frame degradation patterns.bash autoresearch --spi --strip-sizes 550 --frames 2now produces clean PASS with all 550 LEDs verified byte-for-byte across both frames. Also extended RMT RX capture past 170 LEDs viaRxConfig::use_dmastreaming (ESP-IDF partial-rx + 14336-symbol mem_block so the DMA descriptor chain covers ~680 LEDs in one rmt_receive).Telemetry on attached ESP32-S3 after both fixes:
Closing as completed.
fix(autoresearch): recognise the whole SPI family, and triage discove…
fix(autoresearch): three RP SPI harness bugs that reported host failu…