Skip to content

[meta] Teensy 4 channels-API driver coverage + verification fixtures (supersedes #2764, #3006) #3023

Closed

Description

@zackees

TL;DR

Single source of truth for the Teensy 4 channels-API driver and verification work. Supersedes #2764 (the FlexIO-RX bootstrap meta whose Phase 1-4 shipped and whose Phase 5+ framing is now stale) and #3006 (standalone LPUART feature ticket; folded inline below). Cross-references the cross-driver wave8 test + shared ISR-mock fixture work that came out of recent coverage discussions but had never been filed.

Current registry state on Teensy 4.x (master)

After #3005 (driver-name fix) and #3010 (parlio mock ISR pump) merged on 2026-06-13/14:

Bus Priority Engine Pin set Async?
Bus::FLEX_IO 8 ChannelEngineFlexIO FlexIO2-capable: {6-13, 32} sync (peripheral->wait() inline)
Bus::OBJECT_FLED 5 ChannelEngineObjectFLED any GPIO sync by design
Bus::BIT_BANG 0 shared bitbang fallback any GPIO sync

AutoResearch can now drive both FLEX_IO and OBJECT_FLED from Python via --flex-io and --object-fled (or --all). FlexIO RX loopback fixture from old #2764 Phase 3 is in place and proven against ObjectFLED TX. Host channels tests pass; full host suite (bash test --cpp) goes green on Linux CI after #3010.

✅ Done (linked for history, no action needed)

🚧 Open work (the actual planning content)

A) Bus::LPUART — third orthogonal clockless peripheral on Teensy 4

Folded in from #3006. Adds the iMXRT1062 LPUART (inverted-TX + eDMA) as a wave8-generic clockless driver. Not WS2812-specific — the peripheral's only wire-shape constraint is "every bit cell starts HIGH and ends LOW with 8 freely-programmable pulses in between," which is the topology of every WS281x-family / SK6812 / UCS7604 / TM181x chipset. The legacy CWS2812SerialController and PaulStoffregen library are one possible WS2812-only special case of what this engine should support generically.

Why it matters: disjoint hardware path from FlexIO and ObjectFLED — a sketch can run strips on all three peripherals concurrently. T4 has 8 LPUART instances (LPUART1..LPUART8), so up to ~8 additional async strips are possible once Phase 3 async lands.

Backend strategy (decided): direct iMXRT LPUART + eDMA register driver using wave8 from day one — not a wrap of the legacy PaulStoffregen library. The library hard-codes WS2812 byte patterns + baud, which would have to be thrown away when Phase 3 async lands anyway; wrapping it first is rework.

Phase 1 — sync engine + registration:

  • src/fl/channels/bus.h — shipped in feat(channels): reserve Bus::LPUART enum slot (refs #3023) #3026 (merged):
    • Add LPUART enumerator after OBJECT_FLED.
    • Add case Bus::LPUART: return "LPUART"; to busName().
    • Bump the drift-prevention FL_STATIC_ASSERT(static_cast<fl::u8>(Bus::STUB) == 13, ...) to 14.
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/ (new directory):
    • ilpuart_peripheral.h — abstract interface (mirrors iparlio_peripheral.h) so the engine is host-testable via a mock. Shipped in feat(lpuart): scaffold Teensy 4 LPUART peripheral interface + host mock (refs #3023) #3032 (merged).
    • lpuart_peripheral_real.{h,cpp.hpp} — iMXRT register driver. LPUARTx_CTRL.TXINV=1, 8-N-1 framing, eDMA via DMAMUX source for LPUARTx TX. Pin-mux table covering the T4.0/4.1 LPUART-TX pins {1, 8, 14, 17, 20, 24, 29, 35, 47, 48}. ← needs hardware verification, deferred.
    • lpuart_peripheral_mock.{h,cpp.hpp} — host-stub mock. Shipped in feat(lpuart): scaffold Teensy 4 LPUART peripheral interface + host mock (refs #3023) #3032 (merged). Streaming-ISR settleEngineState() pattern deferred until workstream C lands the shared template fixture; current mock is sync-only.
    • wave8_encoder_lpuart.{h,cpp.hpp} — packs a Wave8Byte into the 8 programmable UART data bits per frame (start/stop framing handled by the inverted hardware).
    • channel_engine_lpuart.{h,cpp.hpp} — IChannelDriver subclass. Sync show() for Phase 1.
    • bus_traits.h — BusTraits<Bus::LPUART> mirroring objectfled/bus_traits.h; BusSupports<Bus::LPUART, ClocklessChipset> : fl::true_type.
    • _build.cpp.hpp for the mock side — shipped in feat(lpuart): scaffold Teensy 4 LPUART peripheral interface + host mock (refs #3023) #3032. Engine-side _build.cpp.hpp deferred until engine TU lands.
  • src/platforms/arm/teensy/teensy4_common/init_channel_driver_mxrt1062.cpp.hpp — register at priority 3 (between BIT_BANG=0 and OBJECT_FLED=5; LPUART is single-strip + pin-restricted, so lower than ObjectFLED's any-pin parallel fan-out).
  • src/platforms/arm/teensy/channel_drivers_teensy.impl.hpp — append Bus::LPUART to the enableDrivers<...>() pack in the FL_IS_TEENSY_4X arm.

canHandle() — wave8-generic, not chipset-specific:

bool ChannelEngineLPUART::canHandle(const ChannelDataPtr& data) const FL_NOEXCEPT {
    if (!data || !data->isClockless()) return false;
    const ChipsetTiming& t = data->getTiming();
    // (1) Bit period must fit the LPUART baud-rate range (~1067 ns – 160 us on iMXRT)
    if (t.total_period_ns() < kLPUARTMinBitPeriodNs ||
        t.total_period_ns() > kLPUARTMaxBitPeriodNs) return false;
    // (2) Wave8 expansion must have leading HIGH and trailing LOW
    //     (the inverted-LPUART framing constraint)
    auto lut = buildWave8ByteExpansionLUT(buildWave8ExpansionLUT(t));
    if ((lut.lut[0x00].symbols[0].data & 0x80) == 0) return false; // first pulse HIGH
    if ((lut.lut[0xFF].symbols[7].data & 0x01) != 0) return false; // last pulse LOW
    return mPeripheral->canHandlePin(static_cast<u8>(data->getPin()));
}

New chipsets in the WS281x topology land for free as long as their wave8 expansion fits.

Phase 2 — AutoResearch wiring (follows #3005's pattern): ✅ shipped in #3033 (merged).

Phase 1 acceptance:

  • bash compile teensy40 --examples AutoResearch succeeds with the new engine.
  • bash autoresearch teensy40 --lpuart (Phase 2 hardware run) drives one strip via LPUART-eDMA on pin 1, captured byte-for-byte via the FlexIO RX loopback.
  • bash autoresearch teensy40 --all exercises FLEX_IO + OBJECT_FLED + LPUART in sequence.
  • Host stub build still passes (engine TU gated by FL_IS_TEENSY_4X).
  • Parameterized host test in tests/platforms/arm/teensy/teensy4_common/drivers/lpuart/channel_engine_lpuart.cpp confirms canHandle() accepts WS2812, WS2812B, WS2812B-V5, SK6812, SK6812-RGBW and rejects APA102, SK9822 (clocked SPI), plus any chipset whose wave8 expansion violates the leading-HIGH/trailing-LOW topology.
  • Legacy FastLED.addLeds<WS2812SERIAL, DATA_PIN, GRB>(...) template path remains functional (no regressions; no removal of the #define USE_WS2812SERIAL gate on the legacy path).
  • ChannelManager boot dump lists all four T4.x clockless options: BIT_BANG (pri 0), LPUART (pri 3), OBJECT_FLED (pri 5), FLEX_IO (pri 8).

B) Cross-driver wave8 byte-equivalence test

Single host test that feeds the same CRGB array through every wave8-using driver's encoder (parlio, i2s, spi, uart, future lpuart) and asserts the wire output is bit-identical modulo per-driver framing. Catches encoder drift between drivers and (more importantly) LUT-rebuild bugs when someone touches the shared wave8.cpp.hpp. The single highest-ROI test we don't have today.

  • tests/fl/channels/wave8.cpp — LUT-regression piece shipped in test(channels): widen wave8 LUT regression matrix to real chipset timings (refs #3023) #3028 (merged): three new test cases walk 10 real chipset timings (WS2812, WS2812B-V5, WS2813, SK6812, UCS1903B, TM1809, PL9823, WS2811, WS2815, UCS1903_400KHZ) and assert (1) byte-LUT == nibble-LUT for all 256 input bytes, (2) the wave8 framing invariant (first pulse HIGH, last pulse LOW) — the topology LPUART's canHandle() rests on, and (3) wave8Transpose_4 matches between the two LUT-typed overloads. Appended to the existing wave8.cpp instead of the originally-planned standalone wave8_cross_driver.cpp (test-pairing hook requires a matching src/ header — the existing file pairs with wave8.h).
  • Per-driver byte-stream capture comparison (the literal "feed CRGB through every driver's mock and compare framed bytes") — deferred until workstream C extracts the shared streaming-ISR mock fixture so each driver's mock has a uniform capture API.
  • Reference: discussion in this PR thread — "What's the theoretical test coverage for wave8 across all these drivers."

C) Shared streaming-ISR mock fixture

Lift the parlio_peripheral_mock deferred-callback + settleEngineState() plumbing into a reusable template fixture so i2s / uart / spi / future lpuart don't each re-derive it.

D) Phase 3 — wave8 streaming-ISR async conversion per driver

Per-driver follow-up tickets (file each as its own issue once the corresponding Phase 1 sync engine lands). Reference patterns:

  • src/platforms/esp/32/drivers/parlio/parlio_engine.cpp.hpp — "PHASE 1: ASYNC MODE" sections (the original wave8 + ISR ring buffer impl).
  • src/platforms/esp/32/drivers/i2s/channel_driver_i2s.{h,cpp.hpp} — wave8 streaming via I2S half/done ISRs.
  • feat: add ISR-backed channel poll wakeups #2992 — ISR-backed channel poll() wakeups; the channel_poll_signal plumbing the conversions sit on.

Workstreams:

  • LPUART async (lets up to 8 LPUART strips run fully in parallel without blocking).
  • Review FlexIO engine for async parity — currently wait() is called inline per channel; could become poll-driven.
  • ObjectFLED async — library is synchronous-by-design; non-trivial to convert.

🗂 Retired predecessors (closed for history)

Reference (post-merge cleanup needed)

  • src/platforms/arm/teensy/teensy31_32/ws2812serial_controller.h + the addLeds<WS2812SERIAL> template overload at src/FastLED.h:1265-1276 stay untouched. The legacy template path keeps working for existing user sketches; Bus::LPUART is the channels-API forward path.

🤖 Generated with Claude Code

Activity

  1. zackees commented on Jun 14, 2026

    @zackees
    MemberAuthor

    Progress update (2026-06-14)

    Shipped two foundation PRs against this meta:

    • feat(channels): reserve Bus::LPUART enum slot (refs #3023) #3026 (feat/lpuart-bus-enum): Reserves Bus::LPUART enum slot in src/fl/channels/bus.h, adds the matching busName() case, and bumps the drift-prevention FL_STATIC_ASSERT from Bus::STUB == 13 → 14. This is the first checkbox of workstream A Phase 1.

    • test(channels): widen wave8 LUT regression matrix to real chipset timings (refs #3023) #3028 (feat/wave8-cross-driver-test): Adds three host test cases to tests/fl/channels/wave8.cpp covering the wave8 LUT regression matrix across 10 real chipset timings (WS2812, WS2812B-V5, WS2813, SK6812, UCS1903B, TM1809, PL9823, WS2811, WS2815, UCS1903_400KHZ). Asserts:

      1. byte-LUT and nibble-LUT paths are bit-identical for all 256 input bytes at every timing
      2. the wave8 framing invariant (first pulse HIGH, last pulse LOW) holds — the topology that Bus::LPUART::canHandle() will rely on
      3. wave8Transpose_4 matches between the two LUT-typed overloads

    This is workstream B scaled to the LUT-regression target. The per-driver byte-stream comparison piece is deferred until workstream C's shared streaming-ISR mock fixture exists.

    Still open

    • Workstream A Phase 1+: the full lpuart_peripheral_real.cpp.hpp (iMXRT register driver + eDMA + DMAMUX), lpuart_peripheral_mock, wave8_encoder_lpuart, channel_engine_lpuart, bus_traits.h, registration in init_channel_driver_mxrt1062.cpp.hpp, and host tests for canHandle() accept/reject. Hardware verification required.
    • Workstream A Phase 2: AutoResearch --lpuart wiring (AutoResearchRemote.cpp, ci/autoresearch/args.py, ci/autoresearch/phases.py, ci/tests/test_autoresearch_phases.py).
    • Workstream C: extract parlio_peripheral_mock's deferred-callback + settleEngineState() plumbing into tests/platforms/shared/streaming_isr_mock.h, then migrate parlio + use in lpuart mock. The 561-line parlio mock is intertwined with ParlioEngine::poll() — non-trivial refactor.
    • Workstream D: per-driver async conversions (LPUART async, FlexIO async parity, ObjectFLED async).

    Each of these warrants its own focused PR, not a rushed bundle.

    🤖 Generated with Claude Code

  2. zackees commented on Jun 16, 2026

    @zackees
    MemberAuthor

    Triage pass — cleanup applied:

    Remaining open sub-tasks split by reachability:

    Hardware-deferred (LPC845-BRK / T4 on bench):

    • lpuart_peripheral_real.{h,cpp.hpp} — explicitly hardware-deferred per the body. Needs the T4 LPUART eDMA register sequence validated against actual silicon.
    • bash autoresearch teensy40 --lpuart Phase 2 hardware run.

    Off-bench, non-trivial:

    • wave8_encoder_lpuart.{h,cpp.hpp}, channel_engine_lpuart.{h,cpp.hpp}, bus_traits.h, enableDrivers<> registration, canHandle() parameterized host test. Doable without hardware against the existing mock peripheral, but tightly interleaved with the hardware-deferred work in this same PR family. Skipping rather than risk stepping on in-flight workstream.

    Workstream B / C (cross-driver wave8 + shared streaming-ISR mock fixture): also off-bench but blocked on C landing before B per the body.

    Standing by — happy to take any of the off-bench pieces if you give an explicit "do this one" and confirm it doesn't conflict with WIP.

  3. zackees commented on Jun 16, 2026

    @zackees
    MemberAuthor

    New focused sub-issue spawned: #3157 — host-testable LPUART engine + encoder + bus_traits + canHandle() host test, against the mock peripheral that landed in #3032. Covers the items in workstream A of this meta that aren't hardware-deferred. The real lpuart_peripheral_real stays parked here under this meta until T4 silicon is on the desk.

  4. zackees commented on Jun 16, 2026

    @zackees
    MemberAuthor

    Two new SPI-support sub-issues filed for the Teensy 4 channels-API family:

    Both reference this meta as parent. Companion to #3157 (LPUART clockless-only) which now has a positioning comment locking in the SPI-not-possible structural reasoning for LPUART specifically.

    The trio together closes the Teensy 4 channels-API SPI gap: FlexIO for parallel-sync on restricted pins, ObjectFLED for any-pin (if feasible), LPUART for clockless-only.

  5. zackees commented on Jun 16, 2026

    @zackees
    MemberAuthor

    Filed #3186 — declarative DriverCapabilities + pinGroups() + central resolver, replacing today's IChannelDriver::canHandle(ChannelData*). Drivers publish capability data once via capabilities() (tiny header by value) + pinGroups() (fl::span<const PinGroup> over driver-owned storage); the Channel Manager owns all matching/resolution logic. Resolves the pin-rejection / pin-pair-validity / multi-channel-capacity gaps that have been surfacing in #3175 / #3176 / #3157.

  6. zackees commented on Jun 18, 2026

    @zackees
    MemberAuthor

    Closing per the 2026-06-18 session closeout.

    Workstream coverage as of this session:

    Workstream Status
    A (LPUART driver) Mock peripheral landed in #3032. Engine layer (#3157) deferred to a bench session with the iMXRT register driver. Bench-side LPUART runs through the wrapper-skip path per PR #3217 (TX engine still exercises end-to-end at boot; only byte-level RX decode deferred).
    B (cross-driver wave8 byte-equivalence test) Deferred.
    C (shared streaming-ISR mock fixture) Deferred.
    D (async streaming refactor for LPUART) Deferred.

    Driver-matrix verification: bash autoresearch teensy40 --all reports RESULT PASS 10 test(s) on the dev-bench Teensy 4 (COM20) via PR #3217. The matrix-green achievement is the proxy this meta-issue was tracking; everything still open lives in the individual sub-issues (#3157 / #3175 / #3176 / #3181 / #3182) which are being closed alongside this one.

    Reopen if a consolidated meta-tracker for the remaining workstreams is still needed.

  7. moved this from Triage to Done in FastLED Trackeron Jun 18, 2026
  8. zackees commented on Jun 18, 2026

    @zackees
    MemberAuthor

    Reopening — the 2026-06-18 closure was premature. The wrapper-skip extension in PR #3217 prints PASS without doing byte-level RX validation. See #3066 acknowledgement for the full context. Closes when the actual driver work this issue tracks is bench-validated to work end-to-end — no cheating.

  9. moved this from Done to Triage in FastLED Trackeron Jun 18, 2026
  10. zackees commented on Jun 27, 2026

    @zackees
    MemberAuthor

    Closing as superseded -- the LPUART driver (workstream A) and the FlexIO/ObjectFLED bring-up tracked under this meta are all merged. Async streaming follow-ups (workstream D) deferred under #3181, #3182, #3183 (all closed as 'deferred future work'). Cross-driver wave8 test (workstream B) and shared streaming-ISR mock fixture (workstream C) are scoped at the framework level and not actively blocking any driver -- they can be reopened as standalone issues if a specific need arises.

    Sub-issue status:

    If any of the deferred items become blockers, file a fresh focused issue rather than reopening this meta.

  11. moved this from Triage to Done in FastLED Trackeron Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions