Notes

Powered by The LE Company

Friday, October 25, 2013

Building Linux kernel image for ARM with Eclipse [Part 1]

I feel quite lazy to remember a lot Linux build commands while building Linux kernel image and also don't want to repeat to typing the build commands every time need to modify and rebuild the kernel image. So, I looked at a tool help to make build processes to be more user friendly. Eclipse IDE and its plug-ins are the great fit tools for this purpose.

In this article, I intend to setup needed environment for building the Linux kernel image for Atmel AT91SAM9260 SoC which is based on ARM926EJ-S core. The target board is Olimex SAM9-L9260. Host OS is Ubuntu 13.10 64-bit. There are some differences in setting up environment between Ubuntu 13.10 and previous versions.
A great thing here is all tools used in this project is free ^-^.

A.  Prerequisite

1.      Ubuntu 13.10 64-bit host system configuration

a.      Run command: sudo apt-get update to update software list to local repository.
b.      Run command: sudo apt-get dist-upgrade to upgrade to latest version of all programs in the system.
c.      Run command sudo apt-get install ia32-libs to support for 32-bit applications which need 32-bit libraries to work. CodeSourcery GCC will need these libraries (ia32-libs packages are no longer support from Ubuntu 13.10 onward, see the note at end of this page for workaround).
d.      Run command sudo apt-get install libncurses5-dev. This library is to support for make menuconfig running on 64-bit host PC.
e.      Run command sudo apt-get install u-boot-tools. This is a utility to package vmlinux image to uImage format which is able to be booted by U-boot.


2.      Installation & Setting up Eclipse IDE

a.      Download Eclipse Java EE 64-bit (http://eclipse.org) and unzip it to home directory. You can download Eclipse IDE for C/C++ Developers instead. I’m using Eclipse Kepler 4.3.
b.      Install JDK if it haven’t been installed yet. Run command: sudo apt-get install openjdk-7-jdk
c.      Install g++, run command: sudo apt-get install g++
d.      Install Eclipse C/C++ plug-in (if you haven’t installed it yet).
e. Create Eclipse shortcut to Desktop (this is just an optional step). In terminal, goes to eclipse directory and runs command: sudo gedit eclipse.desktop
- Paste content below to the file and save it.

[Desktop Entry]
Type=Application
Exec=env UBUNTU_MENUPROXY=0 /home/thangle/eclipse/eclipse
Terminal=false
Icon=/home/thangle/eclipse/icon.xpm
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE
Name[en]=Eclipse IDE

- Make the file executable and copy it to desktop directory.
(Note: A bug was found in Eclipse Kepler 64-bit when running on Ubuntu, follow step e above to fix the problem).

3.      Installation Git tool
- Installs git tool (this is optional step) by command: sudo apt-get install git.
- However, in Eclipse EE, Egit an Eclipse plug-in for git already built-in. We will use Egit for management our source code.

4.      Installation GNU ARM Eclipse Plug-in
Install GNU ARM Eclipse plug-in at link: http://gnuarmeclipse.sourceforge.net/updates
 



5. Installation CodeSourcery GCC
Downloads CodeSourcery GCC Lite (http://www.mentor.com) and executes it. Before you run installer, change system shell from dash shell to bash shell by run command: sudo dpkg-reconfigure -plow dash. Selects No in pop-up window appearing. This step is only applied for Ubuntu OS.



Follow guidance in installer to start installation.



And completed installation



Check again to ensure compiler path was updated to PATH variable by run command: arm-none-linux-gnueabi-gcc –v



If it doesn’t show result as above, then you need set PATH again. Run command: sudo gedit /etc/environment and append the path of CodeSourcery directory to current PATH variable. Check in user guide for more details.  



6.      Downloads Linux kernel using Git tool

There are two ways to get the kernel source code: by git tool via terminal and by Egit plug-in from Eclipse.
- To get kernel source code by git tool, firstly needs to install the git tool if it hasn’t installed by executing the command: sudo apt-get install git. After that, in order to download kernel source code, runs the command: git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git.
After completed download, the kernel source code will be stored in folder linux-stable of current directory. In this example, it is /home/thangle/linux-stable.
However, we will not use this method to get the source code but Egit will be used instead.


- Get kernel source code by Egit, an Eclipse plug-in.
In Eclipse, select File -> Import ->Git -> Clone URI. Fill in link below in URI box:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git


Select branch “master” which is latest stable base-line.



Select local work space to store source code


Now, program will retrieve source code from git server




And completed downloading source code to your local directory (/home/thangle/git/linux-stable).


Click Cancel button to completed check-out kernel source code. We will import kernel source code to Eclipse later.


To check kernel version, go to linux-kernel directory downloaded and run command: make kernelversion


Note: Because from Ubuntu 13.10 64-bit onward, there is no longer support ia32-libs, so we need to manually install it with command as following (copy and paste to terminal): 

sudo apt-get install bluez-alsa:i386 gstreamer0.10-plugins-base:i386 gstreamer0.10-plugins-good:i386 gtk2-engines:i386 gtk2-engines-murrine:i386 gtk2-engines-oxygen:i386 gtk2-engines-pixbuf:i386 gvfs:i386 ibus-gtk:i386 libacl1:i386 libaio1:i386 libao4:i386 libasound2:i386 libasound2-plugins:i386 libasyncns0:i386 libattr1:i386 libaudio2:i386 libcanberra-gtk-module:i386 libcap2:i386 libcapi20-3:i386 libcups2:i386 libcupsimage2:i386 libcurl3:i386 libdbus-glib-1-2:i386 libesd0:i386 libfontconfig1:i386 libfreetype6:i386 libgail-common:i386 libgconf-2-4:i386 libgdbm3:i386 libgettextpo0:i386 libglapi-mesa:i386 libglu1-mesa:i386 libgphoto2-6:i386 libgphoto2-port10:i386 libgtk2.0-0:i386 libmpg123-0:i386 libncursesw5:i386 libnspr4:i386 libnss3:i386 libodbc1:i386 libopenal1:i386 libpulse-mainloop-glib0:i386 libpulsedsp:i386 libqt4-dbus:i386 libqt4-network:i386 libqt4-opengl:i386 libqt4-qt3support:i386 libqt4-script:i386 libqt4-scripttools:i386 libqt4-sql:i386 libqt4-svg:i386 libqt4-test:i386 libqt4-xml:i386 libqt4-xmlpatterns:i386 libqtcore4:i386 libqtgui4:i386 libqtwebkit4:i386 librsvg2-common:i386 libsane:i386 libsdl-image1.2:i386 libsdl-mixer1.2:i386 libsdl-net1.2:i386 libsdl-ttf2.0-0:i386 libsdl1.2debian:i386 libsqlite3-0:i386 libssl0.9.8:i386 libssl1.0.0:i386 libstdc++5:i386 libstdc++6:i386 libxaw7:i386 libxml2:i386 libxp6:i386 libxslt1.1:i386 libxss1:i386 libxtst6:i386 odbcinst1debian2:i386 xaw3dg:i386 libgl1-mesa-dri:i386 libgl1-mesa-glx:i386 libpam-winbind:i386

B.  Introducing the procedures to build the Linux kernel

1.      Kconfig: the file that descripts compilation options. It is input file for menuconfig program
2.      Defconfig: store default compiler options
3.      .config: store selected compilation options, generated by menuconfig program
4.      Makefile: script file is processed by make program
5.      menuconfig: the program will process Kconfig file and generate .config file. The make program will build and auto start menuconfig program when we enter command: make menuconfig. Note: menuconfig program is distinct from make program. In kernel source code, menuconfig is on directory linux-stable/scripts/kconfig.
6.      Patch file: is used for software version control.
7.       include/generated/autoconf.h
8.      include/config/auto.conf

Reference link:

(Update later...)

3 comments:

Aslam's blog said...

Hi,
This topic is realy nice.
i am working with 32 bit system, how prerequisite will change for 32 bit system?

Anonymous said...

Just same as 64bit version. Compiler works with both 32 & 64 bit host machine (Ubuntu, Fedora).

Anonymous said...

Great tutorial. I still have some old SBC with AT91SAM9260 SoC - is it still possible to install a new kernel on it? (64MB SDRAM, 1GB NandFlash)