Skip to content

Configure audio on STM32F746G-DISCO: dmsai and dmwm8994 - #124

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

@JohnAmadis JohnAmadis commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Loads the WM8994 codec stack on STM32F746G-DISCO. The nodes are:

  • /dev/wm8994: codec controls and stereo PCM;
  • /dev/dmsai1: the SAI2 stream the codec drives.

An application plays through /dev/wm8994 with the DMDRVI_IOCTL_AUDIO_* commands (dmdrvi 2.7): AUDIO_CONFIGURE, AUDIO_START, write, AUDIO_DRAIN, AUDIO_STOP.

Draft: codec-with-touch.ini is not in a dmwm8994 release yet. See "Before this can merge".

Changes

  • configs/board/stm32f746g-disco/flash.dmd: adds dmsai and dmwm8994 driver=board/stm32f746g-disco/codec-with-touch.ini. dmsai_port, dmclk_port and dmdma come in through dmsai's dependencies.
  • Touch and audio on one I2C3. The codec's own codec.ini configures I2C3, so it cannot be loaded next to touch.ini. codec-with-touch.ini (new, in dmwm8994) has the SAI2 pins, the SAI node and the codec but no I2C3 pins or bus. It joins touch.ini's friends_group=lcd, so the codec finds the bus node the touch panel creates. dmi2c gives every client its own handle and serializes the transfers.
  • Renode (opt-in). -DDMBOOT_RENODE_AUDIO_CAPTURE=<file> wires the audio models from configs/renode/STM32F7_Audio.cs (added in Renode models for SAI audio through the WM8994 #122) into the generated renode.resc: SAI2, a WM8994 on I2C3 at 0x1A, and a DMA2 with circular mode and half-transfer interrupts. The codec writes what it plays to the file as raw stereo s16le. DMA2 is replaced before the SD card setup, which connects to it by name. Without the option nothing changes in the Renode machine. Documented in docs/cmake-options.md.

Before this can merge

  1. Add a board config that shares I2C3 with the touch panel dmwm8994#5 (adds codec-with-touch.ini), then a dmwm8994 release that contains it. The current v0.1 does not, so dmf-get logs Configuration file not found: …/codec-with-touch.ini and the board would boot without the codec config. The firmware builds still pass.
  2. dmsai v0.1 and dmwm8994 v0.1 are released and already implement the dmdrvi 2.7 audio stream commands; nothing is needed there.

CI: "Test Renode Simulation" is red here, and on master

It is not caused by this PR. master has been red since 08:44 UTC with the same failure at step 5: ✗ echo prints its argument: no prompt after 'echo uart-test-…'. The firmware prints the shell prompt but never answers input, and all later steps (SD, LCD, touch, network) are skipped.

I compared the module versions dmf-get resolved in the last green run (PR #123, 08:34) and the first red one (master, 08:44). Only three differ: dmuart 1.1 → 1.1.1, dmuart_port 1.1 → 1.1.1 and dm_sw_ring 0.5 → 0.6. Pinning versions locally in a build of master (no change from this PR), then booting in Renode:

dmuart dmuart_port shell
1.1 1.1 works
1.1.1 1.1 works
1.1 1.1.1 hangs
1.1.1 1.1.1 hangs

So dmuart_port 1.1.1 is the cause (dm_sw_ring 0.6 was used in all four rows). I do not know whether it also affects the real board or only Renode's USART model; I could not look at the dmuart repository from here. dmuart_port@1.1 pinned in configs/common/flash.dmd would get CI green again as a stopgap; I have not added it.

Verification

Done with the released dmsai v0.1, dmwm8994 v0.1 and the current dmdevfs 1.5 fetched by dmf-get, plus codec-with-touch.ini from the dmwm8994 PR, and dmuart_port 1.1 pinned to get around the regression above. The renode.resc was generated by this PR's CMake with -DDMBOOT_RENODE_AUDIO_CAPTURE and -DDMBOOT_RENODE_SDCARD.

  • Boot: /dev/dmi2cx, /dev/dmsai1, /dev/touch and /dev/wm8994 all appear.
  • Playback: an 8 s, 32-note melody through /dev/wm8994 with a generic player that uses only the dmdrvi audio commands. The codec model received it with no dropouts; the only underruns were the drain tail.
  • While it plays, on the same machine: touchtest read reports the injected touch correctly (240,136), and a file is written and read back on the SD card (/mnt/DMODTEST), with DMA2 replaced by the audio model.
  • Without the audio models (stock Renode machine): the system boots and the shell works. Codec calls fail with an error rather than hanging.
  • Not run: scripts/run_renode_tests.sh end to end, and nothing on the physical board.

Note: playback is sensitive to other work

During playback, shell activity makes short dropouts. In Renode:

  • an idle system is clean;
  • 5× echo gave 3 dropouts (1.2–2.7 ms);
  • 5× touchtest read (each loads a module) gave 9 dropouts, up to about 6.7 ms.

The SAI queue plus DMA buffer hold about 8 ms and the FreeRTOS tick here is 100 Hz (10 ms). This is unrelated to the shared bus, and I have not yet isolated the cause.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Nr1HhezRY951yBxxTm1b65

Load the WM8994 codec stack on the board: dmsai (SAI2 stream) and
dmwm8994 with codec-with-touch.ini. That config joins the touch panel's
I2C3 bus node instead of configuring I2C3 a second time, so touch and
audio work at once. The nodes are /dev/wm8994 (codec controls and
stereo PCM) and /dev/dmsai1 (the SAI stream the codec drives).

Emulation: DMBOOT_RENODE_AUDIO_CAPTURE=<file> loads the audio models of
configs/renode/STM32F7_Audio.cs (SAI2, the WM8994 on I2C3 and a DMA2
with circular mode and half-transfer interrupts) and writes what the
codec plays to the file as raw stereo s16le. DMA2 is replaced before the
SD card setup, which connects to it by name. Without the option nothing
changes in the Renode machine.

Needs dmwm8994 with codec-with-touch.ini and dmsai/dmwm8994 releases
that implement the dmdrvi 2.7 audio stream commands.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nr1HhezRY951yBxxTm1b65
@JohnAmadis
JohnAmadis marked this pull request as ready for review October 11, 2026 10:37
@JohnAmadis
JohnAmadis merged commit 0efbabe into master Oct 11, 2026
5 checks passed
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