Building Android Kernel - Diego Stamigni

download Building Android Kernel - Diego Stamigni

of 5

Transcript of Building Android Kernel - Diego Stamigni

Android: Building Kernel from source1 2 1 Install CyanogenMod on the device 2 Install development support packages 1 2 3 4 5 6 7 8 9 2.1 Debian based Linux distributions 2.2 Red Hat based Linux distributions

3 Setup Repo 4 Download ROM Source Code 5 Download Kernel Source Code 6 Congure the Build 7 Make the build 8 Merge the build 9 Compiling wi kernel module

10 10 Installing kernel modules for debian chroot installation 11 11 Sources

Install CyanogenMod on the deviceFirst, you will need to get a working install on the device: Installing CyanogenMod on the device.

Install development support packagesInstall the following packages using your favorite package manager:

Debian based Linux distributions32bit and 64bit systems: git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev 64bit only: ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib

Setup RepoMake sure you have a ~/bin directory, and setup repo. mkdir -p ~/bin curl http://android.git.kernel.org/repo > ~/bin/repo chmod a+x ~/bin/repo echo $PATH|grep ~/bin>/dev/null||export PATH="${PATH}":~/bin hash -r To validate the repo command is in your path, type 'which repo'. If you do not have ~/bin in $PATH by default and are using bash, do the following: echo "export PATH=\"\${PATH}\":~/bin" >>~/.bashrc eval . ~/.bashrc

Download ROM Source Codemkdir -p ~/android/system cd ~/android/system repo init -u git://github.com/CyanogenMod/android.git -b gingerbread repo syncThis may take 1.5 hours, more or less, depending on your connection. Create an environment variable denoting the location of the android toolchain as follows:

export CCOMPILER=${HOME}/android/system/prebuilt/linux-x86/ toolchain/arm-eabi-4.4.0/bin/arm-eabi-

Download Kernel Source Codemkdir -p ~/android/kernel cd ~/android/kernel git clone git://github.com/CyanogenMod/cm-kernel.git cd cm-kernel

Congure the BuildRetrieve a working kernel cong from the device, and unzip it:

adb pull /proc/config.gz /home/user_name/android/kernel/cmkernel/config.gz gunzip config.gz && mv config .configAlternatively, you can pull the .cong from the newest boot.img

scripts/extract-ikconfig boot.img > .configCongure the build. Just enter to accept defaults, or customize as needed:

make ARCH=arm CROSS_COMPILE=$CCOMPILER oldconfig make ARCH=arm CROSS_COMPILE=$CCOMPILER menuconfig

Make the buildmake ARCH=arm CROSS_COMPILE=$CCOMPILER -j`grep 'processor' / proc/cpuinfo | wc -l`This step may take a while, depending on your computer. At this point you should have a kernel stored in

~/android/kernel/cm-kernel/arch/arm/boot/zImage

Merge the buildYou will need to merge this le with a working cyanogen ramdisk in order to create a boot image suitable for ashing. Follow these instructions here. If all goes well, you should now be running your own custom CyanogenMod kernel on the device. Note: If you are building for Nexus One, you should use --base 0x20000000 when running mkbootimg.

Compiling wi kernel moduleAfter installing a custom kernel, the wi module may be unstable or unusable. The solution is to recompile the module, linking it to the new kernel build.

cd ~/android/system/system/wlan/ti/sta_dk_4_0_4_32 KERNEL_DIR=~/android/kernel CROSS_COMPILE=$CCOMPILER ARCH=arm make -j`grep 'processor' /proc/cpuinfo | wc -l`A le named wlan.ko will be produced in the current directory. You must install the new module to the device.

adb shell mount -o remount,rw /system adb shell cp /system/lib/modules/wlan.ko /system/lib/modules/ wlan.ko.backup adb push wlan.ko /system/lib/modules/wlan.koReboot the device. If all goes well, you should be using the newly compiled 'wlan.ko'.

Installing kernel modules for debian chroot installationIf you have a debian chroot install on the device, you will want to add to it the loadable modules that were built along with the kernel. This is necessary to use things like fuse, cifs, etc. First tar up and transfer over the modules

cd ~/android/kernel tar -czf modules.tgz `find . | grep ko$` adb push modules.tgz /sdcardThen, Copy the modules to your debian install (Replace with the root of your debian installation)

adb shell mkdir /lib/modules/`uname -r` cd