android内核
http://source.android.com/source/building-kernels.html#figuring-out-which-kernel-to-build
http://blog.csdn.net/luoshengyang/article/details/6564592
下载内核
git clone https://android.googlesource.com/kernel/goldfish.git
git branch -a 显示branch, 然后选择一个分支(git checkout branch)
配置prebuilt gcc
export PATH=$PATH:(android源代码目录)/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin
Build
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-eabi-
make goldfish_defconfig
make (Kernel: arch/arm/boot/zImage is ready 编译成功)
在模拟器中运行编译好的内核
1.#export PATH=$PATH:out/host/linux-x86/bin/ (android源码目录下)
2.#export ANDROID_PRODUCT_OUT=out/target/product/generic/
#emulator -kernel kernel/goldfish/arch/arm/boot/zImage &
出现错误:(emulator: ERROR: You did not provide the name of an Android Virtual Device with the '-avd <name>' option. Read -help-avd for more information.
If you *really* want to *NOT* run an AVD, consider using '-data <file>' to specify a data partition image file (I hope you know what you're doing).)
根据错误提示创建一个AVD
1#android list targets (1.查看当前支持版本(在列出的版本中我们需要记住id值,这个值在第2步中使用):)
3. 2#android create avd -n 4.3 -t 5 (android create avd --name avdName --target 2 [--skin SkinName] 创建AVD)
#emulator -kernel ../kernel/goldfish/arch/arm/boot/zImage -avd ~/.android/avd/4.3.avd/
出现错误:PANIC: Could not open: /home/guo/.android/avd/4.3.avd/
4.#emulator -kernel ../kernel/goldfish/arch/arm/boot/zImage -data ~/.android/avd/4.3.avd/userdata.img 成功
或#emulator -kernel ../kernel/goldfish/arch/arm/boot/zImage -avd 4.3 出现黑屏
出现错误:Failed to load libGL.so。
在android源码目录:find ./ -name libGL.so 可以看到列出的文件。 执行sudo ln -s ./prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/sysroot/usr/lib/libGL.so /usr/lib/libGL.so
出现黑屏的原因:arm版本问题。2.3用的arm版本是5; 4.3用的是7,所以编译内核时用
#make goldfish_armv7_defconfig (2.3用make goldfish_defconfig) #make
4. # emulator -kernel ../kernel/goldfish/arch/arm/boot/zImage -avd 4.3 成功
创建sdcard: mksdcard -l sdcard 512M ~/xx/sdcard.img
android create avd -c ~/xxx/sdcard.img -n 4.3 -t 5
android create avd -c ~/xxx/sdcard.img -n 4.3 -t 5 --skin WXGA800
android list avd 显示avd信息