I have tested the building of a basic Linux system with Buildroot. I would like now to add audio support to this system with mp3 decoding capabilities.
The mp3 decoding will be handled by the mpg123 application. The decoded audio playback will go through the alsa-lib userland interface that communicates with the alsa kernel subsystem.
The target hardware is the Versatile/PB platform emulated in QEMU.
System base configuration
The Builroot base configuration is the same as in my previous post:
- Target Architecture: arm
- Target Architecture Variant: arm926t
- Target ABI: EABI
- Toolchain/Kernel Headers: 2.6.36.x (I could specify a path to my kernel sources)
- Package Selection for the Target/Busybox 1.17.x
- Target Fileystem Options/cpio the root filesystem and Compression method: gzip
I select those options in the Buildroot configuration menu and then save the resulting config file in the configs directory.
$> cd buildroot-2010.11 $> make menuconfig $> cp .config configs/versatilepb926_defconfig
The saved configuration can be directly applied from make if you want to return to a known state:
$> make versatilepb926_defconfig # # configuration written to [...]/buildroot-2010.11/.config #
Adding the alsa and mpg123 support
To enable the alsa and mpg123 support:
- Toolchain/Enable large file (file > 2GB) support
- Package Selection for the target/Audio and Video libraries
- alsa-utils / aplay
aplay is useful to check if simple WAV files can be played by the system. The Large File support is a dependency requirement from the alsa-utils package.
Adding the /dev/snd/* entries
By default, Buildroot does not add create audio device files. It uses the default device table that is located in target/generic/device_table.txt.
To add the /dev/audio and /dev/snd/* device files, I create a new device table file derived from the generic one adding the entries required by Alsa: target/generic/alsa_device_table.txt.
Then I change the selected device table in the Buildroot configuration:
- Target Filesystem options/Path to the device table
Here is the updated audio section of the device table:
# Audio stuff /dev/audio c 666 0 29 14 4 - - - #/dev/audio1 c 666 0 29 14 20 - - - /dev/dsp c 666 0 29 14 3 - - - #/dev/dsp1 c 666 0 29 14 19 - - - #/dev/sndstat c 666 0 29 14 6 - - - /dev/mixer c 666 0 29 14 0 - - - /dev/snd d 755 0 29 - - - - - /dev/snd/controlC0 c 666 0 29 116 0 - - - /dev/snd/pcmC0D0c c 666 0 29 116 24 - - - /dev/snd/pcmC0D0p c 666 0 29 116 16 - - - /dev/snd/seq c 666 0 29 116 1 - - - /dev/snd/timer c 666 0 29 116 33 - - -
My patched file for buildroot-2010.11: alsa_device_table.txt
Sorry I don’t remember the original source from where I copied those major/minor device numbers.
Saving the updated configuration
$> cp .config configs/versatilepb926_alsa_defconfig
Copying audio files in the root filesystem
Audio files can be directly copied in the output/target/root directory of Buildroot for test purposes.
When running make again, buildroot includes those files in the CPIO archive of the rootfs.