SqueezePi (Part 2 – RaspberryPi)

RaspberryPi

This is the second part of the four part SqueezePi series.  Here I will be guiding you through the configuration of the project’s heart, the RaspberryPi.

Once ArchLinux is installed, on the Pi’s SD card, as the operating system, all configurations will be done over SSH.  The goal will be to have the RaspberryPi on power up, boot quickly, connect to the WiFi network, and start SqueezeLite with USB audio output enabled.

The instructions in this post could easily be adapted for other projects where you are trying to setup a headless wireless device.  Just nix the audio and SqueezeLite sections and substitute your desired application to autostart.

Shopping List

  1. RaspberryPi Model B
  2. SD card Class 10, greater than 2GB (I used this one)
  3. Edimax Wireless Nano USB Adapter EW-7811UN
  4. Syba SD-CM-UAUD USB Stereo Audio Adapter (Optional but sounds much better than onboard)

Install ArchLinux

  1. Download the latest copy of ArchLinux: Download
  2. Download Win32 Disk Imager: Download
  3. Write ArchLinux to SD card with Win32-Image-Writer

Temporary Setup

  1. Plug in SD card and Ethernet cable
  2. To turn on RaspberryPi, plug in microUSB cable

Configure RaspberryPi

Initial Setup

The following configuration are done from a laptop via SSH

$ ssh root@alarmpi

Default password is “root” Change the default password

$ passwd "new password"

Change the timezone to your local area (I slected New York)

$ nano /etc/timezone

Change to: America/New_York

Change your hostname from alarmpi (I chose squeezepi)

$ nano /etc/hostname

Change to: squeezepi

$ nano /etc/hosts

Change last line to: 127.0.0.1 localhost.localdomain squeezepi Generate a pacman key (this takes a while!)

$ pacman-key --init

Run a system update (this takes a while!)

$ pacman -Syu

Reboot Now

$ reboot

Setup Sudo

$ pacman -S sudo
$ EDITOR=nano visudo

Locate the section marked as: ## ## User privilege specification ## Uncomment the line below to say: %wheel ALL=(ALL) ALL %sudo ALL=(ALL) ALL Save and Exit

Create Standard User

$ pacman -S adduser
$ adduser

Enter username, I chose squeezepi For groups enter

users

then:

audio lp optical storage video wheel games power scanner sudo

Enter password for the new user squeezepi

$ logout

Login with newly created account

$ ssh squeezepi@squeezepi
$ sudo usermod -a -G wheel squeezepi

WiFi Driver/Setup

The setup below is for the Edimax EW-7811UN under ArchLinux. Plug the WiFi adapter into one of the free USB ports.

$ pacman -S wireless_tools wpa_supplicant wpa_actiond dialog netcfg
$ pacman -S base-devel unzip
$ cd downloads
$ wget https://dl.dropbox.com/u/4563987/RTL8192xC_USB_linux_v3.4.4_4749.20121105.zip
$ unzip RTL8192xC_USB_linux_v3.4.4_4749.20121105.zip
$ cd RTL8188C_8192C_USB_linux_v3.4.4_4749.20121105/driver/
$ tar -xvzf rtl8188C_8192C_usb_linux_v3.4.4_4749.20121105.tar.gz
$ cd rtl8188C_8192C_usb_linux_v3.4.4_4749.20121105/

Symbolic link to kernel source (note directory changes with linux kernel updates).

$ ln -s /usr/src/linux-3.6.11-6-ARCH+/
$ nano Makefile

Search for ‘($(CONFIG_PLATFORM_I386_PC)’: Change ‘ARCH ?= $(SUBARCH)’ to ‘ARCH ?= arm’ Save and exit

$ make
$ make install
$ modprobe 8192cu
$ reboot
$ ssh squeezepi@squeezepi
$ ip link set wlan0 up
$ wifi-menu

Configure desired wifi

Autostart Wifi and Connect on Power Up

The setup below is for the Edimax EW-7811UN under ArchLinux.

$ nano /etc/conf.d/netcfg

Add the following:

AUTO_PROFILES=("wlan0-Nacho_WiFi_EXT")

$ systemctl enable net-auto-wireless
$ systemctl disable net-auto-wired

You can now disconnect the ethernet cable. When you restart, the RaspberryPi will autoconnect to the configured WiFi network.

Install Squeezelite

https://code.google.com/p/squeezelite/

$ ssh squeezepi@squeezepi
$ wget https://squeezelite.googlecode.com/files/squeezelite-armv6hf
$ sudo chmod +x squeezelite-armv6hf
$ sudo pacman -S alsa-utils
$ sudo usermod -a -G audio squeezepi
$ ./squeezelite-armv6hf
$ sudo mv squeezelite-armv6hf /usr/bin
$ cd /usr/bin
$ sudo chmod u+x squeezelite-armv6hf

Setup Audio Output

Audio Option 1: 3.5mm

$ sudo pacman -S alsa-firmware alsa-lib alsa-plugins alsa-utils
$ sudo modprobe snd-bcm2835

Unmute and adjust volume with alsamixer (mine is already unmuted at this point):

$ sudo alsamixer
$ speaker-test -c 2
$ amixer cset numid=3 1
$ sudo alsactl store

Audio Option 2: USB

This will sound much better and is what I used. A cmedia usb sound card should just work without any additional drivers. I used the Syba SD-CM-UAUD USB Stereo Audio Adapter. Plug in the USB Stereo adapter to the remaining USB port.

$ cd /usr/bin
$ sudo alsamixer

Change alsa to USB sound card.

$ sudo alsactl store

Determine output device:

$ aplay -l

Test Squeezelite with USB Audio, update “front:CARDevice,DEV=0” based on your output deivce:

$ ./squeezelite-armv6hf -o "front:CARDevice,DEV=0" -n squeezePi

Autostart Squeezelite with USB Audio Output

$ cd /lib/systemd/system/
$ nano squeezelite.service

Add the following

[Unit]
Description=Squeeze Player Service
[Service]
ExecStart=/usr/bin/squeezelite-armv6hf -o "front:CARDevice,DEV=0" -n "squeezePi"
[Install]
WantedBy=multi-user.target

Save and exit.

$ systemctl daemon-reload
$ systemctl enable squeezelite.service
$ systemctl start squeezelite.service

Now that everything is configured, I would highly recommend making a backup of your SD card.  You can do that fairly quickly by using the Win32 Disk Imager that you used to write ArchLinux to the SD card.  You just need to specify where you want to save the image and click Read instead of Write.

OK, so now that you have you RaspberryPi configured and backed up, you can put it to the side until we are ready to install it during the fourth installment of the SqueezePi Series.

SqueezePi Series

  1. Introduction to SqueezePi
  2. RaspberryPi Configuration (this post)
  3. Electronics Setup (coming soon)
  4. Speaker Construction (coming soon)

Comments are closed.