1、 arm编译器
先取得arm工具链,或使用android自带的。
注意选择较早的版本,很有可能是google那班人在编译的时候 选择的是当时的最新的版本,但是后来就一直用那个版本
http://www.codesourcery.com/sgpp/lite/arm/portal/subscription?@template=lite
要之前的版本:点击 All versions 即可看到所有的发行版本,2008q3-41这个版本是经过很多人测试可以用的。
解压后,设置环境变量,将/usr/local/arm-2008q3/bin 添加到$PATH中
其中 /usr/local/为保存解压后的arm-tools-chain的根目录
2、 下载Android的Linux内核
记住是Android的Linux内核(git clone git://android.git.kernel.org/
kernel/common.git),
而不是通用的Linuxe内核源码(git clone git://android.git.kernel.org/kernel/linux-2.6.git
)
$ git clone git://android.git.kernel.org/kernel/common.git kernel-common
//其中 kernel-common为存放从代码库下来的代码的目录
$ cd ~/kernel-common
$ git branch
$ android-2.6.36
//这个随着版本的变化而变化
3、 下载完Android的Linux内核源码,你会发现在/arch/arm/configs/下没有goldfish_defconfig这个文件,恩我们需要check_out gold_fish版本(模拟器的硬件配置就是Gold_Fish的)
$ cd ~/kernel_common
1 git checkout -b emulator archive/android-gldfish-2.6.29
2. Generate the kernel configuration file:
make ARCH=arm CROSS_COMPILE=arm-eabi- goldfish_defconfig
3. Modify the kernel configuration file:
make ARCH=arm CROSS_COMPILE=arm-eabi- menuconfig
4. Build the kernel:
make -j4 ARCH=arm CROSS_COMPILE=arm-eabi- zImage
5. Build Android for generic in the Qualcomm-modified Android tree (from clean, if already 30 built):
choosecombo 1 1 generic 3
make -j4
6. Run the emulator with the new kernel.
编译完最后两行信息:
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
6 用我们刚刚编译成功内核启动模拟器(这样不会对原有的模拟器产生任何的影响)
$ emulator -avd AVD15 -kernel ~/kernel_common/arch/arm/boot/zImage
如果模拟器能起来,那说明成功了。
打开另外一个终端,这样就能解决上面的终端被占用的情况下,也能使用终端
$ adb shell
#cd /proc
# cat version
Linux version 2.6.29-gb0d93fb (scm@Android-Compiler02) (gcc version 4.4.0 (GCC) ) #2 Tue Jul 5 09:28:41
# cat cupinfo
cupinfo: No such file or directory
# cat cpuinfo
Processor : ARM926EJ-S rev 5 (v5l)
BogoMIPS : 272.79
Features : swp half thumb fastmult vfp edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant : 0x0
CPU part : 0x926
CPU revision : 5
Hardware : Goldfish
Revision : 0000
Serial : 0000000000000000
PS: 建议模拟器版本与内核版本要对应