🛠 Son sur CM4 : DAC I2S/PCM (PCM5102) sans prise jack

Raspberry Pi Compute Module 4 (CM4, 2020) — Board Sheet · intermediaire · Schéma : IMG-compute-module-4-intermediaire-3-audio-i2s-pcm5102-cm4.svg — CM4 sur IO Board ; l'interface PCM/I2S de l'empreinte HAT (SCLK, LRCLK, BCLK, DIN) relie un petit DAC PCM5102 muni d'un amplificateur vers deux haut-parleurs ; une croix barre la prise jack, absente du CM4.

Objectives

The CM4 has no audio jack (no embedded ADC/DAC), but exposes a PCM (I2S) interface on its pins. This tutorial connects an inexpensive I2S DAC (PCM5102) to the HAT footprint of the IO Board and configures the board as the default audio output via a device tree overlay — the standard approach across the entire BCM2711 ecosystem.

Hardware

Complete code

# 1) Activer I2S et charger le driver du DAC
sudo raspi-config nonint do_i2s 0        # active device tree I2S
{ echo 'dtparam=i2s=on'; echo 'dtoverlay=hifiberry-dac'; } | sudo tee -a /boot/firmware/config.txt
sudo reboot

# 2) Vérifier la carte audio
aplay -l                                  # attendu : snd_rpi_hifiberry_dac
cat /proc/asound/cards

# 3) En faire la sortie par défaut
cat > /etc/asound.conf <<'EOF'
pcm.!default {
  type plug
  slave.pcm "hw:1,0"}
EOF

# 4) Test sonore
speaker-test -D plughw:1,0 -c 2 -t sin -f 440 --duration 3

Expected verification

aplay -l lists snd_rpi_hifiberry_dac; speaker-test produces a clear 440 Hz tone in the speaker; a wav file plays with aplay music.wav without options. dmesg | grep -i hifiberry shows no probe errors.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials