Repository navigation
Description
Context
FastLED's Teensy integration currently reaches the external Teensy framework libraries through broad dependencies, most notably:
- Audio.h for Teensy audio/I2S support
- Arduino SD.h / Teensy's SdFat compatibility layer for filesystem support
- SerialFlash and related Audio playback dependencies
- Framework DMA and global/static subsystem state
This causes ordinary Teensy sketches to select and retain code that they do not use. The monolithic Teensy Audio.h header exposes the complete Audio library, including SD and SerialFlash playback paths. Framework globals and static DMA state can then become linker roots or retain RAM even when the feature is unused.
The existing Teensy bloat investigation is tracked in #2656. The current Audio LDF shim also intentionally includes Audio.h so PlatformIO LDF and fbuild discover the dependency, but this solves dependency discovery by selecting too much code.
Proposal
Fork the required Teensy implementations into FastLED-owned platform code:
src/platforms/arm/teensy/
audio/
sdfat/
serialflash/
Copy only the implementations needed by FastLED, document their upstream repositories and revisions, and refactor the fork to comply with FastLED's C++ conventions and lint rules.
The migration should:
- Remove FastLED's dependency on Audio.h.
- Route the Teensy I2S audio engine through FastLED's internal audio/ implementation.
- Move required SD/SdFat and SerialFlash support behind FastLED-owned, feature-specific implementations.
- Replace framework-level global objects with fl::singleton-managed state.
- Avoid unconditional static constructors, registration objects, address-taken storage, and unrelated DMA buffers.
- Keep each subsystem in independently discardable sections so LTO and section garbage collection can remove it when unused.
- Use the correct Teensy/audio/filesystem feature guards.
- Ensure platform source files are visible to FastLED's C++ lint and review tooling.
- Preserve upstream provenance and make future synchronization with Teensy framework updates practical.
fl::singleton should provide lazy, function-local access to subsystem state. When a Blink sketch never requests Audio, SD, or SerialFlash state, there should be no reference path to the singleton storage, constructor, or implementation sections. This is not sufficient by itself: the fork must also avoid unconditional registration, used attributes, and cross-subsystem references that create artificial linker roots.
Acceptance criteria
- src/platforms/arm/teensy/ldf_headers.h no longer includes Audio.h.
- A Teensy 4.1 Blink build does not select the external Teensy Audio library.
- Teensy 4.1 Blink's final linked Flash and RAM usage return to the expected pre-regression baseline; no budget increase is accepted as the fix.
- A Teensy I2S/audio example still compiles through FastLED's internal implementation.
- The internal I2S implementation preserves the existing FastLED audio API and behavior.
- An ordinary Blink build contains no retained Audio, SD, SdFat, SerialFlash, or unrelated Audio DMA symbols.
- A build that explicitly uses SD/SdFat, SerialFlash, or audio pulls in only the corresponding implementation.
- PlatformIO LDF and fbuild both discover and build the internal feature implementations correctly.
- FastLED C++ lint and the relevant Teensy build/test checks pass.
- The forked sources include upstream provenance and any intentional FastLED changes are documented.
Related issues
-
teensy41 Apa102 binary 148KB / 88KB budget — async logger + HTTP/task pulled into SPI sketch #2656 ? Teensy APA102 binary bloat and unrelated framework code being retained.
-
Run fbuild bloat (or the Teensy-supported equivalent) on the before/after Teensy Blink ELF and document the symbol-level report, confirming Flash/RAM return to the established baseline and that the unwanted Audio, SD, SdFat, SerialFlash, and DMA symbols are absent.
-
Confirm the Teensy HydroPack I2S example compiles successfully and uses FastLED's internal Teensy I2S implementation rather than the external monolithic Audio.h dependency.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Jul 16, 2026
Implementation progress:
src/platforms/arm/teensy/audio/, with upstream provenance and lazyfl::Singletonstate.ldf_headers.hno longer includesAudio.h; the I2S adapter uses the private implementation.bash compile teensy41 --examples Blinksucceeds at the established size baseline (100,352 B Flash; 72,544 B RAM).bash compile teensy41 --examples hydropack --no-filtersucceeds, proving the internal Teensy I2S path compiles.<SD.h>and routes through a private lazy SdFat adapter.The final Blink symbol criterion remains blocked by fbuild LDF self-selection: a fresh
fbuild lib-selectselects Audio, SD, SdFat, and SerialFlash from their own framework headers/sources, and the linked Blink ELF still retains the frameworkSDglobal (1,236 B) plus DMAChannel code. Cross-repo blocker: FastLED/fbuild#1094.zackees commentedon Jul 16, 2026
Validation update: FastLED now owns the imported Teensy Audio/SdFat subset and Blink + HydroPack compile successfully. The remaining external SD/SdFat/Audio symbol bloat is isolated to fbuild LDF self-selection: lib-select --explain scans 2,254 sources and selects each framework extra from its own headers/sources, despite Blink not reaching those headers. The required fix is tracked in FastLED/fbuild#1094: sketch-rooted transitive resolution, with candidate libraries excluded from nominating themselves.
zackees commentedon Jul 16, 2026
Cross-repo resolver fix is now in FastLED/fbuild#1097. Its live Blink selector run no longer selects Audio, SD, SdFat, or SerialFlash. This FastLED PR will remain open until #1097 lands and a fresh Teensy Blink ELF/bloat report confirms the linked symbol reduction.
zackees commentedon Jul 16, 2026
The root-selection PR (FastLED/fbuild#1097) is open, and the remaining inactive-conditional selector behavior is now explicitly tracked by FastLED/fbuild#1098. #3696 remains open pending both resolver fixes plus the final Blink symbol/bloat proof.
zackees commentedon Jul 16, 2026
Fresh fbuild-native Teensy 4.1 Blink evidence on the FastLED migration branch:
bash bloat teensy41 --top 25still reports upstreamSDClass/SdFatpayload, includingSDClass::format,FatFile::open, andSdBase<...>::begin.This is the expected remaining fbuild 2.5.2 LDF false-positive: the private FastLED Teensy imports are not the source of those symbols. The linked payload will be remeasured after the sketch-rooted and active-conditional LDF fixes in fbuild #1097 and #1099 are merged/released.