Skip to content

diag(objectfled): snapshot XBARA1_SEL0/SEL1 (correct timer→DMA wiring registers) - #3393

Merged
zackees merged 1 commit into
teensy-fixfrom
diag/objectfled-xbar-sel0-snapshot
Jun 25, 2026
Merged

zackees merged 1 commit into
teensy-fixfrom
diag/objectfled-xbar-sel0-snapshot

Conversation

@zackees

@zackees zackees commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

The existing ObjectFLED snapshot reads XBARA1_SEL15 / XBARA1_SEL47 but ObjectFLED actually programs XBARA1_SEL0 and XBARA1_SEL1. Teensy core maps XBARA1_OUT_DMA_CH_MUX_REQ30 = 0, REQ31 = 1, REQ94 = 2 (XBAR output indices, not register addresses), and xbar_connect() writes to XBARA1_SEL(output / 2).

Adds xbar.sel0 and xbar.sel1 to every snapshot event. No runtime behavior change.

First run evidence on canonical TX 22 -> RX 8

xbar.sel0=0x2524  -> output 0 src=0x24=36 (QTIMER4_TIMER0)
                     output 1 src=0x25=37 (QTIMER4_TIMER1)
xbar.sel1=0x0026  -> output 2 src=0x26=38 (QTIMER4_TIMER2)

ObjectFLED's TMR4 -> XBAR -> DMAMUX -> DMA wiring is confirmed correct. Combined with prior diagnostics this rules out one more layer; zero_capture root cause remains unidentified.

Test plan

  • bash test --unit -> 254/254
  • bash lint --cpp -> clean (PlatformIO-internal-usage warnings unchanged)
  • bash autoresearch teensy41 --object-fled --tx-pin 22 --rx-pin 8 --timeout 120 --skip-lint -> completes normally, class=zero_capture, new xbar.sel0/sel1 fields render with the QTIMER4 source bytes.

Refs: #3359

🤖 Generated with Claude Code

…FLED actually programs)

ObjectFLED wires TMR4 to DMA via xbar_connect() with output indices
XBARA1_OUT_DMA_CH_MUX_REQ30=0, REQ31=1, REQ94=2 (Teensy core macros).
xbar_connect() therefore writes to XBARA1_SEL0 (outputs 0 + 1) and
XBARA1_SEL1 (outputs 2 + 3), NOT to SEL15 / SEL47 the existing
snapshot was reading. Adds xbar.sel0 / xbar.sel1 fields to every
snapshot event.

First diagnostic run on canonical TX 22 -> RX 8 confirms:
  xbar.sel0=0x2524  -> output 0 src=0x24=36 (QTIMER4_TIMER0)
                       output 1 src=0x25=37 (QTIMER4_TIMER1)
  xbar.sel1=0x0026  -> output 2 src=0x26=38 (QTIMER4_TIMER2)

So the TMR4 -> XBAR -> DMAMUX -> DMA chain is wired exactly as
ObjectFLED requests. Combined with the existing evidence
(DMA citer decrements, dma1 daddr cycles GPIO1..4_DR_SET, dma2/dma3
daddr cycles GPIO1..4_DR_CLEAR, standard-bank DR_SET / DR_CLEAR
writes via the probe reach the pad), the TX-side hardware program
is internally consistent with WS2812 generation. Zero capture is
still observed; root cause remains in a layer the current
diagnostics do not yet expose.

No runtime behavior change.

Validation:
- bash test --unit: 254/254 passed
- bash lint --cpp: clean
- bash autoresearch teensy41 --object-fled --tx-pin 22 --rx-pin 8
  --timeout 120 --skip-lint: completes normally, returns
  zero_capture (no regression), new xbar.sel0/sel1 fields render.

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

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 84c98c15-c2b0-4d17-9963-9c8f9d911188

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch diag/objectfled-xbar-sel0-snapshot

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.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 25, 2026
@zackees
zackees merged commit 3ea9d89 into teensy-fix Jun 25, 2026
1 check passed
@zackees
zackees deleted the diag/objectfled-xbar-sel0-snapshot branch June 25, 2026 20:45
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 25, 2026
zackees added a commit that referenced this pull request Jun 26, 2026
…rdening (#3405)

* Harden Teensy AutoResearch guardrails (#3360)

* Wire AutoResearch capture diagnostics (#3361)

* Harden AutoResearch test RPC acceptance (#3362)

* Require AutoResearch test pin metadata (#3363)

* Require AutoResearch capture backend metadata (#3364)

* Require AutoResearch capture evidence for PASS

* Classify AutoResearch hardware failures

Classifies AutoResearch hardware failures for Teensy/ObjectFLED bring-up.

* Sync AutoResearch default pins with firmware

Synchronize AutoResearch host fallback pins with firmware platform defaults, including Teensy 4.x, ESP32-S3, ESP32-P4, CLI half-overrides, and failed pin-discovery fallback. Validated with focused pytest, ruff, and diff checks.

* Always apply AutoResearch effective pins

Queue setPins for every final effective AutoResearch TX/RX pair, including defaults, discovered pins, and discovery fallback. Adds focused coverage for all pin setup paths.

* fix(autoresearch): expose Teensy FlexIO default pins

Expose the Teensy FlexIO omitted-TX default through AutoResearch effective pin setup instead of hidden runSingleTest params. Validation: pytest ci/tests/test_autoresearch_phases.py -q; ruff check; ruff format --check; git diff --check.

* fix(autoresearch): verify setup pin state

Require setup RPC pin echoes to match wrapper-requested pins, classify mismatches as pin_state_mismatch, and keep setPins normal-path state in JSON-RPC instead of FL_PRINT.

* fix(autoresearch): block stale upload and direct runtime output

- remove stale .pio Teensy pre-upload from AutoResearch port detection so fbuild owns deploy
- add AutoResearch runtime output lint for direct FastLED/Serial logging in scoped runtime files
- convert scoped diagnostics to JSON-RPC/JSONL result data

* fix(autoresearch): map Teensy SPI to SPI_UNIFIED

Map Teensy AutoResearch --spi to the registered SPI_UNIFIED driver, wire firmware SPI test/decode paths for SPI_UNIFIED, and harden scoped AutoResearch runtime-output linting.

* diag(objectfled): attach register snapshots

Adds AutoResearch-attached ObjectFLED register snapshots for issue #3359 S3.

* fix(objectfled): reclaim gpio mux after pwm (#3375)

* fix(objectfled): drain dma before ready (#3376)

* diag(objectfled): report busy state snapshots

* fix(objectfled): flush legacy groups at frame end (#3378)

* fix(objectfled): transmit raw framebuffers (#3379)

* fix(objectfled): finalize legacy strips once per frame (#3380)

* test(objectfled): cover legacy one-strip path

Add current Teensy pin-22 legacy ObjectFLED one-strip coverage and tighten AutoResearch runtime-output lint.

* test(objectfled): cover legacy same-timing strips

Allow historical legacy multi-lane AutoResearch requests and add same-timing ObjectFLED regression coverage.

* tighten autoresearch output lint (#3383)

* add legacy mixed timing coverage (#3384)

* test(objectfled): cover legacy RGBW small counts (#3385)

* Guard ObjectFLED runtime output paths

Extend AutoResearch runtime-output lint markers to driver .cpp.hpp files and protect ObjectFLED transmit paths.

* Add explicit ObjectFLED channel pixel formats (#3387)

* Harden ObjectFLED ownership and test paths (#3388)

* fix(objectfled): enable standard GPIO clocks + alias mode sync, FlexPWM RX fixes, AutoResearch diagnostics (#3389)

ObjectFLED hardware fixes (S4/S8 related):
- ObjectFLED::begin() now enables CCM_CCGR1/0/2/3 GPIO1-4 clocks before
  remapping fast GPIO6-9 to standard GPIO1-4 via IOMUXC_GPR_GPR26..29.
  Without this, DMA writes to the standard GPIO alias addresses had no
  observable effect on the pad, producing zero RX capture even though
  DMA, TCD, and busy state all reported success.
- New configure_pin_output_aliases() programs both the fast and standard
  GDIR registers as outputs and clears any pending DR bits in both
  aliases so the pad is in a known state before DMA drives it.
- ObjectFLEDDmaManager::waitForCompletion() gains a 250 ms watchdog and
  returns bool, so a stuck DMA fails cleanly instead of spinning forever.

FlexPWM RX corrections (S9 acceptance prerequisite):
- IOMUXC_FLEXPWM*_PWMA*_SELECT_INPUT daisy-chain values were 0 (wrong)
  for pins 8, 22, 23, and 36; corrected to the SION-tied alt entry for
  each pad so the FlexPWM submodule actually samples the wired pin.
- FlexPwmRxChannelImpl::wait() now compares CITER against the value
  captured at configureDma()/arm time, not at wait() entry. The earlier
  sampling falsely classified successful capture as TIMEOUT whenever
  FastLED.wait() drained the TX DMA before wait() was invoked.

Diagnostic surface (S3/S11):
- ObjectFLED snapshot adds CCM_CCGR0..3 plus per-pin standard mode/
  input/output and fast mode registers so diagnostics can prove the
  alias bank is clocked and configured.
- New JSON-RPC probes runSingleTest emits on ObjectFLED runs:
  objectFledStandardGpioProbe (manually toggles TX via standard GPIO
  and reads RX to prove electrical connectivity) and
  objectFledRxCaptureProbe (drives manual pulses while sampling
  FlexPWM RX state through flexPwmRxDiagnosticsToJson()).
- RunResult/runSingleTest response now include per-pattern decodeOk,
  decodeError, decodeBytes, decodeOutputCapacity, and a compact
  rawEdgeSample, so AutoResearch failures can distinguish decode
  failure vs zero capture vs partial capture without serial spam.
- context.py renders the new RX/decode fields and probe summaries
  alongside the existing ObjectFLED diagnostic block.

AutoResearch phase plumbing:
- Removed the broken leading setLaneSizes RPC for --lane-counts; the
  per-lane sizes now ride on the runSingleTest/runParallelTest params
  directly, eliminating a setup-time failure mode and pulling the test
  matrix into a single lane_size_sets list. Existing fan-out semantics
  (drivers x lane_counts x strip_sizes) are preserved.

Validation:
- bash test --unit: 254/254 passed
- bash lint --cpp: clean (PlatformIO-internal-usage warnings unchanged)
- uv run pytest ci/tests/test_autoresearch_phases.py: 81 passed

Refs: #3359

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

* Revert "fix(objectfled): enable standard GPIO clocks + alias mode sync, FlexPWM RX fixes, AutoResearch diagnostics (#3389)" (#3390)

This reverts commit 0527d8d.

* diag(teensy4): emit FlexPWM RX register snapshot on every runSingleTest (#3391)

Adds fl::FlexPwmRxChannel::diagnosticsToJson(pin) - a read-only snapshot
of the active FlexPWM input-capture receiver: IOMUXC mux/select register
live vs expected values, FlexPWM submodule MCTRL/CTRL/CTRL2/DMAEN/
CAPTCTRLA/CAPTCTRLB/CAPTCOMPx, the four CVAL2..CVAL5 capture values,
the receiver DMA channel + DMAMUX + ERQ/HRS/INT/ERR/ES, and the full
TCD descriptor.

Wired into the ObjectFLED branch of runSingleTest so every ObjectFLED
acceptance attempt now returns objectFledDiagnostics AND
flexPwmRxDiagnostics. context.py renders both blocks.

No runtime behavior change in the FlexPWM RX driver, ObjectFLED, or
AutoResearch test loop - this is strictly observability.

First diagnostic run on canonical TX 22 -> RX 8 with this PR confirms
zero-capture root cause is upstream of the receiver: FlexPWM RX is
fully armed (mctrl bit 11 set, captctrla ARMA + EDGA bits set,
dmaen=0x60, dma erq=8) but cval2..cval5 stay at 0 and DMA citer
never decrements, so no edges ever reach the FlexPWM submodule.
That points the next investigation step at whether ObjectFLED's
GPIO1_DR_SET / GPIO1_DR_CLEAR writes actually toggle the standard
GPIO1 alias on pin 22 after IOMUXC_GPR_GPR26 bit 24 is cleared.

Validation:
- bash test --unit: 254/254 passed
- bash lint --cpp: clean (PlatformIO-internal-usage warnings unchanged)
- bash autoresearch teensy41 --object-fled --tx-pin 22 --rx-pin 8
  --timeout 90 --skip-lint: completes in <30s, returns zero_capture
  (no regression), now emits flexPwmRxDiagnostics block

Refs: #3359

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

* diag(autoresearch): add standard-GPIO direct-drive pad probe (#3392)

Adds probeStandardGpioPad(tx_pin, rx_pin) that manually drives the TX
pin via the standard GPIO1-4 alias (clearing IOMUXC_GPR_GPR26 bit,
setting the standard GDIR bit, and pulsing standard DR_SET/DR_CLEAR
in software) while reading RX via digitalReadFast. Probe saves and
restores all touched IOMUXC/GPIO state and never touches FlexPWM or
DMA, so it cannot disturb the subsequent ObjectFLED + FlexPWM RX
test run.

Runs once per ObjectFLED runSingleTest before driver setup; result
is attached as response field standardGpioPadProbe and rendered by
context.py.

First-run evidence on canonical TX 22 -> RX 8:
  standardGpioRxHighCount: 5
  standardGpioRxLowCount: 5
  standardGpioConnected: True

Standard GPIO1 alias *does* reach the pad and *does* drive RX
through the soldered loopback. Combined with the prior FlexPWM RX
diagnostic showing cval2..5=0 / citer never decrements, this
isolates the zero-capture failure to ObjectFLED's DMA-driven TX
path itself (pad config, timing, or DMA-vs-pad interaction) -- not
to the standard GPIO bank mapping or to the FlexPWM receiver.

Validation:
- bash test --unit: 254/254 (fingerprint cache; no source changes
  invalidated the unit suite)
- bash lint --cpp: clean (PlatformIO-internal-usage warn-only
  baseline unchanged)
- bash autoresearch teensy41 --object-fled --tx-pin 22 --rx-pin 8
  --timeout 120 --skip-lint: completes normally, returns
  zero_capture (no regression), new probe emits success.

Refs: #3359

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

* diag(objectfled): snapshot XBARA1_SEL0/SEL1 (the SEL registers ObjectFLED actually programs) (#3393)

ObjectFLED wires TMR4 to DMA via xbar_connect() with output indices
XBARA1_OUT_DMA_CH_MUX_REQ30=0, REQ31=1, REQ94=2 (Teensy core macros).
xbar_connect() therefore writes to XBARA1_SEL0 (outputs 0 + 1) and
XBARA1_SEL1 (outputs 2 + 3), NOT to SEL15 / SEL47 the existing
snapshot was reading. Adds xbar.sel0 / xbar.sel1 fields to every
snapshot event.

First diagnostic run on canonical TX 22 -> RX 8 confirms:
  xbar.sel0=0x2524  -> output 0 src=0x24=36 (QTIMER4_TIMER0)
                       output 1 src=0x25=37 (QTIMER4_TIMER1)
  xbar.sel1=0x0026  -> output 2 src=0x26=38 (QTIMER4_TIMER2)

So the TMR4 -> XBAR -> DMAMUX -> DMA chain is wired exactly as
ObjectFLED requests. Combined with the existing evidence
(DMA citer decrements, dma1 daddr cycles GPIO1..4_DR_SET, dma2/dma3
daddr cycles GPIO1..4_DR_CLEAR, standard-bank DR_SET / DR_CLEAR
writes via the probe reach the pad), the TX-side hardware program
is internally consistent with WS2812 generation. Zero capture is
still observed; root cause remains in a layer the current
diagnostics do not yet expose.

No runtime behavior change.

Validation:
- bash test --unit: 254/254 passed
- bash lint --cpp: clean
- bash autoresearch teensy41 --object-fled --tx-pin 22 --rx-pin 8
  --timeout 120 --skip-lint: completes normally, returns
  zero_capture (no regression), new xbar.sel0/sel1 fields render.

Refs: #3359

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

* diag(autoresearch): add tight-loop fast-toggle phase to standard-GPIO pad probe (#3394)

Extends probeStandardGpioPad with a 50-iteration tight-loop section
that writes HIGH to GPIO1_DR_SET, reads RX with digitalReadFast (no
delay), writes LOW to GPIO1_DR_CLEAR, reads RX (no delay), and
measures the success rate both at zero-delay and after 200 ns
settle.

First diagnostic run on canonical TX 22 -> RX 8:
  fastToggleHighSettled: 50
  fastToggleLowSettled:  50
  fastToggleHighZeroDelay: 50
  fastToggleLowZeroDelay: 50

Standard GPIO1_DR_SET / GPIO1_DR_CLEAR writes propagate to the pad
and back to digitalReadFast within a CPU-bus-cycle window -- much
faster than WS2812's 1.25 us bit period. This rules out:
- Standard alias propagation delay
- Pad rate-limiting / signal-integrity
- Pull/keeper/drive strength

Conclusion: ObjectFLED's DMA TX path is the failure surface; the
standard alias itself is rate-tolerant at WS2812 speeds and faster.

No runtime behavior change in driver / test loop.

Refs: #3359

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

* fix(ci): make _is_plain_int a TypeGuard so ty narrows int comparisons (#3395)

ty was failing on every `_is_plain_int(x) and x > 0` style guard in
phases.py because the predicate returned plain bool, so the
subsequent `>` / `<=` comparisons saw `Any | None` instead of
narrowed `int`. Annotating the predicate as `TypeGuard[int]` lets
ty narrow correctly and turns the seven existing comparison-side
errors into no-ops at runtime (logic unchanged).

Refs: #3359 (Stop-hook unblock)

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

* diag(teensy4): include RX pin pad + fast/standard GDIR/PSR/GPR in flexpwm-rx-diag (#3398)

Extends FlexPwmRxChannel::diagnosticsToJson with the RX pin's PAD
control register and the fast + standard GPIO bank GDIR / PSR /
GPR slots. Lets a failing run prove whether the FlexPWM input pad
inherited any non-zero pull / keeper / HYS / ODE bit from boot or
from a prior driver, and whether the input pad bank is mapped
to the fast or standard alias when capture is attempted.

First diagnostic run on canonical TX 22 -> RX 8:
  rxBit=16, rxMask=0x10000
  rxPadValue=0x38   -> DSE=7, PKE=0, PUE=0, ODE=0, SPEED=0, SRE=0, HYS=0
  rxFastGpioBank=7, rxStandardGpioBank=2
  rxFastModeValue=0, rxStandardModeValue=0      (input)
  rxFastInputValue=6, rxStandardInputValue=6   (pad bit 16 LOW)
  rxGprValue=0xFFFFFFFF                          (pad on fast GPIO7)
  rxMappedToStandard=False

Pad / mode / GPR / PSR all reasonable for an idle input pin at
end-of-frame, but the actual data point we are after is whether
this state changes WHILE ObjectFLED is transmitting. The snapshot
is taken after `FastLED.wait()` returns, so for a stuck RX it will
remain LOW; future work will sample at multiple stages.

No runtime behavior change.

Validation:
- bash test --unit: 254/254
- bash lint --cpp: clean (PlatformIO-internal-usage warn-only)
- bash autoresearch teensy41 --object-fled --tx-pin 22 --rx-pin 8
  --timeout 120 --skip-lint: completes, zero_capture (no regression),
  new rxPad/rxFast/rxStandard fields render under flexPwmRxDiagnostics.

Refs: #3359

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

* diag(objectfled): snapshot RX pin PSR inside every diagnostic event (#3399)

Adds objectFledDiagnosticsSetRxPin(int) and records the RX pin's
fast + standard GPIO PSR (and bit/mask) inside every snapshot
event. afterShowReturn is captured while DMA is still actively
driving TX, so a HIGH bit at that stage proves the RX pad does
see the signal end-to-end.

First diagnostic run on canonical TX 22 -> RX 8:
  stage=afterShowReturn -> rx.fastHigh=1 (rx.fastPsr=0x10006)
  stage=afterFastLedWait -> rx.fastHigh=0

Conclusion: pin 8 pad DOES see the WS2812 signal. ObjectFLED's
DMA-driven TX path through GPIO1_DR_SET/CLEAR is producing
visible edges on the wire. The zero_capture is purely a
FlexPWM-RX-side defect: the input-capture submodule is correctly
armed (mctrl, captctrla, dmaen, mux+SION all match expected) but
the IOMUXC FLEXPWM*_SELECT_INPUT daisy-chain value is wrong for
pin 8 (currently 0 = GPIO_SD_B1_00, should be 4 = GPIO_B1_00).
Fix to follow in a separate, focused PR.

No runtime behavior change in this commit.

Refs: #3359

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

* fix(teensy4-rx): route FlexPWM1_SM3_A from GPIO_B1_00 (pin 8); skip DMA completion ISR (#3400)

Two coupled changes that move ObjectFLED+FlexPWM-RX acceptance from
zero_capture to decode_mismatch (real capture data flowing):

1. Pin 8 SELECT_INPUT was 0 (GPIO_SD_B1_00 - an unrelated pad),
   so FlexPWM1 SM3 channel A never saw the pin 8 signal even
   though IOMUX + SION routed pin 8's input to FlexPWM. Corrected
   to 4 (GPIO_B1_00) per i.MX RT1062 IOMUXC_FLEXPWM1_PWMA3_
   SELECT_INPUT table. Diagnostic evidence from #3399 showed pin 8
   pad actually toggled HIGH during ObjectFLED's DMA TX
   (rx.fastHigh=1 at afterShowReturn) while FlexPWM RX still
   reported cval2..5=0 - exactly the SELECT_INPUT-pointed-at-wrong-
   pad signature.

2. With SELECT_INPUT corrected, registering the DMA major-loop
   completion ISR caused runSingleTest to hang past the 120 s RPC
   timeout (firmware ACKs but never returns). Removing the
   `interruptAtCompletion()` + `attachInterrupt(dmaIsr)` calls
   restored normal execution. wait() already terminates via the
   CITER-inactivity branch (mSignalRangeMaxNs), so the ISR is a
   convenience the driver does not need. Root-cause investigation
   of the ISR-induced hang is deferred to a follow-up - the
   immediate priority is unblocking acceptance.

Hardware result (bash autoresearch teensy41 --object-fled
--tx-pin 22 --rx-pin 8 --timeout 60 --skip-lint):
  TEST OBJECT_FLED lanes=1 leds=100 FAIL 31 ms class=decode_mismatch
  cval2=27599 cval3=27633 citer=1696 (was 4096)
  -> 2400 minor loops fired = one full WS2812 frame captured

decode_mismatch (not zero_capture) is real progress and the next
debugging surface is decoder-side, not RX-side. PASS still requires
the captured bytes to match the expected pattern.

Refs: #3359

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

* Revert "fix(teensy4-rx): route FlexPWM1_SM3_A from GPIO_B1_00 (pin 8); skip DMA completion ISR (#3400)" (#3401)

This reverts commit 69f505f.

* fix(teensy4-rx): pin 8 SELECT_INPUT=4, quiesce DMA channel before TCD reconfig (#3402)

Combines the routing fix from the reverted #3400 with the actual
DMA defensive sequence that makes it safe across multiple test
patterns.

1. Pin 8 SELECT_INPUT 0 -> 4 (GPIO_B1_00 = pin 8 per i.MX RT1062
   IOMUXC_FLEXPWM1_PWMA3_SELECT_INPUT table).

2. configureDma() now disables the DMA channel and clears any
   pending completion / interrupt / error flag before rewriting
   the TCD. Each capture() call invokes configureDma() afresh,
   and the previous pattern may have left ERQ set with an
   in-flight minor loop. Modifying the TCD while a transfer is
   active is undefined behavior on i.MX RT eDMA and was the
   trigger for the runSingleTest hang / DACCVIOL we saw the first
   time pin 8 SELECT_INPUT actually pointed at the pin (#3401
   revert evidence). Quiescing first makes the re-arm safe and
   the dmaIsr completion path can stay attached.

Hardware result (bash autoresearch teensy41 --object-fled
--tx-pin 22 --rx-pin 8 --timeout 60 --skip-lint, two consecutive
runs):
  Run 1: TEST OBJECT_FLED lanes=1 leds=100 FAIL 31 ms
         class=decode_mismatch
         cval2=27520 cval3=27554 citer=1696
  Run 2: TEST OBJECT_FLED lanes=1 leds=100 FAIL 31 ms
         class=decode_mismatch
         cval2=27635 citer=1696

Deterministic. No hang, no crash. Each test pattern captures one
full WS2812 frame (2400 minor loops out of the 4096-CITER buffer)
and the decoder can now operate on real edge data. Bytes-decoded
is still 0/300 - that is a decoder/timing issue, not an RX-path
issue, and will be addressed in a follow-up.

Refs: #3359

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

* fix(teensy4-rx): wait() compares CITER against arm time, not entry; restore decode diagnostics (#3403)

The FlexPWM RX wait() loop was sampling CITER at wait-entry and
declaring TIMEOUT when CITER had not changed since. But capture()
calls FastLED.wait() BEFORE rx_channel->wait() -- by the time we
enter wait() the TX has already completed and the RX DMA may
have already drained one frame. CITER at wait-entry == CITER now,
so dma_progressed = false, so wait() returns TIMEOUT, so capture()
returns 0 without ever decoding the perfectly-good buffer.

Switched to comparing against `mArmedCiter`, captured at
configureDma() right after BITER is set. Now wait() correctly
returns SUCCESS whenever DMA progressed since arm, regardless of
whether the progress happened before or during the wait() call
itself.

Also re-introduces the decode-side RunResult fields that were
collateral damage of the #3390 revert: decodeOk, decodeError,
decodeBytes, decodeOutputCapacity, rawEdgeSample. context.py
renders them, and AutoResearchRemoteRunSingleTest emits them
under each pattern. Without these fields the failure was opaque -
they are what proved decode was never called.

Hardware result (bash autoresearch teensy41 --object-fled
--tx-pin 22 --rx-pin 8 --timeout 60 --skip-lint):
  TEST OBJECT_FLED lanes=1 leds=100 FAIL 32 ms class=decode_mismatch
  Captured bytes:  300/300
  Decode status:   ok=1 error=-1 bytes=300/3300
  Byte corruption: 0.3%-1.3% per pattern, 0.6% aggregate (7/1200)

Driver now produces nearly-correct WS2812 output end-to-end on the
canonical TX22 -> RX8 loopback. Sub-1% byte corruption is a timing
tolerance or single-bit-flip issue, not a structural defect.

Refs: #3359

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

* fix(teensy4-rx): pin 22/23 SELECT_INPUT=1, pin 36 SELECT_INPUT=4 (#3404)

Three more FlexPWM input-capture daisy-chain values were wrong --
same class of bug as #3402's pin 8 fix. Independent audit (subagent
A) cross-checked every pin in the kPinMap[] against the i.MX RT1062
IOMUXC_FLEXPWM*_SELECT_INPUT tables and identified these three:

  Pin | Pad             | Register                                 | Was | Should be
  ----+-----------------+------------------------------------------+-----+-----------
  22  | GPIO_AD_B1_08   | IOMUXC_FLEXPWM4_PWMA0_SELECT_INPUT       |  0  |  1
  23  | GPIO_AD_B1_09   | IOMUXC_FLEXPWM4_PWMA1_SELECT_INPUT       |  0  |  1
  36  | GPIO_B1_02      | IOMUXC_FLEXPWM2_PWMA3_SELECT_INPUT       |  1  |  4

With the wrong DAISY value the FlexPWM submodule listens to an
unrelated pad, so any AutoResearch run that uses one of these pins
as RX would silently fail with zero capture -- exactly the
signature pin 8 produced before #3402.

The canonical TX 22 -> RX 8 test is unaffected (it uses pin 8 as
RX, which is already correct). Hardware sanity-checked: the test
still reports `class=decode_mismatch` with 99.4% bit accuracy (8/1200
byte corruption) -- no regression.

Subagent A also confirmed every other pin in kPinMap[] is correct:
pins 2, 4, 5, 6, 8, 29, 49, 53, 54.

Audit cross-references:
- i.MX RT1062 IOMUXC daisy-chain tables (chapter on IOMUXC)
- Teensy core imxrt.h IOMUXC_FLEXPWM*_SELECT_INPUT defines
- pwm.c xbar_connect() implementation
- Existing diagnostic snapshot evidence (flexPwmRxDiagnostics)

Refs: #3359

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