Repository navigation
Description
Context
Native child of #5024, found while validating #5044's real ClearCore forced-software configuration. This is a distinct shared fallback correctness defect, present in baseline 94dab9c6b, not a failure caused by missing board hardware.
Round 1 traced actual selection: defining FASTLED_FORCE_SOFTWARE_PINS selects the common FastPin class in src/fl/system/fastpin_base.h:69-123; SAME53's platform specialization is intentionally excluded by src/platforms/arm/same53/fastpin_arm_same53.h:16-20. same53/led_sysdefs_arm_same53.h:8 defines FASTLED_NO_PINMAP because the connector API does not expose Arduino register maps.
Round 2 verified the defect and contract: _init() at fastpin_base.h:74-80 skips every assignment with FASTLED_NO_PINMAP. sPinMask, sPort and sInPort are zero-initialized static storage (definitions122-124). hi/lo (92-94), pointer overloads (103-105), set/fastset (107-110) and hival/loval (113-115) still dereference those pointers. GenericSoftwareSPIOutput::init calls setOutput but that cannot initialize them. Ordinary bulk sees two null port identities as equal and enters same-port snapshot code, then hival/loval dereference zero. Forced interrupt-safe output enters scalar hi/lo and still dereferences zero. Compiler optimization may exploit this undefined behavior; it must not be treated as a harmless no-op.
src/fastled_config.h:13-16 publicly documents the option as forcing digitalWrite access for debugging, limited to Arduino environments. ClearCore is Arduino and src/platforms/arm/same53/pin_same53.hpp:15-35 supplies correct connector-aware pinMode/digitalWrite adapters. There is no found contract excluding Arduino NoPinMap boards. The existing runtime fl::Pin in src/platforms/generic_pin.h:68-105 already falls back to digitalWrite/digitalRead when register pointers are absent; the forced compile-time FastPin does not.
The root's real ClearCore audit build with FL_SOFTWARE_SPI_COMPILE_PROBE=1,FASTLED_FORCE_SOFTWARE_PINS=1 currently stops at an additional API mismatch: forced FastPin has no validpin() while the probe asserts the hardware specialization's validity. Removing only those probe assertions would reveal the unsafe writer; compilation alone must not certify it.
Proposal
Implement a safe portable forced-software pin path for Arduino cores without register pin maps, preserving connector polarity via the native digitalWrite API. Ensure the SPI writer selects per-pin logical operations and never compares dummy/null port identities to enter snapshot/whole-port streaming. Retain mapped-Arduino behavior where appropriate, and never route a NoPinMap fallback through fabricated physical register pointers or a fake register bank.
A precise compile-time rejection is acceptable only for configurations actually outside the documented supported contract, with evidence and a clear diagnostic. Do not relabel ClearCore as unsupported to obtain a green gate. Scope is the forced compile-time fallback and its real software-SPI selection; runtime Pin is reference evidence, not proof it fixes this class.
Acceptance criteria
- Establish RED through the actual
FASTLED_FORCE_SOFTWARE_PINS && FASTLED_NO_PINMAPFastPin and GenericSoftwareSPIOutput path, calling init then scalar/word, bytes, repeat and pixels with/without start bits. Use an instrumented real platform adapter or actual compiled target output. Prove the zero/uninitialized-port access and lack of native digitalWrite traffic before implementation; do not copy the writer into a model or rely on the missing-validpin compile error as the sole behavioral repro. - GREEN produces correct native digitalWrite pin/value operations, MSB data/setup/clock sequence, exact sample count and final logical LOW. Cover all256 values/all8 bit positions, zero/one/multiple byte lengths, pixel boundaries/start bits/modifiers, unrelated-pin activity and normal/inverted connector semantics. No dereference of null output/input pointer, zero-mask output, fake whole-port snapshot or unintended streaming eligibility is allowed.
- Mutate the fixed production selection/forced pin path back to the baseline empty NoPinMap init plus pointer dereferences, leaving the focused test intact; the same gate must fail. Demonstrate restoration returns GREEN. A fixture that already bypasses the production forced pin class cannot establish this.
- Compile and inspect actual ClearCore forced-software objects for IO0/IO1 and IO2/IO3 with and without FAST_SPI_INTERRUPTS_WRITE_PINS. Retain genuine normal-hardware pin validity assertions; adapt probe assertions only because the documented forced class lacks that hardware-only API. Never define FASTLED_ALL_PINS_VALID or substitute success metadata.
- Expand real-core compile/codegen coverage to reachable forced common fallback variants: Renesas UNO R4, RP2040/RP2350, STM32, Apollo3 and CI13xx where supported Arduino builds exist, plus mapped AVR/SAMD control. Check each platform's forced dispatch: some headers retain hardware specializations despite the define, so their behavior must be classified honestly rather than assumed identical. Preserve platform native pinMode/mux setup and actual package pin validity boundaries.
- Preserve conservative SPI timing and concurrency contracts. Portable digitalWrite calls can be slower; this is a correctness restoration, with no invented throughput gain. New latency credits, skipped padding or physical waveform/speed claims require measurement. Compilation/codegen and adapter traces do not establish electrical validation.
Decisions
- P1 correctness: a documented debug/fallback mode can dereference address zero even after init on reachable Arduino NoPinMap boards.
- One shared implementation child covers affected boards with a per-dispatch matrix; do not duplicate it as a ClearCore-only register optimization.
- Reuse test: gate software SPI changes on exhaustive production-path and mutation evidence #5031's production trace/source/configuration/mutation gate and fix(same53): correct existing inverted-clock software-SPI bulk output before optimization #5044's real ClearCore compile probe; those children cannot close this independent fallback defect by fixing hardware GPIO polarity alone.
- No source edits, builds, tests or hardware measurements were performed for this research follow-up. Root's failed probe-build log is existing evidence; the null-access conclusion is verified from production source and baseline history.
Next steps
- Preserve hardware-only validity assertions while allowing actual forced-mode probe compilation; inspect resulting forced production output without accepting unsafe code as a pass.
- Establish forced NoPinMap RED, implement smallest real adapter-based fallback and SPI eligibility correction, then run GREEN and restored-baseline mutation.
- Validate actual target matrix, preserve normal mapped/hardware regressions and document any genuinely unsupported non-Arduino configuration explicitly.
Open questions
Which legacy FastPin full-port methods have external forced-mode callers needs an inventory before choosing safe semantics or explicit method-level rejection. Individual cores may ignore the force define via retained specializations; matrix coverage must trace actual selection. Metadata-only duplicate searches for FASTLED_FORCE_SOFTWARE_PINS and FASTLED_NO_PINMAP found no strong same-component fallback correctness issue.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(spi): inline bounded default delays and retain target probes
zackees commentedon Nov 7, 2026
#5137 fixes software SPI on forced no-pin-map pins, so this stays open. Still unmet: a gate that fails when the forced FastPin branch is reverted, ClearCore object inspection, interrupt-mode, STM32 and CI13XX forced builds, inverted connectors and unrelated-pin activity. Follow-ups: clockless #5136, Apollo3 #5138.
fix(fastpin): use digitalWrite for forced pins with no pin map (FastL…
zackees commentedon Nov 22, 2026
Status before PR #5394 closes this.
The defect is fixed on master by #5137 (118409a):
src/fl/system/fastpin_base.h:86-103: with forced software pins and no pin map,FastPinresolves toNoPinMapPin. The pointer-storing class (:104-163) is only used where a pin map exists, and its_init()now always sets the pointer.src/fl/system/fastpin_no_pinmap.h:28-50: every write goes throughfl::digitalWrite.port()returnsnullptrand nothing dereferences it.src/platforms/shared/spi_bitbang/generic_software_spi.h:72-75: pins without a pin map always take the per-pin write path.hi()/lo()(fix(spi-bitbang): platform policies bypass hi()/lo() on FastPin subclasses that override them #5122): platformBitbangPinregister paths are guarded against these pins. Clockless drivers that writeport()directly refuse to compile with forced pins: STM32, Renesas, LPC, LPC PLU, D51, the ESP8266 block driver and AVR.Gate (PR #5394):
tests/fl/system/fastpin_forced_no_pinmap.cpprunsGenericSoftwareSPIOutput(init,writeByte,writeBytes,writeBytesValueRaw,writePixels) on theFastPinthatfastpin_base.hactually selects. It checks MSB-first data, the bit count, and that the clock ends LOW. With the pre-#5137 header restored it crashes with SIGSEGV ininit; with the fix it passes, including under--debugsanitizers.Not covered, accepted as a limitation: the ClearCore object inspection and the forced-mode compile matrix on the other boards. Both need real board builds. The host-side gate exercises the selected production class on the path that used to dereference null. A regression in an individual platform's register path is covered by the compile-time refusals above, not by this test.
test(fastpin): gate forced no-pin-map software SPI on the production …