Tuesday, April 30, 2013

As Easy As Pi

Raspberry Pi... it's easy, peasy, wheezy ...


The famous(?) $25 tag line is more like $110 plus shipping when you've got a reasonable collection of parts plus the RaspPi revB ($35).

That being said... wow... a polished hobbyist's experience ;o)

There are 100s of guides out there and easy to follow.  This is not a guide of any sort... just my experience with the RaspPi B and poking at it whenever I have spare time.

The Wheezy (Feb2013) install was easy (http://elinux.org/RPi_Easy_SD_Card_Setup)

Using SDHC Kingston Card Reader via USB2.0 takes ~20mins

~/Downloads$ sudo dd bs=4M if=./2013-02-09-wheezy-raspbian.img of=/dev/sdd
462+1 records in
462+1 records out
1939865600 bytes (1.9 GB) copied, 1260.12 s, 1.5 MB/s

Note: about 300Mb remains of free space.  On the rasp-config utility, you can reclaim the rest of the SD Card for the root filesystem.  In my case, I used a 16Gb SDHC so 14Gb was added to the root filesystem.


The configuration menu on first-boot-up, easy, connecting USB devices (keyboards, wifi dongle etc) just easy.

In some part, made easier by Adafruit suggesting/recommending parts that are known to work with the popular RaspPi distros.

I don't plan initially to do anything ground breaking with this little computer.
The two main applications: XBMC client and multi-Wifi-webcam client.

I have found a range of Ubuntu-style configuration guides on Raspberry Pi webpages and will likely create a third application: Wifi Router with an ARM version of OpenWRT or similar.

Headless Mode


The first boot up configuration asks whether or not to start the desktop.

The following guide shows you how to remove the desktop, if you plan on a headless installation: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=25777

You can re-run the config after the first time boot and adjust these settings.  I find using any of the desktop applications painfully slow although it was nice to see a Wifi Configuration (wpa_gui) included in this latest Wheezy edition.

Wifi Client

http://pingbin.com/2012/12/setup-wifi-raspberry-pi/

Note: the Feb 2013 Wheezy has a Wifi Manager GUI which was pretty straightforward to select an available AP and connect.

Copying files from my media server yields ~230KB/s with rsync. Other systems in the house are typically 2-3MB/s with the same backup script.

Web Cam Support

Using two C920 Logitech webcams I've found only 1 works 90% of time with "motion" and there is a 5-10secs delay on the live webcam.  52-100% CPU when there is motion detected.  Adding a second webcam has issues.  The 'motion' application sees both but in the process of bringing both online it seems to time out and close the stream for both webcams after ~60secs.

The other problems are related to stability of the webcam itself.  Probably C920 has poor linux support and has been unstable on U12.04.  The net-effect is that it seems to crash and break the USB bus rendering all attached USB devices useless to some degree.  This is pretty odd and unpredictable.  It is necessary to unplug the C920 webcam to address this problem.  (I've also seen the USB bus die without any webcams plugged in but this is very rare.)

http://www.teslasassistant.com/?p=97

http://programmaticponderings.wordpress.com/2013/01/01/remote-motion-activated-web-based-video-surveillance-with-raspberry-pi/

Wifi Access Point

http://www.rpiblog.com/2012/12/turn-raspberry-pi-into-wireless-access.html

Attempting to turn my RaspPi into an AP I stumbled out the gate with what looks like a Wifi dongle that can't support AP mode.  With the cryptic "iw list" command yielding "nl80211 not found.".  This seems to be a problem with newer version of iw.

However, it is still possible to use hostapd to create an AP using these guides with various Linux networking guides to forward traffic:

http://www.jenssegers.be/blog/43/Realtek-RTL8188-based-access-point-on-Raspberry-Pi
and
http://ariandy1.wordpress.com/2013/04/07/setting-up-wifi-access-point-with-edimax-ew-7811un-on-raspberry-pi/


I chose the Edimax USB dongle as it has been cited as working as an AP as well as a client.  I could not get the iw list command to work but proceeded to install hostapd but the version that jensegers.be blogger included the Edimax driver in.

The AP worked well, once, then I could not get any device to connect to it reliably.  Also,  starting hostapd blew away wlan0 settings that wpa_supplicant configured.
I also found installing the custom Edimax hostapd version from jenssegers' guide broke MPD audio playback completely.

In the end, I've given up trying to have two wifi dongles present and one present as an AP.

XMBC

This page has a good list of debian based XBMC distros/releases for RaspPi.
http://elinux.org/RPi_XBMC

I've tried this version on top of Wheezy and the results are so-so:
http://michael.gorven.za.net/raspberrypi/xbmc

The XBMC GUI experience is sluggish.  Video playback did not happen until I installed the RaspBMC standalone without Wheezy being first installed.

Then I tried the ~800Mb XBian distro.  It looked ok with surrounding graphics/posters and icons a bit pixelated.   Video playback did work this time at 720p.

Network Music Player & Server

Using Music Player Daemon (MPD) on the RaspPi as a server and MPD clients on Android which is impressively efficient and effective.

http://www.audiohobby.com/raspberry-pi-for-audiophiles/

(I've followed this guide without the USB-DAC changes and using the RaspPi audio chipset)

However, keeping MPD working with PulseAudio is another matter.  In the end I used XBMC installation and simply used XBMC as a headless media player. Using the remarkably complete Yatze XBMC Media Player on Android you can stream to the client device.

Pops and Crackles

The next link shows how to remove the odd and annoying crackle/noise when switching tracks.  Using Studio-quality headphones, I can still hear a faint whine between track changing but it's way better than without the fix from ALSA to Pulseaudio.

http://dbader.org/blog/crackle-free-audio-on-the-raspberry-pi-with-mpd-and-pulseaudio

This worked for a short period, then stopped working and crack and pops came back.
There are plenty of posts stating pulseaudio is just not stable in Wheezy but the pops and crackle on audio is just unusable.

I searched (and searched) for various solutions but aside from newer in-testing firmware I couldn't find anything specific.  This site seems to give the best description of the problem and it's hardware related.  I ended up trying to find a configuration option between MPD and Pulseaudio in the end wound up with no sound coming out of MPD although test-sounds still worked from the command line.
Even the USB DAC systems reported that there were still playback issues unless the media was encoded at one of several sampling rates.  This is just a mess.

System Wide Pulse Audio


Ultimately, I found this guide set up MPD as a system daemon (in a headless pi configuration) and worked the most reliably for a day, then stopped for no reason.  You have to update /etc/pulseaudio/system.pa setting to not suspend on idle.

Guide: system-wide pulse configuration guide.


Audio Pops and Crackles fixed by Firmware

There appears to be a 'fix' for the USB sound issue... using an experimental firmware fix: http://www.raspyfi.com/raspberry-pi-usb-audio-fix/

This worked for me when I uninstalled pulseaudio completely.  However, pops and crackles can still be heard on boot up.  The easier route would be an external USB DAC.

Multiple Outputs

System-wide pulseaudio seems to keep the audio line powered and pop-free.  In addition, I have MPD using the 3.5mm jack and it's inbuilt HTTP streamer.

Power Cycling

Power cycling... so far the RaspPi as-is does not gracefully power-cycle.  Abruptly removing the power is problematic without shutting down is ill advised.  Using external RaspPi module, called http://www.pimodules.com/

Other

Seen "JBD2: Detected IO errors while flushing file data on mmc..." periodically.  Not sure if these coincided with the broken USB functionality when the webcams failed.