Repository navigation
Description
Important
SUPERSEDED BY #3023 — see that meta for the current status of Teensy 4 channels-API driver work.
This issue's Phase 1-4 (FlexIO RX backend) all shipped on master:
- feat(rx): FlexIO RX backend skeleton (Phase 1A of #2764) #2765 (Phase 1A skeleton), feat(rx): FlexIO RX hardware programming (Phase 1B of #2764) #2766 (Phase 1B HW programming), feat(autoresearch): flexioRxBenchmark RPC + Python harness (Phase 2 of #2764) #2767 (Phase 2 RPC), feat(autoresearch): ObjectFLED → FlexIO RX loopback + WS2812 decoder (Phase 3 of #2764) #2769 (Phase 3 ObjectFLED→FlexIO RX loopback), docs(rx/flexio): FlexIO RX backend docs + enum-comment refresh (Phase 4 of #2764) #2770 (Phase 4 docs)
- HardFault fix
7bda3e402(closed FlexIO RX begin() hangs on real Teensy 4.0 silicon — WDOG3 fires (#2764 Phase 5 follow-up) #2772)
Phase 5-8 (verify the rest of the TX driver matrix) are now reframed in #3023 with the post-#3005 understanding that FLEX_IO wasn't even reachable from AutoResearch until that PR landed, plus the new Bus::LPUART workstream that replaces what would have been a separate Phase 6.
Closed for history; body preserved below.
Goal
Unblock high-fidelity driver development for Teensy 4 by adding a FlexIO-based RX backend and using it to verify a first end-to-end TX↔RX driver path. After this lands, AutoResearch on Teensy 4 has a true bit-exact loopback fixture and the rest of the driver matrix (FLEX_IO, OBJECT_FLED, SPI variants, BIT_BANG) can be qualified against it incrementally.
Why FlexIO RX specifically
The current RxBackend::PLATFORM_DEFAULT on Teensy 4 resolves to FlexPWM RX (per src/fl/channels/rx/types.h:9). FlexPWM works for the gap-aware decoder path but lives in a different peripheral clock domain than the FlexIO TX driver, which means symbol-rate verification of FlexIO output is doing a cross-peripheral capture. A FlexIO RX backend lets us:
- Capture FlexIO TX into FlexIO RX in the same peripheral clock domain → no DMAMUX cross-routing skew
- Use FLEXIO1 or FLEXIO3 (both free; FastLED's TX uses FLEXIO2 only, per
flexio_driver.h:2) - Drive eDMA from the FlexIO RX shifter status flag, mirroring the TX-side design
Hardware can do it. Software doesn't yet.
Verified preconditions (already true on master)
- ✅ Unified
fl::Watchdog+FL_WATCHDOG_AUTO()hardware-proven on Teensy 4.0 (refactor(autoresearch): adopt unified watchdog API + move boot diagnostic into platform impl #2763, 96+ min stable uptime on dev bench) - ✅ AutoResearch JSON-RPC harness alive and responding on COM20 (
ping,drivers,findConnectedPins,status) - ✅ Jumper wire on GPIO 3 ↔ GPIO 4 (auto-discovered)
- ✅ Registered drivers: SPI_UNIFIED (pri 7), FLEX_IO (pri 1), OBJECT_FLED (pri 1), BIT_BANG (pri 0)
Phase 1 — FlexIO RX backend implementation
Files to add:
src/fl/channels/rx/types.h— extendRxBackendenum withFLEXIO, extendRxDeviceTypeaccordinglysrc/fl/channels/rx/channel.cpp.hpp— wire the newRxBackend::FLEXIOcase increateBackendDevice()src/platforms/arm/teensy/teensy4_common/flexio_rx_channel.{h,cpp.hpp}— driver itself
Driver work:
- Pick host peripheral — FLEXIO1 (FLEXIO2 is owned by TX, FLEXIO3 has fewer mapped pins on Teensy 4.0)
- Configure 1 shifter in RX mode + 1 timer in dual-8-bit-counter / edge-capture mode
- Pin-mux configuration table (Teensy 4 GPIO → FLEXIO1 pin index)
- eDMA channel + DMAMUX source for the RX shifter status flag
- Implement
RxDeviceinterface:begin(config),wait(timeout_us),read(out_span),stop() - Lint clean +
bash test --cpppasses - Compile-only test on host stub (mock the FLEXIO1 register addresses)
Phase 2 — Bench-verify FlexIO RX with known square-wave signals
Need an independent (non-FlexIO) reference signal generator on the dev board. Easiest: drive a third GPIO via the Teensy core's analogWriteFrequency(pin, hz) + analogWrite(pin, 128) — that gives a 50% duty PWM up to several MHz. Patch that signal pin to the RX pin via jumper wire and measure.
New RPC: flexioRxBenchmark({ frequency_hz: int, duration_ms: int }) → returns { edges_captured, period_mean_ns, period_sigma_ns, period_min_ns, period_max_ns }.
Acceptance pass criteria:
| Test | Period | Tolerance (σ) | Tolerance (mean) |
|---|---|---|---|
| 2.1 — 1 kHz | 1 000 000 ns | < 1 000 ns | ±1 % |
| 2.2 — 10 kHz | 100 000 ns | < 500 ns | ±1 % |
| 2.3 — 100 kHz | 10 000 ns | < 100 ns | ±1 % |
Each test is a separate RPC call driven by the autoresearch Python harness. 100 kHz is intentionally just above WS2812 bit-cell rate (~800 kHz / 1.25 µs per bit) to prove the capture path can resolve the symbol times we'll need in Phase 3.
- Add
flexioRxBenchmarkRPC binding inAutoResearchRemote.cpp - Add Python test driver in
ci/autoresearch/test_flexio_rx_squarewave.py - All three rates pass on real Teensy 4.0 hardware
- Document peripheral resource use (which DMA channel, which DMAMUX source)
Phase 3 — End-to-end driver verification (ObjectFLED)
Picking ObjectFLED over the SPI/Serial driver for the first end-to-end verification because:
- One TX wire (WS2812 self-clocked) — no clock-line capture needed
- Already registered + tested as a working TX driver on Teensy 4
- Uses the same WS2812 bit-cell timing the FlexIO RX is being designed to resolve in Phase 2.3
- Smaller blast radius if Phase 1/2 has bugs — only one peripheral to bring up on the RX side
Test matrix (each is a separate runSingleTest RPC call):
| # | Pattern | Verifies |
|---|---|---|
| 3.1 | CRGB::Red single LED |
Basic 24-bit GRB pattern (0x00FF00 in wire order), T1H/T1L on 8 bits |
| 3.2 | [Red, Green, Blue] three LEDs |
Inter-LED bit alignment, no missing reset gap |
| 3.3 | All zeros (24 × 0x00) | T0H/T0L timing fidelity at zero-density bit cells |
| 3.4 | All ones (24 × 0xFF) | T1H/T1L timing fidelity at one-density bit cells |
| 3.5 | 100 LEDs, alternating R/G/B | Long-duration capture, RAM/DMA sizing, watchdog safety |
Acceptance: each captured bit sequence decodes byte-for-byte to the transmitted CRGB array, with bit-cell timing variance < ±10 % of WS2812 nominal.
- Wire
runSingleTestto setRX_BACKEND = FLEXIOfor these test cases - Add bit-decoder for captured edge timestamps → CRGB bytes
- All 5 test cases pass via
bash autoresearch teensy40 --object-fled --rx-backend=flexio(or equivalent) - Add to CI dispatch list once it's stable
Phase 4 — Documentation + CI integration
- Update
src/fl/channels/rx/types.h:9comment to mention FLEXIO option on Teensy 4 - Update
agents/docs/hardware-autoresearch.mdwith: new--rx-backend=flexioflag, GPIO pin restrictions for FlexIO1 mapping, peripheral resource budget - Decide policy on
RxBackend::PLATFORM_DEFAULTfor Teensy 4 — stay on FlexPWM (safe default), or switch to FlexIO once Phase 3 is stable. Default change is separate PR to keep blast radius small. - Add
bash autoresearch teensy40 --object-fled --rx-backend=flexioto the nightly hardware test matrix once the dev-bench Teensy 4.1 (see Teensy 4.1 hardware verification deferred (RTV-silicone interference) #2760) is back online
Follow-up phases (not in scope of this issue, but unlocked by it)
Once Phase 3 is green, the same pattern extends to:
- Phase 5 — Verify
SPI_UNIFIED(APA102/SK9822, two-wire DATA+CLK; needs FlexIO RX to capture both lines or move to 2-channel capture) - Phase 6 — Verify
FLEX_IOclockless TX driver (same FlexIO peripheral family on TX and RX — the headline win of this work) - Phase 7 — Verify
BIT_BANGfallback driver (sanity check that BIT_BANG output is also bit-accurate) - Phase 8 — Verify ParallelIO multi-lane drivers (when present)
Each becomes its own issue / PR once the FlexIO RX backend is proven.
References
- Unified watchdog + Teensy 4 bare-register WDOG3 hardware proof: feat(watchdog): Teensy 4 bare-register WDOG3 impl, hardware-verified #2753, refactor(autoresearch): adopt unified watchdog API + move boot diagnostic into platform impl #2763
- Reset classification API used to surface FlexIO RX errors in
findConnectedPins/runSingleTest: feat(watchdog): non-allocating reset/crash classification API + ScopedWatchdog #2756 - Existing FlexPWM RX backend (the working reference design we mirror for the FlexIO RX driver):
src/platforms/arm/teensy/teensy4_common/flexpwm_rx_channel.{h,cpp.hpp} - Existing FlexIO TX driver (the existing intra-peripheral coexistence anchor):
src/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.h - Teensy 4.1 hardware blocker (RTV silicone interference): Teensy 4.1 hardware verification deferred (RTV-silicone interference) #2760
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(rx): FlexIO RX backend skeleton (Phase 1A of #2764) (#2765)
feat(rx): FlexIO RX hardware programming (Phase 1B of #2764) (#2766)
fix(autoresearch): address CodeRabbit review on PR #2767
feat(autoresearch): flexioRxBenchmark RPC + Python harness (Phase 2 of …
fix(autoresearch): address CodeRabbit review on PR #2769
fix(autoresearch): Python @TypeChecked + EvaluationResult dataclass (PR
feat(autoresearch): ObjectFLED → FlexIO RX loopback + WS2812 decoder …
fix(autoresearch): KBI002 — route KeyboardInterrupt through project h…
docs(rx/flexio): FlexIO RX backend docs + enum-comment refresh (Phase…
zackees commentedon Jun 14, 2026
Superseded by #3023.