Skip to content

Forced mapped toggle writes an input-status register on Teensy 4 #5086

Closed

Description

@zackees

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:29 selects Teensy4 implementation.
  • src/platforms/arm/teensy/teensy4_common/fastpin_arm_mxrt1062.h:15 excludes native specializations when forced.
  • src/fl/system/fastpin_base.h:73–74 selects the actual shared forced component.
  • src/fl/system/forced_software_pin.h:24–29 initializes mapped output/input pointers; toggle() writes the mapped input pointer.
  • tests/fl/system/forced_software_pin.cpp:260–261 currently 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

Open questions

Related issues

Parent #5024. Related but different: #5056, #5026, and ESP8266 forced-selection #5068.

Activity

  1. added
    sanitized
    on Nov 6, 2026
  2. zackees commented on Nov 7, 2026

    @zackees
    MemberAuthor

    Deferred, not fixed: the mapped forced toggle (*sInPort = sPinMask) is still in master's src/fl/system/fastpin_base.h. Open PR #5058 moves this component into src/fl/system/forced_software_pin.h and rewrites fastpin_base.h. A master-side change would conflict with it, so this is left for #5058 or for a follow-up after it lands.

  3. moved this from Triage to Done in FastLED Trackeron Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    sanitized

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions