-
Notifications
You must be signed in to change notification settings - Fork 3
System setup @ petli
Actual stuff:
- RaspberryPi B with 5.25V 2A power supply
- Cambridge Audio DacMagic (0d8c:000c C-Media Electronics, Inc. Audio Adapter)
- SATA Bluray reader
- USB-SATA adapter with external power
- Wifi USB dongle with external antenna (148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter)
- A small wireless USB mouse (as remote control)
- USB-hub, 4 ports, no external power
Conceptual setup:
The DAC is connected to one of the two onboard USB ports of the RPi. The DVD and the wifi dongle are connected to the USB hub which is in turn connected to the other RPi USB port. (Always a good idea to reduce the signal path for the time-critical USB audio).
A proper CD/Bluray reader with a USB-SATA adapter is much better than typical USB DVD readers. The latter are fiddly, the slim drive wears the discs, and can take a long time to figure out how to start ripping.
- Volumio.org Raspbian dist (beta 1)
- Kernel 3.10.25 with USB audio buffer size fixes from 3.13-RCx: https://github.com/petli/linux/tree/rpi-3.10-usb-sound-backport
Kernel compilation documenation: http://elinux.org/RPi_Kernel_Compilation
The Volumio web interface want to administer the system, so for now I disable it all to avoid having it overwrite my own config.
Disable volumio account, change password on pi and root. Change /etc/sudoers to remove access for volumio account and require password for all accounts in sudo group.
Set up wifi, and disable eth0 to not waste boot time attempting to get a dhcp lease. /etc/network/interfaces:
auto lo
iface lo inet loopback
# auto eth0
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
wpa-ssid ABC
wpa-psk XYZ
Shutting down most services, including all the Volumio web UI ones:
sudo update-rc.d php5-fpm disable
sudo update-rc.d samba disable
sudo update-rc.d exim4 disable
sudo update-rc.d myruns disable
sudo update-rc.d nginx disable
sudo update-rc.d dbus disable
sudo update-rc.d triggerhappy disable
Re-enabling some services:
sudo apt-get install rsyslog
/etc/fstab (reduced ramdisk size):
/dev/mmcblk0p3 / ext4 noatime,nouser_xattr,errors=remount-ro 0 1
/dev/mmcblk0p1 /boot vfat utf8 0 0
Ramdisk /run/shm tmpfs defaults,size=128M,noexec,nodev,nosuid 0 0
turf.haga:/data/music/coddb /mnt/turf/coddb nfs noatime,rw,nodev,nosuid 0 0
turf.haga:/home /mnt/turf/home nfs noatime,rw,nodev,nosuid 0 0
/etc/crontab: change hourly jobs into daily jobs.
Very important: add dwc_otg.fiq_split_enable=0 to /boot/cmdline.txt to avoid pops and crackles in the sound.
Ensure that the DAC is always ALSA card 0. If running the stock kernel and not the backport, set nrpacks=1 to avoid logs being spammed with "delay: estimated X actual Y" messages. /etc/modprobe.d/usb-dac.conf:
options snd slots=snd-usb-audio
# options snd-usb-audio nrpacks=1
Force performance CPU scaling (but no overclocking yet), in /etc/rc.local:
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
After following the steps in INSTALL.md.
Start codplayer in /etc/rc.local (TODO: move into proper RC script):
mkdir -p /var/run/codplayer
chown pi.pi /var/run/codplayer
sudo -u pi codplayerd
sudo -u pi /usr/local/bin/trigger_rpi_cdrom_udev.sh >/var/run/codplayer/trigger.log 2>&1 &
sudo -u pi /usr/local/bin/codctl_widget /etc/webcontrolwidget.json >/var/run/codplayer/webcontrol.log 2>&1 &
/usr/local/bin/codmousectl /dev/input/by-id/usb-MLK_Trust_Mouse-event-mouse > /var/run/codplayer/mouse.log 2>&1 &
Update in progress, documented below
- Rasbian from http://www.raspberrypi.org/downloads/
- Kernel 3.12.28 with USB audio buffer size fixes backported from 3.13
TODO: upload pre-built kernel and modules.
The following steps sets up a plain Raspbian to run codplayer with a USB DAC, WIFI network and accessing the disc database over NFS.
This assumes that a standard Raspbian has already been installed and is running.
If the system no longer boots properly after one of the steps, you can always mount the SD card in a Linux box and try to fix the botched files.
Change /etc/network/interfaces:
auto lo
iface lo inet loopback
# auto eth0
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
wpa-ssid ABC
wpa-psk XYZ
Replace ABC and XYZ with the wifi network and password. eth0 is disabled to not waste boot time attempting to get a dhcp lease.
sudo apt-get update
sudo apt-get upgrade
This command will move it to 3.12.28+, matching the kernel above:
sudo rpi-update 973de697f8f72cb768b7609eae93bf1bdc27ce56
Reboot and make sure this kernel works.
Replace that freshly fetched kernel with the patched version above. This step can be done on a Linux box by mounting the SD card, instead of downloading it. If so, adjust the paths to the local media.
Replace /boot/kernel.img with the patched version. Keep a copy of the old one.
Unpack the patched modules:
cd /
tar xjvf linux-modules-3.12.28pl.tar.bz2
Reboot again and make sure this kernel works. You can tell that the patched kernel is running by running uname -a, and that the USB module is patched by running modinfo snd-usb-audio and checking that there is no nrpacks parameter listed.
Install and enable the necessary daemons:
sudo apt-get install nfs-common
sudo update-rc.d rpcbind enable
sudo update-rc.d nfs-common enable
Add the mountpoints to '/etc/fstab` (do not remove any existing lines, and change server names and paths to match your system):
turf.haga:/data/music/coddb /mnt/turf/coddb nfs noatime,rw,nodev,nosuid 0 0
turf.haga:/home /mnt/turf/home nfs noatime,rw,nodev,nosuid 0 0
To avoid hourly cron jobs messing with playback, change /etc/crontab to make them daily:
# m h dom mon dow user command
17 5 * * * root cd / && run-parts --report /etc/cron.hourly
25 5 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 5 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 5 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
These are no use:
sudo update-rc.d dbus disable
sudo update-rc.d triggerhappy disable
Ensure that the DAC is always ALSA card 0. Create the file /etc/modprobe.d/usb-dac.conf with this line:
options snd slots=snd-usb-audio
Create ~/.asoundrc to set the default card to the USB card:
pcm.0 { type hw; card 0; }
ctl.0 { type hw; card 0; }
pcm.!default pcm.0
ctl.!default ctl.0
Force performance CPU scaling by adding this line to /etc/rc.local (before any exit 0):
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Following the steps in INSTALL.md to install all dependencies and install codplayer in a virtualenv with pip.
Install the /etc/udev/rules.d/99-codplayer.rules script to trigger playback when a CD is inserted. This also requires that codctl is found in PATH, easiest with a symlink:
sudo ln -s ~/cod/bin/codctl /usr/local/bin/codctl
Start codplayer by adding these lines to /etc/rc.local (before any exit 0 line):
mkdir -p /var/run/codplayer
chown pi.pi /var/run/codplayer
sudo -u pi /home/pi/cod/bin/codplayerd
Since codplayer logs a lot and continuously updates state files, these are stored in ramdisk on /var/run to avoid wearing out the SD card with writes. Since it's a ramdisk, the dir must be setup on each boot.
Configure codplayer in ~/cod/local/etc/codplayer.conf. This configuration matches the setup above, and allows remote control over ZeroMQ:
# This is really -*-python-*-
from codplayer.state import FilePublisherFactory
from codplayer.command import FifoCommandFactory
# ZeroMQ-related config factories
from codplayer.zeromq import ZMQPublisherFactory, ZMQCommandFactory
zmq_command = ZMQCommandFactory('tcp://0.0.0.0:7923')
zmq_publisher = ZMQPublisherFactory(address = 'tcp://0.0.0.0:7924',
command_factory = zmq_command)
database = '/mnt/turf/coddb'
# Drop privs to this user and group if not None and started as root
user = None
group = None
# Various interface files
pid_file = '/var/run/codplayer/codplayer.pid'
log_file = '/var/run/codplayer/codplayer.log'
# List ways to send command to the player
commands = [
# Uncomment to disable sending commands over ZeroMQ
zmq_command,
# Accept commands over a plain FIFO
FifoCommandFactory('/var/run/codplayer/codplayer.fifo'),
]
# List of ways to publish (and get) player state
publishers = [
# Uncomment to disable ZeroMQ publishing of state
zmq_publisher,
# Publish state and current disc to JSON files
FilePublisherFactory(
state_path = '/var/run/codplayer/codplayer.state',
rip_state_path = '/var/run/codplayer/codplayer.ripstate',
disc_path = '/var/run/codplayer/codplayer.disc'),
]
cdrom_device = '/dev/sr0'
cdrom_read_speed = 16
# Path to the cdrdao binary - the options are added by codplayer
cdparanoia_command = '/usr/bin/cdparanoia'
cdrdao_command = '/usr/bin/cdrdao'
eject_command = '/usr/bin/eject'
# Audio device type, one of:
#
# file: test device saving audio to a file in current directory
#
# alsa: play sound using ALSA
#
audio_device_type = 'alsa'
# If True, allow starting player even if audio device can't be opened.
# If False, player will not start on device open errors.
start_without_device = True
# If True, log the performance of some key parts of the player
log_performance = False
#
# ALSA device configuration
#
alsa_card = 'default'
#
# File device configuration
#
# Simulated playback speed. 0 means no delay at all, 1 more-or-less
# realtime, > 1 faster than real playback.
file_play_speed = 10
Run ~/cod/bin/codplayerd -d to run codplayer without forking it as a background daemon. See if it logs any errors. This line is OK if the USB DAC isn't connected yet:
c_alsa_sink: error opening card: No such file or directory