Adventures in WiFi

Using wicd-curses

I know of no better way than getting WiFi to connect automatically than using the wonderful wicd-curses package. So, here’s how to do it:

  1. Plug your wifi dongle in. I cannot impress on you enough how important this is 😉
  2. If you’ve not done it already, login as root and install wicd-curses:
    1. apt-get install wicd-curses
  3. Run it. Just type
    1. wicd-curses
  4. You’re given the wicd interface. You probably haven’t got anything showing yet, so do Shift-R to refresh the network scan.
  5. Use the arrow keys to highlight your router and press –>
  6. Go down and hit space when you reach the Automatic connection checkbox.
  7. Then, go down to the password field and put your wifi router password in.
  8. Hit F10 to save the settings and you’ll go back to the first screen.
  9. Highlight your router if it’s not already and hit shift-C to connect.
  10. Hopefully, this will connect you. If not, check your password!
  11. Do shift-Q to come out of wicd.
  12. Type ifconfig -a and you should see your wlan0 connected to your router and your ip address displayed.
The beauty of doing it like this rather than via the command line is that wicd runs as a daemon when your Pi starts up and will automatically connect to the network without you doing anything else.
NB: You may have to wait a minute or so for it to connect.

Operating Systems… So many, and yet so far

Oh, the trials and tribulations (or Tribbleations) of installing an operating system on the Pi. I tried about 5 operating systems before succeeding in my goals including Debian Wheezy, Fedora, Arch, Risc OS… They all failed in some way, mostly to do with a) WiFi and/or b) Bluetooth.

Eventually, I found an image that did work: Debian 6 19-04-12. And, yes, I do realise that this was the recommended one at the time… That’ll teach me to go cutting-edge! With this distro, I got everything working. Since then, the recommended distro has changed to the Raspian version of Debian Wheezy. Here’s the original RPi foundation post.

So, into the wonderful world of Raspian we go! Now, may aim here is to install everything without getting up from the sofa. i.e. No LAN connection

Here are the steps I took to get the Pi up-and-running. I might change tenses throughout, but hopefully I haven’t missed any steps! I’m on Windows 7, 64 bit, so any problems I have running apps on Windows may not affect you.

Installing the Operating System before the Pi starts up

  1. Download the Raspian image from the Raspberry Pi foundation.
  2. Get the SD card out of your Pi and put it into your laptop. 
  3. The following steps are only if you have a current SD card OS for the Pi:
    1. Download Winimage. This is far better than the Win32diskimager, in that it starts up more reliably each time. I do, however, think that it’s a bit of a rip-off at $30. You may find other packages that can backup and restore images, and most of them are fine.
    2. Backup your card with Winimage (or whatever you have).
  4. Carrying on, we’re going to install Raspian onto the card.
    1. Using Winimage/Win32DiskImager, restore the image you downloaded onto the SD card. !!! Make sure you are restoring to the card and not your hard drive 😉
    2. If your SD card is larger than 2GB, you’re going to want to expand the card so that the OS has more room to breathe.
      1. Insert a USB stick, preferably one that is 2GB or more.
      2. Download the gparted Linux ISO.
      3. Using either Winimage, Win32DiskImager, unetbootin or the LinuxLive USB Creator (my preferred method), install the ISO you downloaded to the USB stick.
      4. Reboot your laptop with the USB stick in and have the laptop boot from the USB stick. You can do this in a variety of ways, depending on your laptop. Sometimes, you have to go into the Bios to make this work.
      5. Once the gParted OS is up, just follow the instructions and steps until you get the desktop.
      6. At this point, a window will open showing the partitions on your SD card. You should have a FAT format bit at the beginning, then a Linux partition and then an unused part at the end.
      7. Right-click the Linux partition and choose to Move/Resize. Click and drag the extent of the partition size bar until you have used ALL the disk EXCEPT about 1-2 GB at the end. Click OK or Continue.
      8. Now right click on the smaller unused space and make a new partition. Just use ext2 for now. This will eventually be our swap space (I hope!).
      9. Make sure you apply the changes and wait for it to finish.
      10. Shutdown the gParted OS desktop. This should turn your laptop off.
      11. Remove the USB stick. Your SD card should stay in for now.
  5. Start up your laptop again to Windows.
  6. Download the Linux firmware for the USB WiFi dongle you are going to use.
    1. My dongle runs on the ZD1211 firmware so I downloaded it from Sourceforge.
    2. Unzip/untar the firmware into a folder on Windows.
    3. Copy the folder onto the SD card.
  7. Remove the SD card safely.

First Pi start-up

  1. Put the SD card carefully into the Pi.
  2. Insert your dongle (oo-er, Mrs) into the Pi, and plug in a keyboard and a monitor. You will not get anywhere unless you can see what the Pi is doing and can type stuff in!
  3. Put the power lead in, try not to get motion-sick from the Linux start-up scrawl.
  4. When the prompt comes up, use the ‘root’ username. There won’t be a password at the moment.
  5. This should give you the shell/command line prompt.
  6. Now, you need to mount the SD card, despite it actually being what you’re running off. This is because you want access to the FAT partition where the firmware is.
  7. First of all, you want the number one partition on the SD card. I can’t remember what that is at the moment, but it’s the one in /dev/ that begins with mmc and has a ‘1’ in it.
    1. ls /dev – get the name of the mmc device to put into the mmc*** space below.
    2. mkdir /mnt/sd
    3. mount /dev/mmc*** /mnt/sd
    4. mkdir /lib/firmware/zd1211
    5. cp /mnt/sd/zd1211/* /lib/firmware/zd1211/
  8. You should now have your firmware in the right place.
  9. At the prompt, type ‘reboot’. This will, surprisingly enough, reboot the Pi. Hopefully. If it fails to come back up, pull the power, wait a few seconds and re-insert.
  10. When the Pi comes back up, your firmware should have loaded and your dongle should now be active.
  11. Fortunately, the library necessary for connecting to my WPA-secured router is included in this distribution. If it wasn’t, I’d have to plug it into the LAN and do:
    1. apt-get install wpa-supplicant
  12. But it is, so I don’t have to.
  13. You now need to know the ID of your router (the SSID to be more exact) and the connection password.
  14. Now, you will need to edit the file /etc/wpa_supplicant.conf
    1. I use vi, you don’t have to. I’m going to assume you’re using ‘nano’ which is easier to use.
    2. nano /etc/wpa_supplicant.conf
    3. This will create a new file.
    4. Add the following to the file:
      ssid=”your router SSID”
      psk=”your router connection password”
    5. Save the file & exit.
  15. Type the following at the prompt:
    1. wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf -Dwext &
    2. (The & means it is a background process – if you don’t do this, you end up stuck in the command).
    3. Once it comes up with text that makes it sound like you’ve successfully connected, type:
    4. dhclient wlan0
    5. (This gets your IP address)
  16. Type ‘ifconfig -a’ at the prompt. The bottom one should be your wifi adapter and you should be able to see an ip address. If you don’t, well, you probably got the ssid/password wrong in the conf file.
  17. You should now be on the Internet.

Update the operating system and get a decent WiFi interface

  1. At the prompt, type:
  2. apt-get update
  3. This will update the package database so you can update your operating system.
  4. Once that’s done, do:
  5. apt-get upgrade
  6. This will upgrade any module that needs it. It will take some time.
  7. Once that’s done, do:
  8. apt-get install wicd-curses
  9. Say yes to it using up the space on the disk. Thanks to the steps with gparted you will have lots of space to play with.
  10. wicd-curses is an interface to wireless networking that you can use to see what other WiFi networks there are in the area and gives you a handy interface to enter passwords, automatically connect etc.
  11. Do another ‘reboot’ and when the Pi comes back up, login as root again and do:
  12. shutdown -h 0
  13. This will shut down your Pi. Wait until it says “System Halted” and then pull the power. (It may just switch off by itself, but once you see that message, it’s safe to pull the plug.

Next time…

We will add the wpa_supplicant commands to rc.local to automatically start-up when we boot. And we will look at getting the Bluetooth keyboard/mouse all working nicely!

The Pi Pod

Aims of the Project

  • To become familiar with the Pi and the Linux operating systems available.
  • To have a fairly self-contained unit with:
    • The Pi
    • A screen
    • A keyboard
    • A mouse
    • WiFi.
  • To not blow the thing up before I’ve had it for five minutes!

Components of the Project

The Raspberry Pi itself!
Purchased from RS Components
Waited 4 months for it to be produced and delivered.
Apart from that, I cannot recommend them at all – their after-sales service is email only and they will refuse to speak to you on the phone regarding anything to do with the Pi.
Cost: £35 (I think!)
An 8GB micro SD-card with adapter
This was a bit of a risk, but forced on me by needing more space than the 2GB SD card I had lying around. As it turns out, this was a good solution.
Again, I had it lying around so it was free.
You should be able to pick one up for under £20, possibly a lot lower.
I recommend starting out with something larger than 2GB as you will need to install packages and never know if you’ll need more room.
A Rii Bluetooth mini-keyboard with in built touchpad
Neat little device this. Even came with a tiny-tiny bluetooth dongle, stored inside the actual keyboard itself. Very neat.
Got mine from eBay seller ‘cigbargain’.
Delivery would have been fairly quick if Royal Mail hadn’t screwed it up first!
Cost: £19.
A “Really Useful Box”
think mine was a 1.75 litre box.
Purchased from Hobbycraft in person.
Cost: £4 (approx)
A 3.5″ car rear-view parking camera screen
Purchased from eBay seller easybuying168
This little piece of kit comes with all the cables except the actual power cable. It’s supposed to be used inside a car so the power cable you get is supposed to be wired in to one of the tail lights. However, it is merely a 12V power supply and they are fairly cheap to get. You may even have an old one lying about from other gadgets like speakers, that kind of thing.
One of the best things about this is: it’s the only I’ve found that is foldable – it flips down so the screen is protected.
Cost: £21.
A non-slip mat
This came with the screen, but is very handy when the Pi is slipping all over the bloody place.
A Belkin WiFi Dongle
I just had this lying about from the good-ol-days of needing a dongle for WiFi. You should be able to get one for under £10, for example, on eBay.
A craft knife
I knew I’d need one. I already had it. Let the hacking commence!
A pack of cable ties
Yes, I know. Very Heath-Robinson. Still, they do come in handy and you can pick them up in stores like the Poundstretcher chain.
I can also recommend the Rapstrap if you want something a bit easier/flexible to work with.
Cost: £2.99 for a big ol’ pack, various colours and lengths.
A micro-USB charger
That’s the connector that’s really flat and small. It’s what powers the Pi. Do not go cheap – the better adapter you have, the better and more stable the power supply will be. You’ve probably already got one, as I did, if you’ve been through a few phones. Samsung use them extensively.

Next time…

I install the operating system. Well… Systems. Repeatedly.

Raspberry Pi – booting from USB

So! RPi post 3!
NOTE: This was pretty much an abject failure and is only included here for completion purposes (i.e. it was on the wrong blog and I wanted it moved!)

Get the Pi booting from a USB flash drive.

For reasons of speed and to allow more to be installed on the operating system.

It’s impossible to boot from a USB flash drive directly. What you will be doing is to use the SD card as a ‘bios’ and then bootstrap it to jump to the flash drive.

Main reference
I decided not to try and do this all by myself. I tried the guide here:

but found that it didn’t give me enough information to do anything with.
I then found this guide from Andrew Ord in Somerset, UK:

It’s not completely accurate (or wasn’t when I ran through it on July 4/5 2012, so here’s an updated version.

My set-up

  • Raspberry Pi model B.
  • 2GB SD card (from MobyMemory, their own brand).
  • 16GB flash drive. (from
  • USB keyboard.
  • Ethernet cable.
  • A 3.5″ car rear view camera screen. (You can use any monitor/screen that will connect)
  • Laptop running Windows 7 and the Putty terminal.

A – Preparation
Install the Debian Wheezy Beta distribution. This was done on Windows. You may find that the image writer doesn’t work. There are alternatives, but the most import thing is to get this done. You can’t go any further unless you do.

  1. Download from the link above.
  2. Download the newest version of win32 diskimager from
  3. Using it, write the image you downloaded to your SD card.
  4. Put the card in pi.
B – Devices and Partitions and Swaps, Oh My!
Sort out partitions and swaps and mount points. NB This will wipe your USB card
  1. Boot up the Pi with your flash drive and other cables plugged in. All the steps from here on (up to the networking step) were done over a Putty terminal.
  2. Log in as root with password root. (You’re going to sudo loads of stuff anyway, so logging in as root seems sensible).
  3. ls /dev and look for a device called ‘sda’. This is the whole USB flash drive. You are now going to sort it out so you can actually use it.
  4. fdisk /dev/sda
  5. Do p <enter> to see the partition table.
  6. Delete any existing partitions by doing d <enter> and picking the partition if necessary.
  7. Create new partitions:
  8. Do n <enter> p <enter> 1 <enter>
  9. Hit <enter> so it takes the default ‘start’ position.
  10. Choose an appropriate size for the main boot partition by following the instructions on that line. I think it’s something like size=+12GB or something. It says it on screen.
  11. Once you’re back to the fdisk console, do n <enter> p <enter> 2 <enter>.
  12. Use the default ‘start’ and ‘end’ positions (so that it automatically takes up the whole disk).
  13. This gives you two partitions. Exit from fdisk.
  14. At the prompt, type mkfs.ext4 /dev/sda1 (formats the main partition)
  15. Then do mkswap /dev/sda2 (which formats the swap drive).

Using the most recent Debian SD card image, I’ve booted up with the external drive attached to the second USB port

1.Logged in to debian with the pi/raspberry account
2.sudo su (switch to su mode without the root password) /dev
(list all devices, depending on the type of drive)
Look for /dev/sda
Note your SD card will be listed as /dev/mmcblk0 (with partitions p1, p2, p3)
4.fdisk /dev/sda (obviously change this to match your HDD configuration)
5.p (print the partition table)
6.d <Enter> <number> (for each partition to delete them)
7.n <Enter> p <Enter> 1 <Enter> (Choose appropriate size for your main file area)
8.n <Enter> p <Enter> 2 <Enter> (make sure to have left yourself some swapspace)
9.You can set the boot flag if you want, but it isn’t needed since your booting from the SD card
10.mkfs.ext4 /dev/sda1 (format the first partition)
11.mkswap /dev/sda2 (format the swap space)

Now we need to prepare the installation onto this new drive ready to boot
1.mkdir /a (create a folder called a in the root, this is where we will build our new install)
2.mount /dev/sda1 /a (mount our new drive on /a)
3.apt-get update (update our package sources)
4.apt-get install debootstrap (install debootstrap)
5.debootstrap squeeze /a
(do a minimal build onto our folder)
I use apt-cacher-ng on another machine, use

Once the packages have downloaded and installed we should have an extremely minimal debian install in /a
Let’s move across into this new environment and start to build it up to be able to operate on it’s own

Download the kernel file from … _armel.deb
(Note : You may find that the version has been updated since I wrote this note, please go to to find the latest file name if needed)

1. wget … _armel.deb
Copy the downloaded files, linux-image-3.2.18-rpi1+_5_armel.deb and linux-raspberrypi-3.1.9-18-arm.pkg.tar to your new area (/a/root/installation was where I put the files)

1.chroot /a (Change root to our new folder)
2.passwd <Enter> (follow instructions to set the new passwd for root on your new install)
3.apt-get update
4.apt-get install aptitude openssh-server locales ntp
5.dpkg-reconfigure locales

This should provide us with a remotely accessible platform once we get the kernel installed

Let’s get the kernel and modules installed /root/installations
2.dpkg -i linux-image-3.2.18-rpi1+_5_armel.deb

The new kernel is now stored in /boot. In order to update your SD card to use this kernel you now need to do a little slight of hand

The file you need is in /boot called vmlinuz-3.2.18-rpi1+, and to use it we need to copy this file and rename it to kernel.img and store it on the SD card

When I applied the kernel update on my SD card, I did the following
1.mkdir /tempSD
2.mount /dev/mmcblk0p1 /tempSD /tempSD/kernel.img /tempSD/kernel.img.original
4.cp /boot/vmlinuz-3.2.18-rpi1+ /tempSD/kernel.img
5.nano /tempSD/cmdline.txt
6.(modify the boot command by changing root=/dev/mmcblk0p2 to root=/dev/sda1)
8.umount /tempSD
9.rmdir /tempSD

These changes now mean you have the up to date kernel on the SD card and you’ve modified the boot commands to use your USB HDD as the root file system

Now do a reboot (reboot <Enter>) and let’s see what happens

The first thing you should notice is that it boots up fairly quickly. Always a good sign I think

The second is that you should be able to logon as root, using the password you set earlier

Now we need to make a few modifications to the configuration in order to automatically get the internet connection up and running

1.Log on to the PI
2.nano /etc/network/interfaces
3.Add the following lines to the file if they are not already present
auto eth0
iface eth0 inet dhcp
4.Before we forget, we need to turn on our swap if it hasn’t already
5.nano /etc/fstab
add the following line
none    /dev/sda2    swap    sw    0    0
7.swapon /dev/sda2
8.To address a bug I keep finding with the network connection, edit the sysctl.conf file in /etc and include the line vm.min_free_kbytes=32768
9.Now you should be able to reboot and have networking available

XBMC time (incomplete text, still trying to make this bit work correctly)

Edit apt sources.list file to include a local mirror for debian-multimedia

When you try to do an apt-get update you will get an error due to the gpg key, use the following command and substitude the code returned in the error message in order to correct the problem
1. wget -q “” -O- | sudo apt-key add –

Now we can install xbmc using “apt-get install xbmc lxde”. File sizes are around 260Mb alone for XBMC, probably about the same for LXDE packages so be prepared to wait

1. dpkg-reconfigure x11-common
2. Choose Anybody

Raspberry Pi – Post 2

Herewith some quick notes on my slightly frustrating, but ultimately successful RPI experience!

Objective for this session
Get the Pi on the network, preferably with WiFi.

Did I manage it?
Sort of!

So, SD card loaded with the Debian Wheezy OS.

Started the Pi up, tried out the X desktop by typing startx.
Now to try to get it on the network… I want to use Wifi.

I plugged my old Belkin wifi dongle in. Didn’t really expect it to work first time.
It didn’t. I needed firmware for Debian – the boot up screen for Debian told me so.

Nuts. Error message for the dongle. No firmware driver… so, shutdown the Pi as there’ll be no way to get it on there short of plugging it in to the router with a wire.

So, I downloaded the relevant firmware from
Then copied it onto the SD card using Windows. I knew this would be a problem… getting at it on Linux.

I started up the Pi with the SD card back into it.

So… it’s on the SD card… which means it’s a FAT partition, so I can’t get onto it directly. So, mount the filesystem… Found this article:

Then, in an xterm.
fdisk -l
This lists all the disks including the SD card.

I forget what it comes up with, let’s just call it /dev/wibble.

Make the folder for the mounted drive:
mkdir /mnt/SD

Then mount it:
mount -t vfat /dev/wibble /mnt/SD

Then go into it with cd /mnt/SD.

Then copied the folder with the firmware in it to /lib/firmware/zd1211

What I could have done is use Linux’s ‘aptitude’ to install it:
I kind of wish I had done, but I wasn’t willing to fall back to cabled LAN yet!

Right, so that’s the drivers installed. Reboot. Piss about with iwconfig trying to set it up from the command line.

Realise that it’d be easier with a gui for managing the network. Bugger. Get fed up. Plug it into my router with a LAN cable and screen, mouse, keyboard.

Start to follow this guide for using the GNOME network manager.

Give up as not only did it not install, it also began to dawn on me that a 2GB SD card is just not going to cut it!

More adventures next time once I have a bigger card!

Raspberry PI – First experiments

I received my Raspberry Pi on 22nd June and now, on 24th June I finally have time to play around with it.
My first experiment will be simply to get a Linux distro up and running and displaying on my downstairs television (which is a Toshiba Regza).

1. Unboxing
Just a few pics of unboxing the RPi. This shows the box it came in and the contents – the Pi itself, the Safety information/Regulations sheet and the Quick Start guide. I’m sort-of following the quick start guide (I will explain in a minute). I apologise for the length of this page… the Blogger HTML editor isn’t helping!

As you can see from where my little finger is pointing, SD card slot is visible.

2. Downloading
I downloaded the 2012-06-18-wheezy-beta distro from here. This isn’t the one they recommend (which is the April Debian 6 release) but I felt adventurous… well, as adventurous as a geek gets! I also downloaded the Win32 Disk Imager from here.

3. SD Card time
I have this SD card from MobyMemory:

It’s a bit old and battered, but good enough for now.
This is what it looks like when inserted into the Pi. I’m not all that keen on the way it sticks out, but heigh-ho.

I ran the tool and chose my Wheezy image, then wrote it to the SD card. This took about 4-5 minutes.

4. Peripherals
There’s a list of recommended equipment on the quick start guide.
This is what I’m hooking up:
A keyboard

A USB mouse.
My Toshiba Regza TV via HDMI cable.
Eventually, I’ll add a network cable, or a wifi dongle, which I need to research.
I was very disappointed that it didn’t come with a mains cable. Not everyone will have a mains-to-micro-USB charger… I have a Samsung phone, though, so I do have one of these fortunately. If you ask me, there’s no excuse for not offering one of these at point-of-purchase.
Soapbox mode off!
So… let’s see what we get when we just put the SD card in and hook everything up…
See next post!