Elastic Sheep

Because elasticdog was already taken

Elastic Sheep header image 2

Adding alsa audio support to a Buildroot-based system

January 28th, 2011 · 7 Comments · Uncategorized

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-lib
    • alsa-utils / aplay
    • mpg123

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
    • target/generic/alsa_device_table.txt

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.

Tags: ·····

7 Comments so far ↓

  • Mohamed Tarek

    I don’t know why this post didn’t receive any comments. I have a seep a huge load of people complaining about the missing /dev/dsp in their buildroot builds. Thanks for sharing ! Really helped me.

  • The Chief Sheep

    Thanks for leaving a message. I am happy to see this post have been helpful.

  • Avin

    Hey Chief Sheep,
    does versatilepb in qemu support sound devices ??
    because although i compiled kernel 2.6.27 with alsa support and filesystem with alsa-lib and madplay
    but i am not able to get sound output on qemu

    P.S. i used qemu with -soundhw all option

  • The Chief Sheep

    Hi Avin,
    The Qemu versatilepb machine was not supporting audio playback when I wrote this article.
    I have since delivered a patch to emulate the PL041 AACI interface that has been merged into the Qemu 1.0 release.
    You should be able to see the audio interface detected during the Linux boot.

    The -soundhw option is not necessary. It is only useful to select an emulated audio interface for the x86 machine.

  • Avin

    Hey Mathieu,
    first of all thanx for quick reply

    when i run on command line it shows >>
    QEMU PC emulator version 0.12.3 (qemu-kvm-0.12.3), Copyright (c) 2003-2008 Fabrice Bellard

    i installed from ubuntu repository and hence probably it is not having qemu 1.0, do i need to compile qemu 1.0 from source?

    ALSO when i run kernel with version 2.35 or higher in qemu it wont work(it hangs after message booting kernel), but lower versions work fine. will those newer kernel work with qemu 1.0

    sorry if i sound like naive

  • Avin

    Hey Mathieu,

    finally i got it working!!!
    i installed linaro-qemu which is latest!!
    and yes as u said pl041 interface was identified.
    And guess what linux kernel 3.1 which was not earlier running on qemu <1 is now working fine!!

  • The Chief Sheep

    Good news :)

Leave a Comment