2010年10月27日 星期三

[Android] Build the linux kernel and Android source for the emulator

Build linux kerenl(Eclair):
1.check current kernel version of emulator
$ adb shell
# cat /proc/version
Linux version 2.6.29-00261-g0097074-dirty (digit@digit.mtv.corp.google.com) (gcc version 4.4.0 (GCC) ) #20 Wed Mar 31 09:54:02 PDT 2010
2.download kernel source
$ git clone git://android.git.kernel.org/kernel/common
3.check branch
$ git branch
* android-2.6.27
if it shows * android-2.6.27, list all remote available branches
$ git branch -r
origin/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-2.6.35
origin/android-2.6.36
origin/android-goldfish-2.6.27
origin/android-goldfish-2.6.29
4.switch branch
$ git checkout --track -b android-goldfish-2.6.29 origin/android-goldfish-2.6.29
5.check branch again
$ git branch
android-2.6.27
* android-goldfish-2.6.29
6.obtain kernel configuration
$ cd /path/to/kernel/common
$ adb pull /proc/config.gz .
$ gunzip config.gz
$ cp config .config
7.building and compiling the kernel
$ ARCH=arm CROSS_COMPILE=/path/to/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- make
8.successful message
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready


Build Android source:
1.building and compiling Android source
$ PATH=/path/to/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin
$ cd /path/to/android/
$ make
2.successful message
Install system fs image: out/target/product/generic/system.img
Target ram disk: out/target/product/generic/ramdisk.img
Target userdata fs image: out/target/product/generic/userdata.img


Start emulator:
$ emulator -kernel /path/to/kernel/common/arch/arm/boot/zImage -show-kernel -verbose -image /path/to/android/out/target/product/generic/system.img -data /path/to/android/out/target/product/generic/userdata.img -ramdisk /path/to/android/out/target/product/generic/ramdisk.img

reference:
* Howto BUILD the LINUX KERNEL for the ANDROID EMULATOR (Eclair version)
* Building Android kernel images
* 編譯android原始碼到模擬器上執行

沒有留言: