Wednesday, June 8, 2011

Installing Debian on the Gumstix Overo using Multistrap

This post is going to include step by step instructions to install Debian on the Gumstix Overo. If you are a masochist and would rather have Ubuntu, then please visit Installing Ubuntu on the Gumstix Overo curtsy of Short and Sweet. It is however possible to install Ubuntu using multistrap, such as the method outlined here. It seems to be considerably easier than using the older debootsrtap methods.

This post exists because, as far as I can tell, a tutorial for Debian on gumstix using multistrap does not exist. With that being said,  this post is sloppy and to the point, and I am happy with that.

I am not going to bother telling you which packages to install, if you have read this far into the post you are capable of figuring this out on your own.

Pick a directory to work out of, inside that directory, create a file called emdebian.conf and make it look like this:

[General]

noauth=true
unpack=true
debootstrap=Grip Networking Debian Misc
aptsources=Debian


[Grip]
packages=ntpdate udev lrzsz netcat adduser sudo nano
source=http://www.emdebian.org/grip
keyring=emdebian-archive-keyring
components=main dev
suite=stable


[Misc]
packages=apache2 php5 gpsd gpsd-clients python locales wget lynx openssh-server
source=http://www.emdebian.org/grip
keyring=emdebian-archive-keyring
components=main dev
suite=stable


[Debian]
packages=
source=http://ftp.debian.org/debian
keyring=debian-archive-keyring
suite=stable


[Networking]
packages=netbase ifupdown iproute net-tools iputils-ping
source=http://www.emdebian.org/grip
keyring=emdebian-archive-keyring
suite=stable


The above file is fairly self explanatory,  if you would like to read more about it:


man multistrap


Make a destination directory for your new rootfs,

mkdir EmDebian

And now execute the multistrap command:

sudo multistrap -a armel -d EmDebian/ -f emdebian.conf

This will built in about 5 minutes depending on your internet connection and processing power. Once finished copy over the emulator so we can actually chroot into the system:

sudo cp /usr/bin/qemu-arm-static EmDebian/usr/bin/

Chroot into the system:

sudo chroot EmDebian/

And finalize the installation by executing dpkg,

dpkg --configure -a


While in this environment we should do some basic tasks to make the system functional. Lets add a user:


adduser mba


Add the user to the /etc/sudoers, such as:


mba        ALL=(ALL) ALL

We should probably add some networking functionality by adding the following to /etc/network/interfaces:

auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.0.20
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8


and then add the following to /etc/resolv.conf 



nameserver 8.8.8.8

Create /etc/fstab with the following:

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0

Add a hostname to  /etc/hostname. Then add that to /etc/hosts.

The final task inside the chroot environment is to enable the serial console. Edit /etc/inittab and add the following line in the appropriate place:

T0:2345:respawn:/sbin/getty -L 115200 ttyS2 vt102

Incidentally, if you are following this tutorial to install Ubuntu, head over to Short and Sweet with the link provided above to properly enable the serial console.

This finalizes the work that needs to be performed in the chroot environment. Exit out of the chroot:

exit

Now comes the time to tar up our rootfs for safe keeping, cd into the install directory i.e.

cd EmDebian/

and execute your favorite tar command

sudo tar -czf ../EmDebian.tar.gz *

While that compresses it is time to prepare the SD card. Be sure to unmount it if it mounted automatically, otherwise you might be sorry. There is a correct way to format this card, according to the gumstix wiki and the Short and Sweet blog but I do not care for the long and irritating process. If you would like to do it the correct way, head over there, otherwise we will do it the easy way, save about 10 minutes worth of suffering and only waste a fraction of space on the sdcard. Start off with executing cfdisk:

sudo cfdisk -z /dev/mmcblk0

Make two partitions on the SD card, a 64MB primary that is of type 0C and a second partion with the remainder of the space, type 83. The partition table should look like this:

                                          cfdisk (util-linux-ng 2.17.2)


                                             Disk Drive: /dev/mmcblk0
                                         Size: 3959422976 bytes, 3959 MB
                               Heads: 4   Sectors per Track: 16   Cylinders: 120832


     Name             Flags           Part Type       FS Type             [Label]       Size (MB)
 ---------------------------------------------------------------------------------------------------
     mmcblk0p1        Boot             Primary        W95 FAT32 (LBA)                       64.00
     mmcblk0p2                         Primary        Linux                               3895.43       

Format this first partition:

sudo mkfs.vfat -F 32 /dev/mmcblk0p1 -n FAT

And then the second:

sudo mkfs.ext3 /dev/mmcblk0p2

This concludes the sd card formatting procedure. Now comes the time to add our kernel and supporting images as well as our rootfs to the card.

Mount the two sd partitions to a location on your system, I use the following:

sudo mount /dev/mmcblk0p1 /mnt/SD1
sudo mount /dev/mmcblk0p2 /mnt/SD2

Our first task will be to copy the required binaries to the boot partition.  Search Google for these or check out Short and Sweet, I built my own images to include some kernel code that is not present in the images available from gumstix. Copy these files onto the sd card in the following order, rumor has it that this is important.

MLO

sudo cp MLO-overo /mnt/SD1/MLO
u-boot.bin

sudo cp u-boot-overo.bin /mnt/SD1/u-boot.bin
uImage

sudo cp uImage-overo.bin /mnt/SD1/uImage

If you built modules, copy those over to the sd card as well:

sudo cp modules-2.6.34-r90-overo.tgz /mnt/SD2/


And move the tar file over to the sd card:


sudo cp EmDebian.tar.gz /mnt/SD2 

Extract it onto the sd card:

cd /mnt/SD2
sudo tar zxf EmDebian.tar.gz


and now the modules:


sudo tar zxf modules-2.6.34-r90-overo.tgz

Do not extract into the root of your current system. That completes the install. Unmount the sd card and place it in the overo board. Launch minicom so we can watch the boot procedure and then login to our system.

minicom -o -D /dev/ttyUSB0 -b 115200

If I remember correctly there are some other options that need to be set to get minicom to work correctly,  something about turning flow control off... search google.

And there we have it, a successful boot:

Debian GNU/Linux 6.0 DataAqDebian1 ttyS2
DataAqDebian1 login:


A couple of tasks remain:


sudo dpkg --configure -a


And lets make sure it is on the network:


mba@EmDebian:~$ ping google.com
PING google.com (74.125.93.147) 56(84) bytes of data.
64 bytes from qw-in-f147.1e100.net (74.125.93.147): icmp_req=1 ttl=52 time=31.9 ms

And we are done here.