1. 下载kernel源码:https://android.googlesource.com/kernel/goldfish/
下载 goldfish-android-goldfish-3.4.tar.gz(我是Android4.4的源码)
2. 在Android源码目录新建kernel文件夹
$ mkdir kernel
解压 goldfish-android-goldfish-3.4.tar.gz到kernel文件夹
3. 导出交叉编译工具目录到$PATH环境变量中去.
$ vi ~/.bashrc
输入内容: export PATH=$PATH:~/android/4.4/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin
4. 修改Makefile文件,找到这两行:
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
注释掉然后修改为
#ARCH ?= $(SUBARCH)
#CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
ARCH ?= arm
CROSS_COMPILE ?= arm-eabi-
5. $ make goldfish_armv7_defconfig
$ make -j8
编译好了之后会在kernel/arch/arm/boot 目录下生成zImage内核文件
6. 使用自己编译好的内核运行emulator:
[email protected]:~/android/4.4$ emulator -partition-size 1024 -kernel ./kernel/arch/arm/boot/zImage -system ./out/target/product/generic/system.img -data ./out/target/product/generic/userdata.img
-ramdisk ./out/target/product/generic/ramdisk.img