在Ubuntu 14.04上编译android kernel也没有遇到什么很难的问题。主要分以下几个步骤:
首先查看emulator的cpu型号: adb shell
root@generic:/ # cat /proc/cpuinfo
Processor : ARMv7 Processor rev 0 (v7l)
BogoMIPS : 378.47
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc08
CPU revision : 0
Hardware : Goldfish
Revision : 0000
Serial : 0000000000000000
1、下载Android内核源代码:
/data/data/Android$ mkdir kernel
/data/data/Android$ cd kernel
/data/data/Android/kernel/goldfish$ git branch -a
/data/data/Android/kernel/goldfish$ git checkout -b android-goldfish-3.4 remotes/origin/android-goldfish-3.4
2、设置环境变量:
/data/data/Android/kernel/goldfish$ export ARCH=arm
/data/data/Android/kernel/goldfish$ export SUBARCH=arm
/data/data/Android/kernel/goldfish$ export CROSS_COMPILE=arm-eabi-
3、将交叉编译工具添加到PATH :
/data/data/Android/kernel/goldfish$ export PATH=$PATH:/data/data/Android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin
4、修改 硬件配置文件goldfish_defconfig(注:arm v5则为goldfish_defconfig, arm v7则为goldfish_armv7_defconfig):
/data/data/Android/kernel/goldfish$ make goldfish_armv7_defconfig
5、执行编译:
/data/data/Android/kernel/goldfish$ make
6、编译成功:
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
注意:标红的地方特别需要注意两者需要一致,否则会导致启动模拟器时一直黑屏!