DOWNLOAD THE KERNEL SOURCE CODE
First we download the kernel source code from http://android.git.kernel.org
Within that page there are kernels for other platforms too. We choose to download kernel/common project from there.
$git clone git://android.git.kernel.org/kernel/commonWe check which branch we have downloaded:
$git branchit shows * android-2.6.27, not the one we are searching for:
To list all remote available branches:
$git branch -rorigin/HEAD -> origin/android-2.6.27 origin/android-2.6.25 origin/android-2.6.27 origin/android-2.6.29 origin/android-2.6.32 origin/android-goldfish-2.6.27 origin/android-goldfish-2.6.29
What does goldfish mean? (from android-kernel mail list)
Goldfish is the kernel hacked branch that supports the qemu based arm emulator for android, so it is the one we need.
Download GOLDFISH kernel version
$git checkout --track -b android-goldfish-2.6.29 origin/android-goldfish-2.6.29$git branchandroid-2.6.27 * android-goldfish-2.6.29
RUNNING THE EMULATOR
Within this link we will find how to get the android emulator, and launch it.
Building Android in Debian Sid
Showing the kernel version running in the emulator
$adb shell#cat /proc/versionLinux version 2.6.29-00261-g0097074 (digit@digit.mtv.corp.google.com) (gcc version 4.4.0 (GCC) ) #14 Tue Feb 2 15:49:02 PST 2010
OBTAINING KERNEL CONFIGURATION
We are going to obtain the kernel configuration .config file from within our running emulator.
$cd common # we enter in the kernel source directory.$adb pull /proc/config.gz . # get compressed .config file from the emulator.$gunzip config.gz # uncompress it.$cp config .config # rename it into .configNow you can edit .config file the way it suits you the most.
BUILDING AND COMPILING THE KERNEL
CROSS_COMPILE environment variable stores the path to the arm cross compiling toolchain. I use the one which comes with android source code.
$ARCH=arm CROSS_COMPILE=/path/to/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- makeExecuting make will build the kernel.
Last lines will show:
Kernel: arch/arm/boot/Image is ready Kernel: arch/arm/boot/zImage is ready
So we have obtained Image and zImage kernel binary files.
RUN THE EMULATOR USING THE NEW COMPILED KERNEL IMAGE
We need -kernel option:
$emulator -kernel /path/to/common/arch/arm/boot/zImage -show-kernel -verboseWe can check now the kernel version:
$adb shell# cat /proc/versionLinux version 2.6.29-00262-gb0d93fb (user@myPC) (gcc version 4.4.0 (GCC) ) #1 Sun May 2 14:27:31 CEST 2010
If we do not specify kernel option it usually uses the prebuilt one:
$emulator -show-kernel -verboseemulator: argv[01] = "-kernel" emulator: argv[02] = "/path/to/mydroid/prebuilt/android-arm/kernel/kernel-qemu"
ACTIVATING MODULE LOADING SUPPORT IN THE KERNEL
Module loading support is previously disabled in the kernel, if we want to load modules in the kernel we have to enable it:
edit .config file and set:
CONFIG_MODULES=y
$ ARCH=arm CROSS_COMPILE=/path/to/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- makeI am asked about some options when executing make. I ask yes for module related options.
After compiling I see several modules have been built.
MODPOST 6 modules CC drivers/video/fb_sys_fops.mod.o LD [M] drivers/video/fb_sys_fops.ko CC drivers/video/syscopyarea.mod.o LD [M] drivers/video/syscopyarea.ko CC drivers/video/sysfillrect.mod.o LD [M] drivers/video/sysfillrect.ko CC drivers/video/sysimgblt.mod.o LD [M] drivers/video/sysimgblt.ko CC drivers/video/vfb.mod.o LD [M] drivers/video/vfb.ko
We can upload the modules in the emulator and install them:
$adb push drivers/video/fb_sys_fops.ko /data$adb shell#insmod /data/fb_sys_fops.koREFERENCE
http://www.cianer.com/androidg1/28-building-android-kernel-images
YOU MAY ALSO BE INTERESTED IN:
Building Android in Debian Sid
No comments:
Post a Comment