Skip to content

diag(teensy4/flexio-rx): dump DMA + FLEXIO1 state on wait() timeout (refs #3066 phase 1) - #3067

Merged
zackees merged 1 commit into
masterfrom
fix/3066-phase1-dma-diagnostics
Jun 15, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/3066-phase1-dma-diagnostics

Conversation

@zackees

@zackees zackees commented Jun 15, 2026 •

Copy link
Copy Markdown
Member

Summary

First iteration of the /loop loop targeting issue #3066. Phase 1 sub-task 1: confirm DMA channel is actually being triggered.

Adds FL_WARN dumps inside FlexIoRxChannelImpl::wait() that fire when the completion ISR never arrives. The dumps surface:

  • DMA channel state: complete, error, CITER vs BITER → live transfers_done count.
  • FLEXIO1 module state: SHIFTSTAT, SHIFTERR, TIMSTAT, CTRL.

Live findings (verified on Teensy 4.0, COM20)

flexioObjectFledTest test_case=4 (100-LED OBJECT_FLED frame) → wait() times out → diagnostic fires:

DMA complete=0 error=0 CITER=6064/6064 (transfers_done=0)
SHIFTSTAT=0x0 SHIFTERR=0x0 TIMSTAT=0x0 CTRL=0x1

Decoded:

  • DMA armed correctly (CITER == BITER == 6064 = the configured buffer size).
  • DMA never made a single transfer (transfers_done=0) and didn't error.
  • FLEXIO1 module is enabled (CTRL=0x1 = FLEXEN=1).
  • Shifter 0 never latched a value (SHIFTSTAT=0).
  • Timer 0 never reached its compare value (TIMSTAT=0).

→ The DMA hardware trigger path (Shifter status flag → DMAMUX_SOURCE_FLEXIO1_REQUEST0) is dead because the shifter is never triggered, because the timer never compares.

Root cause hypothesis (for Phase 1 sub-tasks 3 + 4)

TIMOD=3 configures the timer as a 16-bit countdown counter loaded from TIMCMP=0xFFFF and decrementing every functional-clock tick (60 MHz post-#2772 fix). TIMRST=6 reloads the counter on every trigger rising edge.

WS2812 bit period ≈ 1.25 µs ≈ 75 ticks at 60 MHz. Counter starts at 65535, decrements ~75 ticks before the next rising edge slams it back to 65535. It never reaches 0, so the timer compare event never fires, so the shifter never shifts, so DMA never triggers.

This is a fundamental misconfig of the FlexIO timer/shifter for the "capture inter-edge interval" use case. The right pattern likely:

  1. Use a different TIMOD for capture (TIMOD=2 "16-bit baud counter" with the shifter latching on a different event), OR
  2. Use the pin-edge → shifter status flag path directly without the timer compare gating it, OR
  3. Drive the timer via the shifter status flag and capture the timer value on each input edge with a different TIMENA/TIMRST combo.

The next loop iteration picks this up as Phase 1 sub-tasks 3–4.

Test plan

  • Live: diagnostic dumps fire correctly and surface the actionable state on Teensy 4.0 timeout.
  • No behavior change for the success path (only adds logging on timeout).
  • CI

Loop housekeeping

After merge, the next iteration will:

Refs #3066

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved timeout diagnostics for data capture operations, now reporting additional system state information to help troubleshoot communication issues.

…refs #3066 phase 1)

Adds FL_WARN dumps inside FlexIoRxChannelImpl::wait() that fire when
the completion ISR never arrives. The dumps surface:

- DMA channel state: complete flag, error flag, CITER vs BITER (so
  'transfers_done' is visible without an oscilloscope).
- FLEXIO1 module state: SHIFTSTAT (did shifter 0 ever latch?),
  SHIFTERR, TIMSTAT (did timer 0 ever compare?), CTRL.

Live diagnostic output on Teensy 4.0 (COM20), flexioObjectFledTest
test_case=4 (100-LED OBJECT_FLED frame):

  DMA complete=0 error=0 CITER=6064/6064 (transfers_done=0)
  SHIFTSTAT=0x0 SHIFTERR=0x0 TIMSTAT=0x0 CTRL=0x1

Confirms #3066 Phase 1 sub-task 1: the DMA channel is armed
correctly but never triggered, because the FLEXIO1 timer never reaches
its compare value, so the shifter never sets its status flag, so the
DMA hardware-event trigger never fires. The TIMOD=3 (16-bit counter,
counts down from TIMCMP=0xFFFF) + TIMRST=6 (reload counter on every
trigger rising edge) combination resets the counter on every WS2812
bit-period rising edge before it can count down to 0, so the
timer-compare event never fires and the shifter never latches.

Refs #3066 Phase 1.

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

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 06bae574-3230-4eee-86d2-98826c3ae824

📥 Commits

Reviewing files that changed from the base of the PR and between 689138f and d0c0866.

📒 Files selected for processing (1)
  • src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp

📝 Walkthrough

Walkthrough

On timeout in FlexIoRxChannelImpl::wait(), instead of immediately returning RxWaitResult::TIMEOUT, the function now reads DMA channel flags (complete, error), computes transfers processed from TCD CITER/BITER, and dumps live FLEXIO1 status registers (SHIFTSTAT, SHIFTERR, TIMSTAT, CTRL) via FL_WARN.

Changes

FlexIO RX Timeout Diagnostics

Layer / File(s) Summary
DMA and FLEXIO1 register dump on timeout
src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp
22 lines added to the timeout branch of wait(): reads mDma.complete(), mDma.error(), TCD CITER/BITER (computing transfers-done), and four live FLEXIO1 registers (SHIFTSTAT, SHIFTERR, TIMSTAT, CTRL), logging each via FL_WARN before the existing return RxWaitResult::TIMEOUT.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2766: Established the DMA-based wait()/capture pipeline in the same rx_flexio_channel.cpp.hpp that this PR now extends with timeout diagnostics.

Poem

🐇 When the DMA goes quiet and FLEXIO won't speak,
I peek at each register — SHIFTSTAT, TIMSTAT, unique!
CITER and BITER tell me transfers half-done,
FL_WARN prints the clues before TIMEOUT's begun.
Now debugging stalls is a hop, not a run! 🌟

✨ 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 fix/3066-phase1-dma-diagnostics

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 and usage tips.

@zackees
zackees merged commit 09e46e8 into master Jun 15, 2026
5 of 6 checks passed
@zackees
zackees deleted the fix/3066-phase1-dma-diagnostics branch June 15, 2026 09:32
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 15, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 15, 2026
zackees added a commit that referenced this pull request Jun 15, 2026
…hs (refs #3066 phase 1) (#3068)

Extends the wait()-timeout diagnostic block introduced by PR #3067 to
also dump the first 8 words of mCaptureBuffer on both the TIMEOUT and
SUCCESS exits. Distinguishes 'shifter never fired' from 'shifter fired
but all samples were zero' without an oscilloscope.

Surfaced by loop iter 4 (sub-task 1.6 investigation): trying TIMENA=0 +
TIMRST=0 + TIMCMP=10 free-running sample mode produced
`wait() SUCCESS: transfers_done=0/6064` with mCaptureBuffer all zero —
DMA channel signalled completion (CITER reloaded to BITER) without ever
copying a non-zero word into RAM. The dump turns this into actionable
data the next iteration can use.

The TIMENA=0/TIMCMP=10 experiment itself is reverted; only the
diagnostic stays. The Phase 1 active blocker is still 'wire up FlexIO RX
edge capture', the new puzzle is 'why does DMA report complete with
zero transfers'.

Refs #3066

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 18, 2026
…iter 9) (#3214)

* docs(flexio-rx): document iMXRT FlexIO architectural mismatch (#3066 iter 9)

Adds a top-of-file warning block to rx_flexio_channel.cpp.hpp capturing the
iter-9 root-cause finding from #3066: iMXRT FlexIO shifters cannot snapshot a
peer timer's count into SHIFTBUF, and SMOD=1+TIMOD=3 collides shift-and-store
on the same compare event per NXP's own documentation ('shift registers
cannot shift and store on the same clock, so input data may be lost').

This explains the all-zero captures that PRs #3067/#3068/#3069/#3070/#3071
chased without success and the loop's pause at the 5-PR cap. Future readers
should know not to twist more knobs on this file — the path forward is
FlexPWM RX (Phase 4 of #3066), which has dedicated SMx_CAPTCTRL input-capture
silicon.

Pure comment change. Verified compiles via 'bash compile teensy40 --examples
AutoResearch'. References issue comment #3066/4740201201 for the full
register-by-register NXP cross-check.

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

* fix(flexio-rx): drop emoji per C++ style (CodeRabbit on #3214)

Replace the warning-triangle emoji with a 'WARNING:' text prefix per
the FastLED C++ guideline against emoji in source files.

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.

1 participant