Tuesday, October 18, 2011

Tutorial on getting a working IGEP/linaro distribution on the IGEPv2

Hi all!

Over the last couple of months I have been playing around with an IGEPv2. I was starting off with a very limited knowledge of linux and no idea when it came to embedded development. The IGEP wiki was useful, but what with me not having a clue when it came to x-loaders/uboot/kernels, I struggled to get a working microSD card. In order to help out other people in a similar position, I have combined a few different sources from the IGEP wiki into one contiguous file. You can use it from any new ubunutu distribution (or at least all those I have tried), and there is no need to use the 8.04 version supplied by IGEP.

I am not sure exactly what the protocol is when copying bits of a wiki, if there are any copyright issues, please let me know ASAP.

NOTE: Much of what follows is NOT MY WORK. I have copied bits and pieces from various places in the IGEP wiki. It is based on this page.

Preparing the microSD card

Find out which /dev/ directory your micro SD card is connected to:

Open a terminal window and clear your dmesg using:

sudo dmesg -c

Now insert a new microsd card in your PC and then check your dmesg:

dmesg

You should see something like this:

mmc0: new high speed SDHC card at address 0001

mmcblk0: mmc0:0001 00000 3.79 GiB

mmcblk0: unknown partition table

From now on, whenever you see 'mmcblk0' replace it with whatever your output above was . Mine was sdb, and I have replaced it in the following sections. Note that once we make them, partition 1 and partition 2 are

mmcblkp1 <=> sdb1 <=> sdc1

mmcblkp2 <=> sdb2 <=> sdc2

etc, where these appear.

Ensure all in your microsd card it's erased:

$ umount /dev/sdb1
$ umount /dev/sdb2
$ sudo dd if=/dev/zero of=/dev/sdb bs=1024 count=1024
[sudo] password for jdoe:
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 0.43556 s, 2.4 MB/s

Install GParted

We will use the gparted program for create the partitions, if you don't have this program installed then you must install it with this command:

sudo apt-get install gparted

Create the required Partitions

When the install procedure ends you can call the program from your system tools menu or directly using a terminal console using 'sudo gparted'.


Create the MSDOS Partition Table

The next step it's create the msdos table partition for it you should click in the "Device" menu and then in the "Create Partition Table" option.

Check the default option it's create a msdos partition table.

After that you can Apply.

Create the BOOT Partition

The Next step it's create the partitions for it you should go to the partition menu and select the "New" option then the application.

We will configure the partition as:

§ Primary Partition

§ Format: FAT32

§ Size: 100 MegaBytes

§ Label: Boot

§ Align to: cylinder


We must "add" the partition.

It is recommended to apply changes now or you might get an error later.


Create the ROOTFS Partition

The Next step it's create the root file system partition.

First you should select the unallocated partition area and then you should go to the partition menu and select the "New" option.

We will configure the rootfs partition as:

§ Primary Partition

§ Format: EXT4

§ Size: All the Rest

§ Label: Rootfs

At end we will click on "Add" button.


Apply all Changes

Click on apply button in the main menu after that gparted show a window to confirm all operations

We should click on apply button.

Now we can see all partitions and configurations done in the main gparted window

Select "Boot flag" for the boot partition

Now we must select the boot flag for the first partition for it we use the right mouse button over the boot partition and select "Manage Flags" option

Now we have the microsd prepared for copy the boot files

Select the boot partition and mount it in your host.


X-Loader (MLO)

We will build the x-loader (first thing which the processor calls) with Ubuntu Cross Compiler gcc 4.5.2. Install the cross compiler based on your Linux version:

Enviroment Ubuntu 10.10

sudo apt-get install cpp-4.5-arm-linux-gnueabi g++-4.5-arm-linux-gnueabi

Enviroment Ubuntu 10.04

sudo add-apt-repository ppa:linaro-maintainers/toolchain
sudo apt-get install cpp-4.5-arm-linux-gnueabi g++-4.5-arm-linux-gnueabi

Setup the board settings

git clone git://git.igep.es/pub/scm/igep-x-loader.git
cd igep-x-loader
make igep00x0_config

Build

make

Sign the binary x-loader

You should execute contrib/signGP for sign the xloader.

contrib/signGP x-load.bin

Copy the created x-loader.bin.ift into the boot partition and rename x-loader.bin.ift to MLO as follows. Note first you must mount the boot partition by right clicking on 'Places'-> 'boot' and selecting 'mount.'

cp x-load.bin.ift /media/boot/MLO

Now we're ready for test the board boots from the microsd card.

X-Loader boot test

We will eject the boot and rootfs partitions from our Host PC, this step it's a lot important due the Linux must sync all changes before eject the microsd card.

We will insert our microSD card into the IGEP board, connect the serial debug cable and open the serial terminal

Power UP the board and you should see something similar to this put out over the serial console


Configure the IGEP-X-Loader

As mentioned earlier, the x-loader is the first file called by the processor. It is then responsible for calling the kernel. In order to control what start-up parameters the kernel is given, we use a file called igep.ini. You can use a file like this:

[kernel]
; Kernel load address, NOT Modify
kaddress=0x80008000
; RAM disk load Address, NOT Modify
;rdaddress=0x84000000
; Board Serial ID
serial.low=00000001
serial.high=00000000
; Board Revision
revision=0003
; Kernel Image Name
kImageName=zImage
; Kernel RAM Disk Image Name
;kRdImageName=initrd.img-2.6.35-1010-linaro-omap
MachineID=xxxx Where Machine ID = 2344 for IGEPv2 and ID = 2717 for IGEP Module
 
[kparams]
;buddy=igep0022
;buddy=base0010
; Setup the Kernel console params
console=ttyS2,115200n8
; Enable early printk
;earlyprintk=serial,ttyS2,115200
; Setup the Board Memory Configuration
mem=430M
;mem=512M
; Setup the Boot Delay
boot_delay=0
; Setup the ARM Processor Speed
;mpurate=800
; Setup the loglevel
;loglevel=7
; Enable Kernel Debug Output
;debug=1
; Fix RTC Variable
;fixrtc=1
; Configure nocompcache variable
nocompcache=1
; Configure Frame Buffer Configuration
;omapfb.mode=dvi:1280x720MR-16@60
omapfb.mode=dvi:hd720-16@60
; Configure Video Ram assigned
vram=40M
; Configure Video RAM assigned to every frame buffer
omapfb.vram=0:12M,1:16M,2:12M
; Configure frame buffer debug output
;omapfb.debug=1
; Configure DSS Video Debug option
;omapdss.debug=1
; Configure the Board Ethernet Mac Address
smsc911x.mac=0xb2,0xb0,0x14,0xb5,0xcd,0xde
;  --- Configure UBI FS boot --- 
;ubi.mtd=2 
;root=ubi0:igep0020-rootfs 
;rootfstype=ubifs
;  --- Configure NFS boot --- 
;ip=192.168.2.123:192.168.2.129:192.168.2.1:255.255.255.0::eth0:
;root=/dev/nfs
;nfsroot=192.168.2.129:/srv/nfs/igep_rootfs
;  --- Configure MMC boot --- 
root=/dev/mmcblk0p2 rw rootwait
; Assign Init program
;init=/bin/bash
 

Create a new file into the boot partition named igep.ini with these content in it and save the file. I will explain some of the lines in this file in a later post.

Build kernel from sources

Download the latest stable version sources and follow next steps:

wget http://downloads.igep.es/sources/linux-omap-2.6.35.tar.gz

tar xzf linux-omap-2.6.35.tar.gz

cd [kernel version]

A generic configuration is provided for all IGEP machines, and can be used as the default by

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- igep00x0_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- zImage modules


Create the Rootfs mount point

Go to /media directory and create one sub-folder called "binary"

$ cd /media
$ media > sudo mkdir binary


Mount the RootFS partition

Mount the rootfs partition using the 'binary' directory

$ media > sudo mount /dev/sdb2 /media/binary


Download rootfs

The rootfs (also called the 'head' I think) is what we see of the operating system. In this tutorial I will use a rootfs made by linaro. There are several options available from

http://releases.linaro.org/platform/linaro-m/

ALIP - a very basic desktop including applications for internet browsing (ubuntu 10.10 based)

Netbook - has a few more features and is a bit bigger/slower but comes with a bunch of useful programs pre-isntalled

Plasma - the biggest of the options, it also has the nicest features and best looking desktop.

Headless - doesn't use a screen. To access it, you have to use a remote console via a serial link.

$ media > wget http://releases.linaro.org/platform/linaro-m/alip/final/linaro-m-alip-tar-20101109-0.tar.gz

Untar the rootfs package

Make sure "linaro-m-headless-tar-20101108-2.tar.gz" or whichever linaro you have decided on is inside the /media directory and untar it using:

$ media > sudo tar xvfz linaro-m-headless-tar-20101108-2.tar.gz

Install the kernel modules

Now you should install your kernel modules inside your root file system.

$ media > cd /home/jdoe/linux-omap-2.6
 
$ /home/jdoe/linux-omap-2.6 > sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules_install INSTALL_MOD_PATH=/media/binary
 

Install the kernel Image

Just copy the zImage inside your boot partition, remember before that you must mount your mmc boot partition.

$ /home/jdoe/linux-omap-2.6> sudo cp arch/arm/boot/zImage /media/boot/

After that you can unmount the boot & rootfs partitions. You may need to umount sdb2 twice if you get an error the first time

sudo umount /dev/sdb1
sudo umount /dev/sdb2

Now we're ready for test our new microsd card

Test your new MicroSD

Put your new SD card into your IGEP and power it up, with a monitor plugged into you DVI port. A red LED on your IGEPv2 should come on (this is the xloader doing its thing). This should then turn to a solid green LED as the kernel loads. Soon after this, some lines of debug info should start showing up on your screen, then a short pause and finally your working rootfs should load (i.e. your computer is now on!).

3 comments:

Ralf said...

Is it possible to download your sd-image for a quick test? I do not have the environment to follow your steps.
Ralf

Tom said...

Just wanted to say thank you very much for taking the time to put this up on the web. I am just beginning IGEP development, and I found it *immensely* useful.

Thanks again.

Paolo G. Lim said...

Hi, thanks so much for your tutorial.

BTW, the link to the kernel no longer works (http://downloads.igep.es/sources/linux-omap-2.6.35.tar.gz). You can replace it with their git repo instead git://git.igep.es/pub/scm/linux-omap-2.6.git