RoadTest: Wolfson Audio Card for Use with Raspberry Pi
Author: packetgeek
Creation date:
Evaluation Type: Evaluation Boards
Did you receive all parts the manufacturer stated would be included in the package?: True
What other parts do you consider comparable to this product?: Turtle Beach USB sound card
What were the biggest problems encountered?: Compiling the drivers was a serious pain (12+ hours). Usable documentation (for compiling drivers) was almost entirely community-based and, as such, caused me to repeat other's mistakes. That said, once I had it running the first time, I was able to repeat the process and avoid those mistakes.
Detailed Review:
Road test selections were announced on 5 May. Thanks to UPS, the card was on my doorstep when I arrived home from work on 7 May, before I noticed that I'd been selected. I didn't have time to do anything the first day, other than to open the package and look at the card. Over the next couple weekends, I was able to get it up and running, though I did retrace my steps a number of times in getting the drivers compiled and working. My submission was actually a two-parter, the first of which is below. I'll submit the second (connecting to amateur radio receiver) in a week or so, once I've had a chance to experiment with the Wolfson card's inputs. (I plan on editing this file right up until the deadline.)
Before I go any further: Warning!! There is a second small almost-translucent screw in the envelope. There's a stand-off attached to the sound card which provides a physical support when the sound card is attached to the Raspberry Pi. The screw is meant to pass through the Raspberry Pi and enter the free end of the stand-off. In my package, it was loose and I didn't notice it until I was putting the card back into the static-resistent envelope. For us half-blind techies, it's something that can easily be misplaced.
Opinion of the Wolfson Audio Card
Overall, I have a split opinion of the device. It's a very nice end-user device, for applications like a simple media player or an interface to a larger audio system. It's also a poor device to have for anyone wanting to experiment/work with other Raspberry Pi peripherals (LCD displays, etc.) as the sound card hogs the GPIO header. In short, it's a very-nice-to-have for some projects, a limited choice for others.
Using the Raspberry Pi and Wolfson Audio Card as a Softsqueeze Client
My first project involves building a Squeezebox replacment using:using a Raspberry Pi and a Wolfson sound card. The following describes how to get the basic rig set up and then provides a few ideas for expanding/improving the system. Because drivers for the Wolfson card are not yet part of the Raspbian distro, you must either compile them yourself or take advantage of someone else's work (i.e., use their image). I've used both, to produce the same result.
Building the drivers can take 12+ hours (I ran the build overnight). If you're in a hurry, just impatient, or not comfortable with compiling kernels, I recommend taking advantage of Ragnar Jensen's work and installing the image he provides. His procedure (for compiling your own drivers) and his image (to avoid compiling) is available via:
Note: Even if you use Ragnar's image, you'll still want to do much of the below.
Note: Following assumes that you're using a Linux computer to load Raspbian onto the SD card. Windows users should search Google for the Windows-based procedure.
1) Download the latest version of Raspbian, onto a computer with a SD card reader/writer, and unzip it via:
unzip 2014-01-07-wheezy-raspbian.zip
The above should produce a file entitled:
2014-01-07-wheezy-raspbian.img
2) Copy the image onto the SD card by running the following as root:
dd of=/dev/sdc if=/home/tim/Desktop/storage/2014-01-07-wheezy-raspbian.img bs=1M
Note: in the above, sdc may not be the proper device name. It might be sdb or sdd. Running "fdisk -l" will give you an idea of which device is the proper target.
Note: in the above, I've used the full path to the .img file. This is a habit I've picked up from working with multiple versions of Unix and Linux in the same lab. Some versions of dd understand to look in the local directory, others don't. I use the full path to avoid the issue altogether.
In any case, the dd command will take a few minutes to complete.
3) While the SD card is still in the computer, run the following as root:
mkdir /mnt/disk
mount /dev/sdc2 /mnt/disk
cd /mnt/disk/etc/network
4) (As root) Using your favorite text editor, edit the "interfaces" file. Instead of looking like:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
the file should look like:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.2.223
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.1
dns-nameservers 192.168.2.246
dns-search joat
Note: You should edit the above values to suit your own network. I like setting a static IP address so I don't need to install a display or go searching for the Pi on a DHCP-assigned IP address. "joat" is a DNS top level domain that I use for internal machines.
Note: the above assumes that you'll be using the (corded) Ethernet interface, instead of the Wi-Fi interface. If you're going to use Wi-Fi interface instead, change "eth0" to "wlan0" in my example and then go edit /etc/wpa_supplicant/wpa_supplicant.conf.
5) Save the fille and close it. Run the following before removing the SD card from your machine.
umount /dev/sdc1
umount /dev/sdc2
eject /dev/sdc
6) Put the SD card in your Raspberry Pi and boot it.
7) Log into the Raspberry Pi from another computer by ssh'ing to it. Using the example config above, the command line should look something like:
ssh pi@192.168.2.223
When it asks for a password, enter "raspberry" (without the quotes).
8) Once you're logged in as the user "pi", switch to root by running:
sudo -s
9) Run "raspi-config" and expand the file system. Then exit raspi-config.
10) As root, run the following:
apt-get update
apt-get upgrade -y
shutdown -r now
Note: "apt-get upgrade" will take a few minutes. Also, rebooting is mandatory. Otherwise the filesystem resize doesn't take effect.
11) Log back into the Pi, sudo to root, and add a regular user by running
adduser tim
The above will ask you for a password. For everything else, just press enter.
12) Give the recently added user ability to access root by running viduso and changing the last few lines of the file so that they look like:
# pi ALL=(ALL) NOPASSWD: ALL
tim ALL=(ALL) NOPASSWD: ALL
Press Ctrl-x to save and exit the editor. Note: it may be safer to leave the "pi" line uncommented, until you're sure that you can log into the RPi (and jump to root) via the new account.
13) Log out and back into the RPi as the new user:
ssh tim@192.168.2.223
14) Jump to root via:
sudo -s
15) Install various dependencies for Squeezelite by running (as root):
apt-get install -y libflac-dev libfaad2 libmad0 mplayer
Note: mplayer is not required but is a nice-to-have for testing. However, the dependencies that go with it are numerous so if you're space-constrained, omit it from the above.
16) Download Andy Laing's drivers and the PDF entitled "Building the Wolfson Audio drivers into the kernel on the Raspberry Pi" from:
Perform the steps in Andy Laing's PDF, but omit step 6. Also, the second line in step 10 should read:
cp arch/arm/boot/Image /boot/kernel.img
Note: Andy was being polite when he said that compiling would take awhile. It took 12+ hours for mine to compile.
17) Reboot the Pi by running:
shutdown -r now
Log back in and jump to root when it comes back online.
18) If you're audio amplifier (or speakers) is plugged into the light green jack on the Wolfson audio card, you'll need to run the following before attempting to play any audio.
sh Playback_to_Lineout.sh
19) Once you've rebooted (in the step above), log in as root and download the most recent zipped version of SqueezeLite by running:
wget http://squeezelite.googlecode.com/files/squeezelite-armv6hf
Note: this downloads a binary, so there'll be no need to compile the code.
20) Move the file to /usr/bin/ and make it executable
mv squeezelite-armv6hf /usr/bin/squeezelite
chmod +x /usr/bin/squeezelite
21) See if squeezelite can find the audio card(s) by running:
squeezelite -l
22) Run "squeezelite" and point a web browser at your LMS. Click on "Choose Player" on the top right of the page. "Squeezelite" should be an option (if it isn't, wait a few minutes and try again). Select Squeezelite and then order up some music to play (LMS offers some pre-selected Internet radio stations).
Note: On my set up, squeezelite auto-detects the LSM (aka Slimserver). If yours doesn't connect to the Slimserver, run "squeezelight -h" to learn more about available command switches, so that you can point squeezelite at the Slimserver by using the command line switches.
That's about it. You should add squeezelite to your system start-up script so that you don't need to log onto the Pi.
Using the Wolfson Audio Card with FLDigi
I was unable to get FLDigi to work with the Wolfson Audio Card but believe it was not an issue with the card. I actually had a working version before I started writing notes. After setting up the player (above), I decided to attempt adding the LCD display, to show the title of the currently playing song. Some where in the middle of that, I seem to have caused some damage as neither FLDigi nor Squeezelite works now. This is one of the hazards of working with bare board, low voltage components: there's a tendency to handle the live boards, to change connections without shutting down or rebooting. My current problem is that I don't know if the damage is to the audio card, the RPI, both, or neither. The obvious step is to connect the board to another Raspberry Pi. My danger there is that doing so will require taking down the house DNS server, which will anger the-powers-that-be (or those that I live with). In short, FLDigi is available as a package in the normal Raspbian repositories. It takes a bit of fiddling to get it to recognize the proper sound card but it does work.
Note: if you don't have your own transceiver (or even just a receiver), I recommend the networked wideband receiver, at the following link, to search for signals that FLDigi will recognize: Wide-band WebSDR in JO32KF I used another computer to act as the receiver, running an audio patch cable from the larger computer to the Wolfson audio card. Warning! Time will pass very quickly while you're playing with these.
Overall, the card is well worth the asking price, as it adds capabilities (inputs/outputs) that are not on the stock RPi. The one drawback (having to compile drivers) will hopefully cease to exist shortly, once the drivers are incorporated into one of the usual RPi distros.
Other things try
- I had an idea to periodically poll http://slimserverIP:9000/playlist.html, parse it, and push the song info to a LCD display. Even went so far as to write a basic polling script (which is attached). I made multiple attempts at installing the LCD display before I found the "fine print" in the product documentation that the card is incompatible with expanders like the PiRack (which is what I was using to run the card and the LCD display). If you're willing to solder on the sound card, you can probably add the I2C interface for the LCD and get around the "no expanders" limitation.
- There's a program called squeezy that allows you to control LMS from the command line. I use it in a cron job to tune LMS to the local morning radio show, bump up the volume a bit, and turn on the lights in the bedroom (i.e., it's my alarm clock replacement). The code can be acquired via: https://code.google.com/p/squeezy/
- Adding a USB IRToy to the rig, to provide remote control, could be interesting. (see USB Infrared Toy - DP)