dalliard.net

Projects


RavensPi - A Raspberry Pi-based car radio system.

Approximately eighteen months ago, I did a little project to use a Raspberry Pi Model-A as an in-car audio system. I wanted something nicely low-tech and the Model-A did the job wonderfully, running as a no-maintenance headless unit. I learnt loads about Debian, whilst at the same time allowing me to listen to thousands of hours of John Peel broadcasts in my car. It works just like an old radio. There's no skipping or retuning - listen to it, or don't. It's gloriously simple

I put the system together so that it was as simple as possible and you can read about how I put it together here. I created a bare-bones Wheezy installation that doesn't get upset when the power is removed without shutting down (i.e. when you switch the car ignition off). The only time it needs a screen is when you change the audio, but if you use a large enough SD card (mine's 32GB), perhaps you won't need to do that very often. The current draw is low and mine is powered via a USB port in my lighter-socket. The audio is output from the headphone socket of the Pi into the aux socket of my car stereo. Failing that, if you don't have an aux socket, you can use one of those cassette adaptor thingies that are available everywhere. Audio starts playing in ~15s (although this varies, depending on what class of card you're using) and virtually all transactional files are written into RAM so when it's switched off you lose nothing. Many parts of the file system are read-only so as much of the image as possible is protected. MOC Is the audio player of choice and is currently configured to play just MP3s. That's not to say however that you can't add support for othere audio types (i.e. OGG/AC3/FLAC), but you'll need to use a Model-B with a network connection to get hold of the necessary codecs.

If you'd like to download the image file, click here (327MB download). Installation instructions are as follows:

  • Download the image file and expand the zip file so you've got a single file called "pi.img".
  • Write the image file to your SD card of choice. There's plenty of options available if you don't want to use the command-line. If you're a Mac user, I can recommend ApplePi-Baker.
  • Once written, fire up the PI whilst it's connected to a monitor and keyboard. The Pi will boot up as root (the GUI has been removed) and attempt to start up MOC, a command-line based MP3 player. However, at the moment you don't have any audio on it. To make full use of the SD card and allow adequate space for your audio, you'll need to expand the image to fill your SD card. I've left raspi-config on the SD card for you, so expanding the filesystem is simple - just take option one from the menu and reboot it. Shut down the Pi once you're done.
  • Once expanded, it's time to put audio on the card. Get yourself a copy of Virtualbox and a copy of Ubuntu. With the SD card in your computer and Ubuntu booted, copy the audio files from your media to the /root/Audio folder of the SD card. Whilst most of the SD card is read only, MOC tends to generate a database cache of the audio folder once the playlist is created, so whilst it's tempting to fill the card up until you're at 100%, it's better not to. Go to about 97% so that you've got sufficient space for MOC's cache.
  • Once the audio is copied, pop the card back in to your Pi. Let the Pi boot up and get to the command-line. Type "mocp ". This will bring up the player console. You can use the arrow keys, tab and enter to add the files to a playlist. There's only going to be one playlist so, if you move to the left-hand side to the screen, move down to the Audio folder and use to add the entire Audio folder to your playlist on the right-hand size. It may take a while to do this, as it'll be reading the tags in the MP3 files, as well as the titles/durations. Be patient.
  • Once it's added, you need to save the playlist. Use to save the playlist. When prompted for the filename, save it to /root/startup.m3u
  • Quit MOC and reboot - make sure you've got something plugged in to the headphone socket and you should hear music! (It may take some time to boot up on the first boot).

And that's it! Let the music play for a while. Once you've powered off and back on a few times, you should see that music restarts once the machine reboots. You have a bare-bones audio player!

Points Of Note

  • If key files for MOC get corrupted, then the startup script will know and rebuild as appropriate. If this happens, leave it running for about 1 -2 minutes. You'll see the activity light on the Pi flashing away and that's your sign that it's rescanning the tags and rebuilding things. When that happens, just leave it until the lights stop flashing and give it another minute. The audio will start playing eventually, or failing that will after a restart.
  • The faster the SD card you use, the better. A good class 10 or better card should be up and playing in about fifteen-seconds. It's configured to play tracks at random, forever!
  • As always, suggestions are gratefully received. If you think you know of any tricks that will shrink the core image down further, please don't hesitate to let me know. I'm just a Linux n00b, after all.
  • The image is provided as is. If disaster befalls you in some way, that's just too bad. I accept no liability for bad things happening to you as a consequence of using the image.
  • Have fun! If you make anything wonderful with it, do let me know!

edge