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!)

Objective
Get the Pi booting from a USB flash drive.

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

Caveat
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:

http://andreword.co.uk/Applications/Raspberry_PI/Entries/2012/6/4_Preparing_the_destination_drive.html

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 Play.com)
  • 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  https://launchpad.net/win32-image-writer/+download
  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)
3.ls /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 http://192.168.1.11:3142/ftp.debian.org/debian/
(do a minimal build onto our folder)
I use apt-cacher-ng on another machine, use http://ftp.debian.org/debian/

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 http://www.bootc.net/raspberrypi/linux- … _armel.deb
(Note : You may find that the version has been updated since I wrote this note, please go to http://www.bootc.net/raspberrypi/ to find the latest file name if needed)

1. wget http://www.bootc.net/raspberrypi/linux- … _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
1.cd /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
3.mv /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)
7.CTRL+O,<Enter>,CTRL+X
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
6.exit
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 “http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x4874D3686E80C6B7” -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 http://wiki.debian.org/zd1211rw
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:
http://www.ehow.com/how_7165724_mount-sd-card-linux.html

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:
http://wiki.debian.org/zd1211rw
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.

http://wiki.debian.org/WiFi/HowToUse#wpa_supplicant

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.
http://wiki.debian.org/WiFi/HowToUse

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!