mardi 4 janvier 2011

Configuring, Building and debugging Linux kernel using Eclipse IDE


Introduction :

the idea of using eclipse IDE for configuring and building Linux kernel is to help the developer to automate from a presentable GUI ( No command shell) the following operation:
  • configuration of Linux kernel
  • building the binary image kernel for target.
  • clean the previous configuration and binary image
  • compiling and installing of module (driver)
  • compiling the C/C++ code
  • debugging Linux kernel on target or by emulation using qemu
we can also using eclipse for :
  • configuring and building u-boot for target
But before thinking of using eclipse IDE for building the Linux kernel binary image,we must absolutely know the basic theories of embedded Linux kernel and master the necessary steps for configuring and building the kernel eventually in shell, here I will show almost all shell command necessary for building Linux kernel. 

     i- For configuring manually the kernel and Generate “.config” from template, exemple for mini2440 :
host$ make mini2440_defconfig ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- 
     ii- There are two menu configs that we can be use for configuring and Modify the kernel options you would like to run :
host$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig 
(or) 
host$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- xconfig 

    iii- Clean your installation of previous build settings : 
host$ make distclean ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- 
  
1- Create Linux kernel project in Eclipse IDE :

step 1 : first, create a new C project by using File->New->Project...

step 2 : select "C Project", "Makefile project", "Empty Project" , and choose name of your kernel project :

for example I'm choosing "linux-kernel-project" like following screen-shot
:
 

   
step 3 : copy linux kernel source in the eclipse project directory , for me I'm used "linux-2.6.32.2-mini2440" is the kernel source for my friendlyARM mini2440 board is available in the official web site : www.friendlyarm.com.we will get an empty workspace as shown in the screen-shot.
 
I board to disable automatic building , by using the "Window->Preferences" menu, selecting "General->Workspace" and deselected "Build automatically".
now we will be refresh our workspace "File->Refresh" and waiting some time in order to eclipse finish indexing project.
 
  2- Building Linux kernel :

a- Configuring Kernel :

step 1 : in "project->built configurations->manage configuration", click "New" for create a New configuration and enter the configuration name like the following screen-shot :
step 2 : we will define a new build variable by using "project->proprieties" in window of project proprieties, selecting "C/C++ Build; Build variables"


I'm using “xconfig  i It is a graphical Linux compilation utility, which uses Qt.
The xconfig utility is invoked by running 'make xconfig' in the base Linux source directory.
We can also use “menuconfig .

So in

  • “variable name” enter : xconfig
  • type” : choose string
  • Value” : xconfig ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
Step 3 : In Project Proprieties select “C/C++ Build”, in “Behaviour” click in Variables and select xconfig variable as the following screen-shot :
now click in the small hummer in the main window of eclipse IDE, then click in xconfig.
A new window will appear, where we can configure the kernel.
b- Compiling Kernel :

follow the same steps for compiling the kernel, just in addition a new variable, it must be like me :
in 
  • “variable name” enter : uImage
  • type” : choose string
  • Value” : uImage ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
Now we can building uImage :


Conclusion :

Now we know how to use eclipse for configuring and building Linux kernel, in next publication we will show and talk about the different operation mentioned in the introduction. 

Note :
    during development, I'm using ubuntu 10.10 as operating system and we must be install the CodeSourcery tools for compiling kernel.