Skip to content

Renode models for SAI audio through the WM8994 - #122

Merged
JohnAmadis merged 1 commit into
masterfrom
ccr-0ed2b297-4zti6v
Oct 11, 2026
Merged

JohnAmadis merged 1 commit into
masterfrom
ccr-0ed2b297-4zti6v

Conversation

@JohnAmadis

Copy link
Copy Markdown
Contributor

Summary

Adds configs/renode/STM32F7_Audio.cs with three Renode models. They let audio playback on STM32F746G-DISCO run and be inspected in emulation.

  • STM32F7_AudioDMA: a replacement for DMA2 with circular mode and half-transfer interrupts. Renode's STM32DMA copies memory-to-peripheral data in one go and has neither CIRC nor HTIF, both of which dmsai depends on. Peripheral-to-memory requests behave as in Renode's model, so the SD host keeps working.
  • STM32F7_SAI: paces frames from the RCC kernel clock (PLLSAI/PLLI2S, MCKDIV). It serializes each frame bit by bit, using FRCR/SLOTR/CR1 for the FS level, data size and slots, and requests DMA to keep its FIFO fed. A synchronous RX block B is also modeled.
  • WM8994: an I2C register file on I2C3 at 0x1A. It decodes the bit stream according to AIF1_CONTROL1 (format, word length, LRCLK inversion) and writes what DAC1 receives to a raw stereo s16le file.

The file header describes how to load the models. They are not wired into renode.resc yet: the board's flash.dmd loads the FT5336 touch config, which owns I2C3 just like dmwm8994's codec.ini.

Why

These models reproduced crackling playback and found two causes:

  • choco-technologies/dmwm8994: AIF1 was left in right-justified mode, so the codec decoded only 0 / -32768.
  • choco-technologies/dmsai: the TX writer slept a full 10 ms tick, which caused about 4900 underruns over 8 s.

With both fixes, the captured output matches the played melody note for note.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Nr1HhezRY951yBxxTm1b65


Generated by Claude Code

Adds a DMA2 model with circular mode and half-transfer interrupts
(Renode's STM32DMA has neither), an STM32F7 SAI that paces frames from
the RCC kernel clock and serializes them bit by bit with their FS level,
and a WM8994 on I2C3 that decodes that stream per AIF1_CONTROL1 and
writes what DAC1 receives to a file.

Used to reproduce crackling playback on STM32F746G-DISCO: the codec was
left in right-justified mode (dmwm8994) and the SAI writer starved its
queue on a 10 ms tick (dmsai).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nr1HhezRY951yBxxTm1b65
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.

2 participants