I2S Sound Buildroot Configuration - cu-ecen-aeld/buildroot-assignments-base GitHub Wiki

Details:

This wiki link will help in integrating audio playback on Buildroot.

References:

https://github.com/cu-ecen-aeld/final-project-sachininja/tree/i2s-buildroot --> Buildroot commit.
https://github.com/cu-ecen-aeld/final-project-dash6424 --> i2s package for buildroot.
https://bytesnbits.co.uk/raspberry-pi-i2s-sound-output/ --> Details related to i2s, required packages and drivers.

Configuring and Building

If using a Raspberry Pi 3B+ please modify your config.txt to ensure these changes are included. Other hardware platforms are likely to use similar settings.

dtparam=i2s=on
dtoverlay=hifiberry-dac
dtoverlay=i2s-mmap

To customize config.txt, see instructions in the Raspberry Pi Hardware Hints Page

  1. In the buildroot folder, run "make menuconfig" and enable all the ALSA (Advanced Linux Sound Architecture) drivers required for audio. "make menuconfig" --> "Target Packages" --> "Audio and video applications" --> "alsa_utils"

image

Recommendation is to enable all the supported tools inside alsa-utils. But if required, you can only enable required tools.

  1. Run save-config.sh and ensure the below packages are added in defconfig file as shown below:
BR2_PACKAGE_ALSA_UTILS=y
BR2_PACKAGE_ALSA_UTILS_ALSACONF=y
BR2_PACKAGE_ALSA_UTILS_ACONNECT=y
BR2_PACKAGE_ALSA_UTILS_ALSALOOP=y
BR2_PACKAGE_ALSA_UTILS_ALSAUCM=y
BR2_PACKAGE_ALSA_UTILS_ALSATPLG=y
BR2_PACKAGE_ALSA_UTILS_AMIDI=y
BR2_PACKAGE_ALSA_UTILS_AMIXER=y
BR2_PACKAGE_ALSA_UTILS_APLAY=y
BR2_PACKAGE_ALSA_UTILS_APLAYMIDI=y
BR2_PACKAGE_ALSA_UTILS_ARECORDMIDI=y
BR2_PACKAGE_ALSA_UTILS_ASEQDUMP=y
BR2_PACKAGE_ALSA_UTILS_ASEQNET=y
BR2_PACKAGE_ALSA_UTILS_BAT=y
BR2_PACKAGE_ALSA_UTILS_IECSET=y
BR2_PACKAGE_ALSA_UTILS_SPEAKER_TEST=y
  1. Below modules are required to run audio on buildroot image:
    snd_soc_pcm5102a
    snd_soc_rpi_simple_soundcard
    snd_soc_bcm2835_i2s

To add them, modprobe manually once the buildroot image is flashed or automate it by adding these changes as part of a start stop script as shown below:

image

and run this startup script using the rootfs overlay strategy discussed and implemented in Assignment 7 (or by including in a package).

  1. Optional: Add a package with sound and i2s related files and configuration.

This will vary by project. The package at https://github.com/cu-ecen-aeld/final-project-sachininja/tree/i2s-buildroot/base_external/package/i2s_package installs files related to the project described at https://github.com/sachininja/final-project-SachinMathad/wiki/Project-Overview

  1. Clean build the buildroot image and flash it on rpi

Validation

  1. Verify that the audio soundcard is loaded in rpi by running aplay -L command. It should output as shown below:

image

This ensures that the audio related packages and overlays are present and working.

  1. Follow the i2s pin configuration to connect the i2s pins to HW codec as shown here.
    or
    connect the speaker to audio jack and run below command:
aplay <audio_file.wav>
  1. Enjoy the music on your devboard! :)
⚠️ **GitHub.com Fallback** ⚠️