Compiling Linux for SAM9: SAM9G20-EK board (Target) on Ubuntu (Host)

I am compiling Linux for SAM9G20-EK board. I will be doing this fresh with my Host as Ubuntu 9.10. Ubuntu will be running on Sun Virtual Machine. I will be also working on a native Linux machine

If you are expecting an already configured virtual machine for ARM9G20-EK board you can download form the following link http://www.at91.com/component/resource/article/Academy/44-Workshop/1147-sam9g20-linux-buildroot-workshop.html

This exercise is to help any newbie in bringing up the tool-chain. Here the tool-chain will not be recompiled. I will fetch already compiled binaries to build Linux.

1. Please download the appropriate package from the link http://www.angstrom-distribution.org/toolchains/ for the SAM9G20 a package with  arm5te should be chosen. I have chosen the package angstrom-2009.X-test-20091214-armv5te-linux-gnueabi-toolchain-qte-4.6.0-i686.tar.bz2 for Ubuntu9.0 on i686 host.

2. After downloading the same untar it to the root folder (/). You will find a new folder /usr/local/angstrom/arm/ and it contains the environment-setup.

3. Add the commands in environment-setup to your ~/.profile and log off and log in to make the commands take effect.

4. We can test our installation and tool-chain by following the example. This example is taken form http://www.angstrom-distribution.org/toolchains/ Creating and building a simple example. We will create a simple Qt Embedded application and use qmake2 and make to cross compile.

$ cd $HOME
$ mkdir qte-example
$ cd qte-example

$ echo "TEMPLATE=app
SOURCES=main.cpp
" > qte-example.pro

$ echo '#include <QApplication>
#include <QPushButton>

int main(int argc, char** argv) {
    QApplication app(argc, argv);

    QPushButton btn("Hello World");
    btn.show();
    btn.showMaximized();

    return app.exec();
}
' > main.cpp

$ qmake2
$ make
$ ls -l

-rw-r--r-- 1 prajosh prajosh   221 2011-03-07 14:53 main.cpp
-rw-r--r-- 1 prajosh prajosh  4500 2011-03-07 14:53 main.o
-rw-r--r-- 1 prajosh prajosh 10505 2011-03-07 14:53 Makefile
-rwxr-xr-x 1 prajosh prajosh  9516 2011-03-07 14:53 qte-example
-rw-r--r-- 1 prajosh prajosh    31 2011-03-07 14:52 qte-example.pro

will be the output of ls command. Where qte-example is the executable generated from make

$ ./qte-example 
bash: ./qte-example: cannot execute binary file

which shows this executable is not for the Host. This confirms our toolchain

5. Download the kernel source from kernel.org. I have used linux-2.6.31.14

6. Once the Kernel have been downloaded we can unzip it and start work
$ cd $HOME
$ mkdir Code
$ mkdir -p Code\Linux_kernel
$ cd Code\Linux_kernel

copy the kernel zip bundle here and unzip or rar or tar it here

$ cd linux-2.6.31.14 or which ever version you have downloaded
$ make at91sam9260ek_defconfig ARCH=arm

this will generate the .config file for the final make

6. Fire make with the following command
$ make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi-

On completion of the make the Linux image can be found in the Linux folder in my case linux-2.6.31.14 🙂 enjoy.........

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s