Skip to content

fix(teensy4): autoresearch framework hang + Teensy 4 USB-CDC DTR race + LPUART polish - #3423

Merged
zackees merged 15 commits into
masterfrom
feat/lpuart-ws2812-driver
Jun 27, 2026
Merged

zackees merged 15 commits into
masterfrom
feat/lpuart-ws2812-driver

Conversation

@zackees

@zackees zackees commented Jun 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Post-#3421 follow-up: addresses the framework-level autoresearch hang that was misattributed to the LPUART driver, plus the underlying USB-CDC DTR race in fl::print/println, plus remaining CodeRabbit / pin-map / lint polish.

Commits (oldest first)

  • 1ecf032c2a — lint cleanup (BareAllocationChecker, IwyuPragmaPrivateChecker, NoexceptAstChecker, UnityBuildChecker, BannedMacrosChecker); single Bus::UART registration (removed duplicate Bus::LPUART that triggered ChannelManager replace-driver path on every boot)
  • 7d795766a0 — pin map audit against Teensyduino HardwareSerial[1-8].cpp; added per-pin `mux_alt` field; added T4.1 entries (pins 35, 47, 53); corrected `kLPUARTTxPins` public contract; trimmed flexIoDiagnostics/flexPwmRxDiagnostics JSON for LPUART tests
  • 6a46bb2240 — autoresearch framework hang fix. Root cause: FL_WARN unconditionally constructs fl::sstream() << X even under ScopedLogDisable (which only suppresses OUTPUT). Cumulative heap alloc/free cycles leave Teensy 4 heap in a state where function-exit destructor of heap-backed fl::string hangs (~80% of runs). Fix: AR_FL_WARN/AR_FL_ERROR macros gate sstream construction on fl::getLogLevel(). Swept 73 sites in AutoResearchTest.cpp + 8 in AutoResearchHelpers.cpp. LPUART autoresearch: 1/5 → 5/5 success. Closes [teensy4] OBJECT_FLED 100-LED autoresearch: ~5% jitter — re-investigate post-#3342 FL_WARN audit #3343.
  • 6c2d12e80d — fl::print/println: ride out Teensy 4 USB-CDC DTR debounce. Teensyduino's `usb_serial_class::operator bool()` returns false for 15ms after every DTR transition (line discipline settle, usb_serial.h:166-169). Without this fix, messages emitted immediately after host re-opens the serial port are silently dropped. New `waitForSerialReady_DtrSettle()` helper: fast-paths Serial-already-true, otherwise yields in bounded 30ms loop (2× debounce).
  • 91f410bf4c — extend DTR settle to fl::flush + fl::serial_ready (same race surface)

Bench results (Teensy 4.0, --tx-pin 8 --rx-pin 22)

Driver Baseline After this PR
LPUART 1/5 success (intermittent ~55s hang) 5/5 success (0.3-2.0% byte corruption — noise floor matching FlexIO/ObjectFLED)
FlexIO 0/5 success 1-2/5 success (residual heap pressure beyond AR_FL_WARN scope; tracked)

Closes

Test plan

  • `bash lint --cpp` clean
  • `bash test --cpp` — 338/338 pass
  • `bash compile teensy40 --examples AutoResearch` ✓
  • `bash compile esp32dev --examples Blink` ✓
  • `bash compile uno --examples Blink` ✓
  • Hardware bench validation per table above

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added Teensy 4.x LPUART-based LED output support, expanding available driver options.
    • Improved serial connection handling so early messages are less likely to be dropped after reconnects.
    • Added richer runtime diagnostics and better test/run reporting for supported drivers.
  • Bug Fixes

    • Corrected Teensy pin mapping for LPUART-capable boards.
    • Reduced noisy or misleading logging during async runs.
    • Improved driver detection so LPUART is recognized consistently in timing/decoding flows.

zackees and others added 14 commits June 26, 2026 16:15
Adds Bus::LPUART workstream A from #3023:

- src/.../drivers/lpuart/lpuart_encoder.h: header-only WS2812 -> UART
  byte encoder. 2 WS2812 bits per UART byte using TXINV semantics.
  Wire pattern per bit at 4 Mbps:
    '0' -> H L L L L  (250 ns + 1000 ns)
    '1' -> H H H L L  (750 ns + 500 ns)
  Pair-to-byte table: (0,0)->0xEF, (0,1)->0x8F, (1,0)->0xEC, (1,1)->0x8C.
- src/.../drivers/lpuart/lpuart_driver.{h,cpp.hpp}: Teensy 4.x real
  driver. Configures LPUARTn for 4 Mbps with TXINV + TDMAE, programs
  the IOMUXC pad to ALT2 + SION, allocates a 4 KB DMAMEM buffer, and
  drives eDMA from the encoded byte stream to LPUARTn_DATA.
- src/.../drivers/lpuart/lpuart_peripheral_real.cpp.hpp: ILPUARTPeripheral
  factory for Teensy 4.x. Wraps the procedural driver in the existing
  ILPUARTInstance interface that the mock in
  src/platforms/shared/mock/arm/teensy4/drivers/lpuart/ already targets.
- tests/.../drivers/lpuart/lpuart_encoder.cpp: 8 host-side unit tests
  covering all-zeros, all-ones, MSB-first ordering, palindromic
  patterns, the pair-byte table, and the wire-format invariant.

Verified:
- bash test ilpuart_peripheral: existing mock interface tests pass
- bash test lpuart_encoder: 8/8 encoder tests pass on host
- bash compile teensy40 --examples Blink: clean build on T4.0 with
  the new driver in the unity build path

Pin map (T4.0): pin 1/8/14/17/20/24/29 map to LPUART6/4/2/3/8/1/7
TX respectively. Bench-rig pin 8 reuses the existing FlexIO/ObjectFLED
loopback jumper to FlexPWM-RX pin 22.

Refs #3023
Add the high-level ChannelEngineLPUART (mirrors ChannelEngineFlexIO)
plus a BusTraits<Bus::LPUART> specialisation so Bus::LPUART routes
through the real Teensy 4.x driver.

- channel_engine_lpuart.{h,cpp.hpp}: engine creates one ILPUARTInstance
  per (pin, strip-length) combination, encodes raw WS2812 bytes into
  the instance buffer using lpuart_encode_byte(), and calls
  instance->show().
- bus_traits.h: standard registerWithManager() pattern.
- lpuart_driver: add lpuart_show_encoded() for callers (the engine)
  that pre-encode externally; refactor common TCD arming into
  lpuart_arm_dma().
- bus_priorities.h: Bus::LPUART defaults to priority 1 (same as FlexIO
  and ObjectFLED).

Teensy 4.0 AutoResearch builds clean. Hardware test next.
Hardware bring-up progress on Teensy 4.0:
- Init sequence runs cleanly: clock gate, BAUD config, FIFO+CTRL,
  pin mux + IOMUXC SELECT_INPUT daisy.
- LPUART4 STAT = 0xC00000 after configure -> TC+TDRE both set,
  transmitter is alive.
- Polled writes successfully push 1200 wave8 UART bytes in 10 ms
  (= ~120 kbps actual due to per-byte STAT-polling overhead, well
  short of the 4 Mbps the BAUD divisor targets but proves the
  hardware path works).
- DMA arming sequence currently never sees the major-loop ISR fire;
  next iteration adds DMA_ES + CITER snapshots to diagnose whether
  TDMAE is being honored.

Also wires --lpuart through the autoresearch driver dispatcher and
enables Bus::LPUART in the Teensy 4.x enableAllChannelDrivers list.

Hardware test reproducible: bash autoresearch teensy40 --lpuart
--tx-pin 8 --rx-pin 22 reaches LPUART firmware and emits bytes on
pin 8 (polled path). Full WS2812-rate DMA path is the remaining
work.
Working LPUART driver path bring-up:
- Force CCM_CSCDR1 UART_CLK_SEL=PLL3_80M / UART_CLK_PODF=1 so the
  LPUART clock is 80 MHz regardless of what the Teensyduino boot
  state left CSCDR1 at. Empirical: post-boot the LPUART clock was
  24 MHz, making OSR=4/SBR=4 produce ~1.2 Mbps instead of 4 Mbps.
- Move triggerAtHardwareEvent() + attachInterrupt() out of the
  per-show arm path into lpuart_dma_init() (set once at init).
- Add LPUART transmit-complete (STAT.TC) wait after the DMA major-
  loop ISR fires, so the final byte fully drains through the FIFO
  + shift register before show_encoded() returns.

Hardware verification (bench loopback, Teensy 4.0 pin 8 -> pin 22
via FlexPWM4_SM0_A RX):

  raw_sample: H753 L499 H746 L499 H753 L499 ... H253 L999 H246 L999
  -> exactly matches wave8 4-Mbps encoding:
       '1' bit = ~750 ns HIGH + ~500 ns LOW
       '0' bit = ~250 ns HIGH + ~1000 ns LOW
  -> Byte corruption: 1.4% (17/1200) on the first 4-pattern frame
     -- matches the FlexIO/ObjectFLED noise floor on the same rig.

DMA progression confirmed via CITER snapshots (in earlier diagnostic
revs): CITER decrements smoothly from BITER=1200 to 0 within ~3 ms
at 4 Mbps, then the major-loop ISR fires and resets CITER back to
BITER and sets sLpDmaComplete = true.

Still TODO: the autoresearch RPC sometimes times out after 2 TX
frames before the test framework collects results. The TX driver
itself completes cleanly each time -- the hang is in the test
harness's between-pattern handoff, not in the LPUART path.
- Replace function-local static CachedInstance with proper member
  state (mInstance, mCurrentPin, mCurrentRawBytes, mCurrentTiming)
  mirroring ChannelEngineFlexIO's per-engine cache pattern.
- Add yield() after each show() so the USB-CDC RPC stack can flush
  responses; without it the autoresearch test pipeline stalls.
- Per user note: ws2812b-v5 datasheet specifies 150 us reset/latch,
  not the 280 us we had hard-coded. Update TIMING_WS2812B_MINI_V3
  (which TIMING_WS2812B_V5 aliases). The longer 280 us was a
  conservative carry-over from older WS2812 variants.
Audited every entry in kLpuartPins[] against the matching
UARTn_Hardware struct in Teensyduino's HardwareSerial[1-7].cpp and
the IOMUXC_SW_MUX_CTL_PAD_GPIO_* offsets in imxrt.h. Found 6 of 7
entries had wrong mux_offset/pad_offset/select_input_value -- only
pin 8 was correct, which is why the bench rig works there but other
pins would have silently driven the wrong pad.

Corrected (all entries verified for Teensy 4.0):
  pin  1 -> LPUART6 TX, GPIO_AD_B0_12 (mux 0x0EC),  SELECT_INPUT=1
  pin  8 -> LPUART4 TX, GPIO_B1_00    (mux 0x17C),  SELECT_INPUT=2
  pin 14 -> LPUART2 TX, GPIO_AD_B1_02 (mux 0x104),  SELECT_INPUT=1
  pin 17 -> LPUART3 TX, GPIO_AD_B1_06 (mux 0x114),  SELECT_INPUT=0
  pin 20 -> LPUART8 TX, GPIO_AD_B1_10 (mux 0x124),  SELECT_INPUT=1
  pin 24 -> LPUART1 TX, GPIO_AD_B0_13 (mux 0x0F0),  no SELECT_INPUT
  pin 29 -> LPUART7 TX, GPIO_EMC_31   (mux 0x090),  SELECT_INPUT=1

Also revert WS2812B_V5 RESET back to 280 us per user follow-up.

Strip debug Serial.printf from engine + driver. Engine kept member-
state refactor (mInstance/mCurrentPin/mCurrentRawBytes) + yield()
after show.

Hardware status: bench rig with pin 8 LPUART loopback to pin 22
FlexPWM RX intermittently completes the 4-pattern test at the
~1% byte corruption noise floor matching FlexIO/ObjectFLED. Some
runs RPC-timeout downstream of the engine show() -- the LPUART TX
itself completes cleanly each time per the diagnostic snapshots.
In examples/AutoResearch/AutoResearchTest.cpp `is_uart_driver` was
narrowly checking `driver_name == "UART"`. The LPUART driver
emits a wave8-encoded 4 Mbps signal whose wire shape is functionally
identical to the existing UART path -- T0H=250 ns, T1H=750 ns,
T1L=500 ns -- so it should take the same decode branch (UART-specific
timing thresholds, 500 ms RX wait, gap_tolerance_ns=100us). Expand
the check to also match LPUART.
5 actionable findings:

- bus_traits.h: move BusTraits<Bus::LPUART>::instancePtr() function-
  local static `gHolder` out of the header into the .cpp.hpp TU
  (per repo's no-static-in-headers rule).
- channel_engine_lpuart.h: move getName() / getCapabilities() bodies
  out of the header into the .cpp.hpp.
- channel_engine_lpuart.cpp.hpp: clear mHwInitialized/mCurrentPin/
  mCurrentRawBytes BEFORE attempting createInstance() so a failed
  create leaves the engine in a clean re-init-required state instead
  of a half-torn-down state that the next channel could inherit.
- lpuart_driver.cpp.hpp: honour reset_us. Record the previous
  frame's end-of-TC micros and stall the next show until reset_us
  has elapsed -- contractual fix per the public docstring.
- ci/autoresearch/args.py: pin-to-LPUART mapping is board-dependent
  (T4.0 vs T4.1), don't hard-code "pin 8 -> LPUART4" in help text.

Remaining CodeRabbit MAJOR finding (pin map missing pins 35/47/48
per kLPUARTTxPins contract) is T4.1-only / SD-bottom-pad coverage,
deferred to follow-up.

Verified: teensy40 AutoResearch builds clean, lpuart_encoder host
tests still 1/1 pass.
Per user feedback:
- BusTraits<Bus::UART> specialised for Teensy 4.x to route through
  ChannelEngineLPUART. This matches the ESP32 pattern where Bus::UART
  binds to that platform's UART hardware; sketches that name
  Bus::UART work portably across both platforms.
- Bus::LPUART kept as an alias resolving to the same singleton
  instance so code that names the hardware directly still works.

CodeRabbit-flagged fixes:
- lpuart_encoder.h: replace `u8*` with `fl::span<u8, 4>` (static-
  extent span) so the 4-byte-output contract is checked at the type
  level. Call sites use `fl::span<u8, 4>{&buf[i*4], 4}`.
- lpuart_driver.cpp.hpp: reject oversize transfers instead of
  silently truncating them (was logging + truncating + returning
  success, leaving tail LEDs stale).
- lpuart_peripheral_real.cpp.hpp: return nullptr from createInstance
  if hardware init failed inside the constructor, instead of handing
  back a non-functional instance that would silently drop frames.
  Switch mTxBuffer from raw `new[]`/`delete[]` to
  `fl::unique_ptr<u8[]>` RAII.

Verified: bash test lpuart_encoder 8/8 pass; bash compile teensy40
AutoResearch clean.
- channel_drivers_teensy.impl.hpp: register only Bus::UART (not both
  Bus::UART and Bus::LPUART). Both resolve to the same singleton via
  the trait alias in bus_traits.h, so registering both was triggering
  the ChannelManager replace-driver path on every boot.

- lpuart_encoder.h: add IWYU pragma: private + FL_NO_EXCEPT on the
  two inline encode helpers.

- lpuart_driver.cpp.hpp: suppress BareAllocationChecker on the
  DMAChannel new/delete pair (Teensyduino DMAChannel has no
  fl smart-pointer factory).

- _build.cpp.hpp: alphabetize unity build includes (channel_engine
  before lpuart_*).

- flexio_driver.cpp.hpp: use FL_STATIC_ASSERT instead of raw
  static_assert per BannedMacrosChecker.

- third_party/object_fled/src/_build.cpp.hpp: alphabetize (ObjectFLED
  before ObjectFLEDDmaManager).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Pin map audit (per user's "Audit pin map against every Teensyduino
HardwareSerial*.cpp" blocker):
- Cross-referenced every kLpuartPins entry against the corresponding
  HardwareSerial[1-8].cpp UARTn_Hardware struct's {pin, mux_val,
  select_input_reg, select_input_value} 4-tuple.
- Added per-entry mux_alt field so the T4.1 LPUART5_TX (pin 35,
  ALT 1, not 2) doesn't get force-driven through the wrong alt.
- Added T4.1-only entries (pins 35, 47, 53) gated on
  ARDUINO_TEENSY41. Verified IOMUXC offsets against imxrt.h.
- Corrected the kLPUARTTxPins public contract: the original list
  included pin 48 (which is actually LPUART5_RX_ALT on T4.1, not
  a TX pin) and was missing pin 53 (the real T4.1 LPUART6_TX_ALT).
  Fixed list is {1, 8, 14, 17, 20, 24, 29, 35, 47, 53}.

JSON-RPC minimization (per user "json-rpc should be kept to the
minimal possible without excessive spam"):
- runSingleTestImpl: skip flexPwmRxDiagnostics and flexIoDiagnostics
  emit for LPUART tests. Both are FlexIO/FlexPWM register snapshots
  that surface nothing LPUART-relevant; LPUART status already lives
  in lpuart_read_diagnostics. Trims ~660 bytes of JSON per response.
- ScopedLogDisable scope: kept enabled for all drivers including
  LPUART (per-driver carve-out empirically worsened hangs to 0/3
  due to USB-CDC saturation from FL_WARN spam during the 4-pattern
  loop).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Resolves intermittent ~55s RPC timeout on Teensy 4 clockless tests
(LPUART, FlexIO, ObjectFLED autoresearch) when the test framework's
RPC ASYNC handler wraps execution in `fl::ScopedLogDisable`.

Root cause (marker-narrowed across this session):
`FL_WARN(...)` macro ALWAYS constructs `fl::sstream() << X` regardless
of log level -- `ScopedLogDisable` only suppresses OUTPUT inside
`log_emit`. The cumulative `fl::sstream`/`fl::string` heap alloc/free
cycles across this file's many FL_WARN sites (banner, per-run dump,
per-pattern hex dump, summary, OVERALL pass/fail) leave the Teensy 4
heap in a state where the function-exit destructor of a heap-backed
`fl::string` hangs indefinitely -- traced via Serial.println markers
to the `fl::variant<NotNullStringHolderPtr, ...>` destructor in
fl::sstream::~fl::sstream() at the close of runMultiTest.

Reproduction: ~80% of LPUART/FlexIO/ObjectFLED runs hung at exactly
`mt_pre_inner_close` marker → no `mt_dtors_done` → no
`art_after_multitest` → ~55s host timeout.

Fix: introduce `AR_FL_WARN` / `AR_FL_ERROR` macros that check
`fl::getLogLevel()` before expanding FL_WARN -- when under
ScopedLogDisable (level=NONE), the sstream is never constructed and
the heap stays clean. Sed-swept all 73 FL_WARN sites in
AutoResearchTest.cpp and 8 sites in AutoResearchHelpers.cpp.

Also gates `flexIoDiagnostics` / `flexPwmRxDiagnostics` JSON emit
to OBJECT_FLED only (their original #3343/#3410 purpose). LPUART
and FLEX_IO no longer carry that ~660-byte / 22-field JSON payload
that further compounds the heap pressure post-test.

Results (bench rig, Teensy 4.0, --lpuart --tx-pin 8 --rx-pin 22):
- LPUART:  1/5 baseline → 5/5 success (clean 0.3-2.0% noise floor)
- FlexIO:  0/5 baseline → 1-2/5 success (intermittent residual --
           likely additional heap pressure outside this file; not
           blocking since FlexIO landed via #3415 prior)
- LPUART tests now return reliable byte-corruption reports
  matching FlexIO/ObjectFLED noise floor, confirming the LPUART
  driver itself works correctly when the framework returns.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Per /goal "USB-CDC DTR race" research follow-up.

Teensy 4 `Serial.operator bool()` (usb_serial.h:166-169) returns
false for a hard-coded 15ms after every DTR transition (line
discipline settle window). Without a retry on the device side, the
first messages emitted by the device after a host re-opens the
serial port are silently dropped -- the `if (!Serial) return;`
guard in fl::print/fl::println short-circuits before the debounce
clears.

Reproduction surface: autoresearch RPC reconnects for each new test
session (close → re-open). Device output during the first ~15ms
after re-open vanishes -- visible as "missing log lines between
RPC sessions" or "first FL_WARN after reconnect never arrives".

Fix: extract a small `waitForSerialReady_DtrSettle()` helper that:
  - Fast-paths the common case (Serial already true → no wait)
  - Otherwise yields in a bounded 30ms loop (2× the Teensy 4
    debounce) waiting for `Serial.operator bool()` to settle true
  - Drops the message after 30ms if host is genuinely absent

On non-Teensy Arduino platforms `Serial.operator bool()` either
always returns true (real UART) or has its own non-blocking drop
path (ESP32 HWCDC: setTxTimeoutMs(0) applied by fl::begin()), so
the 30ms bound is invisible there.

Cross-platform compile verified: teensy40 ✓, esp32dev ✓, uno ✓.
Lint clean. 338/338 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Follow-up to 6c2d12e. The DTR debounce race window doesn't only
affect fl::print/fl::println -- fl::flush and fl::serial_ready use
the same `if (!Serial) return ...` short-circuit pattern, and would
also report "host absent" during the first ~15ms after a host
re-opens the USB-CDC port on Teensy 4.

Wire both through the same `waitForSerialReady_DtrSettle()` helper
so the device-side host-presence view stays consistent across all
three paths: print, flush, and the explicit ready-check.

`fl::write_bytes` is intentionally left untouched -- it does not
gate on `Serial`, so the underlying `Serial.write` path drives its
own back-pressure / drop semantics (Teensy 4 usb_serial_write has
its own 120ms tx-buffer-wait timeout). LPC platforms are also
intentionally left untouched -- their Arduino-core USB-VCOM bridge
has different debounce semantics that aren't documented to need
the same window.

Cross-platform compile: teensy40 ✓, esp32dev ✓.
Lint clean. 338/338 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Implements a complete Teensy 4.x LPUART clockless LED driver: Wave8 encoder, eDMA low-level driver, ILPUARTPeripheral real backend, ChannelEngineLPUART, BusTraits registration for Bus::UART/Bus::LPUART, unity-build wiring, and Arduino serial DTR-settle fix. AutoResearch CI --lpuart flag is unblocked. All FL_WARN/FL_ERROR sites in AutoResearch tests are gated behind AR_FL_WARN/AR_FL_ERROR macros to prevent fl::sstream heap construction under ScopedLogDisable.

Changes

Teensy 4.x LPUART Clockless Driver

Layer / File(s) Summary
Wave8 encoder and tests
src/.../lpuart/lpuart_encoder.h, tests/.../lpuart/lpuart_encoder.cpp
Header-only lpuart_pair_to_byte and lpuart_encode_byte (4 UART bytes per WS2812 byte, MSB-first). Host-side tests validate all byte patterns and wire-format invariants.
Low-level LPUART eDMA hardware driver
src/.../lpuart/lpuart_driver.h, src/.../lpuart/lpuart_driver.cpp.hpp, src/.../lpuart/ilpuart_peripheral.h
Full LpuartPinInfo/LpuartDiagnostics public interface and implementation: pin-to-LPUART IOMUXC mapping, 4 Mbps baud config, eDMA TCD arming, frame-latch timing, bounded wait with timeout recovery, teardown, diagnostics. Corrects kLPUARTTxPins (pin 48 → 53).
ILPUARTPeripheral real backend
src/.../lpuart/lpuart_peripheral_real.cpp.hpp
LPUARTInstanceReal owns encoded TX buffer and calls lpuart_init/show_encoded/deinit. LPUARTPeripheralReal validates pin/buffer overflow and constructs the instance. ILPUARTPeripheral::create() returns the Teensy 4.x implementation.
ChannelEngineLPUART and BusTraits
src/.../lpuart/channel_engine_lpuart.h, src/.../lpuart/channel_engine_lpuart.cpp.hpp, src/.../lpuart/bus_traits.h, src/fl/channels/bus_priorities.h
Declares/implements fl::ChannelEngineLPUART with canHandle, enqueue, show (conditional hardware reinit, 4× encoding, blocking transmit), and poll. Adds BusTraits<Bus::UART>/BusTraits<Bus::LPUART> sharing a singleton, BusSupports for ClocklessChipset, and Bus::LPUART priority=1.
Unity-build wiring and driver registration
src/.../lpuart/_build.cpp.hpp, src/.../drivers/_build.cpp.hpp, src/.../channel_drivers_teensy.impl.hpp, src/.../flexio/flexio_driver.cpp.hpp, src/third_party/object_fled/src/_build.cpp.hpp, src/fl/chipsets/led_timing.h
New LPUART unity-build header included in top-level drivers aggregation. Bus::UART registered in enableAllChannelDrivers(). FlexIO switches to FL_STATIC_ASSERT. ObjectFLED include order swapped.
Arduino serial DTR-settle fix
src/platforms/arduino/io_arduino.hpp
Adds waitForSerialReady_DtrSettle() with a 30ms bounded yield loop. Updates print, println, flush, and serial_ready to use it instead of raw (bool)Serial.
AR_FL_WARN/AR_FL_ERROR log-gating macros
examples/AutoResearch/AutoResearchHelpers.cpp, examples/AutoResearch/AutoResearchTest.cpp
Introduces AR_FL_WARN/AR_FL_ERROR macros gated on fl::getLogLevel() to prevent fl::sstream construction under ScopedLogDisable. Converts all FL_WARN/FL_ERROR sites in testDriver, runTest, runMultiTest, and capture(). Adds kLogsEnabled guard in runMultiTest. Expands UART detection in capture() to include "LPUART".
AutoResearch CI LPUART enablement and diagnostics gating
ci/autoresearch/args.py, ci/autoresearch/phases.py, examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp
Removes --lpuart reserved-flag rejection in phases.py, updates help text. Gates FlexPWM/FlexIO diagnostics emission to driver_name == "OBJECT_FLED" only.

Sequence Diagram(s)

sequenceDiagram
  participant AutoResearch as AutoResearch CI
  participant ChannelEngineLPUART
  participant LPUARTPeripheralReal
  participant lpuart_driver as lpuart_driver (eDMA)
  participant LPUART_HW as LPUART / DMA HW

  AutoResearch->>ChannelEngineLPUART: enqueue(ChannelData)
  AutoResearch->>ChannelEngineLPUART: show()
  ChannelEngineLPUART->>ChannelEngineLPUART: conditional createInstance (pin/timing changed)
  ChannelEngineLPUART->>LPUARTPeripheralReal: createInstance(pin, total_leds)
  LPUARTPeripheralReal->>lpuart_driver: lpuart_init(pin_info, reset_us)
  lpuart_driver->>LPUART_HW: configure IOMUXC, BAUD, FIFO, DMA
  ChannelEngineLPUART->>ChannelEngineLPUART: lpuart_encode_byte × N into TX buffer
  ChannelEngineLPUART->>LPUARTPeripheralReal: show()
  LPUARTPeripheralReal->>lpuart_driver: lpuart_show_encoded(buffer, uart_bytes)
  lpuart_driver->>LPUART_HW: arm DMA TCD, enable TDMAE
  LPUART_HW-->>lpuart_driver: DMA TC interrupt
  lpuart_driver->>lpuart_driver: lpuart_wait (50ms timeout)
  lpuart_driver-->>LPUARTPeripheralReal: done
  LPUARTPeripheralReal-->>ChannelEngineLPUART: done
  ChannelEngineLPUART-->>AutoResearch: READY
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#3357: This PR directly reverses that PR's explicit disabling of --lpuart in ci/autoresearch/phases.py, removing the fail-fast guard that PR added.
  • FastLED/FastLED#3032: This PR updates ilpuart_peripheral.h to correct kLPUARTTxPins, directly extending the LPUART interface/mock scaffold introduced in that PR.
  • FastLED/FastLED#3421: Both PRs modify bus_priorities.h, the drivers/lpuart channel engine/peripheral, and AutoResearch log-gating in the same files and code paths.

Poem

🐇 Hop hop, the LPUART is free!
No more "reserved" blocking me.
Four UART bytes per WS bit,
eDMA streams—a perfect fit.
AR_FL_WARN guards the heap with care,
Teensy 4.x LEDs flash everywhere! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main themes of the PR: AutoResearch hang fixes, Teensy 4 USB-CDC DTR timing, and LPUART-related cleanup.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/lpuart-ws2812-driver
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch feat/lpuart-ws2812-driver

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…driver

# Conflicts:
#	examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[teensy4] OBJECT_FLED 100-LED autoresearch: ~5% jitter — re-investigate post-#3342 FL_WARN audit

1 participant