Raspberry Pi Starters Guide
The Raspberry Pi (RPi) has certainly captured the imagination of the computing world. The first batch sold out in around 3.14 seconds, and the subsequent batches are already earmarked for those who put their names on the list. However, what many buyers of the first RPis seem to have forgotten is that this is the first-generation development board. As Eben Upton has said over and over again, the goal of the first RPis is to get people busy creating and modifying, so that the coming generations of RPis are more suited for the average user. Still that hasn’t stopped people going all potty over the this miniature wonder.

Raspberry Pi Starters Guide
The Poor eBay Pi
What makes us shrug our shoulders in disbelief is the amount of RPis we see on the likes of eBay – going for ridiculous amounts in some cases. While most of the people selling a Pi on eBay are doing so because they can get a considerable mark-up on the original price they paid, there are some that managed to beat the initial rush and received their RPi within a few days of it going on sale. Then, they unwrapped the box, took the tiny device out of its anti-static bag, hooked up the relevant cables and sat looking at a blank screen. After fiddling with it for a day or two, they then got bored, as it didn’t look like it was going to help them achieve anything useful, and they got rid of it.
There have been far too many cases of people getting hold of RPis and not knowing what to do with them, or how to set them up, or how to just enjoy the basics. Thankfully, we think many of the Micro Mart readers who own one have already managed to get it up and running and are now hooking up their robot arms to RPi and getting it to attack the BigTrack as it trundles by. Good for you!
For the rest of the people out there, those who haven’t had theirs in the post yet or those who don’t want to get one because it seems too technical, we’ve put together this starter guide, which will help you get RPi up and running, with a few applications to play with, and a wealth of accessories to whet your appetite.
Getting Started
Gently unbox your brand new RPi. Now take it out of its anti-static bag and hold it aloft saying, in a loud voice, “I have the power!” Okay, you don’t have to do that bit, but it’s a wondrous little device, isn’t it?
Many of you will have no doubt purchased your RPi with an SD card that already contains the Debian Squeeze operating system. That being the case, you can skip this next bit, and hook up the RPi to a monitor/TV, keyboard, mouse, network and give it power via the micro-B USB port. Those of you that only have the RPi, you’re going to need at least a 2GB SD card (see the rather gigantic ‘Working SD Cards’ boxout for a list of compatible cards).
Install The OS Onto An SD Card
Now that you have all the relevant bits and pieces, go to raspberrypi.org/downloads, and scroll down until you see the Debian Squeeze section. We’re going to use Debian Squeeze for this write-up, purely because it’s one of the easiest operating systems to get used to, and if you’ve already used the likes of Ubuntu in the past, then you’ll have a working knowledge of what to expect.
The direct download location for the zip file containing the image is at Link , but the Raspberry Pi Foundation would prefer you to download the file via a torrent, because it cuts down on the amount of bandwidth it has to manage. Alternatively, when you click the link, you will be redirected to a page that contains plenty of mirrors, just in case you’re unable to work with torrents.
The zipped image file is roughly 450MB in size and, once unzipped, it can be transferred to the SD in a number of ways, depending on what operating system you insert the SD card into. The first thing to do, though, is unzip the downloaded file and place the two files into a location that you’re going to remember.
Transfer Via Windows
If the computer you’ve downloaded the image to runs Windows, then open up a browser and navigate to Link. This is the website for Image Writer, a tool that’s used for writing images to USB sticks and SD cards. To help you save time, you’ll need the binary version, which can be found at Link. Plug your SD card into the slot on your computer, then unzip the Image Writer tool and run the executable.
Now point the program to the location where you unzipped the debian6-19-04-2012.img and, if it’s not already selected, select the appropriate drive letter that corresponds to your SD card from the drop-down ‘Device’ menu. When you’re ready, click on the ‘Write’ button and wait for a few moments while the image is written to the SD card. Once it’s complete, eject the SD card and place it carefully into the RPi.
Transfer Via Linux
If the computer you’re using to transfer the image is Linux based, then unzip debian6-19-04-2012.img from the downloaded zipped file, and drop into the terminal.
In the terminal, type ‘df –h’ and see which of the listed filesystems is the SD card; it’s usually ‘/dev/something’ and it’s mounted on ‘/ media/something’. If you can’t find it, then remove the SD card, run the ‘df –h’ command, then reinsert the SD card and run the command again to see which of the filesystems has been added. In our example the device name is ‘/dev/mmcblk0’, and ‘p1’ refers to the partition that’s already on the card.
When you have your SD card device name, you’ll need to write the image to the card by using the ‘sudo dd’ command. In our example, the command would look like this:
sudo dd if=/home/david/Downloads/debian6-19-04-2012/debian6-19-04-2012.img of=/dev/mmcblk0 |
What this is doing is reading the IMG file from the location we unzipped it to, and writing it onto the SD card. All you need to do is replace the location (the ‘/home/david…’ part) with the location of where you unzipped the IMG file, and change the name of the device (the ‘/dev/mmcblk0’ part) with the name of the SD card in your computer. Don’t forget to enter your root password after hitting enter, by the way.
For a handy tip, if you’ve placed the unzipped IMG file in an awkward location, like we did, then all you need to do is type in the first few letters of the location and press Tab to auto-fill in the rest of the command, and do the same with the name of the device if necessary.
Unfortunately, you won’t get to see a progress bar or anything; there is a way to output what’s going on, but it’s not necessary. The time it takes to write the image depends on the type of card you’re using and the speed of your computer, but ten minutes isn’t an unreasonable amount of time.
When the transfer is complete, you’ll get a read-out of the amount of bytes written, and the time in seconds it took to complete. All you need to do now is type ‘sudo sync’. This will make sure the cache is flushed and that it’s safe to eject your SD card.
RPi First Boot
Now you have the image transferred to your SD card, all that’s left to do is to insert it into the RPi, hook up the monitor, keyboard and mouse, plug in the network cable and finally give it power via the mini-USB connection. Make sure you connect the power last, as it’s not recommended to insert or remove the SD card during power-up.
The RPi will now run through a first-time boot and you’ll notice a load of text scrolling up the screen. You’ll also notice that there are a number of red failure remarks. Don’t worry about them; this is just the RPi sorting itself out for the first time on that SD card.
After a minute or two, the RPi will reboot and you’ll eventually get to the login prompt, which is:
Login: pi Password: raspberry |
All being well, you should now be looking at a command prompt. To open up the GUI, simply type in ‘startx’ and hit Enter. Now enjoy.
Configuring The RPi
One of the problems most people have, and we are no exception, is that they only have one monitor/TV, one keyboard and mouse, and limited access to other network connections. Therefore, we thought it would be a good idea to show you how to access the RPi desktop remotely from any Windows, Linux or Mac machine.
As with most things Linux (for the OS on the RPi is Linux), there is more than one way to skin a cat. The method we’ve chosen to use is via VNC (Virtual Network Computing); it’s very easy to get up and running and will allow you to access the RPi desktop from another location without the need to attach it to a keyboard, mouse or monitor.
To do this, we have to make sure a few things are in place. First, we need the RPi to be able to log in automatically, and start the GUI without us needing to hook a keyboard up to it. Secondly, we need to make sure that the RPi is connected to our network and is always going to have the same internal IP address every time it boots up. And thirdly, we need to install a VNC viewing client onto our computer in order to access the RPi.
Auto-Login
To get the RPi to auto-login, open up a terminal window by clicking on the start button in the bottom left of the RPi desktop, then hovering the mouse over ‘Accessories’, and clicking on LXTerminal icon. When the terminal opens, type in the following:
sudo nano /etc/inittab |
This will open up the boot time system configuration script. What we want is to scroll down until you reach the line ‘1:2345:respawn:/sbin/getty 115200 tty1’. When you’ve found that line, put a hash (#) in front of it to disable the command, then go to the end of the line and hit Enter to add a new line underneath. Now add the following command:
1:2345:respawn:/bin/login –f pi tty1 / dev/tty1 2>&1 |
Don’t forget to add the spaces and the ‘pi’ bit is the login account, so if you eventually end up with other accounts on your RPi, just replace the ‘pi’ bit with the other accounts you want to use.
Double-check that the line you’ve entered is correct, then when you’re ready, press Ctrl+X to exit, followed by ‘Y’ to accept the changes and then press Enter a couple of times to get to the command prompt in the terminal.
Auto-Load The Desktop
You don’t need to reboot the RPi yet, but by all means go ahead and check if the added line will auto-login the RPi with the details you entered earlier. What we need to do now is auto-load the GUI desktop, so if you haven’t done so already, open up a terminal session and type in:
sudo nano /etc/profile |
This is the system-wide profile for the Bourne Shell, and all you need to do is scroll to the very bottom of the file and add ‘startx’. If everything looks okay, exit nano as before. Now when you reboot, the RPi will auto-login and launch the desktop GUI without any intervention from the user.
Static IP Address
If you’re running the RPi on your local network, then the chances are your router will dish out the same IP address for the RPi every time it boots up, but there’s also a chance that it might not. If you’re going to be connecting to the RPi remotely, then it makes sense to force the RPi to have the same IP address every time it’s powered up. That way, easy shortcuts can be placed on your desktop for access.
To set up a static IP address, drop into a terminal and type the following:
sudo nano /etc/network/interfaces |
This file controls the IP addressing for the RPi; all you need to do is scroll down slightly to the ‘iface eth0 line’ and remove DHCP and replace it with static. Now, on the line directly below, enter the IP address you want your RPi to have, along with the subnet mask and the gateway. Our example looked like this, but yours will be dependant on your home network setup:
address 192.168.1.93 netmask 255.255.255.0 gateway 192.168.1.254 |
After you’ve entered the details, exit nano, making sure that you’ve saved the changes you’ve made. You can now either reboot your RPI, or type into the terminal:
sudo /etc/init.d/networking stop sudo /etc/init.d/networking start |
This will restart the networking components with the new IP address in place.
Install VNC Server
To access the RPi remotely via VNC you’ll need to install and configure a VNC server onto the device. To do this, open up a terminal again, and type in the following:
sudo apt-get install tightvncserver |
The VNC server package should now download onto the RPi. Should any acceptance prompts pop up, just type ‘Y’ to agree and the package will continue to download and install.
Next, when the VNC server package has downloaded and installed, type in ‘vncserver’. This will launch the VNC server and ask you for a password. You can type in anything you want; just make it easy to remember. It will then ask you to type the password in again to verify it, and finally the configuration will ask you if you want to enter a view only password. In this case we don’t want that, so just type in ‘N’ then hit Enter to initiate the VNC server. If all went according to plan, your screen should look something like this:
pi@raspberrypi:~$ vncserver You will require a password to access your desktops Password: Warning: password truncated to the length of 8. Verify: Would you like to enter a view-only password (y/n)? n New ‘X’ desktop is raspberrypi:1 Creating default start-up script /home/pi/.vnc/ xstart-up Starting applications specified in /home/pi/.vnc/ xstart-up Log file is /home/pi/.vnc/raspberrypi:1.log |
What we need to do now is install a VNC viewer on our computer so we can access RPi desktop remotely. The best place for a good, basic VNC viewer is TightVNC, but there are plenty around. To get hold of TightVNC for Windows, browse to Link and follow the links for either the 32- or the 64-bit versions. For other operating systems, you should Google what’s best for the OS you’re using. A good viewer for Linux Mint, for example, is Remmina, which can be found in the Software Centre.
Once TightVNC is downloaded, or whichever VNC viewer you’re using, install it. You’ll only need the viewing features, unless you want to remote desktop from the RPi to a Windows machine, for example. Next, enter the IP address of the RPi into the Remote Host connection, followed by a colon and the number 1.
The colon and the number refer to the display number that the VNC server has set up for that user. In this case we launched the VNC server and it allocated the display number 1 for the RPi user ‘pi’. If you run it again, it will allocate the number 2 and so on. If you want, you can tell the VNC server to allocate a number of your choice by entering it at the command line. For instance, entering ‘vncserver :2’ will always launch the VNC server with display number 2, even if it’s the first time you’ve launched the command. In our example, the Remote Host connection looks like this:
192.168.1.93:1 |
When you’re ready, click on the ‘Connect’ button and enter the password you entered earlier when setting up the VNC server. Provided you’ve entered the correct information, you should now be looking at the RPi desktop via VNC on your computer, regardless of the operating system.
Auto-boot With Auto VNC
The next part of the project is to get the RPi to auto-boot, with the VNC server automatically running. There are a few ways we can accomplish this, but for this tutorial we’re going to stick with a method that’s a bit rough around the edges, and not altogether pretty, but it works effectively and it’s easy to sort out if something goes wrong. For practical reasons, though, here is the more elegant method.
Method 1
The other method is to create a start-up script in ‘/etc/init.d’, making it executable, then using the ‘update-rc.d’ command to allocate the script a runlevel service at boot. The problem with playing around with a runlevel service is that, although nine times out of ten it works perfectly, there can be the odd occasion where the service doesn’t work. When this happens, it has the nasty tendency of fouling up the boot process and you’re left with nothing but a blank screen and not much in the way of a bootable computer, plus the service you initially set up isn’t working either, so you can’t remote desktop or SSH into it to fix the error.
Speaking from experience, if you have the time to create a script, and make it a runlevel service, then by all means go for it. An example of a script called ‘vncserv’ will probably look something like this:
#! /bin/sh
export USER=”pi”
export PATH=”/usr/local/bin:/usr/bin:/bin:/usr/bin/
X11”
NAME=vncserv
start()
{
su - $USER -c”vncserver :1”
}
stop()
{
su - $USER -c”vncserver -clean -kill :1”
}
case “$1” in
start)
echo -n “Starting Xvnc: “
start
;;
stop)
echo -n “Stopping Xvnc “
stop
;;
restart)
echo -n “Restarting Xvnc “
stop
start
;;
****)
echo “Usage: /etc/init.d/$NAME
{start|stop|restart}”
exit 1
;;
esac
exit 0 |
You’ll then have to save this script as ‘vncserv’ in ‘/etc/init.d’ and make it executable by entering:
chmod 755 /etc/init.d/vncserv |
Then add it to the boot services list by entering:
sudo update-rc.d /etc/init.d/vncserv defaults |
However, as we said, this has at times led to problems.
Method 2
To make everyone’s life a little easier, the not so elegant method, and the one we’re going to use, is simply to drop into a terminal and enter the following:
sudo nano /etc/profile |
This is where we entered the ‘startx’ command earlier on, and it’s where we’re going to add the command to start the VNC server. All you need to do is scroll to the bottom of the file and put a line before the ‘startx’ command, then enter ‘vncserver :1’. Save the file as before, and power off the RPi.
Now all that’s left is to put the RPi in a place where it’s easily powered up, when the network is on, and where it has access to the network, of course. As many routers these days have a USB port built into them, we suggest that hooking the RPi up to the router’s USB for power and using a short network cable are a pretty good ideas, but that all depends on your own home setup.
You’ll notice if you boot the RPi up with a monitor attached that after entering the ‘vncserver :1’ command in the profile, the GUI desktop doesn’t start up. It creates an error regarding permissions and the owner being root. Don’t worry, you’ll be accessing the RPi remotely, so you won’t see this error; you’ll just see the RPi desktop. However, if you need to hook the RPi back up to a monitor and so on, then editing ‘/etc/profile’ again from the command prompt and removing the ‘vncserver’ entry will fix the issue after a reboot.
Cool Software
Now that we have the RPi up and running, how about getting some software installed so we can start to personalise it a little?
There are loads of software titles that have been ported over to the ARM processor family. What you install is up to you, but here are a few of our favourites and how to install them:
Gimp: Gimp 2.6 is available for ARM, and can be installed by dropping into a terminal and typing ‘sudo apt-get install gimp’. The packages total roughly 74MB, so make sure you have enough room on the RPi before installing.
Chromium: The Chromium browser is considerably better than the stock Midori. To get hold of it, from the terminal run ‘sudo apt-get install chromium-browser’. Again, the packages total about 37MB so make sure there’s enough free space on the RPi before committing to an installation.
3D Chess: While a relaxing game of chess may not be everyone’s cup of tea, we enjoy it, even if we do lose quite a lot. To install 3D Chess, type in ‘sudo apt-get 3dchess’.
ACM: ACM is a multi-player, air combat simulator, which runs quite well on a Raspberry Pi. To install it, type ‘sudo apt-get acm’.
Spectemu-X11: One of the first projects most people want to play with on a Raspberry Pi is emulating some classic retro machines, and what better machine to emulate than the good old ZX Spectrum. Getting it all up and running is fairly straightforward; all you need to do is download these three packages:
• Spectemu-common – Link
• Spectrum-roms – Link
• Spectemu-X11 – Link
When they’re downloaded, open a terminal to where you stored them and type in the following commands, pressing Enter after each:
sudo dpkg –i spectemu-common_0.94a-11_armel.deb sudo dpkg –i spectrum-roms_20081224-3_all.deb sudo dpkg –i spectemu-x11_0.94a-11_armel.deb |
When you’ve run the commands in order, type in ‘xspect’ to start the Spectrum emulator. If you have a TAP file handy, type in ‘xspect’ followed the name of the TAP file. When the Spectrum loads up, press ‘J’ followed by two speech marks (LOAD “”) and press F6 to start the TAP.
Accessories
Just as there are hundreds of things we can do with the RPi internally, there are equally hundreds of things we can do with the RPi externally. The list of accessories, add-ons, and bits and pieces we can add to RPi is growing by the day, and while we may not have enough space to list all of them, here are some of the very best accessories you can buy for your Pi.
Cottonpickers Raspberry Pi Battery Pack And Solar Charger
This is, without a shadow of a doubt, the best accessory you can currently buy for the RPi. It’s just incredible. With one of these you have the ability to power the RPi from the sun via the large 6V polycrystalline solar panel, which in full sunlight will provide over 300ma of current. On the reverse is a well engineered, biodegradable, PLA (Polylactic) plastic case that’s fashioned from a BFB 3000 3D printer that the RPi fits into easily, as well as a battery pack ready for four rechargable AA batteries, which act as a buffer for when the sun goes down.
Amazingly, this is a hand-made unit, lovingly crafted by a chap whose passion for tinkering with solar energy has given us humble RPi users a little taste of good old ingenuity. But as Cottonpickers himself states, “This is a hand made unit, not a professionally made device!” Still, we think it’s excellent, and well worth the asking price of only £19.99 including postage for the UK, £22.99 including postage for the EU, and £24.99 including postage for the rest of the world.
To get your hands on a free energy solution for the RPi, head on over to www.cottonpickersplace.com, and follow the links for the Raspberry Pi related topics. There you can find order details, plus you have the opportunity to ask the inventor any questions and leave comments or suggestions.
RPi Starter Kit
If you’re going to get serious with tinkering with the electronics side of the Raspberry Pi, then consider having a look at this starter kit from SK Pang Electronics. It comes with a RPi and breadboard cover; an 840 contact breadboard; jumper wires; red, yellow and green LEDs; a couple of mini push buttons; 12 270R resistors; two 10k resistors; and an MCP23017 16-bit IO expander. In fact, it’s everything you’ll need to get working on that electronics project.
The starter kit costs £28.80 inc VAT and can be bought from Link, along with many other accessories, cables and covers for the RPi.
GearZap
GearZap.com does a pretty fine spread of RPi accessories,
with everything from retractable Ethernet cables, HDMI cables
and USB power supplies to mini speaker kits and a portable
vibration speaker.
The goods are reasonably priced; it just depends on what exactly you want. Head to Link to check out its latest stock.
Farnell
Then, of course, there’s Farnell, which stocks every conceivable connection, cable and component that can be plugged into the RPi. There’s loads, so you’re better off just popping along to the Farnell site and doing a search for ‘Raspberry Pi’ and seeing what comes up.
RS Components
Finally, we have RS Components which, like Farnell, stocks tons of accessories, cables and other cool stuff that you never even realised you needed for the RPi. Pay it a visit online, and do the same search as with Farnell.
Micro Mart – 05 July 2012
