Saturday 7 July 2012

My Raspberry Pi and I - Part Two

A few weeks back, I wrote a quick introduction to the Raspberry Pi, a mini computer that has been created to be a cheap and easy way of getting into programming. Its target audience is schoolkids in an attempt to replicate the days of things like the BBC Micro and its contemporaries. But for now it appears to be available for purchase so that enthusiasts and the like can faff with it and see what it can do before kids get their grubby little hands on them later this year.

I first heard of the Raspberry Pi sometime last year when reading the news during lunch at work. At first, I thought it was one of those cheap laptops that were being produced and provided to third world countries as part of the $100 laptop or One Laptop per Child scheme. It was only through the coverage of the Raspberry Pi as it was getting ready for release that I realised that it was something entirely different. A fully working computer for only £25! I'm not really sure what made me want one. In one way, I thought I could use it as a dedicated retro gaming machine, and in another way, I thought I could use it to get into programming, or back into it seeing as I did a spot of very basic programming when I was younger on my Acorn Electron. Maybe it's because I'm into gizmos and gadgets and this gizmo gadget seemed quite interesting and unique.

The Raspberry Pi went on sale sometime towards the end of February. However, it didn't stay on sale for very long. The number of people pre-ordering devices crashed the websites of the two companies supplying them, and the ability to do so was stopped. Instead, you had to register an interest in the devices and wait to be invited to place your order. I registered an interest with both companies supplying the Raspberry Pi: Element 14 (or Premier Farnell, I'm not really sure what the company is actually called as its two names appear interchangeable), and RS Components. Shortly after registering my interest, I received an email from Element 14 with a link to place a pre-order. So I placed my order through them without actually knowing when I'd receive my gadget, although the forums at the time suggested it was likely to be August. Incidentally, I only received my invitation to order through RS Components about two weeks ago. More recent updates suggested that any orders placed before mid-April would be delivered before the end of June, including mine!

Before receiving my Raspberry Pi, I did a bit of reading up on how it works and what it does, but it all seemed a little confusing and bewildering so I thought I'd wait until I received mine to figure out what I needed to do to get it going. After months of waiting, it finally turned up. Although the Raspberry Pi itself comes in a little box, the actual packaging was a little bigger due to me receiving a free T-shirt with my purchase too. After putting my T-shirt on, I unpacked my Pi and, er, stared at it for a while trying to figure out what to do next with it. As I was off out to the pub that night, I didn't have much time to do anything with it, but decided to set myself a mission to locate a USB keyboard (turns out that the one plugged into my PC is PS2!), and a micro USB lead. Despite having a collection of old mobile phone chargers, none of these are micro USB. I ended up discovering that the cable for my Samsung digital camera was micro USB, and my charger for my (broken) Kindle would provide the 5 volts of power needed.  I already had a USB mouse, thought I had a SD memory card, and I could borrow the HDMI cable from my Virgin TV box or PlayStation 3.

The following day, I thought I was ready to go. But on locating my SD card, I discovered it only had 1 GB capacity. The Pi needs at least 2 GB, so I had to nip out to Tesco to buy a new card, plumping for a 4 GB card to provide me with more than enough space. Back at home, hopefully now with everything needed to get going, it was time to set it up. But I now needed to get an operating system onto the card. The Raspberry Pi currently runs Linux operating systems. I visited Element 14's Raspberry Pi section (http://www.element14.com/community/groups/raspberry-pi#downloadcenter), which provides links to three operating systems. The first two are Arch Linux ARM and Debian for ARM, with the third being Raspberry Pi Development VM v0.8. The latter had a warning about it being 8 GB in size, and sounded a bit techy, so I went for the first one. I downloaded the file, unzipped it, and then discovered that getting it onto the card would require another program - it's not just a simple case of moving it onto the card. Finding instructions on how to do so wasn't easy on Element 14's website, so a ventured over to Raspberry Pi's official site. The Quick Start guide there provided a list of all the physical equipment I needed (keyboard, mouse, power, SD card and so on), followed by a paragraph about downloading on OS, and then it started talking about "sudo" and DHCP leases and superusers, kernel sources, cross-compiling toolchains and suchlike. Quick Start my arse! Still, I followed the link to the OS downloads from the second paragraph, discovering that I should have downloaded the Debian one, the second one listed on Element 14's download page (why not first?). But, as I'd downloaded Arch Linux ARM, I thought I'd stick to it. I found that the program I needed that would allow me to transfer my OS to my SD card, now plugged into my PC, is something called Win32DiskImager. So, I visited the link for this, and found myself on a highly complicated looking page - https://launchpad.net/win32-image-writer The download link is somewhere to the right, one is a source.zip file and one is a binary.zip file. Which one to download??? Thinking logically, I tried the first link. Once downloaded and unzipped, I searched for an .exe file to run the program, but there wasn't one there. Nope, it was in the binary.zip download. Ah! I should know by now that the first link is usually the wrong one. Assisting me with all of this detective work to find files and folders and links and downloads and instructions and everything was the Raspberry Pi wiki at http://elinux.org/RaspberryPiBoard.

So, I now had the unzipped OS on my PC, and a program to move it to my SD card, and the SD card plugged into my PC. Getting the OS onto the card was actually quite easy using Win32DiskImager, and when it was completed, I excitedly plugged the card into my Raspberry Pi, unplugged the HDMI cable from the back of the Virgin TV box and into the Pi, and then connected the USB keyboard, mouse and finally the power. And then I switched it on. Lights began flashing on the Pi, but I got a message on the TV that it wasn't detecting an HDMI signal. I tried my PlayStation 3 HDMI cable instead, but nothing. After unplugging and plugging the cables back in over and over again, I still couldn't get my TV to pick up the Pi. Grrrrr! So, I decided to try it out on a portable TV upstairs (usually used for my Mega Drive and Master System) using a component cable. This still didn't do anything (I'll explain why later!) so I decided to try a different OS as, a little bit of forum searching mentioned something about something in a config.txt containing information about HDMI hotplug forcing, whatever any of that means. Feeling that if I can't even get my Pi to output a display using Arch Linux ARM without having to faff about in config.txt files, I've got no chance of knowing what I'm doing with it when I've finally got a display. Maybe Debian would be easier. So, I downloaded the Debian "Squeeze" OS, the one recommended for beginners, and thickos like me, and transferred it to my SD card. Again, I plugged the card into my Pi, the Pi into the portable TV, and the power into the Pi. Lights flashed in the correct sequence, but still nothing on the TV. I tried manual tuning and all kind of troubleshooting, but nothing. As I'd now been at it for about 3 hours, I'd resigned myself to giving up, but thought I would give it one last try on the main TV using the HDMI cable. So, I picked up my Pi and all its wires and cables, went back downstairs, plugged everything in again and, all of a sudden, the screen went blank, and then started filling with text and a little Raspberry logo. Finally! It works! I'd already read up on how to get into some kind of graphical interface, so typed in the preset username "pi" and password "raspberry" and then the command "startx" and, lo and behold, I was treated to a desktop. It was a desktop that continued to flicker though, but removing the Virgin HDMI cable and trying out the PS3 one fixed this. And that was it. My Raspberry Pi in action. The first thing I did was reset it, and start it up again, as there is something quite satisying about 'logging in' to a computer using a username and password and text commands. Something very 80s-esque.

However, as it was now very late, and I really couldn't face having to figure out what to do next for fear that I wouldn't be able to get my Pi to do what I wanted and I would end up spending even more time winding myself up, I logged off one last time and went to bed. I will follow up with more of my adventures with my Raspberry Pi some other time.

No comments:

Post a Comment