Search This Blog

Wednesday, October 9, 2013

Developing Linux OS for ARM - Part IV

Bootstrap is in place ------- > Yes

U-boot is in place      ------->  Yes

Now its time to build kernel image, which will take­over control of the hardware.
We would be discussing the procedure for booting the Linux operating system on board. However,  AT91SAM9260 also supports other popular operating systems like WinCE, FreeRTOS, uC/OS­II, eCOS etc. Refer to  for more information on the same.

The primary site for the Linux kernel source is

we will download the kernel source at the following path:­2.6.27.tar.bz2

Download it to the following path: /Embedded_Linux_Complete/Sources/Linux_kernel/ . A copy of the source is also present in the archives under the following path:


Extract the contents in the current directory.

/Embedded_Linux_Complete/Sources/Linux_kernel$ ls
linux-2.6.27   linux-2.6.27.tar.bz2

Next step would be to download the AT91 maintainers patch, which is the stable patch for AT91. This can be downloaded from:

Download/Copy this to the following path:
After downloading the maintainer's patch apply it on top of the Linux kernel as shown:
 zcat 2.6.27-at91.patch.gz  | patch -p1

Next you can also take the experimental patchset

to the same location and apply it on top of the AT91 one as shown:

/Embedded_Linux_Complete/Sources/Linux_kernel/linux-2.6.27$ zcat 2.6.27-at91-exp.2.patch.gz  |  patch -p1

Now you have to configure the Linux kernel according to your hardware. First identify your kernel revision, your board and then, download the corresponding configuration file. In our case, for AT91SAM9260, the configuration file can be downloaded from

Download the configuration file in


Follow the below mentioned steps to configure the build process:

~/linux-2.6.27$ cp at91sam9260ek_defconfig .config

~/linux-2.6.27$ make CROSS_COMPILE=/home/sanket/Download/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi- ARCH=arm oldconfig

In the above case, the default config that was stored in ~/Linux_kernel/linux­-2.6.27/arch/arm/configs will be used based on the target controller that you have specified.

In case you want to make your own customised kernel, you can configure all options individually using a menu based configuration interface. This can be done using:

~/linux-2.6.27$ make CROSS_COMPILE=/home/sanket/Download/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi- ARCH=arm menuconfig

But before that, for kernel compilation and buildroot, you need to have the some software packages installed on the the host machine. The folliwing is the list of softwares required:

• GNU C/C++
• GNU make
• wget
• sed
• flex
• bison
• m4
• patch
• gettext
• libtool • texinfo
• autoconf
• automake
• ncurses library (development install)
• zlib library (development install)
• libacl library (development install)
• lzo2 library (development install)
• glib library (development install) ­ if some packages selected

On ubuntu, one can install all of these packages simultaneously in the following way:

~/linux-2.6.27$ sudo apt-get install make flex bison m4 ncurses-dev gettext texi2html texinfo zlib1g zlib1g-dev liblzo2-2 liblzo2-dev libacl1 libacl1-dev libglib2.0-dev autoconf automake libtool

Once these packages have been correctly installed , we would be able to have a menu based configuration as shown below:

~/linux-2.6.27$ make CROSS_COMPILE=/home/sanket/Download/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi- ARCH=arm menuconfig

 On typing the above command you would see a menu based configuration utility

Each of the categories shown above will further have kernel modules which can be either retained or removed. Linux supports the concept of loadable kernel modules, which means that many of these kernel modules can also be dynamically loaded/unloaded after the kernel has booted on the target hardware instead of including them at compile time.

Typically, [*] or <Y> symbolises that the corresponding modules are to be retained in the kernel image at the time of compilation, [ ] or <N> symbolises that the corresponding modules are not to be included in the kernel during the compilation, while <M> symbolises that the corresponding modules will not be loaded during the compile time but the kernel will include modules that would support the dynamic loading of these modules.

There are two options available while doing this:

   1. Load a default configuration: We have a default configuration file called
at91sam9260ek_defconfig, which we can load using the “Load an Alternate
configuration file”

    2. Make your own configuration: If we want to prepare a new configuration altogether, we can select the appropriate options.

Once these steps have been performed we can then save the required configuration using the “Save an Alternate configuration file” option. You will get a .config file generated within your current directory. Also, if there was a previous .config file existing within your current directory, a .config.old would be generated so that you can load it at some time in future if required again.

We will go with the default configuration file supplied to us by the AT91 maintainers. Once this is done, you can ensure that the .config file has been generated in the following way:

/linux-2.6.27$ ls -al| grep "config"

Finally , we arrive to the point where we are ready to build the kernel image:

/linux-2.6.27$ make CROSS_COMPILE=/home/sanket/Download/Embedded_Linux_Complete/Package/GNU_GCC_toolchain/arm-2007q1/bin/arm-none-linux-gnueabi- ARCH=arm

At the end of the compilation process, a zImage and Image file would be generated under the following path: /Linux_kernel/linux­2.6.27/arch/arm/boot.

U­Boot does not support normal linux kernel images like zImage or Image (arch/arm/boot/), so you have to create an uImage file with the mkimage tool which encapsulates kernel image with header information, CRC32 checksum, etc. Download mkimage using:

/linux-2.6.27$ sudo apt-get install uboot-mkimage
Once mkimage is available run the following command to generate an uncompressed uImage file:

/linux-2.6.27$ mkimage -A arm -O linux -C none -T kernel -a 20008000 -e 20008000 -n linux-2.6 -d arch/arm/boot/Image uImage

Once the above steps are performed you will get a uImage file generated in your current directory, which would be used as the kernel image for booting Linux on your ARM platform.

Next step would be to build a rootfs image. That we would be continuing in my next post.


No comments:

Post a Comment