Skip to content

platform: teensy41: add PJRC Teensy 4.1 platform support, Audio PLL scheduling, and UAC2 loopback - #11197

Draft
lgirdwood wants to merge 7 commits into
thesofproject:mainfrom
lgirdwood:feature/teensy41-sof-port
Draft

lgirdwood wants to merge 7 commits into
thesofproject:mainfrom
lgirdwood:feature/teensy41-sof-port

Conversation

@lgirdwood

@lgirdwood lgirdwood commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds Sound Open Firmware (SOF) platform and USB Audio Class 2.0 (UAC2) bridge support for PJRC Teensy 4.1 (NXP i.MX RT1062 Cortex-M7 @ 600 MHz), built directly on top of upstream SOF static_pipeline infrastructure (CONFIG_STATIC_PIPELINE, CONFIG_STATIC_PIPELINE_UAC2) and ARM Cortex-M SIMD optimizations.

Review Updates

  • Upstream static_pipeline integration: Rebased onto main (1df7dfba5), removed bespoke sof_static_pipeline.{c,h}, and wired Teensy 4.1 directly to upstream src/audio/pipeline/static_pipeline_uac2.c and src/platform/teensy41/teensy41_pipeline_def.c.
  • src/audio/drc/drc_arm.c type alignment: Aligned byte, frame, channel, and boolean types (size_t, unsigned int, bool) with 1fe1b8ca6aef.
  • Zephyr SoC/board/DT/pinmux moved to Zephyr: Moved Audio PLL4 initialization, spdif / sai1_dai DT nodes, Teensy 4 audio pinmux, and SAI1 MCLK direction control out of SOF into lgirdwood/zephyr (feature/teensy41-dai-port @ 16a19aec155), referenced temporarily in west.yml, and split SOF into 7 atomic commits.
  • Host tooling moved to sof-utils: Removed scripts/teensy_*.py from SOF and moved them to thesofproject/sof-utils#5 (sof-teensy/).

Commit Series

  1. audio: drc: arm: align byte, frame, and channel types with size_t and unsigned int
  2. zephyr: build: guard userspace syscalls and support Cortex-M full app builds
  3. ipc4: dai: add support for NXP i.MX SAI, SPDIF, ESAI, and MICFIL DAIs
  4. audio: dai-zephyr: support audio timer LL scheduling and static pipeline capture
  5. audio: usb_audio: add USB Audio Class 2.0 host component and static pipeline bridge
  6. west: manifest: temporarily reference Zephyr fork for Teensy 4.1 DAI support
  7. platform: teensy41: add PJRC Teensy 4.1 platform and board support

Hardware Verification

Flashed both Teensy 4.1 boards (build-teensya Master Tx & build-teensyb Slave Rx; 219,548 B FLASH, 240,096 B RAM) and ran end-to-end S/PDIF hardware loopback (sof-utils/sof-teensy/test_teensy_loopback.py --interface spdif):

  • Channel 0 (Left): Peak 1000.0 Hz, SNR = 140.81 dB [PASS]
  • Channel 1 (Right): Peak 1000.0 Hz, SNR = 140.81 dB [PASS]
  • Dropped Frames: 0 (>= 70.0 dB target)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@lgirdwood

Copy link
Copy Markdown
Member Author

@dbaluta ARM SIMD in here.

@dbaluta

dbaluta commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Thanks @lgirdwood will have a look!

@dbaluta

dbaluta commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

@lgirdwood this looks very promising tested the ARM SIMD instructions on imx8mp with M7 core, looks like the load for simple volume pipeline decreased by at least 30%. Also, looking to borrow an RT to do some more testing.

@lgirdwood
lgirdwood force-pushed the feature/teensy41-sof-port branch from 7ce7441 to 8e00e42 Compare October 15, 2026 19:35
@lgirdwood
lgirdwood force-pushed the feature/teensy41-sof-port branch from 8e00e42 to 2996255 Compare November 11, 2026 12:36

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls rebase as sof static pipeline support is now upstream, we need to use teh upstream infra.

Comment thread src/audio/drc/drc_arm.c
Comment on lines +72 to +73
size_t nbyte,
unsigned int nch)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls make sure this aligns with recent commits like 1fe1b8c for size_t and int usage.

Comment thread app/boards/teensy41.conf
@@ -0,0 +1,89 @@
# Target Platform & SOF Core

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit is too large, all the zephyr changes should go to zephyr, this can go to my fork atm and be referenced viw a local west url in this pr.

Comment thread scripts/teensy_diag.py Outdated
@@ -0,0 +1,168 @@
#!/usr/bin/env python3

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tooling should go into sof-utils

… unsigned int

Align drc_arm.c helper signatures and local loop/index variables with
commit 1fe1b8c ("audio: drc: use size_t for byte, sample and frame
counts"):
- Use size_t for byte, division frame, and loop indices (nbyte,
  div_start, count, i, j, inc).
- Use unsigned int for channel counts and indices (nch, ch).
- Use bool for boolean flags (is_release, is_releasing, is_bad_db,
  is_2byte).

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
… builds

Allow CONFIG_SOF_FULL_ZEPHYR_APPLICATION targets without CONFIG_USERSPACE
(such as single-core ARM Cortex-M microcontrollers) to build cleanly:
- Guard generated <zephyr/syscalls/*.h> includes with CONFIG_USERSPACE and
  map syscall wrappers directly to z_impl_* functions when userspace is
  disabled.
- Set Cortex-M cache line fallback alignment to 32 bytes in rtos/cache.h
  while preserving 64 bytes for host/POSIX library builds.
- Ensure generated sof_versions.h and uuid-registry.h are created and
  added to include paths before building SOF subdirectories and app.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Wire up NXP i.MX SAI, S/PDIF, ESAI, and MICFIL DAI types in IPC4/IPC3 DAI
lookup and DMA device mapping so Zephyr-based NXP i.MX / i.MX RT platforms
can instantiate SAI and S/PDIF Copiers in IPC4 pipelines.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…ine capture

- Add CONFIG_ZEPHYR_DOMAIN_AUDIO_TIMER to drive the Zephyr LL scheduling
  domain directly from hardware DAI DMA period completion callbacks while
  suppressing SysTick k_timer ticks when audio is active.
- Scope eDMA source/destination address increment setup in dai-zephyr.c
  to NXP i.MX DAI types.
- Allow DAI component state transitions in dai_comp_trigger_internal() when
  CONFIG_STATIC_PIPELINE is enabled alongside IPC4.
- Pass (dma_fmt, local_fmt) instead of (local_fmt, dma_fmt) to
  pcm_get_conversion_function() for capture streams in
  set_new_local_buffer().
- Reset static pipelines cleanly on XRUN recovery when host IPC stream
  structures are absent.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…ipeline bridge

- Add the COMP_USB_AUDIO host endpoint component with lock-free SPSC
  playback/capture ring buffers and asynchronous USB SOF-to-DAI rate
  estimation for explicit UAC2 feedback.
- Extend upstream static_pipeline_uac2.c to bridge Zephyr UAC2 callbacks
  with COMP_USB_AUDIO ring buffers, support zero-copy UAC2 capture double-
  buffer replenishment via static_pipeline_uac2_buf_release(), and query
  the playback rate adjustment for USB feedback.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…support

Temporarily point the Zephyr project remote to https://github.com/lgirdwood/zephyr
at revision 16a19aec1550a3f4ded4d825325e75f69d711cd0 (branch feature/teensy41-dai-port)
which contains the i.MX RT10xx Audio PLL4 initialization, SAI1/SPDIF DAI
Devicetree nodes, Teensy 4 audio pinmux, and eDMA cyclic/ping-pong support
while upstream Zephyr PR reviews are pending:

  16a19aec155 soc: nxp_imxrt: teensy4: add Audio PLL4 init, DAI DT nodes, and audio pinmux
  4e4b0a8fd8c drivers: dai: nxp: add S/PDIF transceiver driver with eDMA ping-pong support
  7bf76a034a9 drivers: mcux: support Teensy 4.1 clocking, SAI DAI, and eDMA cyclic mode

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add Sound Open Firmware platform and board support for PJRC Teensy 4.1
(NXP i.MX RT1062 Cortex-M7 @ 600 MHz):
- src/platform/teensy41/: pure SOF platform initialization, clocks, memory
  layout, and upstream static_pipeline descriptor graph (USB Audio <->
  Volume <-> S/PDIF or SAI1 I2S Copier).
- zephyr/lib/{alloc.c,dma.c}: static SOF heap and eDMA0 registration.
- app/boards/teensy41.{conf,overlay} & app/src/: Zephyr UAC2 composite
  device initialization, HalfKay bootloader soft-reboot request (0xFB),
  and upstream static_pipeline startup.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
@lgirdwood
lgirdwood force-pushed the feature/teensy41-sof-port branch from 2996255 to 078b9a8 Compare November 12, 2026 22:55
@lgirdwood lgirdwood changed the title WIP: teensy41: add PJRC Teensy 4.1 platform support, Audio PLL scheduling, S/PDIF loopback, and ARM Cortex-M7 SIMD optimizations platform: teensy41: add PJRC Teensy 4.1 platform support, Audio PLL scheduling, and UAC2 loopback Nov 12, 2026
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.

4 participants