Jump to content

k-man's Blog

  • entries
    2
  • comments
    30
  • views
    1596

Beaglebone Black- the $45 MPD server


k-man

-or known as the ‘Summer Holiday’ project. Credit mainly goes to Richard Dale for the build instructions that I simply followed to get ‘bit-perfect’ audio playback with a USB DAC. We shared the view that embedded systems like this are adequate, even for high-end setups. Since I have no previous experience of programming or understanding Linux, I’ll admit it was a big learning curve, and without Richard’s support I would have been hopelessly lost on many occasions.

 

Recommended accessories:

 

5V/2A Power supply 5V 2A (2000mA) switching power supply - UL Listed ID: 276 - $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Acrylic case Adafruit Bone Box - Enclosure for Beagle Bone/Beagle Bone Black ID: 699 - $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Or a steel case- in stock from July 15th(tip: follow them on Google+ for a 30% discount) LGX BB100 Case for BeagleBone Black SoC

Micro SD USB adapter Micro SD TF Card Reader Adapter and USB 2 0 Adapter | eBay

2 4GB Micro SD cards

 

Installing Debian Wheezy onto the Micro SD card:

 

For anyone very new to Linux, it’s helpful to follow the Beagleboard website to familiarize yourself with the board, and follow the setup guide. Try creating the most up to date Angstrom image onto one of the SD cards (instructions from the same website). I’ve been accessing the Beaglebone via shell (SSH) using the Mac Terminal.

 

sudo su

(enter your Mac password)

 

ssh [email protected]

type y/yes to register the host key. If verification fails due to a different host key i.e booting off a different SD, just edit the file with the registered host keys with the ‘nano’ command and delete the lines.

Once you can successfully boot off that image, then you can start using the following shell commands:

wget http://rcn-ee.net/deb/rootfs/wheezy/debian-7.0.0-console-armhf-2013-06-14.tar.xz

tar xJf debian-7.0.0-console-armhf-2013-06-14.tar.xz

unpacks the image

cd debian-7.0.0-console-armhf-2013-06-14

Now insert the SD card you want to install Debian Wheezy on the USB adapter and plug it into the Beaglebone USB port. Now type:

sh ./setup_sdcard.sh --mmc /dev/sda –uboot bone_dtb

where sda is the intended card destination. Use this command if you are unsure (you still get another chance to verify):

./setup_sdcard.sh --probe-mmc

Once the flashing is complete, just swap the cards and hold the boot button (make sure you hear the click sound) and power the board up. Keep holding the boot button until all the blue LED lights light up solid, then release. Debian Wheezy is now ready. I access it by shell using:

ssh [email protected] 

where 192.168.X.XX is the network address of the Beaglebone. Password is temppwd

 

Installing MPD

 

I’ve shortened the commands to a minimum, and save the tweaks for later.

sudo apt-get install mpd

 

sudo apt-get install libfaad2 libfaad-dev libflac8 libflac-dev libogg0 libogg-dev \
libvorbis0a libvorbis-dev libid3tag0 libid3tag0-dev libmad0 libmad0-dev \
libcue-dev libcue1 libasound2 libasound-dev libasound2-dev \
libao-dev libwavpack-dev libwavpack1 libsamplerate0 \
libsamplerate-dev libmikmod2-dev libmikmod2 libmikmod-dev \
libshout-dev libavformat-dev libavcodec-dev libavutil-dev \
libcurl4-openssl-dev libmms-dev libmms0 \
libtwolame-dev libtwolame0 libmp3lame-dev

 

git clone git://git.musicpd.org/master/mpd.git

cd mpd

git checkout release-0.17.4

 

./autogen.sh --prefix=/usr --disable-bzip2 --disable-iso9660 --disable-zzip \
--enable-id3 --disable-sqlite --enable-ffmpeg --enable-alsa \
--disable-wave-encoder --enable-pipe-output --enable-httpd-output \
--disable-recorder-output --disable-sndfile --enable-oss \
--enable-shout --disable-pulse --disable-ao \
--disable-mad --disable-inotify --disable-ipv6 --enable-curl \
--disable-mms --disable-wavpack --disable-lame-encoder \
--disable-twolame-encoder --enable-vorbis --enable-lsr \
--with-zeroconf=auto

 

The –-prefix=/usr can be omitted (on Richard’s advice) in case MPD is overwritten if the Debian package is updated.

If all is well, then the following should appear:

########### MPD CONFIGURATION ############

Archive support:
 (-bzip2) (-ISO9660) (-ZIP) 
Client support:
 (-IPv6) (+TCP) (+UNIX Domain Sockets) 
File format support:
 (+AAC) (-C64 SID) (+FFMPEG) (+FLAC) (-FluidSynth) (-GME) (-libsndfile) 
 (-MikMod) (-MODPLUG) (-MAD) (-MPG123) (-MP4) (-Musepack) 
 (-OggTremor) (+OggVorbis) (-WAVE) (-WavPack) (-WildMidi) 
Other features:
 (+libsamplerate) (-inotify) (-SQLite) 
Metadata support:
 (+ID3) 
Playback support:
 (+ALSA) (-FFADO) (+FIFO) (-File Recorder) (+HTTP Daemon) (-JACK) 
 (-libao) (-Media MVP) (+OSS) (-OpenAL) (-OS X) (+Pipeline) 
 (-PulseAudio) (-ROAR) (+SHOUTcast) (-Solaris) (-WinMM) 
Streaming encoder support:
 (+FLAC) (-LAME) (+Ogg Vorbis) (-TwoLAME) (-WAVE) 
Streaming support:
 (-CDIO_PARANOIA) (+CURL) (-Despotify) (-Last.FM) (-Soundcloud) 
 (-MMS) (-SOUP) 

##########################################

 

Now type:

make

sudo make install

I’ve avoided installing mpc (client) to the build, because I favour using MPoD app on the iPhone (free), or MPaD on iPad (nominal cost).

 

Configuring MPD to recognize USB DAC

Type:

sudo nano /etc/mpd.conf

And edit a few entries; they should be fairly simple to locate:

group should be “audio”

bind_to_address should be “any”

Now locate # An example of an ALSA output and change starting with “the audio_output {“ to the following:

audio_output {
       type            "alsa"
       name            "USB"
       device          "hw:1,0"        # optional
#       format          "44100:16:2"    # optional
}

Commenting out the format line ensures bit perfect output.

 

Setting up NFS

 

On the NAS side:

I use a Synology Diskstation and found a thread on XBMC to be useful:

http://wiki.xbmc.org/index.php?title=Network_Filesystem_%28NFS%29 - NFS_sharing_from_commercial_NAS_systems_such_as_Synology_or_QNAP

It would be best to familiarize yourself with editing using vi – quite different to nano editing.

 

On the Beaglebone side:

To install NFS client software type:

sudo apt-get install nfs-common

then type:

sudo nano /etc/fstab

then add the line for the NFS to mount at startup:

192.168.X.XX:/volume/music /mnt/music nfs soft,intr,ro 0 0

where 192.168.X.XX is the NAS network address and volume/music is the path directory where your music is stored.

Exit and save, then to create the mount point:

sudo mkdir /mnt/music

we then need to create symbolic links (for the client to recognize music files out of the mpd library):

cd /var/lib/mpd/music

sudo ln –s /mnt/music music

Setting up MPoD

 

Remember to set the Wi-Fi mode to ON on the iPhone settings to the same network.

Press the Dartboard symbol on the top and ‘Add player manually’

Name is your choice. Server is your network address (if you don’t know, try ‘arm’ or ‘arm.local’ then press save. The Wi-Fi symbol should darken indicating successful connection.

Now click on the cog button and ‘Update database’ (it will take a while) and then ‘Refresh local cache’. Now you can browse by Artist, Album, or Song. I’ll leave out cover art option for now.

Enjoy! Next write up will be about the hardware and software tweaks.

10 Comments


Recommended Comments

Nice write up Kelvin! I hope this encourages a few people to try out the excellent and cheap BeagleBone.

 

"The –-prefix=/usr can be omitted (on Richard’s advice) in case MPD is overwritten if the Debian package is updated."

 

One minor addition to this. If you install the mpd binary in /usr/local/bin/mpd, you need to make a change to the mpd configuration so that it gets picked up from there:

 

/etc/init.d/mpd stop

echo DAEMON=/usr/local/bin/mpd >>/etc/default/mpd

/etc/init.d/mpd start

Link to comment

Hi Guys - I'm running Debian (Wheezy) directly from the eMMC on the board rather than an SD card. It's nice to reduce possible components and issues. However, all my audio going into a USB DAC is choppy. Sample rate doesn't matter. I have a nearly identical setup on a CuBox Pro without a single issue. Anyone experience this choppy audio on the bbb or have any ideas for me?

Link to comment

Hi Chris,

 

This is a list of various commands to reduce the background processes running:

 

[color=#111111][font=tahoma]sudo apt-get remove apache2[/font][/color]

[color=#111111][font=tahoma]sudo apt-get remove apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common[/font][/color]

 

[color=#111111][font=tahoma]sudo nano /etc/modprobe.d/alsa-base.conf[/font][/color]

Add a line at the end:

[color=#111111][font=tahoma]options snd-usb-audio nrpacks=1[/font][/color]

 

Removing getty processes:

 

sudo nano [color=#000000][font=Helvetica]/etc/inittab[[/font][/color]/CODE]

Comment out these lines with the hash key i.e.
[code][color=#000000][font=Helvetica]# 1:2345:respawn:/sbin/getty 38400 tty1[/font][/color]
[color=#000000][font=Helvetica]# 2:23:respawn:/sbin/getty 38400 tty2[/font][/color]
[color=#000000][font=Helvetica]# 3:23:respawn:/sbin/getty 38400 tty3[/font][/color]
[color=#000000][font=Helvetica]# 4:23:respawn:/sbin/getty 38400 tty4[/font][/color]
[color=#000000][font=Helvetica]# 5:23:respawn:/sbin/getty 38400 tty5[/font][/color]
[color=#000000][font=Helvetica]# 6:23:respawn:/sbin/getty 38400 tty6[/font][/color]

 

Changing the CPU frequency governor:

 

[color=#111111][font=tahoma]sudo nano /etc/default/cpufrequtils[/font][/color]

 

Add this line in:

[color=#111111][font=tahoma]GOVERNOR="performance"[/font][/color]

Note it's a blank page to begin with

 

If you are using NFS sharing try editing NFS settings:

 

sudo nano [color=#111111][font=tahoma]/etc/fstab[/font][/color]/

Amend the entry:

[color=#111111][font=tahoma]192.168.x.xx:/mnt/Music /mnt/Music nfs soft,intr,ro,[b]rsize=32768[/b] 0 0[/font][/color]

Link to comment

Did you get your Wheezy image from the same source?

 

Index of /deb/rootfs/wheezy

 

I still get the occasional pop when using my Debussy and I've narrowed it down to it being an ethernet issue. This is because I transferred some files to the MPD library i.e. /var/lib/mpd/music and I get flawless playback (playing a 24/192 file).

 

There are some LAN tuning guides on the web, but if they don't help, the root cause maybe the ethernet driver (credit to Miska for that response).

Link to comment

Thanks for posting that very informative link. I've had to refer to the site a few times to build fresh images ;-)

 

Another cool Robert Nelson script is the 'beaglebone black copy microSD to eMMC' script. This allow anyone who has finished the blog instructions to transfer it all to eMMC, rather than doing it twice:

 

wget https://raw.github.com/RobertCNelson/tools/master/scripts/beaglebone-black-copy-microSD-to-eMMC.sh

[left][color=#000000][font=Consolas]chmod +x beaglebone-black-copy-microSD-to-eMMC.sh[/font][/color][/left]

[left][color=#000000][font=Consolas]sudo ./beaglebone-black-copy-microSD-to-eMMC.sh[/font][/color][/left]

Unplug the power to the board, remove microSD card, and plug power to the board. It maybe necessary to re-edit /etc/fstab for NFS mounts.

 

I only recommend doing this if you are happy all the optimizations are finalized. I also highly recommend creating back up of built images before tweaks are applied, certainly for anyone doing this the first time:

 

Take the microSD card and place it in the microSD-USB adaptor and attach to a computer. Example using the Mac Terminal:

 

sudo su

diskutil list

This determines the disk number of the SD card. Now use the copy command:

dd if=/dev/disk[b]1 [/b]of=/Users/[b]XYZ[/b]/[b]Folder[/b]/Wheezy1.img bs=1m

Where 'XYZ' is the Mac Administrator Name and 'Folder' is your destination folder. If in doubt of the intended destination, just drag the destination folder to the shell window after "of=" Again it is important to select and type the correct disk number. The back up image will be the same size as the SD card capacity so I recommend compressing it with a utility.

 

To copy an image to a blank card (FAT formatted) reverse the 'dd' destinations i.e.

dd if=/Users/[b]XYZ[/b]/[b]Folder[/b]/Wheezy1.img of=/dev/disk[b]1 [/b]​bs=1m

 

Choosing the wrong disk number can possibly lead to a computer permanently corrupted so be very careful by running the 'diskutil list' command just to be extra sure. If the above command doesn't work, go to Disk Utility Application to 'Unmount' one of the SD cards partition (NOT Eject) and run the command again.

Link to comment



×
×
  • Create New...