Compile aosp and hikey-linaro
文档
首先最有用的就是官方文档了,附上Google的官网地址。https://source.android.com/source/devices
官网上的说明是简明概要的,但是在我们的编译过程中其实可能会遇到各种奇奇怪怪的问题。下面就一些 我们踩过的雷给排掉。
- Hikey960官方网站:
https://www.96boards.org/product/hikey960/
- Hikey960的aosp编译安装文档:
https://source.android.com/setup/build/devices#hikey960
- Hikey960官方预先编译好的代码:
https://www.96boards.org/documentation/consumer/hikey/hikey960/downloads/aosp.md.html
准备工作
- 交叉编译工具Android NDK https://developer.android.com/ndk/downloads/index.html (注意从r18版本开始就不支持使用gcc编译了,而内核编译还是用gcc的,所以我安装的是r16b)
- AOSP相关 https://source.android.com/setup/build/initializing
- Python3
(一)首先就是下载aosp和hikey-linaro的源码。
aosp比较大,压缩后都有60G左右,解压后有115G左右。hikey-linaro压缩不超过2G。这两个源码官网上 可以下载,但是要翻墙!!!
好在校园网ipv6可以直连Google,但是我在实验室下载很慢,据说寝室下载 要快一些。hikey-linaro我们下载的master分支,前期编译4.4版本,
后期编译4.9版本。以下描述二个版本可以通用。
下载清华的hikey-linaro镜像
aosp配套的内核代码
git clone https://aosp.tuna.tsinghua.edu.cn/kernel.common.git
hikey专用内核镜像
git clone heeps://aosp.tuna.tsinghua.edu.cn/kernel/hikey-linaro.git
补充一下从清华的镜像下载aosp和相关工具的方法(该方法非常好用)
详细资料参考他们的官网:
https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
- 正常方法只是因为无法翻墙才无法下载,但是可以将 https://android.googlesource.com/ 全部使用 https://aosp.tuna.tsinghua.edu.cn/ 代替即可。
- 有一个步骤是repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest 该步骤无法完成的原因是repo这个脚本里面默认使用了google的REPO_URL。解法:vim repo,按照下面内容进行修改:
if not REPO_URL:
REPO_URL = 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
可能的error:
AttributeError: 'str' object has no attribute 'decode'
解决方法:直接去掉代码 decode('utf8')
scripts:
#aosp
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
repo init -u https://aosp.tuna.tsinghua.ed