Repository navigation
Description
Symptom
On ESP32-C6FH4 (USB-Serial/JTAG only, COM port enumerated), running the default-payload parlioStreamValidate RPC {numLanes: 16, numLeds: 256, iterations: 10, timeoutMs: 250} hangs the chip within milliseconds of the call. Only the first FL_WARN line from FastLED.add(cfg) reaches the host before the USB-CDC pipe stops responding and the chip drops off the USB bus entirely. Recovery requires a physical power-cycle — esptool --after hard-reset cannot reach the chip while it's off the bus, and fbuild reset fails with 'failed to open COM9' for the same reason.
This is reproducible with the silenced build (FASTLED_DISABLE_DBG=1, see commits on fix-esp32c6-parlio) — i.e. the host-side ClearCommError / PermissionError is NOT the log-flood symptom in #2663. The chip really does wedge.
Sequence captured
ping: {'message': 'pong', 'success': True, 'uptimeMs': 16210, 'timestamp': 16210}
--- parlioStreamValidate(16x256, 10 iter, 250ms timeout) ---
[RPC] Sending: {\"method\":\"parlioStreamValidate\",\"params\":[[{\"numLanes\":16,\"numLeds\":256,\"iterations\":10,\"timeoutMs\":250}]],\"id\":2}
[async-serial] FastLED.cpp.hpp(620): WARN: FastLED.add(cfg): runtime-selection mode — enrolling every available driver via fl::enableAllDrivers(). For minimum binary size, prefer FastLED.addLeds<CHIPSET, PIN, ORDER,
[RPC] Exception during read_lines: Serial read error: ClearCommError failed (PermissionError(13, 'The device does not recognize the command.', None, 22))
[RPC] Timeout: No response with ID 2 within 30.0s
parlioStreamValidate FAILED
The single FL_WARN line happens during the first FastLED.add(cfg) in validateParlioStreaming(). After that, the wedge occurs before any of the other 15 channels are added — or before FastLED.show() runs at all, depending on where exactly we are stalling.
What this likely means
Three plausible root causes — needs lane-sweep triangulation to discriminate:
-
OOM during 16-lane channel setup. Each
ChannelDriverPARLIOImplcarries a per-lane scratch buffer + state. With 16 lanes × 256 LEDs × 3 bytes per LED × any expansion factor, plus the 3-buffer ring (cap 256 KB by default per parlio_engine.h docs), DRAM pressure may exceed the 320 KB available on C6. The 'When cap exceeded, system uses streaming mode (~30 µs overhead per iteration)' comment in parlio_engine.h implies the engine should gracefully fall back, but maybe a sizing math bug makes it allocate before checking. -
Driver-init deadlock.
enableAllDrivers()registers 5 drivers peradd()call. With 16 lanes that's 80 calls; if any take a mutex that the parlio engine setup also takes, we could deadlock. -
Parlio peripheral mis-configuration that hangs the CPU on a peripheral access (e.g. clock not enabled, register write that blocks pending a signal that never arrives).
Why this isn't easy to recover from
ESP32-C6's USB-Serial/JTAG is INSIDE the chip — when the CPU wedges hard enough, the USB-JTAG controller stops responding to host-side resets too. esptool's normal usb_jtag_serial DTR/RTS sequence (which works fine when the chip is responsive) can't reach the chip once it's off the bus. The host literally cannot recover the device without physical intervention. This makes lane-sweep triangulation slow.
(This is a separate bug, tracked as: 'fbuild reset gap on ESP32-C6 USB-Serial/JTAG' — fbuild's own fbuild reset command exits with 'failed to open COM9' rather than attempting the in-USB-JTAG CHIP_EN sequence that might preempt the wedge before it becomes terminal.)
What we still need to measure
- Lane sweep: 1, 2, 4, 8, 12, 14, 15, 16 lanes at 256 LEDs each — find the smallest lane count that wedges.
- LED-count sweep: 16 lanes × 32/64/128/192/256 — find the smallest per-lane count that wedges at 16 lanes.
- Memory delta: snapshot
esp_get_free_heap_size()before/after each add() to detect OOM before the wedge.
These reproduce too aggressively right now — every test wedges the device. Need a CPU-side guard (heap headroom check + early-fail with a clean RPC reply) before the engine can be safely benchmarked at the upper end.
Environment
- Branch: fix-esp32c6-parlio (HEAD commit + FASTLED_DISABLE_DBG=1 flag in ci/boards.py)
- ESP32-C6FH4, MAC 8c:bf:ea:cf:87:b4, USB-Serial/JTAG on COM9, Windows 10
- arduino-esp32 from pioarduino 55.03.35 (IDF 5.5.1)
- Companion build infra issues: esp32c6 parlio: 16-lane FastLED.add() floods HWCDC with idempotent driver-registration log lines and corrupts RPC reply stream #2663, bash compile --backend platformio silently discards root platformio.ini build_flags #2664, esp32c6 default env: Serial silently routed to UART0 instead of USB-Serial/JTAG → AutoResearch RPC unreachable on FH4 boards #2665
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
build(esp32c6): add FASTLED_DISABLE_DBG=1 to compile out FL_DBG idemp…
zackees commentedon May 31, 2026
Lane sweep — narrows the failure to the 8→16-bit data-width transition
Ran progressive
parlioStreamValidate(N lanes × 256 LEDs, 5 iter)on the FH4:The cliff is between 8 lanes and 12 lanes — exactly where
selectDataWidth()(channel_driver_parlio.h:247) jumps from 8-bit to 16-bit PARLIO. 1L/2L/4L/8L all stay within their tight power-of-2 width and work; the first 16-bit configuration (12 lanes with 4 dummy lanes) hangs.This is a much more specific failure than my original 'OOM at 16 lanes' hypothesis. It strongly implicates the 16-bit width path: either the 16-bit DMA-buffer math, the dummy-lane padding logic, or the 16-bit Wave8 transpose dispatch (BF1+pipe4 from #2559).
Observations supporting the width-transition hypothesis
Pure-encode timing (decoupled from hardware)
The 1L→8L progression also gives us a clean encode-cost model:
Linear extrapolation to 16L 8-bit-equivalent would be ~16 ms, well within the encode-vs-TX budget. The hang is not because the CPU can't keep up — it's because the 16-bit code path is broken.
Suggested next steps (for the design-out-the-fix work)
populateDmaBuffer/populateDmaBufferSpifor 16-bit-specific assumptions. Anything that assumesdataWidth ≤ 8ordummy_lanes == 0is suspect.wave8Transpose_16x4_bf1_pipe4(introduced in perf(parlio): #2548 BF1 — chipset-aware direct encode (5.5× vs baseline, 4.4× faster than TX) #2559) — it was originally validated with all-16-real-lane patterns; 12-real + 4-dummy may be untested.ParlioEngine::initialize()so the engine fails the RPC cleanly instead of wedging the CPU. Once esp32c6 parlio: parlioStreamValidate(16 lanes × 256 LEDs) hangs the chip and takes USB-Serial/JTAG down with it #2667 is fixed in the firmware, the chip would never enter the unrecoverable state described in the parent issue.Sweep script for repro:
scratch-issues/parlio_lane_sweep.pyon branchfix-esp32c6-parlio.zackees commentedon May 31, 2026
Code path narrowing — 16-bit Wave8 dispatch + ring buffer math
Walking the relevant code on
fix-esp32c6-parlio:Buffer sizing (
parlio_buffer_calc.h:88): FormDataWidth == 16,outputBytesPerInputByte() = 128. A 256-LED frame at 16-bit width therefore produces256 × 3 × 128 = 98304DMA bytes per frame. WithFASTLED_PARLIO_MAX_RING_BUFFER_TOTAL_BYTES = 256 KBandperBufferCap = 256/3 ≈ 87 KB, the full frame (96 KB) does NOT fit one buffer —calculateRingBufferCapacity()falls into the streaming path: 86 LEDs/buffer × 3 × 128 ≈ 33 KB per ring buffer × 3 = ~99 KB total.That math itself looks fine.
Allocation path (
parlio_engine.cpp.hpp:1523):initialize()callscalculateRingBufferCapacityfirst with the PSRAM cap (1 MB), gets back ~99 KB per buffer, thenallocateRingBuffers()requests99 KB × 3 = 297 KBof DMA-capable memory. ESP32-C6 has no PSRAM, so this allocation hits internal SRAM. The C6 has ~320 KB of DIRAM; allocating 297 KB out of it after FreeRTOS heap fragmentation is very unlikely to succeed — it almost certainly fails. The fallback path then retries with the SRAM cap (~33 KB × 3 = 99 KB) which is more realistic.The PSRAM-first-on-no-PSRAM-chip pattern wastes one allocation attempt and fragments the heap before the real (smaller) attempt runs. This is plausibly the difference between '8 lanes works' (8-bit width — small enough buffers that even the PSRAM-cap path fits) and '12/16 lanes hang' (16-bit width — large enough that the first attempt is doomed). When the fragmented heap then also can't satisfy the smaller retry, ring buffer allocation fails — but the engine has already set
mPeripheraland may have configured DMA channels, so we end up with a partially-initialized engine that subsequent code paths assume is ready.16-lane Wave8 dispatch (
parlio_engine.cpp.hpp:992-1037): thewave8Transpose_16x4_bf1_pipe4fast path (4-position pipelined) is taken whenbyteOffset + 3 < byteCount && outputIdx + 4 * blockSize <= outputBufferCapacity. For 256 LEDs × 3 bytes (768 byte positions), this is hit on every step except the last 3. The fallback (wave8Transpose_16_bf1) is reached whenbyteOffset >= byteCount - 3. Both paths buildlanes_[a|b|c|d][16]with dummy lanes zeroed. The short-circuitactive ? base[...] : 0prevents out-of-bounds reads on dummy lanes — that's correct.Per-add re-initialization:
FastLED.add()in runtime-selection mode goes throughenableAllDrivers()+addDriver()for every lane. If the PARLIO engine is re-initialized per add (whichenableAllDriversmay trigger viaChannelDriverPARLIOImpl::add), each of the 12-16 add calls re-runs the PSRAM-first-then-SRAM-fallback allocation flow → 12-16× heap fragmentation cycles on a 320 KB DIRAM budget. By call 12 of 16 the heap may be too fragmented to satisfy any DMA-capable allocation.Concrete fix design (proposed for this branch)
Three independent patches, in priority order:
1. Skip the PSRAM-first attempt on chips with no PSRAM (highest impact)
In
ParlioEngine::initialize()(line 1523), gate the PSRAM-cap path onesp_psram_get_size() > 0(orBOARD_HAS_PSRAMmacro). For ESP32-C6/H2/C5 etc. without PSRAM, go straight to the SRAM cap. Cost: ~20 LOC, no runtime overhead, eliminates the largest fragmentation cycle.2. Heap-headroom pre-check, fail-fast RPC instead of wedge
Before
allocateRingBuffers(), queryheap_caps_get_largest_free_block(MALLOC_CAP_DMA). If the largest free DMA block <mRingBufferCapacity, return false frominitialize()with a clear error. The validateParlioStreaming RPC handler can then return a{ok: false, error: "insufficient DMA heap"}response before the chip wedges, leaving USB-CDC alive for the next iteration.3. Re-initialization guard
If
mInitialized && mDataWidth == dataWidth && mActualChannels == channelCount && ..., skip re-runningallocateRingBuffers(). Eliminates the multi-add fragmentation cycle entirely. Cost: ~30 LOC, requires careful invariant analysis to avoid stale config.Defensive (won't fix root cause but prevents bricking)
esp_task_wdt_reset()inpopulateDmaBuffer's outer loop for 16-bit width (in case the encode itself is what hangs)I'll prototype (1) + (2) on
fix-esp32c6-parlionext iteration. (3) is bigger surgery and worth its own design pass.zackees commentedon Jun 1, 2026
Reproduced again from
C:\Users\niteris\dev\fastled7on 2026-06-01 with the ESP32-C6FH4 on COM9.Additional observations from this run:
esptool image-info .pio\build\esp32c6\firmware.binreportedFlash size: 4MB.testSimdreturned 85/85 passed andtestSimdBenchmarkreturned success.--parlio --lanes 16 --strip-sizes 256did not exercise the driver becauserunSingleTestrejected it withLaneSizeTooLarge(max_leds_per_lane = rx_buffer.size() / 32).After that COM9 disappeared from
python -m serial.tools.list_ports -vand did not re-enumerate after an additional 60 second poll. No local fbuild/zccache/compiler/serial helper processes were holding the port.pnputil /scan-devicescould not be used from this shell because it requires elevation.One extra suspect from this run: immediately before the direct RPC, AutoResearch pin discovery had auto-applied TX=0/RX=1.
parlioStreamValidatecurrently usesmState->pin_txas its base pin, so this likely attempted PARLIO lanes GPIO 0..15. That includes constrained/strap pins on ESP32-C6 and could be contributing to the post-watchdog USB disappearance. The RPC probably needs an explicitbaseTxPinoverride and/or safe preflight validation before it is used for destructive lane sweeps.zackees commentedon Jun 1, 2026
Current research report: C6 16-lane PARLIO feasibility and next proof point
This is the current state after re-checking the driver, the C6 docs, and the available hardware evidence.
What is proven by hardware so far
The lane sweep already posted above is still the best live evidence:
That still points to the 8-bit -> 16-bit PARLIO-width transition more than to a generic streaming failure. The C6 is currently not back on USB after the hard 16-lane crash, so I could not run a new live sweep with the improved RPC fields in this iteration. Current ports are COM1/COM3/COM4/COM22; COM22 is the ESP32-S3, not the C6.
ESP32-C6 PSRAM answer
PSRAM fallback is not a viable fallback for the ESP32-C6 target we are debugging.
Authoritative Espressif docs:
Conclusion: if the fix depends on pre-encoding 16-lane frames into PSRAM, it is a P4-class strategy, not a C6 strategy. For C6 we should assume internal SRAM only.
CPU / SIMD answer
ESP32-C6 has a single HP 32-bit RISC-V CPU up to 160 MHz and 512 KB HP SRAM in the Espressif datasheet: https://documentation.espressif.com/esp32-c6_datasheet_en.html?q=ESP32-C6
FastLED's local RISC-V SIMD layer does not give C6 vector acceleration.
src/platforms/esp/32/simd_riscv.hppexplicitly uses scalar fallback for ESP32 RISC-V variants, withFASTLED_ESP32_RISCV_HAS_RVV 0; only ESP32-P4 has the optional PIE path when built with__riscv_xesppie. The earliertestSimdRPC passing 85/85 proves the API path is correct, not that C6 has SIMD hardware acceleration.The 16-lane hot path is therefore scalar on C6. The useful optimization work is the BF1/pipe4 transpose path, not SIMD.
Is the crash proven to be a stream-chunk timeout?
No. The current evidence does not prove that the C6 hangs because the hardware timed out waiting for a large stream chunk.
For 16 lanes x 256 LEDs, the per-lane source byte count is 768. In Wave8 16-bit mode, each source byte position expands to 128 DMA bytes. Full pixel data is therefore:
With 16-bit Wave8 back padding and reset padding, the full frame is about 98.7 KB before the 128-byte safety margin. Under the PSRAM cap, that produces roughly a 98.8 KB buffer and would try to allocate three such DMA buffers, about 296 KB total. On a no-PSRAM C6, that is too aggressive for internal DMA memory.
Under the SRAM cap path, each ring buffer is about 33.6 KB.
calculateBufferByteCount()then pre-populates three buffers before the first hardware transmit:So the 16 x 256 case is not waiting on the ISR to compute a large missing stream segment. It has almost the whole frame encoded before TX starts. The only remaining byte position goes through the callback/refill path. That makes a pure "C6 CPU cannot compute the next stream chunk in time" explanation weak for this exact reproducer.
A larger LED count could still underrun if encoding cannot keep up, but 16 x 256 should be dominated by one of these instead:
Detection added locally
I added a low-overhead underrun counter to the local worktree. It increments exactly when
txDoneCallback()sees:That is the event we actually care about: the PARLIO hardware drained the available ring while source bytes remained. The counter is exposed through
ParlioDebugMetricsand returned byparlioStreamValidateas:The RPC now also accepts
baseTxPin, so the next C6 run can avoid GPIO 0..15 and test known-safe lanes explicitly.Validation of the instrumentation:
No logging was added to ISR/hot paths.
Strategy matrix
Skip PSRAM-cap allocation on no-PSRAM chips.
C6 should not first try the PSRAM-sized ring buffer path. Gate that on real PSRAM presence, e.g.
esp_psram_get_size() > 0, so C6 goes directly to the SRAM cap. This reduces failed huge DMA allocation attempts and heap fragmentation.Fail fast on DMA heap headroom.
Before allocating three ring buffers, check largest DMA-capable free block against the requested per-buffer size. If insufficient, return a clean initialization/RPC error instead of entering a partially initialized state.
Use the new underrun metrics to classify the crash.
Next live run should call something like:
If
underrunCount > 0, then CPU/refill latency is real and we can optimize around the transpose/refill budget. IfunderrunCount == 0or the board hard-resets before any response, the failure is earlier/lower: allocation, pin/peripheral configuration, IDF PARLIO 16-bit behavior, or a memory stomp.CPU-assist/blocking mode.
The driver already has partial CPU assist:
beginTransmission()pre-populates the ring on the caller thread before first TX, andpoll()refills from the caller/main-thread side while TX is active. A stricter blocking mode could pre-encode the full frame before TX only when the full frame fits available DMA memory. For C6 16 x 256, full pre-encode needs about 99 KB for one DMA buffer plus driver/peripheral overhead; possible in theory, but not robust for larger frames and not PSRAM-backed on C6.Optimize scalar transpose only if underrun is proven.
The current 16-lane path already uses BF1 and
wave8Transpose_16x4_bf1_pipe4. Because C6 has no RVV/PIE acceleration, more optimization would be scalar loop/layout work. It is not the first lever until the underrun counter says refill latency is the actual failure mode.Fallback if 16-bit mode remains unstable.
Disable 16-bit PARLIO on C6 and split 9-16 lanes into two 8-bit passes in the same frame. The known 8 x 256 measurement is about 15.7 ms total, so two passes are likely around 31 ms before any reuse/overlap optimization. That is slower, but it uses the width that is already proven to work on this board.
Current conclusion
Do not treat this as proven CPU starvation yet. The strongest current hypothesis is still "C6 16-bit PARLIO path is unsafe," with allocation/pin/peripheral behavior ahead of raw compute as likely causes. PSRAM pre-encode is not a C6 fallback. The next decisive experiment is the same lane sweep using a safe
baseTxPinand the newunderrunCountmetrics.zackees commentedon Jun 1, 2026
Follow-up after the report above: I also patched the local worktree with the first mitigation from the strategy matrix.
Changes now in the local branch:
ParlioEnginechecks whether a DMA-capable PSRAM heap exists before using the PSRAM-sized ring-buffer cap.allocateRingBuffers()now fail-fasts on no-PSRAM chips if the internal DMA heap cannot satisfy three aligned ring buffers, avoiding partial allocation/retry churn.parlioStreamValidateRPC changes remain in place: explicitbaseTxPinplusunderrunCount, ISR counts, ring/error state, and byte counts.Validation after this mitigation:
Still not hardware-validated on C6 because the C6 board has not re-enumerated after the prior hard crash. Next physical run should use a known-safe
baseTxPinand inspectunderrunCountto decide whether the remaining 16-bit failure is compute/refill pressure or an earlier 16-bit allocation/peripheral/pin failure.zackees commentedon Jun 1, 2026
Updated C6 hardware pass after #2669 merged and local AutoResearch instrumentation was rebuilt/flashed to the ESP32-C6FH4 on COM9.
What changed in this pass
Serialnow routes through HWCDC withARDUINO_USB_CDC_ON_BOOT=1and non-blocking CDC writes.txDoneCount,workerIsrCount,underrunCount,bytesTotal,bytesTransmitted,hardwareIdle,ringError).txPins:[...]override forparlioStreamValidateso we can test 16 lanes on the C6 DevKit without driving GPIO12/GPIO13, which are the native USB data pins on this board.Espressif's ESP32-C6-DevKitC-1 docs list GPIO13 as
USB_D+and GPIO12 asUSB_D-, and the header table has no GPIO14 entry: https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/user_guide.html#header-blockResults
Encode benchmark on C6 confirms the no-PSRAM path:
PARLIO stream sweep, 256 LEDs/lane, 5 iterations unless noted:
[16][16,17][16,17,18,19][16..23][0..11][0..11,15,16,17,18][0..11][0..15]Important interpretation:
completed=truecurrently only meansshow()+wait()returned before the timeout. For 12 and 16 lanes, the debug metrics show the transfer is not actually complete:bytesTransmitted=514whilebytesTotal=768,underrunCount=1, andhardwareIdle=true. So the 12/16-lane path is still broken even when avoiding USB pins; it is failing as an underrun / early-idle condition rather than a host-visible hang.The legacy contiguous
baseTxPin=0,numLanes=16failure is probably a second, board-specific problem: it drives GPIO12/GPIO13, which are the same native USB pins used by COM9, and also requests GPIO14, which is not on the DevKitC header table. After that test, Windows no longer enumerated COM9; only the S3 on COM22 remained. A physical reset/replug is needed before more C6 RPC runs.Current takeaways
parlioStreamValidateshould treatbytesTransmitted != bytesTotal,underrunCount > 0, orhardwareIdle=trueas failure, not just wall-clock timeout.zackees commentedon Jun 2, 2026
Resolved by the C6 PARLIO fixes that landed in #2681 and #2682, with follow-up hardware validation on the ESP32-C6FH4.
Verified on COM9 after the fixes:
{numLanes:16,numLeds:256,iterations:10,timeoutMs:250}now returns a clean RPC response withchannelsOk=falseinstead of wedging the chip, because the unsafe C6 USB pin map is rejected before PARLIO setup. Follow-uppingsucceeded and COM9 stayed enumerated.txPins:[0,1,2,3,4,5,6,7,8,9,10,11,14,15,16,17],numLanes=16,numLeds=256,iterations=10,timeoutMs=250returnedsuccess=true,completed=true,failedIter=-1,bytesTotal=768,bytesTransmitted=768,ringError=false,hardwareIdle=false. Follow-uppingsucceeded.Closing this as the hard C6 PARLIO crash / USB drop is no longer reproducible with the guarded default path or the safe explicit 16-lane path.