#Compiling Linux Kernel 2.6.39 for the Aria G25 SoM

This article illustrates how get and patch the Linux Kernel version 2.6.39 sources 
and generate a working binary image bootable from the [Aria G25 SoM](/aria).

<img src="./ariag25kernel.jpg">

##Requirements

*  a PC with Linux an [ARM cross compiler](/arm9_toolchain) installed. In this article I've used an <b>Ubuntu 11.10</b>
*  a 1GB or greater microSD card 
*  an [AriaG25 SoM](/aria) with the minimum hardware linked
*  a [Debug Port Interface](/DPI)
*  [Git](http://git-scm.com/) revision system installed on your PC
*  an Internet access

The most part of this article is derived from this Atmel page [Linux4sam.org](http://www.at91.com/linux4sam/bin/view/Linux4SAM/SAM9x5Page#Building_the_Linux_kernel).

##Download the Linux Kernel source tree and apply the patches

Download from the following link the Linux Kernel Vanilla version 2.6.39 sources:

* [Linux Vanilla Kernel version 2.6.39](http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.39.tar.bz2)

Uncompress it and move into the directory created:

<pre class="minicom">
$ tar -xvjf linux-2.6.39.tar.bz2
$ cd linux-2.6.39
</pre>

Download the essential patches to run Linux on AriaG25 (they include both Atmel and Acme Systems patches in one file) inside the Linux source directory:

* [Atmel + Acme Systems patches for Linux 2.6.39](./ariag25.patch.tar.gz)

Uncompress it:

<pre class="minicom">
$ tar -xvzf ariag25.patch.tar.gz
</pre>

and apply the whole patchset by typing this command:

<pre class="minicom">
$ patch -p1 < ariag25.patch
</pre>

Download the Acme Systems .config compressed file:

* [ariag25.config.tar.gz](./ariag25.config.tar.gz)

and uncompress it:

<pre class="minicom">
$ tar -xvzf ariag25.config.tar.gz
</pre>

##Build the bootable Linux Kernel image for Aria G25:

Customize the Kernel configuration (if you need to do that) by typing:

<pre class="minicom">
make ARCH=arm menuconfig
</pre>

Then save it and run the Kernel compilation:

<pre class="minicom">
make -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
</pre>

To produce a kernel image suitable for the [AriaBoot](/ariaboot) boot loader type:

<pre class="minicom">
mkimage -A arm -O linux -C none -T kernel -a 20008000 -e 20008000 -n linux-2.6 -d arch/arm/boot/zImage uImage
</pre>

Copy **uImage** on the first partition of the SD or microSD card and boot from it.

On the same partition save the **boot.bin** file with [AriaBoot](/ariaboot) inside and the file macaddr.txt with the
MAC address you would like to set to the ethernet interface of your board, i.e.:

<pre>
00:04:25:12:34:56
</pre>   

##Compile the Kernel modules

If during the bootstrap you obtain a message like this:

<pre class="minicom">
modprobe: FATAL: Could not load /lib/modules/2.6.39+/modules.dep: No such file or directory
</pre>

probably you have to compile also some kernel modules 

To compile the Kernel modules type:

<pre class="minicom">
$ make modules -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
$ make modules_install INSTALL_MOD_PATH=./ariag25-modules ARCH=arm
</pre>

##Install the modules inside the Aria G25

To copy the just compiled kernel modules from your PC to the Aria G25 you could use this command:

<pre class="minicom">
$ rsync -avc ariag25-modules/lib/. root@ariag25_ip_address:/lib/.
</pre>

Then from the Aria G25 command line update the module dependencies by typing this command:

<pre class="minicom">
$ depmod -a
</pre>

Finally reboot the Aria G25 to load the new Kernel.

@shop='ARIAG25-128'
