Skip to content

Feature/audio – Fix CM5 I2S audio and microphone configuration#149

Draft
danic85 wants to merge 8 commits into
developfrom
feature/audio
Draft

Feature/audio – Fix CM5 I2S audio and microphone configuration#149
danic85 wants to merge 8 commits into
developfrom
feature/audio

Conversation

@danic85

@danic85 danic85 commented Jan 21, 2026

Copy link
Copy Markdown
Collaborator

What type of change is this?

  • New module
  • Change to an existing module
  • Core improvement
  • Other (please describe)

📝 What does this change do?

Fixes audio output (MAX98357B amplifier) and microphone input (ICS-43434 I2S microphones) on a Raspberry Pi Compute Module 5 running Raspberry Pi OS. Resolves four root-cause issues that prevented both playback and capture from working.

❓ Why is this change needed?

Audio output and microphone input on the CM5 carrier board stopped working entirely. Despite the hardware being detected by the kernel, neither aplay nor arecord produced any sound or recording. The configuration files contained several bugs that collectively caused this failure.

🛠️ How was this implemented?

Four issues were identified and fixed:

  1. Resolved merge conflict markers in installers/i2samp.py and install_audio.sh — both files had committed <<<<<<< / ======= / >>>>>>> markers causing a Python SyntaxError and a broken shell script at runtime.

  2. Fixed ALSA card targeting in asound.conf — all card 0 references replaced with the stable ALSA card name card sndrpigooglevoi. On CM5/Pi 5 the two vc4hdmi devices enumerate as cards 0 and 1, pushing the I2S card to card 1 or 2 (variable between boots), so the hardcoded card 0 was silently targeting HDMI output instead of the I2S amplifier. The same fix was applied to the asound.conf written by installers/i2samp.py.

  3. Added microphone capture path to asound.confpcm.!default previously used type plug → softvol, which is playback-only (dmix cannot handle capture). Changed to type asym with separate playback.pcm "softvol" and capture.pcm "hw:sndrpigooglevoi" so that arecord -D default and speech-recognition libraries have a valid capture route.

  4. Fixed i2smic.py to support CM5 / Pi 5 — the Pi model detection table only listed models up to Pi 4/CM4; running on CM5 caused an immediate bail-out with "Unsupported Pi board detected.", meaning the snd-i2smic-rpi kernel module was never installed. Pi 5 and CM5 model strings are now included in the Pi 4-generation group (pimodel_select = 2).

installers/Audio.md updated with a Root Cause Analysis section and corrected reference configuration.

🧪 How was this tested?

Changes are configuration-file and installer-script fixes targeted at CM5 hardware. Manual testing on the CM5 carrier board is required to fully verify playback and capture. The Python scripts (i2samp.py, i2smic.py) pass ast.parse validation and have no syntax errors.

💥 Breaking changes

  • Yes (please describe)
  • No

🗂 Related issues

✅ PR Checklist

  • Title & Description: PR title and description are clear and complete.
  • Documentation: PR links to idea in github discussion group containing complete documentation.
  • Scope & Size: PR is focused on a single issue/feature and is a reasonable size.
  • Code Quality: Code is clean, consistent, and follows the project style guide.
  • Tests: Tests have been added/updated if needed.
  • Manual Testing: Changes have been tested on the latest release of the project.
  • Self-Review: I've reviewed my own code and ensured there are no obvious issues.

🚀 Thank you for your contribution to the project!


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

@danic85 danic85 changed the base branch from main to develop January 21, 2026 21:32
@danic85

danic85 commented Mar 26, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot

This branch is an attempt to fix the audio configuration on a Raspberry Pi Compute Module 5 running the Raspberry Pi OS.

The CM5 is connected to a custom carrier board with 2x ICS-43434 I2S microphones and a MAX98357B amplifier module with speaker connected.

The files aplay.service, asound.conf, config.txt are all copies of the real files on the raspberry Pi that were saved in the correct locations.

Review the changes in the branch including the reference installers below (used as a basis for configuring these modules) and suggest reasons why the configuration is not working.

The expectation is that the raspberry pi would support audio output and microphone input, but currently neither are working despite working (intermittently) in the past. It is not a hardware issue.

Reference installers:

https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/main/i2samp.py
https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/main/i2smic.py

Additional wiki, not used but may be helpful:
https://learn.adafruit.com/adafruit-voice-bonnet

Component datasheets:
https://product.tdk.com/system/files/dam/doc/product/sw_piezo/mic/mems-mic/data_sheet/ds-000069-ics-43434-v1.2.pdf?ref_disty=mouser
https://www.analog.com/media/en/technical-documentation/data-sheets/MAX98357A-MAX98357B.pdf

… capture path, CM5 mic support

Agent-Logs-Url: https://github.com/makerforgetech/modular-biped/sessions/a540dd2d-28c8-45f0-9ce3-5926757b6100

Co-authored-by: danic85 <6583012+danic85@users.noreply.github.com>

Copilot AI commented Mar 26, 2026

Copy link
Copy Markdown

@copilot

This branch is an attempt to fix the audio configuration on a Raspberry Pi Compute Module 5 running the Raspberry Pi OS.
...

After reviewing all the configuration files against the reference installers and aplay -l output recorded in the branch, I found four root causes. All have been fixed in commit dd6a588.


Issue 1 — Merge conflict markers committed (Critical)

Both i2samp.py and install_audio.sh had unresolved <<<<<<< / ======= / >>>>>>> markers left in the files. This caused a Python SyntaxError on import and a broken shell script — meaning install_audio.sh never ran correctly in its committed state.


Issue 2 — asound.conf targeted the wrong ALSA card (Critical — likely the main playback failure)

Every card 0 reference in asound.conf pointed at the HDMI audio device, not the I2S amplifier. On CM5/Pi 5 the two vc4hdmi devices enumerate before the I2S card, so the I2S card is card 1 or 2 — and the number changes between boots (as seen in the aplay -l output recorded in install_audio.sh).

Note: hdmi_ignore_edid_audio=1 prevents HDMI from being selected as the default playback sink, but it does not stop the vc4hdmi cards from appearing in aplay -l with low card numbers.

Fix: All card 0 references replaced with the stable ALSA name card sndrpigooglevoi so the config always targets the correct device regardless of boot-time enumeration order.


Issue 3 — No microphone capture path in asound.conf (Critical — why recording never worked)

pcm.!default used type plug → softvol → dmix. The dmix plugin is playback-only; routing arecord -D default or any speech-recognition library through it silently fails. There was no capture path defined at all.

Fix: pcm.!default changed to type asym, independently routing:

  • Playback → softvoldmix → I2S card (unchanged)
  • Capture → hw:sndrpigooglevoi (direct I2S hardware access)

Issue 4 — i2smic.py bailed out on CM5 / Pi 5

The Pi model detection table only listed models up to Pi 4/CM4. On CM5 the script exited with "Unsupported Pi board detected.", so the snd-i2smic-rpi kernel module was never compiled or installed.

Fix: Pi 5 and CM5 model strings added to the Pi 4-generation group (pimodel_select = 2).

Additional note on mic approach: The googlevoicehat-soundcard overlay already exposes a capture device for I2S microphones wired to the Pi's DATA-IN pin. If arecord -l shows the sndrpigooglevoi card has a capture subdevice after reboot, running i2smic.py (which installs a separate snd-i2smic-rpi driver) may not be necessary and could create conflicts. Worth checking arecord -l first before running i2smic.py.

Copilot AI changed the title Feature/audio Feature/audio – Fix CM5 I2S audio and microphone configuration Mar 26, 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.

2 participants