Repository navigation
Description
Context
With FASTLED_FORCE_SOFTWARE_PINS=1 on Teensy 4.0/4.1 and the default FASTLED_NO_PINMAP unset, the platform suppresses native FastPin specializations and selects fl::FastPin<PIN> : detail::ForcedSoftwarePin<PIN>. The shared mapped toggle() writes *sInPort = sPinMask, which assumes AVR PINx write-to-toggle semantics.
This is not the Teensy SDK contract. In the retained Arduino Teensy 1.160.0 SDK, pins_arduino.h:140–146 maps output to reg+0 and input to reg+2; imxrt.h:5731–5742 identifies these as DR at offset0, PSR at offset8, and a separate DR_TOGGLE at offset0x8c. core_pins.h:145,351 identifies logical pin2 as GPIO9_DR/GPIO9_PSR; its actual digitalToggle implementation uses portToggleRegister at line2302. Writing the sampled input register is not the output toggle operation. No target execution, electrical validation, or timing result is claimed.
Production source path:
src/platforms/arm/fastpin_arm.h:29selects Teensy4 implementation.src/platforms/arm/teensy/teensy4_common/fastpin_arm_mxrt1062.h:15excludes native specializations when forced.src/fl/system/fastpin_base.h:73–74selects the actual shared forced component.src/fl/system/forced_software_pin.h:24–29initializes mapped output/input pointers;toggle()writes the mapped input pointer.tests/fl/system/forced_software_pin.cpp:260–261currently checks that a plain-memory input register was written; this does not prove a hardware output toggle.
Proposal
Give the mapped forced provider a portable toggle contract. Preserve AVR's valid PINx behavior, mapped hi/lo/fastset semantics, unrelated GPIO, and NoPinMap fallback. A target-aware toggle policy or safe portable fallback is preferable to assuming all input registers are toggle registers. Do not bypass FASTLED_FORCE_SOFTWARE_PINS or substitute native specialization selection to hide the fault.
Acceptance criteria
- Capture a focused RED using the actual production forced component with a realistic separate input/output register model: HIGH→toggle→LOW→toggle→HIGH, checking all unrelated bits. The existing input-write assertion cannot serve as the output oracle.
- Record actual Teensy40 and Teensy41 SDK compilation/codegen for
FASTLED_FORCE_SOFTWARE_PINS=1, NO_PINMAP unset, pin2 plus a pin from another GPIO bank. Bind SDK/tool/source identities and prove the selected forced type and emitted output operation; compilation alone is insufficient. - Test actual mapped AVR control and forced NoPinMap Arduino fallback, including initial HIGH/LOW, repeated toggle/strobe and unrelated GPIO. Keep primary-provider selection independent of native policies.
- Demonstrate GREEN, then restore the old mapped input-write statement and show the focused output-behavior oracle fails. Retain source-restored GREEN evidence.
- Identify all currently supported mapped providers before broadening the fix. ESP8266 mapper compatibility is a follow-on interaction with ESP8266 native FastPin definitions bypass forced software pin selection #5068; do not claim its currently overridden forced primary is already selected.
- Preserve register/timing and interrupt constraints explicitly. No electrical speed or phase claim without physical evidence; no universal atomicity claim for a fallback read/modify/write.
Decisions
- Track a correctness defect in the shared mapped forced provider, with Teensy4 as the verified reachable configuration; native Teensy optimization is separate.
- Keep this distinct from fix(fastpin): prevent null-register access in forced software pins without pin maps #5056's missing-map null-safety and include-order obligation: this profile has valid non-null mappings and still uses the wrong register operation. Its mapped control overlaps and should be strengthened, not counted as proof of toggle correctness.
- Keep perf(teensy4): adopt generic software-SPI full-port and atomic pin policies #5026's native Teensy4 pin policy separate; the forced guard intentionally excludes that implementation.
- No implementation or test/build/device action was performed while preparing this source finding.
Open questions
- Which other mapped non-AVR profiles have an equivalent reachable provider? Teensy3/SAMD and post-ESP8266 native FastPin definitions bypass forced software pin selection #5068 ESP8266 require separate SDK/guard verification.
- A physical output check remains unperformed. SDK source establishes a register-contract mismatch, not measured electrical behavior.
Related issues
Parent #5024. Related but different: #5056, #5026, and ESP8266 forced-selection #5068.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
test(spi): require mapped toggle and SAMD readback findings
zackees commentedon Nov 7, 2026
Deferred, not fixed: the mapped forced toggle (
*sInPort = sPinMask) is still in master'ssrc/fl/system/fastpin_base.h. Open PR #5058 moves this component intosrc/fl/system/forced_software_pin.hand rewritesfastpin_base.h. A master-side change would conflict with it, so this is left for #5058 or for a follow-up after it lands.