Android内核开发 Goldfish Linux Kernel编译及安卓虚拟机测试
本文出处: http://blog.csdn.net/leytton/article/details/52736549
1、配置交叉编译环境
作者用的是android-ndk的/交叉编译工具
方法一:修改环境变量(不推荐)
编辑配置文件
sudo vim /etc/profile
添加环境变量
export ARCH=arm export SUBARCH=arm export PATH=$PATH:/mnt/workbench/android-ndk-r10b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin export CROSS_COMPILE=arm-linux-androideabi-
使环境变量生效
source /etc/profile
注意:虽然上述方法可行,但在编译Linux本地内核模块时由于环境变量变了会出错
因此方法二:修改Goldfish的Makefile比较稳妥
修改/etc/profile文件添加环境变量:
export PATH=$PATH:/mnt/workbench/android-ndk-r10b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin
修改goldfish目录下的Makefile文件
ARCH ?= $(SUBARCH) CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)改为:
ARCHH ?= arm CROSS_COMPILE ?= arm-linux-androideabi-
2、配置goldfish编译选项
生成.config文件
make goldfish_armv7_defconfig
【注意make goldfish_defconfig会导致虚拟机黑屏无法使用】
make menuconfig
选中enable loadable module suppot选项及其前3个子项,否则编译内核驱动模块的时候会出现error: variable '__this_module' has initializer but incomplete type错误
make
编译完会出现以下信息:
Kernel: arch/arm/boot/zImage is ready
3、启动Android虚拟机
指定编译好的镜像作为Android虚拟机内核
adt-bundle-linux-x86_64-20140702/sdk/tools目录下 [hadoop@localhost tools]$ ./emulator -avd AVD01 -kernel /mnt/workbench/android-goldfish-3.4/arch/arm/boot/zImage Failed to load libGL.so error libGL.so: cannot open shared object file: No such file or directory Failed to load libGL.so error libGL.so: cannot open shared object file: No such file or directory emulator: emulator window was out of view and was recentered