Sunday, July 7, 2013

Raspbian + MAME4ALL + XBMC

So as to not loose what I posted to Facebook, I'll recopy below for posterity...

OK - I'll bite...picked one up from Amazon, installed a 32GB SD with (Raspbian) Linux and MAME4ALL and was able to play Galaga (and Time Pilot '84, and...) as if it were the Windows port so "well done" to the Raspberry Pi folks. Had to tweak some of the UK/GB wheezy configs, but that's just normal Linux stuff. Amazing what can be done with a little $35 "computer" (albeit a tad "slow" compared to the typical multi-core/GHz monsters we have these days).

I took the total high road approach (install/tweak Linux, use the Pi Store app to download/install MAME4ALL and SFTP'd the ROMS from my Windoze PC via WinSFTP and "voila", insta-game machine, including sound). Ideally I would think you'd want to configure X11 to autostart the MAME app which wouldn't be that hard (throw it in the .xinitrc startup script?), but would need to test that out. This was literally an hours worth of tinkering . I haven't tried the NOOBS/multi-OS approach yet, but would think that would be the route you'd want to go rather than have multiple SD cards - just configure both OS images to do what you want and then pick one from the boot menu.

...hmm, since I started with Raspbian, I'll see if I can just add XBMC via http://www.raspbian.org/RaspbianXBMC (didn't go so well).

Building XBMC from scratch was a non-starter (would require installing too many dependencies, which I tried doing, but ran into a bunch of walls). Fortunately someone built it already for Raspbian, so I just followed the few steps on http://michael.gorven.za.net/raspberrypi/xbmc and XBMC is now working as well (though I haven't tried playing any DVDs or ripped media with it just yet, nor is there a "boot menu" to pick XBMC vs. MAME yet).

So steps thus far:
  1. install http://downloads.raspberrypi.org/images/raspbian/2013-05-25-wheezy-raspbian/2013-05-25-wheezy-raspbian.zip image via Win32DiskImager (from http://www.raspberrypi.org/downloads) 
  2. boot Raspbian and update locale and keyboard from UK/GB to US (rebooting as necessary) so all the keys on my cheapo Nynex keyboard would work (re: sudo raspi-config) 
  3. install MAME4ALL via the built-in Pi Store app (from the X11 GUI which I also enabled by default) 
  4. copy game ROMs to /usr/local/bin/indiecity/InstalledApps/mame4all_pi/Full/roms/ (per MAME4ALL docs) 
  5. play a few games (via keyboard); may be able to get joystick working at some point but I'll need a USB hub since both USBs are being used for keyboard/mouse at the moment 
  6. install pre-built XBMC binaries via instructions @ http://michael.gorven.za.net/raspberrypi/xbmc 
  7. boot XBMC and tinker around with that a bit; seems to work, but haven't tried any ripped DVDs yet 
  8. need to play with Raspbian boot menu configs a bit yet - the X11 login/boot screen now offers "Default Xsession" (LXDE), LXDE, Openbox (just shows a gray screen since it's probably not configured to start an Openbox session or something) and XBMC as options so all I technically need to do is login with pi/raspberry and pick whichever GUI I want. 
To make this a "consumer box" with just a "Media Center" and "Arcade" boot menu (sans any login) is still on the TODO (http://www.opentechguides.com/how-to/article/raspberry-pi/5/raspberry-pi-auto-start.html mentions some of this).

The raspi-config command/script is what runs the first time you boot Raspbian to set things up, but you can run it again whenever to tweak things (or just hand edit the Linux flat files manually, but that's the "hard way" ). There's also "dpkg-reconfigure keyboard-configuration", "dpkg-reconfigure locales" and "dpkg-reconfigure tzdata" that basically do the same thing (albeit individually). I'd recommend rebooting between changes, but that's just me being paranoid.  Tips on this also @ http://rohankapoor.com/2012/04/americanizing-the-raspberry-pi/.

Other cool H/W toys (GPS comes to mind, in addition to adding Arduino compatibility/connectivity) @ http://www.cooking-hacks.com/index.php/shop/raspberry-pi.html though there's probably others (I've just begun to scratch the surface).

Haven't tried SNES emulation yet, but found a good write-up on that @ http://supernintendopi.wordpress.com/.

Wednesday, July 3, 2013

Decisions, decisions...

Since I am using the vanputer as a mobile entertainment center, I am considering adding a MAME-like emulator to it to let the kids play their games on the go.

I started to research the idea of getting multiple OSes onto my 32GB SDHC card and booting a media center in an optimized setup or an emulation tool. I did alot of googling and it seemed like folks were not using the Rasberry Pi to do these particular things in the way that I wanted (RaspBMC + RetroPie). You either hosted a media center, or a game emulator, but rarely both. I assume that this is related to the performance of the Raspberry Pi.

I came across BerryBoot. It works as advertised, but just did not have the images I was interested in. I left a comment for the author, so maybe this would be something that is available in the future. If you want to boot multiple OSes, and they already have the stuff you want, it seems pretty ideal. If not, it's a whole other level of complexity.

Since I am not a Linux guy, it was quite intimidating to think about installing an OS that could do both by myself. SO... I decided to punt.

I purchased a 16GB SDHC card from Amazon and am going to install the RetroPie image there, following this tutorial. I will let you know where I get to. If the kids want to watch movies, we put in SD card 1, if they want to play games, we put in the second SD card.

The next thing I am hoping to figure out is a power solution that lets the Raspberry Pi shutdown gracefully when I turn off the van's ignition. Might be a tough one...

Thursday, June 20, 2013

Initial Setup

For this post, I am assuming that you have a device to read and write from the SD card. I happen to have an onboard multi card reader in my Windows7 desktop. If you do not, you might need to buy a USB peripheral, or ask someone for help to make it happen.

The steps to get the Raspberry Pi running are:

1. Format the SD card (at least 4GB)
2. Write an operating system image to the card (I chose RaspBMC)
3. Boot the Raspberry Pi to test the loading of the OS
4. Start to install other hardware and software to your liking
5. Enjoy...

1. Format the SD card
I am on windows 7, so I used SDFormatter to format my card. If you do not already have a card that you can use, you can check the list to see what you should get.

2. Write an OS to the card
There are many articles out there on the googlewebs that compare and contrast the different OS options available to be run on the Raspberry Pi. Openelec, Raspbian with XMBC, RaspBMC and others. I am setting up my little machine to run in a van to replace a DVD player, so I went with RaspBMC.

Note that there are instructions on the Raspberry Pi site that point you to a new setup installer. I did not go this way, mostly because I was having power issues at the time and thought they were related to the OS setup. They were not, but by the time I figured that out, I had already installed RaspBMC. Caveat Emptor.

To write to the card, you need to:
Download an OS image. Choose the network image.
Download a tool to format the card and go ahead and format it.
Download a tool to write to the card and write the image to it.

At this point, you should have your SD card set up for an inital boot of the Raspberry Pi into RaspBMC.

3. Boot the Raspberry Pi
It was at this point that I had lots of issues arise. I booted the machine by plugging it in - there is no "on" switch anywhere. I was using the original NOOBs installer, but had also plugged in a wifi chip and a wireless keyboard. On top of that, I had a power supply that powered the lights, but pooped out when the other items came online.

Make sure that when you boot for the first time, you are hardwired to your network. The OS will attempt to download updates via the network connection. Do not try to do this with your wifi card as it needs to be configured before it can work - and SSH'ing into the Raspberry Pi will not work if it is not on the network.

Note: If your Raspberry Pi boots RaspBMC correctly you should get a nice logo screen soon after the power comes on. If not, you might see a "rainbow" test pattern, followed by some scrolling text, then a loss of signal. Then you would see the same thing again and again, in a loop. This was my power issue. Swapping out the power cable solved that issue for me - though lots of people point to a bad write of the OS, reformatting the SD card etc. Try the power first. I used a normal USB cable connected to an iPhone wall wart. Worked like a charm.

4. Start to Install other hardware and software to your liking
Once I had a stable boot sequence, I started to plug in more of the peripherals. I have a USB EDIMax Wifi card, and a FAVI mini keyboard. Both take up a single USB slot on the Raspberry Pi. I started with the mini keyboard. This seemed to work right out of the box. Since I had my power sorted, I was able to plug in the USB, restart the machine and everything worked.

Wifi was somewhat trickier. With the wired connection still in place, I SSH'd into the Raspberry Pi and installed the driver for the card. I used the following commands:

$ sudo bash
$ apt-get update && apt-get install firmware-realtek

To get the software for the card down to the Raspberry Pi. The first command opens a new bash session with root priveleges (or maybe its just admin priveleges, remember I am not a linux guy). Once you are working in a session that has those credentials, you can do the install.

After I installed the driver, I used the RaspBMC UI to pull down the Network Manager add-on program. Once network manager was down, I shut down the machine, swapped the cable for the wifi nic and restarted. I had to use the onboard keyboard to set up the wifi profile, but everything worked well at that point and I was on the network.

Time to load the machine with videos for the van.

Monday, June 17, 2013

What to Buy?

After deciding to augment my van's onboard DVD player with some sort of solid state electronics, I went through a couple of iterations.

I knew that the RPi ran Linux and booted from an SD card. I also knew that it had 2 USB ports (plus an extra for power) as well as an HDMI port and a stereo headphone out. There are other, cool connections available to play with (GPIO jumps to mind) but I am not a hardware hacker at that level. With all that in mind, I started to think about my initial hardware purchase. I decided on a bare-ish bones setup, running directly from the SD boot card for media in the car. I happened to have a 32GB class 10 SD card lying around, so that was the beginning of the build.

I also knew that my 2006 Honda Odyssey EX-L had some aux ports in the way back, by the third row of seats. Specifically RCA inputs for video and left and right audio. It also had a 12V car power socket.

After consulting with some buddies, doing some research online - specifically about power issues and Raspberry Pi in general - I came up with the following list (on amazon.com):

Raspberry Pi Model B Revision 2.0 (512MB) - $42.90

PowerGen Dual USB 3.1A 15w High Output Car Charger - $9.99

FAVI Entertainment Wireless Keyboard (Built-in TouchPad/Laser Pointer) - $18.99

Edimax EW-7811Un 150 Mbps Wireless 11n Nano Size USB Adapter - $10.98

Multicomp Clear Raspberry Pi Enclosure (MC-RP001-CLR) - $10.99

C2G / Cables to Go 40645 3.5mm Stereo Male To 2X RCA Female Adapter - $1.97

I happen to have Amazon Prime, so I did not incur any shipping charges for all of this stuff. 2 days after I ordered it, the hardware showed up. More on the initial boot in the next post.

An Auspicious Beginning

This all started as a way to stop using physical media (DVDs), while travelling with my kids in our 2006 Honda Odyssey EX-L. The DVDs are always scratched and skipping, the kids are always whining about it and changing discs while driving (at night, in a thunderstorm) can be dangerous!

After one such trip, I came into work the next morning and was complaining about the harrowing journey and the DVDs. I said to my co-workers "...is there a hard drive that you can plug into your car to play movies from?" one of them replied "Raspberry Pi and RaspBMC..." that started the odyssey I am about to chronicle for you here.

This blog is somewhat after the fact, but I will try and write the steps down in the order that I took them and enumerate the approaches I took while trying to hack my way through the various hardware and Linux commands I came into contact with along the way.

Fair warning: I am not a Linux guy. There were many stumbles along the way and I read many forum postings with scathing remarks about how the "Linux people" did not know how to describe something for non Linux folks. That is the reason I am making this blog, to let you know how a schlub like me got something this cool up and running.