Skip to content

fix(teensy): auto-link Teensyduino CMSIS-DSP per-MCU (#300)#313

Merged
zackees merged 1 commit into
mainfrom
fix/teensy-cmsis-dsp-300
May 30, 2026
Merged

fix(teensy): auto-link Teensyduino CMSIS-DSP per-MCU (#300)#313
zackees merged 1 commit into
mainfrom
fix/teensy-cmsis-dsp-300

Conversation

@zackees
Copy link
Copy Markdown
Member

@zackees zackees commented May 30, 2026

Summary

Data-driven CMSIS-DSP auto-link for Teensy 3.x / 4.x / LC / MM, mirroring PlatformIO+Teensyduino's per-MCU matrix. Adds optional build.cmsis_dsp_lib field to the board JSON schema, surfaces it as BoardConfig.cmsis_dsp_lib, and has TeensyLinker append -l<lib> after mcu_config.linker_libs. Resolves via the existing -L<core_dir> so the Teensyduino-bundled libarm_cortex*_math.a is found without extra downloads.

MCU Library Boards
MK20DX128/256 arm_cortexM4l_math teensy30, teensy31
MK64FX512, MK66FX1M0 arm_cortexM4lf_math teensy35, teensy36
MKL26Z64 arm_cortexM0l_math teensylc
IMXRT1062 arm_cortexM7lfsp_math teensy40, teensy41, teensymm

Unblocks FastLED's Ports/PJRCSpectrumAnalyzer example on Teensy 3.x/4.x.

Closes #300.

Test plan

  • 4 new BoardConfig tests (ARM Teensy boards, AVR Teensy 2.x absence, non-Teensy absence, override precedence)
  • 3 new TeensyLinker tests (link-command includes/omits the lib; field round-trip)
  • teensy_boards_carry_cmsis_dsp_lib data-driven test asserts every ARM Teensy board's JSON value
  • soldr cargo check/clippy --workspace --all-targets -- -D warnings clean
  • RUSTDOCFLAGS="-D warnings" soldr cargo doc --workspace --no-deps clean
  • Full workspace ./test — no failures

🤖 Generated with Claude Code

Mirrors PlatformIO+Teensyduino's SCons builder, which auto-appends the
right libarm_cortex*_math.a to the link command based on MCU. Without
this, FastLED's Ports/PJRCSpectrumAnalyzer (and any Teensy sketch using
Audio.h FFT classes) failed at link with undefined references to
arm_cfft_radix4_q15 / arm_cfft_radix4_init_q15.

Data-driven via a new build.cmsis_dsp_lib field on the board JSONs,
surfaced as BoardConfig.cmsis_dsp_lib and threaded into TeensyLinker.
The bundled archive ships inside the Teensyduino toolchain
(framework-arduinoteensy.../cores/teensy*/), which the linker already
gets via -L<core_dir> through LinkerScripts::single — no extra search
path or download is needed.

Per-MCU mapping populated on the JSONs:

  MK20DX128/256 (3.0, 3.1, 3.2) -> arm_cortexM4l_math
  MK64FX512 (3.5), MK66FX1M0 (3.6) -> arm_cortexM4lf_math
  MKL26Z64 (LC) -> arm_cortexM0l_math
  IMXRT1062 (4.0, 4.1, MicroMod) -> arm_cortexM7lfsp_math

The previously-hardcoded -larm_cortexM7lfsp_math entry in
teensy4x.json's mcu config linker_libs is removed; the same library is
now contributed via the data-driven path so teensy40/41/mm all share
the same mechanism as the 3.x family.

Tests:
  - fbuild-config: every ARM Teensy board carries the expected
    cmsis_dsp_lib, AVR Teensy 2.0/2pp omit it, non-Teensy boards omit
    it, env overrides win over the bundled value
  - fbuild-build: teensy36 build_link_args() includes
    -larm_cortexM4lf_math and -L<core_dir>; the flag is absent when no
    lib is configured; mcu_config-level test now asserts each ARM
    Teensy board declares its expected library

Refs #300, #257.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Warning

Review limit reached

@zackees, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 46 minutes and 57 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d9a1631e-391c-4a53-8584-97e03f37e4d4

📥 Commits

Reviewing files that changed from the base of the PR and between 1a4d661 and 2f4bbd4.

📒 Files selected for processing (16)
  • crates/fbuild-build/src/teensy/configs/teensy4x.json
  • crates/fbuild-build/src/teensy/mcu_config.rs
  • crates/fbuild-build/src/teensy/orchestrator.rs
  • crates/fbuild-build/src/teensy/teensy_linker.rs
  • crates/fbuild-config/assets/boards/json/teensy30.json
  • crates/fbuild-config/assets/boards/json/teensy31.json
  • crates/fbuild-config/assets/boards/json/teensy35.json
  • crates/fbuild-config/assets/boards/json/teensy36.json
  • crates/fbuild-config/assets/boards/json/teensy40.json
  • crates/fbuild-config/assets/boards/json/teensy41.json
  • crates/fbuild-config/assets/boards/json/teensylc.json
  • crates/fbuild-config/assets/boards/json/teensymm.json
  • crates/fbuild-config/src/board/db.rs
  • crates/fbuild-config/src/board/loaders.rs
  • crates/fbuild-config/src/board/tests.rs
  • crates/fbuild-config/src/board/types.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/teensy-cmsis-dsp-300

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees zackees merged commit 3cf0eed into main May 30, 2026
5 of 87 checks passed
zackees added a commit that referenced this pull request May 30, 2026
…ror (#316)

`build_link_args` was added by #313 (CMSIS-DSP auto-link refactor) but a
hold-over from #305 still referenced `output_dir.join("firmware.map")`,
which doesn't exist as a parameter of `build_link_args` (it takes
`elf_path: &Path`, not `output_dir`). The workspace failed to compile
with:

    error[E0425]: cannot find value `output_dir` in this scope
      --> crates/fbuild-build/src/teensy/teensy_linker.rs:93:24

Every PR opened against main since #313 has been red because of this.

Derive the map path from `elf_path.with_extension("map")`, which is
equivalent to `output_dir.join("firmware.map")` since
`elf_path = output_dir.join("firmware.elf")` at the only call site.

Adds `test_teensy_link_command_emits_linker_map_next_to_elf` so the
regression is caught locally next time.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fbuild deficiency vs PlatformIO+Teensyduino: CMSIS-DSP not auto-linked for Teensy 3.x/4.x

1 participant