Compiling a Raspberry Pi kernel for ASoC audio implementation > I2S to DAC

UPDATED: 28/10/2013 – thanks to reader feedback for corrections and updates.

Having struggled to successfully compile a working kernel for the Raspberry Pi, I thought I would share my notes for those also trying to implement an i2s interface for use with an audio ADC/DAC. If you’re not sure what you are doing, there’s a bunch of links at the bottom of this page which you may find helpful too. This how-to guide is 90% about cross-compiling the kernel, but there is also a few details about hooking up your rPi to an audio DAC/ADC. Disclaimer: I am no expert in cross-compilation or coding drivers or anything to do with embedded linux systems – I am more of a hardware kind of guy who has to get past the software stage to have fun with my soldering iron!

i2s success! RaspberryPi i2s audio interfacing with mBed audio board from RS.

My setup:

I am using a Raspberry Pi Model B (rev. 2).

The computer I used for cross-compiling the kernel is a Macbook Pro 8,1 running Ubuntu 12.04 LTS 64-bit. Any computer running a recent version of Ubuntu should work fine with exactly the same instructions.

The DAC/ADC I used is a Texas Instruments tlv320aic23b chip which is conveniently available on the mbed audio codec board made by RS. It has stereo in and out on PCB which is easily mounted to my breadboard. Perfect for rapid prototyping like this. Because this i2s implementation uses the awesome Asoc layer, many other DAC chips are also compatible. Check out the extensive list!

The mBed audio codec board from RS is a convenient way to rapidly implement i2s without having to worry about soldering up a chip.

I’ll break down the process into 4 stages, which should be completed consecutively.

1. Prepare a working Raspbian installation.

To get the SD Card prepared we need to install the latest version of Raspbian. Later we will replace the kernel image, the firmware and modules folders on this installation. I won’t try and replicate instructions which can be easily found in many places already, but here is the order of things you need to get done:

Get a copy of raspbian:

Go to and download the zip file containing the latest Raspbian installation. I used the torrent link:

Install it onto your SD card:

Instructions on how to install Raspbian on a SD card are explained very well at, I used the dd command. Once complete, load the SD card into your rPi and boot.

Get access to the rPi terminal:

Whether you have a USB keyboard and mouse with a monitor, or whether you do this remotely is up to you. I don’t bother with a mouse and screen, instead I use SSH get into the rPi to run commands. This means I have to setup the network side of things immediately. There are lots of resources explaining this process better than I can, such as this guide (PDF).

Set up the rPi with basic configurations:

Using raspi-config set password, timezones and locale, enable/disable desktop and expand root to fill SD card, etc:

pi@raspberrypi:~$ sudo raspi-config

Follow on screen instructions.

Update firmware and reboot:

I used Hexxeh’s script to update my firmware, which also needs GIT.

pi@raspberrypi:~$ sudo apt-get update
pi@raspberrypi:~$ sudo apt-get install git-core
pi@raspberrypi:~$ sudo wget -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
pi@raspberrypi:~$ sudo rpi-update
pi@raspberrypi:~$ sudo reboot

(These instructions thanks to Mark Williams)

You should now have a working rPi with terminal access and the latest firmware. Excellent. Time to break it. (Just kidding. Sort of.) But seriously, back it up now and save yourself lots of time rebuilding it later if you muck something up from here on in.


Raspberry Pi pin-out – header P5 has to be soldered on. You can choose to do this upright like I have or some orient it under the board like it was designed.

2. Compiler Environment.

The second step is to get a suitable cross-compiler environment working on your “host” system. In my case this means my Macbook Pro running Ubuntu 12.04 LTS. If we were building the kernel within the rPi itself we wouldn’t need to “cross compile” as such because the rPi, like any Linux system, can replicate itself. But that would take a very long time because the processing power of the rPi is limited compared to the i5 @ 2.30GHz × 4 available inside my Mac.

Install compiler tools:

me@Ubuntu:~$ sudo apt-get update
me@Ubuntu:~$ sudo apt-get install git gcc-arm-linux-gnueabi make ncurses-dev
me@Ubuntu:~$ git clone git://

(The command above will create a “tools” folder in your home drive.)

me@Ubuntu:~$ cd tools
me@Ubuntu:~/tools$ ls

You should see something like this:

me@ubuntu:~/tools$ ls
arm-bcm2708 configs mkimage pkg sysidk

Now set an environment prefix pointing to the directory location of the compiler tools:

me@ubuntu:~/tools$ export CCPREFIX=/home/me/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-

(Adjust the above line accordingly to suit your file structure, you want to point to the same prefix as at the end of this line. In this example I used the linaro gcc compiler)

You should now have a suitable environment for cross-compilation for the rPi. Wasn’t that easy?

3. Get the Kernel source and build the Kernel.

Because we are building for a very specific purpose, we need to choose the right kernel “source” from the developer: Koalo’s blog is the easiest place to check for updated information on his kernel source. This section borrows heavily from the excellent guide to cross compilation. If you have any issues try looking there.

Download and install latest kernel source (make a cuppa, this can take a while…): Update: Note the 5th line in the following has to be entered as one line – thanks to reader feedback for the headsup. Previously I had it broken into two parts.

me@Ubuntu:~$ cd /home/me
me@Ubuntu:~$ mkdir linux
me@Ubuntu:~$ cd linux
me@Ubuntu:~/linux$ git init
me@Ubuntu:~/linux$ git fetch git:// rpi-3.8.y-asocdev:refs/remotes/origin/rpi-3.8.y-asocdev
me@Ubuntu:~/linux$ git checkout rpi-3.8.y-asocdev
me@Ubuntu:~/linux$ ls

You should see something like this:

me@ubuntu:~/linux$ ls
arch CREDITS drivers hash.log init Kconfig MAINTAINERS net samples sound virt
block crypto firmware image.img.sha1sum ipc kernel Makefile README scripts tools
COPYING Documentation fs include Kbuild lib mm REPORTING-BUGS security usr

Set an environment variable KERNEL_SRC to point to the location of the downloaded source:

me@ubuntu:~/linux$ KERNEL_SRC=/home/me/linux

From the kernel clone location, i.e. your /home/me/linux folder, clean the kernel source folder:

me@ubuntu:~/linux$ make mrproper

From the rPi, prepare to export the working config file:

pi@raspberrypi ~ $ sudo zcat /proc/config.gz > .config

Then import the config file to the kernel source folder:

( Replace ‘raspberrypi’ below with the IP address of your Raspberry Pi if hostname lookup fails.)

me@ubuntu:~/linux$ sudo scp pi@raspberrypi:.config .

(Don’t be alarmed if you can’t see the imported file, its hidden!)

‘Prime’ the kernel with the old config:

me@ubuntu:~/linux$ ARCH=arm CROSS_COMPILE=${CCPREFIX} make oldconfig

(You may be prompted to answer a whole lot of cryptic questions about things which you never dreamed of. Don’t worry, hitting enter/return will choose the default. If you know about these things then you can customise to your hearts content.)

Modify the kernel config and choose appropriate modules:

Note: this step is the most important part for our purposes. It is important that we enable the Alsa aSoC modules and drivers, and also the DMA Engine.

me@ubuntu:~/linux$ ARCH=arm CROSS_COMPILE=${CCPREFIX} make menuconfig

(A menu system will appear. Read the header for navigation instructions.)

Enable the following device drivers as modules with the “m” or “y” keys:

Device Drivers > Sound card support (*) > Advanced Linux Sound Architecture (m)> ALSA for SoC audio support (m)> SoC Audio support for the Broadcom BCM2708 I2S module (m) > Select (m) for everything here including > Build all ASoC CODEC drivers (m)

Enable the following device drivers as modules with the “y” and “m” keys:

Device Drivers > DMA Engine Support (*) > BCM2708 DMA Engine support(m)

When finished selecting your config options, select ‘exit’ to move backwards in the menu and select “yes” to save changes.

Build the new kernel:

me@ubuntu:~/linux$ ARCH=arm CROSS_COMPILE=${CCPREFIX} make -j6

(Note: Evidently you can enable parallel processing for a faster compile, if you have a dual core processor add -j 3 to the end of the command below. If you have quad core, add -j 6. I couldn’t verify this – can you?)

Once build is complete and if successful, make a new directory folder for the modules:

me@ubuntu:~/linux$ mkdir /home/me/modules

Set an environment variable MODULES_TEMP to point to the new folder:

me@ubuntu:~/linux$ MODULES_TEMP=/home/me/modules/

Make the new kernel modules by using:

me@ubuntu:~/linux$ ARCH=arm CROSS_COMPILE=${CCPREFIX} INSTALL_MOD_PATH=${MODULES_TEMP} make modules_install

From the ~/tools/mkimage/ directory, run:

me@ubuntu:~/tools/mkimage$ ./ ${KERNEL_SRC}/arch/arm/boot/zImage

Sweet, if all has gone well you have your cross-compiled kernel and modules/drivers ready to be installed on your prepared rPi. Have a lovely cup of tea to celebrate! Prost. Now get ready to transfer your built image to your pi….


Get this sweet GPIO cheat sheet from

4. Transfer the new kernel and modules to rPi:

Move the built kernel file to the Raspberry Pi’s /boot/ directory:

me@ubuntu:~/linux$ scp arch/arm/boot/Image pi@raspberrypi:.
pi@raspberrypi ~ $ sudo cp Image /boot/kernel.img

Before we copy over the modules folder to the rPi, remove the “build”and “source” folders within as these are large and not required:

me@ubuntu:~/raspberrypi-linux$ sudo rm -f -r ../modules/lib/modules/3.2.27+/build
me@ubuntu:~/raspberrypi-linux$ sudo rm -f -r ../modules/lib/modules/3.2.27+/source

(Note: check that this actually works, if they are symbolic links and not real folders it may be more effective to just to remove them by deleting them using your GUI. EDIT: the lines above have the raspbian version that I used :  3.2.27+. This should be adjusted to suit your downloaded version ie: I think we are up to 3.8.10+ now….)

Now, within the rPi, remove the original folders and copy the new ones over to your root directory:

pi@raspberrypi:~ $ sudo rm -f -r /lib/modules
pi@raspberrypi:~ $ sudo rm -f -r /lib/firmware
pi@raspberrypi:~ $ sudo scp -r me@ubuntu:/home/me/modules/lib /

Reboot and cross your fingers!

The Raspberry Pi should now boot with the newly configured/recompiled kernel. Boom. You still need to enable the driver modules and test your system – best to follow the instructions on Koalo’s blog.

If you need a source of audio to test with, try this in mplayer once you are setup and ready to listen:

pi@raspberrypi:~ $ sudo apt-get install mplayer
pi@raspberrypi:~ $ mplayer -ao alsa:device=hw=1,0 -nolirc

You should hear some pretty sweet tunes from my local station!


I used the following wiring to interface the Raspberry Pi to the Mbed audio CODEC (playback mode):

In this example I have only wired the chip up for audio output. Note that /CS is set high by strapping it to 3.3v rail, and MODE is set low by linking it to ground.

Raspberry Pi Header Pins:           Mbed CODEC board:

P1-03                                   —–                                SDIN     (i2c data)

P1-05                                   —–                                SCLK     (i2c clock)

P5-02                                   —–                                3.3V

P5-03                                   —–                                BCLK     (bit clock in)

P5-04                                   —–                                LRCIN     (frame sync clock in)

P5-06                                   —–                                DIN          (i2s data in)

P5-08                                   —–                                GND

You can find all the information you need about GPIO pin-outs on your rPi at modmypi – a site dedicated to hardware modding your rPi! Sweet.


The above instructions would be much shorter and far less effective if it wasn’t for the following people who actually know what they are doing:

And of course the forum thread where it has all come together:

Tagged with →  
Share →

63 Responses to How to: easy i2s audio with your Raspberry Pi

  1. comfuture says:

    Hi pasdesignal,

    I’m trying on rpi 3.12.28+ with audio codec proto board.

    Is there any updated kernel modules?
    I’ve been tries your instruction and successfully compiled kernel.img and modules but it did not boot and stuck on rpi.
    so i tried to compile again from your github 3.12.y branch, but there is no snd-soc-rpi-proto or bcm2708* modules.
    but i can not merge 3.8.y-asocdev into 3.12.y because of bunch of conflicts.


  2. gurayc says:

    Hi Pasdesignal,

    I found a new sound card with WM8731 chipset, named as Wolfson Audio Card, on Did you test it?


  3. rahul says:

    I am getting problem of crosstalk…..some swapping of data in both channel occurs..Can anybody help to solve this problem

  4. Matthias says:

    I’ve installed the Kernel successfully and built up the DAC prototype.
    It seems that the system is working. There i8s something going on at the PCM_FS line and the PCM_DOUT line.
    But I don’t have any traffic at the PCM_CLK line.
    Do I have to enable the PCM_CLK?

    • pasdesignal says:

      Hi Matthias,

      What do you mean there is no “traffic at the PCM_CLK line”? Could you please elaborate a little. You do not have to enable anything, it is all done with the modules and drivers.

      Depending on what chip you are interfacing with, the PCM_CLK can be an input or an output….

      • Matthias says:

        Well, when I use my oscilloscope to measure the signal of the PCM_CLK, I don’t have any signal.

        I’m using the the Texas Instruments PCM 5102 DAC. My understanding is, that the clock comes from the Raspberry, when using this DAC, right?

        Thank you

  5. jonathan says:


    I can compile the new kernel but i cant download the kernel to the raspberrypi.
    This is the code.

    pi@raspberrypi ~ $ sudo rm -f -r /lib/modules
    pi@raspberrypi ~ $ sudo rm -f -r /lib/firmware
    pi@raspberrypi ~ $ sudo scp -r ubuntu@ubuntu:/home/ubuntu/modules/lib/
    usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
    [-l limit] [-o ssh_option] [-P port] [-S program]
    [[user@]host1:]file1 … [[user@]host2:]file2
    After a reboot ant type aplay -l i the terminal it returns:
    pi@raspberrypi ~ $ aplay -l
    aplay: device_list:252: no soundcards found…

    it looks that the kernel would be copied to the raspberry…?

    Thanks for the help.

  6. asti says:

    Anybody solved the recording problem? The playback working correctly, but the recording is not working, only some periodically ticking sounds will be in the sample.
    LRCOUT/LRCIN connected to PCM_FS, DOUT connected to PCM_DIN, any idea?
    Thank you

    • pasdesignal says:

      You mean with the Mbed board? I know someone has made it work, but I have left that chip behind am am solely concentrating on WM8731 at the moment…

      • Octavio says:

        Hello, do you have a working WM8731 on raspberry pi, ? cause i cant have a working kernel, every time y reboot at the end of the process, y have nothing my system never come back, :( if you have an image of a distro running with the WM8731 i appreciate your help regards.

        • pasdesignal says:

          Hi there, I do actually have a built image that I can share with you. I will post the link to it in my blog. Instructions on how to download and install will also be included. Please see my video demonstrating my soundcard to see it working. Regards

          • Malcolmcjcc says:

            any chance you could share this link with me. I’m working on a project but again i’m struggling with the audio input.

  7. Louis says:


    Thanks for the post mine works fine right up to the cross compile then i keep getting the file not found error. I have checked the folder and the files are there but for some reason I can’t get it to see them; Help would me much appreciated. Thanks:

    m1stikal@Louis-LT:~/linux$ ARCH=arm CROSS_COMPILE=${CCPREFIX} make -j3
    make: /home/m1stikal/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: Command not found
    scripts/kconfig/conf –silentoldconfig Kconfig
    warning: (DVB_USB_PCTV452E) selects TTPCI_EEPROM which has unmet direct dependencies (MEDIA_SUPPORT && MEDIA_PCI_SUPPORT && MEDIA_DIGITAL_TV_SUPPORT && I2C)
    warning: (DVB_USB_PCTV452E) selects TTPCI_EEPROM which has unmet direct dependencies (MEDIA_SUPPORT && MEDIA_PCI_SUPPORT && MEDIA_DIGITAL_TV_SUPPORT && I2C)
    make: /home/m1stikal/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: Command not found
    WRAP arch/arm/include/generated/asm/auxvec.h
    WRAP arch/arm/include/generated/asm/bitsperlong.h
    WRAP arch/arm/include/generated/asm/cputime.h
    WRAP arch/arm/include/generated/asm/current.h
    WRAP arch/arm/include/generated/asm/emergency-restart.h
    WRAP arch/arm/include/generated/asm/errno.h
    WRAP arch/arm/include/generated/asm/exec.h
    WRAP arch/arm/include/generated/asm/ioctl.h
    WRAP arch/arm/include/generated/asm/ipcbuf.h
    WRAP arch/arm/include/generated/asm/irq_regs.h
    WRAP arch/arm/include/generated/asm/kdebug.h
    WRAP arch/arm/include/generated/asm/local.h
    WRAP arch/arm/include/generated/asm/local64.h
    WRAP arch/arm/include/generated/asm/msgbuf.h
    WRAP arch/arm/include/generated/asm/param.h
    WRAP arch/arm/include/generated/asm/parport.h
    WRAP arch/arm/include/generated/asm/poll.h
    WRAP arch/arm/include/generated/asm/resource.h
    WRAP arch/arm/include/generated/asm/sections.h
    WRAP arch/arm/include/generated/asm/segment.h
    WRAP arch/arm/include/generated/asm/sembuf.h
    WRAP arch/arm/include/generated/asm/serial.h
    CHK include/generated/uapi/linux/version.h
    WRAP arch/arm/include/generated/asm/shmbuf.h
    WRAP arch/arm/include/generated/asm/siginfo.h
    UPD include/generated/uapi/linux/version.h
    WRAP arch/arm/include/generated/asm/sizes.h
    WRAP arch/arm/include/generated/asm/socket.h
    WRAP arch/arm/include/generated/asm/sockios.h
    WRAP arch/arm/include/generated/asm/termbits.h
    WRAP arch/arm/include/generated/asm/termios.h
    WRAP arch/arm/include/generated/asm/timex.h
    CHK include/generated/utsrelease.h
    WRAP arch/arm/include/generated/asm/trace_clock.h
    WRAP arch/arm/include/generated/asm/types.h
    WRAP arch/arm/include/generated/asm/unaligned.h
    UPD include/generated/utsrelease.h
    HOSTCC scripts/genksyms/genksyms.o
    SHIPPED scripts/genksyms/lex.lex.c
    SHIPPED scripts/genksyms/keywords.hash.c
    SHIPPED scripts/genksyms/
    SHIPPED scripts/genksyms/
    HOSTCC scripts/genksyms/lex.lex.o
    HOSTCC scripts/genksyms/
    Generating include/generated/mach-types.h
    CC scripts/mod/empty.o
    /bin/sh: 1: /home/m1stikal/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
    make[2]: *** [scripts/mod/empty.o] Error 127
    make[1]: *** [scripts/mod] Error 2
    make[1]: *** Waiting for unfinished jobs….
    CC kernel/bounds.s
    /bin/sh: 1: /home/m1stikal/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
    make[1]: *** [kernel/bounds.s] Error 127
    make: *** [prepare0] Error 2
    make: *** Waiting for unfinished jobs….
    HOSTLD scripts/genksyms/genksyms
    make: *** [scripts] Error 2

  8. Hello! Would you mind if I share your blog with my zynga
    group? There’s a lot of people that I think would really enjoy your content.

    Please let me know. Thank you

  9. Matthias says:

    Hi there,

    thank youi for this great tutorial!
    But I have a problem. I can’t compile the Kernel.
    There are a lot of errors and I don’t know what to do.
    This is what it says:

    matze@matze-VirtualBox:~/Desktop/linux$ ARCH=arm CROSS_COMPILE=${CCPREFIX} make -j6
    CHK include/generated/uapi/linux/version.h
    CHK include/generated/utsrelease.h
    make[1]: `include/generated/mach-types.h’ is up to date.
    CC scripts/mod/empty.o
    gcc: error: unrecognized command line option ‘-mlittle-endian’
    gcc: error: unrecognized command line option ‘-mapcs’
    gcc: error: unrecognized command line option ‘-mno-sched-prolog’
    gcc: error: unrecognized argument in option ‘-mabi=aapcs-linux’
    gcc: note: valid arguments to ‘-mabi=’ are: ms sysv
    gcc: error: unrecognized command line option ‘-mno-thumb-interwork’
    make[2]: *** [scripts/mod/empty.o] Error 1
    make[2]: *** Waiting for unfinished jobs….
    make[1]: *** [scripts/mod] Error 2
    make: *** [scripts] Error 2
    make: *** Waiting for unfinished jobs….
    CC kernel/bounds.s
    gcc: error: unrecognized command line option ‘-mlittle-endian’
    gcc: error: unrecognized command line option ‘-mapcs’
    gcc: error: unrecognized command line option ‘-mno-sched-prolog’
    gcc: error: unrecognized argument in option ‘-mabi=aapcs-linux’
    gcc: note: valid arguments to ‘-mabi=’ are: ms sysv
    gcc: error: unrecognized command line option ‘-mno-thumb-interwork’
    make[1]: *** [kernel/bounds.s] Error 1
    make: *** [prepare0] Error 2

    Can you help me with that?


    • pasdesignal says:

      It looks to me like you haven’t “primed” the kernel properly with a good config.gz file?
      You know that you export this file from a working raspberry pi right?

  10. Vasile says:

    Thank you for the very well written tutorial, and thank you for the radio station!
    It sound awesome with TDA1387 DAC (TDA1541 module loaded).
    I had to install ia32-libs on my 32bit ubuntu 12.04 to be able to compile the kernel.

  11. am1337 says:

    just a small hint: If you want to use SPI (e.g. for PiFace) with Koalo’s kernel you need to compile the SPI drivers into the kernel, not as a loadable module.
    BCM2708 SPI controller driver (SPI0)
    User mode SPI device driver support
    Using SPI doesn’t work. See for further information.

  12. GSWG says:

    Hi all, great walk through – thanks. I’ve followed the above with interest and yesterday rebuilt the linux 3.8.10+, installed modules (as per koalo’s blog) and rebooted several times. lsmod shows the i2s module etc as expected.

    I don’t have any external dac connected yet so I was assuming that if I just played audio on the pi as normal we’d see signals on the i2s or clock lines. BUT we see nothing at all. I added the wmdriver and proto modules to see what happened (again no external DAC connected) and see from dmesg that both the wm driver and proto driver give the expected “hardware not found” type messages.

    I’m pretty confident that the build was successful, that the modules are loaded on the pi itself etc.

    So with no external hardware how can I check (any sw needs to be run other than mplayer?) that the i2s data / clock is “enabled”?

    Thanks in advance,


    • GSWG says:

      Okay, think I solved it….

      Added the following to /etc/modules and now have an extra driver listed under “aplay -l” so getting somewhere.



  13. jean-yves says:

    Very interesting page!
    Do you think this DAC can be use for this application?

    thanks’ a lot

  14. […] และเจ้าของผลงานนี้เคยทดลองกับชิป DAC ตัวอื่นมาก่อน […]

  15. Hi there! Would you mind if I share your blog with my
    facebook group? There’s a lot of folks that I think would really
    enjoy your content. Please let me know. Cheers

  16. Daniel says:

    After tweaking the driver to let the Raspberry become slave for the I2S clocks, I got the Raspberry Pi working together with en ADAU1701 DSP :-)

  17. Daniel says:

    Thank you for this guide. It worked without major problems for me. I’m still developing my DAC, but at least it looks good on the oscilloscope:

  18. […] thanks to Koalo and  Noise if good for the helpful guide to compile a new kernel with I2S […]

  19. Fiatelist says:


    Very useful information.

    I’m running 64bit Ubuntu and could not compile before I installed the 32bit libraries with “sudo apt-get install ia32-libs“. More info in “”

    I’m trying to get my EE9023 DAC working, any tip on what module to use?

    • pasdesignal says:

      Hi Fiatelist, thanks for the info. Thats great help for others who may be compiling on 64bit version. I will add this info to the original post.
      As far as which asoc module to use with your DAC, it looks like it is a non i2s controlled DAC so I think the best option would be to use the snd_soc_tda1541a driver and snd_soc_rpi_tda1541a module as this tda1541a DAC chip is also non controllable. However I don’t have much experience with either your or the TDA1541a so this is just a best guess. Good luck and let me know how you go!

      Maybe someone else here has a suggestion for Fiatelist?

  20. jeff says:

    I think there are a couple things not quite write with your otherwise excellent recipe.

    * emits a new kernel.img in the current directory. This is the file you want to install on your raspberry pi. It is the compressed kernel image with the bootloader and kernel args stuck in front. The zImage is quite a bit smaller than the Image file.

    * removing the build and source folders prior to copying to the raspberry pi can be done with rm — these are symlinks.

    Thanks for posting this — I found it very useful.


  21. […] connected to the I2S pins. Therefore you need to compile your own kernel. Check out the “Noise is good” blog for more information. Hmm, looks like an interesting project for another Raspberry […]

  22. Michael Dam says:

    Hi, like the project! :-)
    I do have the following questions:
    I can’t seem to spot what was done to make sure the i2s headers are enabled and used. So I’m thinking why not use this slimmed down version of linux, start mplayer and I’m done?
    What is it I’m missing here. Or could it be done?

    • pasdesignal says:

      Hi Michael,
      Thanks for visiting and commenting.
      The picoreplayer is a stripped down linux build specifically for using the rPi as an audio playback device.
      Which is great. However you would need to use one of the three standard methods to get audio in/out: built in PWM audio out (pretty crap), take the audio out of the HDMI port (reasonable) or a USB DAC (could be very good, depends on the DAC).
      This project is about getting audio in/out of the rPi by directly connecting the pins of DAC chip to the pins on the processor. Its the option with the most potential for great results inlcuding low latency. There is a lot of work to be done though, its not really very practical yet. But stay tuned! The best is yet to come.

  23. I got my I2S DAC, with PCM1794A, working as well. Modify the Rasbian kernel and add I2S support – it works.
    Great audiophile sound on Rasberry Pi.

  24. Gyozo says:

    Great job! Unfortunately, I am very novice with Linux. I tried to implement the steps, but compilation did not work for me. Someone could give me a download link to download a compiled OS image. Thanks in advance!

    • pasdesignal says:

      Hi Gyozo,
      I don’t have a suitable image but maybe I should look into preparing one. I am not sure what is required to make a build suitable for general use… I’ll look into it.
      I am also very novice with kernel building, so I must encourage you to persevere! If I can do it, surely you can too… good luck.

      • Gyozo says:

        Hi pasdesignal !
        I re-tried to cross-compile all from begining in other distro, under Debian 7 and all work fine. Now I know the “Phisical Memory Adress” value should be the 0x0000000 value according to the BCM2835 datasheet. This value is need for configuration.
        Thanks for your answer!

  25. Max says:

    Same problem here while trying to record only ticking noise. Any solution yet available? Thanks!

    • pasdesignal says:

      Hi Max,
      I didn’t persevere with the Mbed board – I have moved on to play around with the Wolfson WM8731 chip. I am using it on a breadboard setup.
      Sorry I couldn’t help any further…

  26. Hobbit13 says:

    Trying to get this working on a Pi, got some issues during kernel compiling.

    what do you mean by “(Adjust the above line accordingly to suit your file structure, you want to point to the same prefix as at the end of this line. In this example I used the linaro gcc compiler)” in the CCPREFIX description? I assume I just need to replace “/home/me” with “/home/hobbit13″? (hobbit13 is my username).

    I got stuck a few commands afterwards: “git fetch git:// \ rpi-3.8.y-asocdev:refs/remotes/origin/rpi-3.8.y-asocd”

    returns “Invalid refspec”. I guess the “\” should not be there. (it meant next line in the original blog?)

    without the “\” it works.

    • Hobbit13 says:

      Can’t get much further :-(

      compiling of the kernel doesn’t work, I keep getting the following errors:
      gcc: error: unrecognized command line option ‘-mlittle-endian’
      and ‘-mabi=aapcs-linux’ ‘-mno-thumb-interwork’
      make[1]: *** [kernel/bounds.s] Error 1
      make: *** [prepare0] Error 2

      all steps before the “make” succeeded.

      can anyone help?

      • Hobbit13 says:

        Crosscompiling kept failing, thus I compiled everything on the Pi. Took 18 hours, but now it works.

        ES9023 dac is running directly from the Pi (including power). Consumes 10% CPU when playing a 192kbps MP3 internet stream. And less than 100mA power (including the dac!)

        Sound quality is fine, a tad brighter than the same song via USB -> I2S conversion. But more testing is needed before I can draw a conclusion.

        • Hobbit13 says:

          Well, I did the testing, and results are so-so…

          In console playback works without interruptions, but in X, every single activity of other programs will cause hickups in the audio. Probably some buffering issues in the drivers. Furthermore, I only got success using mPlayer, other players didn’t like the PCM Mixer or other aspects of the ALSA driver.

          To make matters worse, sound quality is not that good. I use a ES9023 with a high-quality clock, which is used to reclock the audio data. Thus jitter should not be an issue, nevertheless it sounds rather flat, it’s detailed, but not very nice to listen to. A Tenor TE7022 chip gives a much better I2S stream (and is not considered a perfect I2S source).

          It still can be a nice basis for a remote soundcard (via PULSE, or via a webstream). But not as a replacement for HDMI audio when you are using the Pi as a (video) mediaplayer.

          • pasdesignal says:

            Yes there is a lot more work to be done I think to get the aSOC drivers operating well on the pi.
            I am having some success with a breadboarded WM8731 – once I overcame some power supply issues and better decoupling etc… getting more stable as I improve the board layout.

      • sebastian says:

        I get the exact same thing. did anyone figure this out?

  27. […] blogger called Pasdesignal has written in detail on modifying the Raspberry Pi kernel for ALSA SoC audio – also known as ASoC […]

  28. gianluca says:

    thanks for your great post!

    one question: did you tried to record with the mbed board?
    I’m able to playback fine, but I can’t record using for example “arecord -D hw:1,0 -d 5 -f DAT capture.wav” on my pi board, and I’m quite sure my I2S pin are connected correclty to the dout…


    • pasdesignal says:

      Hi gianluca,

      I have recorded with the mbed codec, yes. But there is a problem with the audio – there is a clicking sound in on channel which sounds like a clocking issue. To record you must connect the lrcout to the lrcin pin. Have you done this?

      Also, what error message do you get when trying to record?


      • gianluca says:

        thanks pasdesignal.

        yes my lrcin and lrcout are connected both to my Rpi PCM_FS pin, my dout is connected to the PCM_DIN and since I can playback correclty (checked with a scope while playing a triangle.wav test file) I assume my connection are fine.

        I also checked in alsa mixer to make sure the line input is selected for record, but when I use arecord nothing is recoded.
        the file is simply “all zero”.

        there is no error, arecord does create the file just fine, simply there is no waveform in it.

        what is your command line to record audio?

        • pasdesignal says:

          Hi again gianluca,
          I am using this command:

          arecord -D hw:1,0 -f DAT -d 10 my_record.wav

          Have you set the correct parameters using “amixer”?
          I think you will find that the chip is set to record microphone input instead of line input.

          amixer -c 1 controls

          and play around with changing the way the chip is configured. Its actually pretty cool!
          I think I will write a short blog post about recording using this mbed CODEC, and see if anyone can help solve the clicking issue.
          Good luck, let us know how you go ok?

          • gianluca says:

            mmm weird, it seems to me that I do have the right settings.
            still .. no audio (but I do have the crackle noise you mentioned, and I noticed if I capture at 44.1K they are a lot more frequent)

            here are my settings, looks to me I’m capturing on line_IN.



            numid=3,iface=MIXER,name=’Line Input Switch’
            ; type=BOOLEAN,access=rw——,values=2
            : values=on,on
            numid=4,iface=MIXER,name=’Line Input Volume’
            ; type=INTEGER,access=rw—R–,values=2,min=0,max=31,step=0
            : values=23,23
            | dBscale-min=-17.25dB,step=0.75dB,mute=0
            numid=6,iface=MIXER,name=’Mic Booster Switch’
            ; type=BOOLEAN,access=rw——,values=1
            : values=off
            numid=5,iface=MIXER,name=’Mic Input Switch’
            ; type=BOOLEAN,access=rw——,values=1
            : values=off
            numid=12,iface=MIXER,name=’Capture Source’
            ; type=ENUMERATED,access=rw——,values=1,items=2
            ; Item #0 ‘Line’
            ; Item #1 ‘Mic’
            : values=0
            numid=8,iface=MIXER,name=’Playback De-emphasis’
            ; type=ENUMERATED,access=rw——,values=1,items=4
            ; Item #0 ‘None’
            ; Item #1 ’32Khz’
            ; Item #2 ‘44.1Khz’
            ; Item #3 ’48Khz’
            : values=3
            numid=2,iface=MIXER,name=’Digital Playback Switch’
            ; type=BOOLEAN,access=rw——,values=1
            : values=on
            numid=1,iface=MIXER,name=’Digital Playback Volume’
            ; type=INTEGER,access=rw—R–,values=2,min=0,max=127,step=0
            : values=121,121
            | dBscale-min=-121.00dB,step=1.00dB,mute=0
            numid=9,iface=MIXER,name=’Output Mixer Line Bypass Switch’
            ; type=BOOLEAN,access=rw——,values=1
            : values=off
            numid=10,iface=MIXER,name=’Output Mixer Mic Sidetone Switch’
            ; type=BOOLEAN,access=rw——,values=1
            : values=on
            numid=11,iface=MIXER,name=’Output Mixer Playback Switch’
            ; type=BOOLEAN,access=rw——,values=1
            : values=on
            numid=7,iface=MIXER,name=’Sidetone Volume’
            ; type=INTEGER,access=rw—R–,values=1,min=0,max=4,step=0
            : values=3
            | dBscale-min=-18.00dB,step=3.00dB,mute=0

        • am1337 says:

          Hi gianluca,
          could you resolve the recording issue? I have the same problem with the mbed codec.

          • gurayc says:

            Hi am1337,
            Did you solve recording problem?

          • pasdesignal says:

            Hi Gurayc,
            I didn’t bother as I wasn’t interested in the chip anyway. I moved on to the WM8731 pretty quickly…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>