On the previous building linux kernel entry we learn how to configure, modify and install a downloaded linux kernel version on our Ubuntu distribution. In this tutorial, we will use an existing configuration from the available from each supported architecture. Later, it will be tested on an open source machine emulator called QEmu which supports ARM architecture, unlike Virtual Box.



As you probably know, you will need to cross compile the linux kernel in order to be able to run it on an ARM architecture, so you will need to compile GCC and utils to generate ARM binary files. Fortunately, toolchains are avaiblable to do this task: on ARM toolchain download website we can download it or even easier we can we can install it through the debian packager:

sudo apt-get install gcc-arm-linux-gnueabi 


Using an existing kernel configuration to build Linux.

In order to run our kernel on the emulator we need to use a kernel version lower 3.20 because if not it will not boot. All available configurations are under arch/<architecture>/<setup> where architecture can be x86 or arm among others. The following will write a new config based on the vexpress_defconfig for the arm architecture and then compile the linux kernel using the toolchain we made available before (all gcc tools e.g. gcc, gdc, ld will have the prefix arm-linux-gnueabi- for our system):

ARCH=arm make vexpress_defconfig
ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make -j12

When kernel is built you can check it is done for the appropiate architecture:

$ file arch/arm/boot/zImage
arch/arm/boot/zImage: Linux kernel ARM boot executable zImage (little-endian)


Testing the kernel on QEmu

Once we have the kernel it's time to install the emulator:

apt-get install qemu 

 The following line will start qemu with our kernel:

qemu-system-arm -M vexpress-a9 -kernel arch/arm/boot/zImage  -serial stdio -append "noinitrd console=tty1" -m 128

  And the console will show something like this:


 Wow! kernel panic!! Don't panic, we did not specify any root file system so far, so it is not able to finalize the boot up process but we are really close to get it. We will do it on the kernel blog entry :)