Hi 🙂 This is my first attempt building an android kernel source. I just thought of sharing my experiences so far. This will be useful for a beginner. 🙂
- Linux installed on a PC or on a Virtual Box
- Android Kernel Source
- A Toolchain
I have installed Ubuntu on Oracle VM VirtualBox.
Getting Android Kernel Source
I am using the kernel source of “omap” project. According to the android official web page the project is used for PandaBoard and Galaxy Nexus, and can be used as a starting point for work on TI OMAP chipsets.
1. Download the “omap.git-android-omap-3.0.tar.gz” from Google repository https://android.googlesource.com/
2. Extract source:
Open a new Terminal and enter following command.
- Create a directory structure as follows and move the downloaded omap.git-android-omap-3.0.tar.gz file into that folder
:~$mkdir -p ~/android/kernel
- Extract it:
:~/android/kernel$tar xvf omap.git-android-omap-3.0.tar.gz
Once you extracted the source: Goto ->android–>kernel–>arch–>arm–>configs folder. You can find the panda_defconfig file there.
Getting prebuilt toolchain
You can get prebuilt toolchain from the same Google repository.
2. Download the master branch and extract the source in to a new folder call toolchain, following the same steps as above.
:~$mkdir -p ~/android/toolchain
:~/android/toolchain$tar xvf arm-eabi-4.6-master.tar.gz
3. Extract source:
Set the path to toolchain
Here in my example the path to toolchain is : /home/tharaka/android/toolchain/bin. You can check the folder where it contains arm-linux-androideabi-gcc
- Open Terminal and enter command: gedit ~/.bashrc
- It will open up the text editor:
Kernels are compiled with a program called gcc. The gcc comes with toolchain is an optimized version of gcc. Therefore here we do a cross-compile.
1. Go inside the kernel source folder and enter following command
make ARCH=arm CROSS_COMPILE=arm-linux-androideabi- panda_defconfig
Build the Kernel
While compiling it gives messages and warnings. We can ignore warnings but when there are errors compilation stops and terminate and we will have to fix the issuses.
Thank You 🙂