Repository navigation
Description
Summary
The SAMD51 hardware SPI drivers (SpiHw2, SpiHw4, and their manager) are gated behind FASTLED_SAMD51_HW_SPI, off by default, because they do not compile. They need bring-up before they can be enabled.
Gated in #4015:
src/platforms/arm/d51/spi_hw_2_samd51.cpp.hpp
src/platforms/arm/d51/spi_hw_4_samd51.cpp.hpp
src/platforms/arm/d51/spi_hw_manager_samd51.cpp.hpp
Why they are broken
These files are guarded by #if defined(FL_IS_SAMD51), which never evaluated true on any board until #4011 fixed SAMD detection: is_samd.h required ARDUINO_ARCH_SAMD, which no SAMD board manifest defines. So the code has never been compiled, and it drifted out of sync with the shared SPI types while nothing was watching.
SPIQuadSAMD51::acquireDMABuffer returns DMABuffer, but:
return SPIError::NOT_INITIALIZED; // DMABuffer(SPIError) is explicit
return fl::span<u8>(mDMABuffer.data(), total_size); // no such conversion existsThe first four are mechanical — DMABuffer(SPIError) exists and is explicit. The fifth is not. The driver owns a raw fl::span<u8> it allocates with fl::malloc and caches across calls, and wants to hand back a view of it. Current DMABuffer owns its memory through shared_ptr<DMABufferInternalData> and has no non-owning construction path. So the driver's buffer-ownership model predates the API and cannot be reconciled by patching return statements.
Work
- Decide the ownership model: either let
DMABuffer(size_t)own the allocation (losing the driver's buffer-reuse caching), or add a non-owningDMABufferconstruction path — an API change affecting every SPI platform, so it wants a deliberate decision rather than a local fix. - Reconcile
spi_hw_2_samd51.cpp.hppandspi_hw_manager_samd51.cpp.hpp, gated together and so far unverified — onlyspi_hw_4errors are known, because compilation stopped there. Assume more. - Exercise on SAMD51 hardware (Feather M4 / Metro M4). None of this has ever run.
- Remove the
FASTLED_SAMD51_HW_SPIgate once it compiles and is verified.
Turning drivers on is safe to defer: init_channel_driver_samd51.cpp.hpp reaches them through the shared SpiHw4::getAll() / SpiHw2::getAll() registries, so with the implementations gated out the registries are simply empty and SAMD51 uses bit-bang SPI — which is what it has always actually done.
Related
- CI: new SAMD workflows fail on every src/** PR — FL_IS_SAMD not detected #4011 — the detection bug that made all of this reachable
- SAMD pulls in Arduino SPI unconditionally; the SAMD SPI stack has never been compiled or exercised #4016 — the same story for SAMD's Arduino-
<SPI.h>backend, routed to bit-bang for the same reason - Framework-library scan misses <SPI.h> for SAMD: neither the active conditional include nor the #if 0 LDF hint is seen fbuild#1371 — why
<SPI.h>cannot be supplied under fbuild today
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(samd51): gate the non-compiling SPI drivers; give Feather M4 a re…
fix(samd): detect SAMD from part macros, not ARDUINO_ARCH_SAMD (#4015)
fix(samd51): restore hardware SPI compilation (#4098)