由于国内访问不到GOOGLE的源,故我们使用清华的源,下面是相关操作:
1、下载REPO工具
mkdir ~/repo_tool
cd ~/repo_tool
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
2、同步源码
mkdir ~/nexus6_aosp_android7.1.1
cd ~/nexus6_aosp_android7.1.1
~/repo_tool/repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-7.1.1_r57
~/repo_tool/repo sync
代码同步过程中可能出现失败,需要多次重复同步直至同步成功,可以创建脚本文件sync_aosp.sh,内容如下:
#!/bin/bash
cd ~/nexus6_aosp_android7.1.1
while true; do
~/repo_tool/repo sync
done
保存后,只需要执行该脚本,就会同步出错中止后继续同步了,我这边测试是同步一晚上就全步同步完成了。
3、打上NEXUS6专项PATCH
打开https://developers.google.cn/android/drivers#anglern2g47w网站,找到如下项:

将上面三项内容全部点击Link后下载,下载后有3个压缩包,解压后有如下3个文件:
extract-broadcom-shamu.sh
extract-moto-shamu.sh
extract-qcom-shamu.sh
将上面这三个脚本文件复制到我们下载下来的AOSP源码根目录下,并且在AOSP源码根目录下分别执行如下命令:
./extract-broadcom-shamu.sh
./extract-moto-shamu.sh
./extract-qcom-shamu.sh
4、编译源码
在编译源码前是需要配置Ubuntu的编译环境,安装相关工具,该部分网上资料非常多,就不介绍,下面直接说编译的命令:
cd ~/nexus6_aosp_android7.1.1
source build/envsetup.sh
lunch aosp_shamu-userdebug
make -j8
5、烧录
编译完成代码后,就通过fastboot来烧录刷机:
首先将NEXUS6手机连接到Ubuntu电脑上,并且在手机上启用ADB调试功能,然后在Ubuntu电脑上执行如下命令:
adb reboot bootloader
执行该命令后,NEXUS6手机会重启进入fastboot模式,此时在Ubuntu电脑上执行如下命令(该命令在同步的AOSP源码根目录下执行):
fastboot flashall -w
烧录完成后,手机会重启,然后就能看到AOSP界面了。
6、参考资料:
https://mirrors.tuna.tsinghua.edu.cn/help/git-repo/
https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
https://www.cnblogs.com/common1140/p/9508293.html
网友评论