Android 入门 -- 编译内核
来源:互联网 发布:阿里云企业邮箱 免费版 编辑:程序博客网 时间:2024/04/28 19:13
Android的源代码中并没有包含内核的源代码,本文介绍在MacOSX下如何下载编译Android的内核。在编译内核之前,请先了解如何编译Android源码,参看博文:Android 入门 - 编译源码(MacOSX)
a). 在模拟器里查看内核版本
得到Android 4.4的内核版本为“Linux version 3.4.0-gd853d22”
一、准备工作
1.1、安装最新的XCODE
XCODE是MacOSX下的开发工具,安装之后,开发需要的各种环境基本就具备了,不需要再各自去下载。如:git,gcc等等。
1.2、安装GoAgent
googlesource站点在国内不能访问,需要翻墙才能访问。建议安装GoAgent来翻墙。
安装步骤:略,可从网上搜索解决。
1.3、设置代理
# export http_proxy=localhost:8087# export https_proxy=localhost:8087
localhost:8087是你的GoAgent代理的地址与端口。
1.4、创建大小写敏感的磁盘映象
- 创建一个大小写敏感的磁盘映象,100G,映象根据实际大小占据磁盘空间,所以,大点没有关系,命令:
# hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 100g ~/android-kernel.dmg
- 挂载磁盘,可在Finder里双击“个人”主目录的android-kernel.dmg.sparseimage,即可挂载一个UNNAME的磁盘,按“右键”更名为android。实际路径为:/Volumes/android-kernel。
二、下载内核源码
2.1、获取内核版本信息
有两种方法获取Android内核版本,都需要运行模拟器:
# emulator -cpu-delay 0
进入 应用 -> 设置 -> 关于手机 ->内核版本,即可查看到此Android的内核版本。
b). 用adb shell 连接模拟器命令查看# adb shell# cd proc# cat version
2.2、下载源码
# cd /Volumes/android-kernel/# mkdir source# cd source# git clone https://android.googlesource.com/kernel/goldfish.git
2.3、查看源码版本
# cd goldfish# git branch -a
结果如下:* master remotes/origin/HEAD -> origin/master remotes/origin/android-3.10 remotes/origin/android-goldfish-2.6.29 remotes/origin/android-goldfish-3.10 remotes/origin/android-goldfish-3.4 remotes/origin/linux-goldfish-3.0-wip remotes/origin/master
2.4、Check out 3.4版本
# git checkout remotes/origin/android-goldfish-3.4
三、编译
3.1、初始化配置
# export PATH=/Volumes/android/source/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.7/bin/:$PATH# vi Makefile
修改如下内容:
ARCH ?= $(SUBARCH)CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)改成:ARCH ?=armCROSS_COMPILE ?=arm-eabi-
3.2、除错
Mac下编译会出现一些错误:# cp /Volumes/android/source/external/elfutils/libelf/elf.h scripts/mod# vi scripts/mod/mk_elfconfig.c
将 include <elf.h> 修改为 include "elf.h"。# vi scripts/mod/modpost.h
将 include <elf.h> 修改为 include "elf.h"。3.3、编译
# make goldfish_armv7_defconfig# make -j16
编译完成后,会在最后显示如下内容:
... OBJCOPY arch/arm/boot/zImage Kernel: arch/arm/boot/zImage is ready
4、运行
运行如下指令:
# emulator -kernel arch/arm/boot/zImage
运行结果如下图: 0 0
- Android 入门 -- 编译内核
- 内核模块编译入门
- 编译linux内核入门
- 内核模块编译 makefile入门
- Android编译 & Linux内核编译
- android内核编译方法
- Android平台内核编译
- Android平台内核编译
- android 内核编译成功
- android内核编译方法
- android内核编译方法
- android 内核的编译
- android内核,busybox编译
- android内核编译札记
- android内核编译方法
- Android 内核编译运行
- android内核编译方法
- android内核编译方法
- C#之Hashtable 的应用
- uva:321 - The New Villa(bfs + 哈希判重)
- 【大数问题】大数阶乘
- QQ免费企业邮箱申请配置
- C++中可以访问private的情况
- Android 入门 -- 编译内核
- linux/unix 环境编程-信号总结
- 基于UDP协议的网络摄像头的关键问题解决及调试过程
- 怎样处理MSER出现的嵌套区域
- VS2010配置FFMPEG
- upx 参数说明
- 使用xml描述的数据周期统计框架
- leetcode:Sudoku Solver
- 一个研究生毕业以后的人生规划(想抛砖引玉,谈谈自己看法,局限于理工科学生)