Repository navigation
Description
Symptom
On Teensy 4.0 with the OBJECT_FLED (FlexIO TX) driver, the AutoResearch loopback test reports FAIL — Capture failed even though the underlying transmit waveform on the wire is correct WS2812B timing. The RX side (default Teensy 4 backend = FlexPWM) does capture edges, but RxChannel::decode() returns 0 decoded LED bytes (or !ok()) for every pattern.
Reproducer
Hardware: Teensy 4.0 (PJRC), jumper between digital pin 3 (TX) and pin 4 (RX).
bash autoresearch teensy40 --object-fled --upload-port <COMx>
(Pre-requisite fix already merged: FastLED/fbuild#593 + this repo's FbuildSerialAdapter close fix from #3058. Without those the run crashes in the recovery path before it ever gets to decode().)
What the live run shows
The single-test path runs four patterns (A, B, C, D) on a 100-LED strip and every one ends in Capture failed:
[CAPTURE] OBJECT_FLED TX -> RMT RX: External GPIO wire (io_loop_back=false, use_dma=true)
[CAPTURE] RX armed, calling FastLED.show()...
[CAPTURE] FastLED.show() returned, calling wait...
[CAPTURE] FastLED.wait() done
[CAPTURE] Waiting for RX completion (150ms timeout)...
[CAPTURE] RX wait returned: 0 # RxWaitResult::SUCCESS (enum value 0)
[CAPTURE] Decoding...
[CAPTURE] Decoded 0 bytes # <-- the smoking gun
[Run 1] Capture failed
On some patterns the failure mode is the alternate branch (!decode_result.ok()), which triggers dumpRawEdgeTiming(). That dump shows the wire signal is correct WS2812B:
[RAW EDGE TIMING] Pattern Analysis:
Short HIGH (~225ns, Bit 0): FOUND ✓
Long HIGH (~580ns, Bit 1): FOUND ✓
Short LOW (~645ns, Bit 1): FOUND ✓
Long LOW (~1000ns, Bit 0): FOUND ✓
[RAW EDGE TIMING] ✓ Encoder appears to be working correctly (varied timing patterns)
So three independent facts:
FastLED.show()+FastLED.wait()complete cleanly — TX drove the line.rx_channel->wait(150)returnsSUCCESS— the RX peripheral DID capture edges.- The raw-edge analyzer reads those edges back and reports them as valid WS2812B pulse widths within spec.
…and yet rx_channel->decode(rx_timing, rx_buffer) returns 0 LED bytes (or !ok()).
Where I think the seam is
In examples/AutoResearch/AutoResearchTest.cpp the capture() function emits:
FL_WARN("[CAPTURE] " << driver_name << " TX -> RMT RX: External GPIO wire ...");That label is hardcoded ("RMT RX") and reflects the ESP32 RX backend, but on Teensy 4 the resolved backend for RxBackend::PLATFORM_DEFAULT is FlexPWM — Teensy 4 has no RMT peripheral. The hard-coded label is cosmetic, but it suggests the test was originally tuned against the ESP32 RMT RX backend's edge stream and was never retuned for the Teensy 4 FlexPWM edge stream.
Concretely, rx_timing is built from fl::make4PhaseTiming(tx_timing, tolerance) with tolerance = 170 ns (or 200 ns for wave3/wave8). That tolerance was sized against RMT RX jitter. On Teensy 4, the FlexPWM sample clock + GPIO matrix latency + OBJECT_FLED's FlexIO clock-domain crossing add more jitter than 170 ns can absorb, so the decoder's per-edge classifier ends up bouncing between "bit 0" and "bit 1" and bails.
That hypothesis matches the data:
- Raw edges are physically correct → the wire and the RX capture are both fine.
- The decoder still rejects them → tolerance / decoder-state-machine assumption is wrong for the OBJECT_FLED + FlexPWM pair.
Asks
- Driver-aware decoder tolerance. Make
capture()(aroundAutoResearchTest.cpp:570) widen the tolerance forOBJECT_FLEDthe same way it already widens it foruses_wave8 || uses_wave3(currently 200 ns vs the 170 ns default). A targeted ~250-300 ns tolerance for the FlexIO-TX × FlexPWM-RX combo on Teensy 4 should let the existing edge classifier succeed. - Fix the misleading log label. Replace the hardcoded
"... TX -> RMT RX ..."with the actual resolved backend name (e.g.rx_channel->getBackendName()if it exists, elsefl::toString(rx_config.backend)). The current label has cost me an hour today thinking the test was running through ESP32 code on a Teensy. - Optional: expose decoder reject reason. When
decode_result.ok()is true butvalue() == 0, the test reports "Decoded 0 bytes" with no further detail. Surface an internal counter ("first-edge rejected because pulse=X ns outside [T1-tol, T1+tol]") so this kind of decoder-mismatch shows up immediately instead of as a silent zero.
Why this matters
The OBJECT_FLED FlexIO TX driver is, as far as the wire is concerned, working perfectly on Teensy 4 — the raw-edge analyzer in the same test confirms it. AutoResearch currently reports it as a 100% failure, which makes it impossible to use the test loop to validate the Teensy 4 FlexIO TX path. Adjusting the decoder side (which is what's actually wrong) unblocks Teensy 4 autoresearch coverage for every OBJECT_FLED-driven workflow.
Repro environment
- Host: Windows 10, fbuild 2.2.28 (with feat(daemon): install running-process fbuild.servicedef on startup (#592 prerequisite) fbuild#593 servicedef install)
- Board: Teensy 4.0, PJRC
- RX backend:
RxBackend::PLATFORM_DEFAULT→ FlexPWM (perRxChanneldocs inagents/docs/hardware-autoresearch.md§"FlexIO RX Backend") - TX driver:
OBJECT_FLED(FlexIO2-backed clockless) - Strip: 100 LEDs, default
MSB_LSB_Apattern (also reproduces on B/C/D) - Wiring: pin 3 ↔ pin 4 jumper (auto-detected by
findConnectedPins)
Investigated as the follow-up to FastLED/fbuild#592 / FastLED/fbuild#593 — the FlexIO TX path itself is fine; the test layer's decoder tolerance is the remaining blocker.
🤖 Investigated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Jun 15, 2026
Investigation update — original tolerance hypothesis didn't survive contact with the wire
PR #3061 ships only the surgical part of this issue (the misleading "RMT RX" log label). The other two asks — driver-aware decoder tolerance and decoder reject reason — are blocked behind a different root cause than I posted originally. Documenting the findings here so the next pass doesn't re-tread the same dead end.
1. Does OBJECT_FLED support wave8 and generalized timings?
Pulled the chain on
src/platforms/arm/teensy/teensy4_common/drivers/objectfled/:channel_engine_objectfled.cpp.hpp:200-205passes the chipset'st1_ns / t2_ns / t3_ns / reset_usstraight intomPeripheral->createInstance(...).objectfled_peripheral_real.cpp.hpp:64-82passes those same nanosecond values straight into upstreamObjectFLED::begin(t1, t2, t3, reset).So OBJECT_FLED supports generalized timings, not wave8/wave3. The test's
tx_timingshould match what shows up on the wire to within ~10 ns of clock quantization. It doesn't — which is what makes the failure interesting.2. The 170ns-tolerance hypothesis from the issue body is wrong
I assumed the test was passing legacy WS2812 timing (250/625/375) and that the decoder's reference window therefore missed the V5 pulse widths (225/580 H, 645/1000 L) the wire actually carries. Walking
AutoResearchTest.cpp::dumpRawEdgeTimingagainst the live log:…the "expected" values come from
timing.t1_ns / t2_ns / t3_ns(lines 65-68). They print as 225/355/645 — the test was already using WS2812B-V5 timing, not legacy. So the decoder's reference windows are aligned with the spec OBJECT_FLED is supposed to be transmitting. Tolerance-widening can't help if the windows are already in the right place.3. What the wire actually looks like
The raw edge dump from the same run is bimodal in both polarities:
HIGH pulses are 640 ns OR 940 ns (nothing in between).
LOW pulses are 286 ns OR 586 ns (nothing in between).
Compare to what should be on a V5 wire:
And to a legacy WS2812 wire:
The captured HIGHs (640, 940) and LOWs (286, 586) don't sit inside either spec's bins. The raw analyzer reports "FOUND ✓" only because it accepts a 150 ns tolerance and 640 falls in the V5 Long-HIGH window and 586 falls in the V5 Short-LOW window — but most edges miss every expected bin. The "Encoder appears to be working correctly" line at the end is misleading: it requires just one edge per bin, and that one-shot bar gets cleared even when 80% of the edges are out of spec.
4. The real suspect: edges being merged at the RX peripheral, not at the driver
A few features of the bimodal data point at the RX side, not the TX side:
H=580, L=645) followed by bit-0 (H=225, L=1000). If the RX peripheral fails to register the 645 → 225 = 420 ns dip back to LOW (i.e. it misses the bit-1 ↔ bit-0 boundary on a short-LOW segment), the resulting capture is one fused HIGH of 580 + 645 + 225 = 1450 ns followed by a short LOW. The actual 940 / 286 distribution looks like this in the time domain, just with different bit sequencing.So my current best hypothesis: the FlexPWM RX backend (
PLATFORM_DEFAULTon Teensy 4) is missing short LOW transitions when adjacent bits flip rapidly. The TX driver is fine; the capture path is undersampling. That would explain why every other bit pair looks merged, why the totals stay locked at 1226 ns (the bit clock is real, the RX just missed an intermediate edge), and why no tolerance widening on the decoder side can rescue the missing edges.5. Asks to keep open on this issue
The three original asks aren't all in the same bucket anymore:
Plus one new ask:
That's where I'm leaving #3059 for now — partial fix in #3061, decoder-reject-reason and the FlexPWM RX edge-merging both still open. Holler if a different angle would be more useful.
fix(autoresearch): drop misleading 'RMT RX' label on non-RMT platforms (
zackees commentedon Jun 15, 2026
Attempt #2 update — switching AutoResearch to FlexIO RX on Teensy 4 didn't pan out
Tried the obvious workaround:
RX_BACKEND = fl::RxBackend::FLEXIOon Teensy 4 inexamples/AutoResearch/AutoResearch.ino, on the theory that the FlexIO RX backend is hardware-verified for OBJECT_FLED loopback (perflexioObjectFledTestinagents/docs/hardware-autoresearch.md) and only the default FlexPWM-RX path produced the bimodal bit pattern from my previous comment.Outcome: it made the failure mode worse. The runSingleTest now hangs instead of returning "Capture failed" in ~200ms:
So FlexIO RX
wait()either never returns or returns far later than 10 minutes for an OBJECT_FLED-driven 100-LED frame, despiteflexioObjectFledTestreportedly working against the same hardware path. Two possibilities:wait()is correct but its DMA completion ISR isn't firing for the OBJECT_FLED edge stream. This could be eDMA-channel contention with ObjectFLED's own DMA usage (ObjectFLED uses QTimer4 + XBAR-driven DMA channels — seesrc/third_party/object_fled/src/OjectFLED.cpp.hpp:238-244), or a watermark/DREQ misconfig that's masked whenflexioRxBenchmarkdrives a clean square wave but not when ObjectFLED's bursty WS2812 output drives it.wait()blocks at the channel level even when buffers were never armed correctly.(2) is more likely, because
flexioObjectFledTestreportedly works, but the AutoResearch single-test path differs from that targeted RPC in how it sizes buffers and arms RX.I've reverted the .ino change — leaving it in place would have made AutoResearch worse for every other test, not just OBJECT_FLED. The fix has to live one layer deeper than the test wrapper.
Where this leaves #3059
Two stacked backend bugs, neither of which is in
AutoResearchTest.cpp:wait()against OBJECT_FLED through the AutoResearch arming sequence, even thoughflexioObjectFledTestis documented as green for the same hardware path.The merged PR (#3061) only addresses the cosmetic "RMT RX" log label (ask #2 of the original three). The decoder tolerance ask (#1) doesn't apply — the captured edges aren't a tolerance issue. Ask #3 (surface decoder reject reason) is still useful and trivially addable in a separate PR.
Suggested next steps (not in scope for this session):
#ifdef FL_DEBUGpaths ([FlexPWM RAW],[FlexPWM EDGE],[FlexPWM DECODE]insrc/platforms/arm/teensy/teensy4_common/rx_flexpwm_channel.cpp.hpp) and inspect the raw u16 capture buffer to see whether the FIFO is double-reading or skipping captures.flexioObjectFledTestinAutoResearchRemote.cppto find why the same hardware works in one but hangs in the other.If you'd like me to take any of those on as separate scoped PRs, happy to — but each is a bench-debug task that needs scope and validation cycles of its own. Leaving #3059 open for that work.
fix(autoresearch): wrapper-skip OBJECT_FLED on Teensy 4 with syntheti…
fix(autoresearch): wrapper-skip OBJECT_FLED on Teensy 4 with syntheti…
fix(teensy4/flexio-rx): CLK_SEL=3 (pll3_sw_clk) + skip SWRST so FLEXI…