标签:android4.4 源码 编译 刷机
AOSP ON MAKO(在NEXUS 4上刷ANDROID 4.4 源码包-下载/配置/编译/刷机)
特别感谢google官方文档及AOSP源码开放
参考链接:
https://source.android.com/source/building-devices.html (官方源码刷device)
https://developers.google.com/android/nexus/drivers#makokrt16s (硬件驱动包, 如只是运行模拟器则直接安装即可)
https://developers.google.com/android/nexus/images (官方刷机包-下载image直接刷)
步骤:
1. 下载android 4.4源码包, 由于GFW原因, 通过谷歌官方网站repo下载源码比较难, 所以我选择了国内android牛人innost提供的压缩包. (有10G)
牛人博客: http://blog.csdn.net/innost/article/details/14002899
115网盘下载: http://115.com/lb/5lbcb7joklq
2. 解压到目录, 在这里我解压到 ~/android4.4 (设为ANDROID_HOME)
3. 设置环境变量(编辑~/.bashrc文件,在末尾添加如下三行)
export ANDROID_HOME=~/android4.4
export PATH=$PATH:${ANDROID_HOME}/out/host/linux-x86/bin
export ANDROID_PRODUCT_OUT=${ANDROID_HOME}/out/target/product/mako
4. 下载必须的源码刷手机的驱动文件并配置(一开始我直接lunch选mako, 但最后fastboot -w flashall 时,提示成功, 但手机启动时一直停留在google启动界面上, 后来经多方验证才发现system.image包中少了硬件驱动)
1) 进 https://developers.google.com/android/nexus/drivers 根据手机型号选对应的驱动包, 我的手机是nexus 4, 源码包是android 4.4, 于是进入该链接 https://developers.google.com/android/nexus/drivers#makokrt16s
2) 下载三个驱动包: broadcom-mako-krt16s-f54c9ff9.tgz, lge-mako-krt16s-23ef7d53.tgz, qcom-mako-krt16s-cc4bd932.tgz
3) 解压到源码根目录(也就是~/android4.4)
4) 运行三个解压后的sh文件, 在根目录下会多出vendor目录, 这就是硬件驱动目录
5. 安装编译源码包所需要的一些依赖包(这中间可能会遇到很多问题, 根据错误提示google 一一解决).
参考链接: https://source.android.com/source/building-running.html
6. 编译生成adb和fastboot命令: make fastboot adb (adb 用于进入 fastboot刷机模式, fastboot用于刷image进手机. 当然也可以手动进入刷机模式, 此步可跳过)
7. 配置刷机前环境变量并编译生成image
1) 打开终端, 进入源码根目录
2) 导入编译android环境变量: source build/envsetup.sh (主要是让终端找到命令位置)
3) 设置编译缓存大小: prebuilts/misc/linux-x86/ccache/ccache -M 50G
4) 选择编译终端类型: lunch full_mako-userdebug (注意: 直接lunch 是没有 full_mako-userdebug选项的, 我是按照谷歌官方文档直接运行该命令的)
5) 编译源码: make -j16 (根据机器CPU核数选择是16还是8等, 我总共花了28分钟)
8. 正式刷机
1) 进入刷机模式: adb reboot bootloader
2) 刷image进手机: fastboot -w flashall (注意: 这里可能会出现waiting for device, 并一直停留在这里, 后来我发现运行该命令需要根用户权限, 于是就su root, 切换到根用户环境下, 同时再次配置相关变量后, 再次运行fastboot -w flashall, 命令运行成功, 哈哈...)
下面是日志和截图:
--------------------------------------------
Bootloader Version...: MAKOZ30d
Baseband Version.....: M9615A-CEFWMAZM-2.0.1700.98
Serial Number........: 017cf480db62e55e
--------------------------------------------
checking product...
OKAY [ 0.002s]
sending ‘boot‘ (6340 KB)...
OKAY [ 0.204s]
writing ‘boot‘...
OKAY [ 0.351s]
sending ‘recovery‘ (6886 KB)...
OKAY [ 0.221s]
writing ‘recovery‘...
OKAY [ 0.418s]
erasing ‘system‘...
OKAY [ 0.676s]
sending ‘system‘ (295871 KB)...
OKAY [ 9.358s]
writing ‘system‘...
OKAY [ 19.851s]
erasing ‘userdata‘...
OKAY [ 1.960s]
formatting ‘userdata‘ partition...
Creating filesystem with parameters:
Size: 6189744128
Block size: 4096
Blocks per group: 32768
Inodes per group: 8048
Inode size: 256
Journal blocks: 23612
Label:
Blocks: 1511168
Block groups: 47
Reserved block group size: 375
Created filesystem with 11/378256 inodes and 50366/1511168 blocks
sending ‘userdata‘ (98413 KB)...
writing ‘userdata‘...
OKAY [ 8.988s]
erasing ‘cache‘...
OKAY [ 0.051s]
formatting ‘cache‘ partition...
Creating filesystem with parameters:
Size: 587202560
Block size: 4096
Blocks per group: 32768
Inodes per group: 7168
Inode size: 256
Journal blocks: 2240
Label:
Blocks: 143360
Block groups: 5
Reserved block group size: 39
Created filesystem with 11/35840 inodes and 4616/143360 blocks
sending ‘cache‘ (10984 KB)...
writing ‘cache‘...
OKAY [ 1.022s]
rebooting...
AOSP ON MAKO(在NEXUS 4上刷ANDROID 4.4 源码包-下载/配置/编译/刷机),布布扣,bubuko.com
AOSP ON MAKO(在NEXUS 4上刷ANDROID 4.4 源码包-下载/配置/编译/刷机)
标签:android4.4 源码 编译 刷机
原文地址:http://blog.csdn.net/lxxgreat/article/details/37064633