Repository navigation
Description
Context
The actual ObjectFLED SPI DMA implementation remaps selected pads from fast GPIO6 to eDMA-reachable GPIO1 by clearing IOMUXC_GPR_GPR26 bits during init. Deinit restores saved mux ALT values but deliberately leaves the GPR26 remap and changes direction/latch state. The comment calls this harmless for undriven pads; it breaks later reuse through normal GPIO6-based APIs.
The installed real Teensy SDK confirms the mismatch: cores/teensy4/core_pins.h maps pin14 PORTREG to GPIO6_DR; digital.c pinMode() (162–190) changes direction/pad/mux but never restores GPR26. After init/deinit, pinMode(14, OUTPUT) followed by ordinary GPIO writes can therefore address the disconnected bank. Pad settings are also overwritten rather than fully restored.
Source at pinned baseline 94dab9c, unchanged current implementation blob e4c2241ae19503cca5127863d9fe7107afae8a5e:
- — remap and GPIO1 direction/latch setup.
FastLED/src/platforms/arm/teensy/teensy4_common/drivers/objectfled/objectfled_spi_mode.cpp.hpp
Line 409 in 94dab9c
IOMUXC_GPR_GPR26 &= ~(pin_info.mosi_mask | pin_info.sclk_mask); - Same file #L661–675 — partial mux restoration and explicit missing GPR26 restoration.
- Actual direct producer: examples/AutoResearch/AutoResearchRemoteDriverMethods.cpp invokes init/show/deinit. The channel engine's canHandle() lookup alone is not claimed as an emitting route.
The implementation is a hardware-assisted GPIO serializer (CPU builds two port words per bit, QTimer/XBAR drives DMA into GPIO1_DR), not a FIFO-only peripheral exclusion. It already uses two words per bit; this report makes no speculative speedup claim.
Proposal
Save and restore the selected pads' bank/mux/pad/direction/output state at the correct ownership boundary, with safe ordering after DMA drain. Cover failed initialization and timeout cleanup too. Preserve unrelated bits and any documented exclusive-bank contract instead of leaving stale remaps for later generic/ordinary GPIO users.
Acceptance criteria
- Show focused RED using the actual production init/show/wait/deinit path and real vendor register definitions, then GREEN. Do not replace it with a copied driver or fabricated MCU struct.
- Test both selected pads starting in GPIO6 and relevant other prior states. Verify selected GPR26, mux, pad, direction and latch restoration, unrelated-bit preservation, repeated init/show/deinit, failed init and timeout cleanup.
- After deinit, exercise actual ordinary pinMode/digitalWrite and/or production FastPin/software-SPI use on the same pins; prove the restored bank is connected rather than only comparing saved metadata.
- Actual Teensy vendor compilation and register-value/code-generation evidence are required. Physical timing or throughput claims require physical measurements, which this finding does not supply.
- Restore the old no-GPR-restore path (and independently omitted pad/state restoration) and require the focused signal to fail, then exact restoration and GREEN. Bind producer, helper, SDK, register and configuration inputs into test: gate software SPI changes on exhaustive production-path and mutation evidence #5031.
Decisions
One child tracks verified pin-state/remap restoration, distinct from generic Teensy pin policy #5026. Whole-bank snapshotted DMA writes and bypassed manager coordination remain a separate ownership/concurrency question until a permitted conflicting producer is verified; they are not falsely claimed as a demonstrated concurrent corruption repro here. Do not resolve this issue through a hardware-only classification, a source comment, or an absent physical board.
Part of #5024.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Nov 7, 2026
#5148 covers part of this issue. SPI-mode init now captures the two pads' GPR26 bank bits, GPIO1 direction and latch bits, and mux and pad-control values. Deinit (and so timeout cleanup) and both init failure paths restore them through one shared teardown, which also clears QTimer3 ch0. Bank select is restored first, and only those pads' bits are written in the shared registers.
Still open here:
fix(objectfled): restore SPI pads' GPR26 bank and pin state on deinit (…
zackees commentedon Nov 22, 2026
Closing with an accepted limitation. The clockless-path leak moves to #5395.
Fix: #5148 (a43c8bc).
objectfled_spi_mode.cpp.hpp:136-156captures the SPI pads' GPR26 bank bits, GPIO1 GDIR/DR bits and mux/pad control at init. It restores them viaObjectFLEDPadState(objectfled_pad_state.h) on deinit, on timeout cleanup and on both init-failure paths, with bank select restored first and only those pads' bits written.Proven by:
tests/platforms/arm/teensy/teensy4_common/drivers/objectfled/objectfled_pad_state.cpp, run against a pad-register model, plus teensy40 and teensy41 builds of the init/deinit chain.Accepted limitations:
ObjectFLED.cpp.hpp:273-274) has the same leak. It is tracked in fix(objectfled): clockless ObjectFLED leaks the GPR26 bank on deinit (same as the SPI path fixed in #5148) #5395, which requires a host test that fails first.The #5031 binding is replaced by a rescoped host-side gate, tracked in #5031.