Connecting the Wolfson Sound Card to the Raspberry Pi3

I’m quite a fan of the Wolfson (later Cirrus) sound cards for the Raspberry Pi – they offer great value for money compared to some of the competition.

Most of the audio cards available for Pi’s offer a DAC only option, with maybe one or two outputs (e.g. Line Out / SPDIF or Headphones).

The Wolfson card offers a DAC and an ADC, SPDIF In and Out, Line In, Line Out, Headphones Out, two on-board stereo Digital Microphones and a 2W Class D amplifier for driving loudspeakers.

I also happen to think it sounds rather good, in particular I like it’s headphone driving capabilities.

The DAC has a 113dB dynamic range, which is much better than CD and the ADC has a 96dB dynamic range. The best HiFi DAC’s can achieve 122dB but the price difference between these and the Wolfson card are significant! The board can exploit 24bit HD audio up to 192kHz sample rate and it also features some very advanced and very complex DSP and mixing capabilities, if you need it.

It’s also worth noting that when Hifi World tested the card with an external DAC, the Wolfson board was capable of utilising the full 121dB dynamic range of a Chord 2Qute external DAC, so as the basis for an upgradeable music streamer, it’s great.

There are two versions of the card, the earlier Wolfson-branded board is only compatible with Raspberry Pis which feature the P5 pads, which can be found on Revision 2 Raspberry Pis onwards.

Wolfson Card Top View

Wolfson Card Top View (click to enlarge)

The board uses some ingenious sprung pogo pins to connect to the P5 connector on the Raspberry Pi, eliminating the need to solder a connector to the board: –

Wolfson Card Bottom View

Wolfson Card Bottom View (click to enlarge)

The newer board was branded Cirrus (after Cirrus bought Wolfson) but this has since been discontinued leaving us without a board that is compatible with the Raspberry Pi3 – until now!

Cirrus Card

Cirrus Card (click to enlarge)

The problem with the board is that the drivers haven’t been part of the Raspberry Pi kernel and hence it requires hacks and patches to make it work, which is ultimately frustrating. Some of the music-related distros (e.g. Max2Play) have the options to enable it but it’s always been a bit messy.

Recently though 

It’s awesome and can be installed in most cases by just updating the Pi kernel with the following command

sudo rpi-update
Update Pi Kernel

There’s an excellent thread on the Element14 website and one of the most interesting elements I spotted is that the earlier Wolfson card can be made to work with the newer Raspberry Pi 3, when using the new driver.

At the time of writing Farnell / Element 14 had >1300 of the Wolfson cards in stock at a cost of £18.76 each, which I think is a bit of a steal.

All of the details necessary to make it work are in the thread above, but to save some digging (and to preserve the information for posterity) I thought I’d document the modifications required. Note that these mods require some soldering and there is a risk of damage to the board, so proceed at your own risk – there are some ingenious methods within the thread above that those less confident with a soldering iron may find easier, although you can’t entirely eliminate the soldering element.

Firstly, the sprung pogo pins require removing or cutting short. These pins are quite difficult to unsolder and it’s important that you do not damage any tracks in the process. I found that carefully cutting away sections of the plastic that support the pins (under the PCB), then removing them one-by-one was easiest and least risky. Pins 7 and 8 connect to the ground plane and require the most heat to remove them.

Remove pogo pins

Remove pogo pins (click to enlarge)

Next there is a resistor (R39) we need to remove from the underneath of the PCB, this disconnects Pin 12 of the GPIO connector (which we are going to wire to the I2S clock from P5) from Pin 5 of the WM8804 high performance S/PDIF transceiver (CSB) pin.

From Matthias “During reset pin 5 of the WM8804 is used as in input to select the I2C address – so you need to have it connected to the pullup (R30). Afterwards it’s an output so if you leave it connected to P1 header pin 12 it’d clash with the I2S clock.”

R39 is here (shown still fitted in this image): –

Remove R39

Remove R39 (click to enlarge)

Finally, we need to attach some wires to P5, which we then wire across to the Raspberry Pi3’s GPIO connector. One of the links can be made permanent on the Wolfson card, but the other three will need wiring to pins 35, 38 and 40 of the GPIO. If you don’t want the ability to easily disconnect the board, you could solder directly to the Raspberry Pi GPIO pins, but some jumper wires with suitable push on terminals might be better.

The connections required are described here, using the names on the Wolfson Card Schematics.

Connections required

Connections required (click to enlarge)

You can use any colour wire you want (electrons are colour blind), I’ve used what I had laying around and the wiring for the above connections is shown here: –

Wiring

Wiring (click to enlarge)

Be aware that there are some high-frequency signals on these wires, so ideally the wires need to be as short as practical and I would route them close to the board, near the GPIO connector to keep them away from sensitive audio circuitry. In my case I ran them under the PCB: –

Mod Bottom View

Mod Bottom View (click to enlarge)

Mod Top View

Mod Top View (click to enlarge)

I’ve attached this to a Raspbery Pi3, with the official 7″ touchscreen, which all looks rather tidy, you will see some Kapton tape I’ve added over the USB port connector bodies; the Wolfson card sits in contact with these so to ensure that nothing gets shorted out it seemed a sensible idea: –

Assembled to Raspberry Pi3 + Touch Display

Assembled to Raspberry Pi3 + Touch Display (click to enlarge)

Assembled to Raspberry Pi and Touch Display

Assembled to Raspberry Pi3 and Touch Display (click to enlarge)

To enable the driver, follow the instructions here on Matthias’s site.

I’ve copied them below just for backup / posterity: –

Configuration for kernel 4.9

Enable the driver

Add the following line to /boot/config.txt to enable the Cirrus Logic card driver

dtoverlay=rpi-cirrus-wm5102

Note: MMAP support is already enabled by default in kernel 4.9, you no longer need to add the i2s-mmap overlay.

Setup module dependencies

The cirrus driver requires some manually defined module dependencies, if you fail to add them the driver won’t load properly.

Create a file /etc/modprobe.d/cirrus.conf with the following content:

softdep arizona-spi pre: arizona-ldo1

Download and install “usecase” mixer scripts

Download cirrus-ng-scripts.tgz and extract it for example in /home/pi/bin.

wget http://www.horus.com/~hias/tmp/cirrus/cirrus-ng-scripts.tgz
mkdir bin
cd bin
tar zxf ../cirrus-ng-scripts.tgz

Note: If you had installed the older usecase scripts for kernel 4.4 you need to remove them.

You have to start the appropriate scripts before you can use the card. For example:

./Reset_paths.sh
./Playback_to_Lineout.sh
./Playback_to_SPDIF.sh
./Record_from_Linein.sh

All that remains is to do some mechanical modifications to the case to make it fit. The headphone socket will fit through the side of the case (once a suitable hole is drilled), but the Line In, Line Out and SPDIF In and Out will get in the way and protrude beyond the rear of the case

I’ll probably desolder them from the board and relocate them to elsewhere on the case.

Case Modifications Required

Case Modifications Required (click to enlarge)

A quick bit of bodging and it fits, I’ve just removed the SPDIF connectors as I don’t use them, the Line in and Line Out I’ve left as is, so they can be used. I just need to modify the back cover that fits on the unit now.

Case Modification

Case Modification (click to enlarge)

This entry was posted in Engineering, Linux, Music, Streaming. Bookmark the permalink.

1 Response to Connecting the Wolfson Sound Card to the Raspberry Pi3

  1. Hervé says:

    Problem…, i have all made like you said. In the order of your tutorial :

    ./Reset_paths.sh
    give me :
    amixer: Control hw0: open error: Invalid argument
    (many times the same line, repeated again and again)

    aplay -l give me :
    aplay: device list:277: control open (0): invalid argument

    I was setup before with 4.4, and during my C++ test, all worked perfectly, playing with sine waves…. and without knowing why, sound stopped… and the aplay -l command has stop working…

    So i try

    wget http://www.horus.com/~hias/tmp/cirrus/cirrus-ng-linux-4.9.4.tgz
    mkdir bin
    cd bin
    sudo tar zxf ../cirrus-ng-linux-4.9.4.tgz -C /

    with :
    sudo nano /boot/config.txt
    dtdebug=1
    dmesg

    i learn :
    [ 3.913997] snd-rpi-cirrus soc:sound: ASoC: CODEC DAI wm5102-aif1 not registered
    [ 3.924215] snd-rpi-cirrus soc:sound: ASoC: CODEC DAI wm5102-aif1 not registered
    etc…

    But that didn’t help me, so… please help !! I spend all the day and the night on this, and i still can’t find why nor a solution …

Leave a Reply

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