Nexus5编译AndroidL固件

MrLee2015-2-12 4685

我们知道,仅仅看代码,提高是比较有限的,而且理解起来也比较肤浅,往往过目就忘. 而自己写过的代码,往往会印象比较深刻,在写的时候也会比较容易理解流程. 所以我们在看代码的同时, 如果能修改代码, 在手机上跑起来并看到修改的效果,这无疑会加快看代码的效率和积极性. 所以这篇文章,就讲解一下如何自己编译AndroidL的源码,并且在Nexus5上跑起来. 至于为何需要自己编译固件,而不是直接安装Google给出的工厂固件?原因是Google给出的工厂固件是User版本,是没法随心所欲Push东西进 去的. 所以我们需要编译自己的Userdebug版本.
本文假设你已经下载了AndroidL的源码,并且有一台Nexus5手机(手机系统开发人员必备), 如果你还没有AndroidL的源码,或者你有源码但是没有配置编译的环境,那么 Initializing a Build Environment 和Downloading the Source这两篇文章你应该先去看一下(我又一次假设你会翻墙,如果你不会翻墙,那么下代码也是一个痛苦的事情). 这后面的教程Google官网也有教程.所以我只针对Nexus5进行讲解.
另外你需要知道AOSP,AOSP即Android Open Source Project 汉语意思是:谷歌开放源代码项目.我们通过Google官方下载的源代码,就是AOSP的代码, 其中是不包含Google开发的那些个应用的,各个厂商拿到的也是这个版本,在这个版本的基础上进行修改. 而Google发布的工厂固件则是包含全套Google服务的. 厂商如果想安装Google服务,就需要过Google的那一套认证,比较麻烦,而且价格不菲,鉴于Google在国内的尴尬地位,国内很多厂商都没有过 这个认证.

1. 初始化编译环境

. build/envsetup.sh

2. 加载机型

lunch

3. 选择要编译的机器

You're building on Linux
 
Lunch menu... pick a combo:
     1. aosp_arm-eng
     2. aosp_arm64-eng
     3. aosp_mips-eng
     4. aosp_mips64-eng
     5. aosp_x86-eng
     6. aosp_x86_64-eng
     7. aosp_shamu-userdebug
     8. aosp_manta-userdebug
     9. full_fugu-userdebug
     10. aosp_fugu-userdebug
     11. aosp_grouper-userdebug
     12. aosp_tilapia-userdebug
     13. aosp_deb-userdebug
     14. aosp_flo-userdebug
     15. aosp_mako-userdebug
     16. aosp_hammerhead-userdebug
     17. aosp_flounder-userdebug
     18. mini_emulator_x86_64-userdebug
     19. mini_emulator_arm-userdebug
     20. mini_emulator_x86-userdebug
     21. mini_emulator_mips-userdebug
     22. mini_emulator_arm64-userdebug

3.1 机型对照表

DeviceCode nameBuild configuration
Nexus 6shamuaosp_shamu-userdebug
Nexus Playerfuguaosp_fugu-userdebug
Nexus 9volantis (flounder)aosp_flounder-userdebug
Nexus 5 (GSM/LTE)hammerheadaosp_hammerhead-userdebug
Nexus 7 (Wi-Fi)razor (flo)aosp_flo-userdebug
Nexus 7 (Mobile)razorg (deb)aosp_deb-userdebug
Nexus 10mantaray (manta)full_manta-userdebug
Nexus 4occam (mako)full_mako-userdebug
Nexus 7 (Wi-Fi)nakasi (grouper)full_grouper-userdebug
Nexus 7 (Mobile)nakasig (tilapia)full_tilapia-userdebug
Galaxy Nexus (GSM/HSPA+)yakju (maguro)full_maguro-userdebug
Galaxy Nexus (Verizon)mysid (toro)aosp_toro-userdebug
Galaxy Nexus (Experimental)mysidspr (toroplus)aosp_toroplus-userdebug
PandaBoard (Archived)pandaaosp_panda-userdebug
Motorola Xoom (U.S. Wi-Fi)wingrayfull_wingray-userdebug
Nexus Ssoju (crespo)full_crespo-userdebug
Nexus S 4Gsojus (crespo4g)full_crespo4g-userdebug

3.2 三个版本说明版本

BuildtypeUse
userlimited access; suited for production
userdebuglike “user” but with root access and debuggability; preferred for debugging
engdevelopment configuration with additional debugging tools
选择aosp_hammerhead-userdebug之后,会有下面的确认信息:
============================================PLATFORM_VERSION_CODENAME=RELPLATFORM_VERSION=5.0.50.50.50.50TARGET_PRODUCT=aosp_hammerheadTARGET_BUILD_VARIANT=userdebugTARGET_BUILD_TYPE=releaseTARGET_BUILD_APPS=TARGET_ARCH=armTARGET_ARCH_VARIANT=armv7-a-neonTARGET_CPU_VARIANT=kraitTARGET_2ND_ARCH=TARGET_2ND_ARCH_VARIANT=TARGET_2ND_CPU_VARIANT=HOST_ARCH=x86_64HOST_OS=linuxHOST_OS_EXTRA=Linux-3.13.0-37-generic-x86_64-with-Ubuntu-14.10-utopicHOST_BUILD_TYPE=releaseBUILD_ID=AOSPOUT_DIR=out============================================

4.生成驱动目录

接下来需要在Android官网下载 Nexus5所需要的驱动:
Hardware ComponentCompanyDownloadMD5 ChecksumSHA-1 Checksum
NFC, Bluetooth, Wi-FiBroadcomLink2c398994e37093df51b105d63f0eb611991346159c95ae75f760014a6822b8b3e8667700
Camera, Sensors, AudioLGLink74cf8235e6bb04da28b2ff738b13eee9175dd5bae81bb54030d072cb0f0b4ec81eb3f71f
Graphics, GSM, Camera, GPS, Sensors, Media, DSP, USBQualcommLink0a43395e175d3de3dc312d8abdcb4f20007cf9d49f0409d5c703e7f2811fd153fee22353
下载完成后,解压出来是三个.sh文件,放到Android源码目录下面,然后执行.会将相关驱动放到vender目录下面.

5. 执行编译命令

make -j8
如果没有出错的话,在经过漫长的时间之后,编译成功:

6. 刷机命令

Nexus5关机状态下,长按音量下+电源,即可进入recovery模式, 然后在源码根目录下执行下面命令:fastboot -w flashall
刷机成功后会自动重启

1423498746620690


~/Android-SourceCode fastboot -w flashalltarget reported max download size of 1073741824 bytesCreating filesystem with parameters:Size: 13725835264Block size: 4096Blocks per group: 32768Inodes per group: 8144Inode size: 256Journal blocks: 32768Label:Blocks: 3351034Block groups: 103Reserved block group size: 823Created filesystem with 11/838832 inodes and 93654/3351034 blocksCreating filesystem with parameters:Size: 734003200Block size: 4096Blocks per group: 32768Inodes per group: 7472Inode size: 256Journal blocks: 2800Label:Blocks: 179200Block groups: 6Reserved block group size: 47Created filesystem with 11/44832 inodes and 5813/179200 blocks--------------------------------------------Bootloader Version...: HHZ12dBaseband Version.....: M8974A-2.0.50.2.22Serial Number........: 08ade1a513dc087b--------------------------------------------checking product...OKAY [  0.100s]sending 'boot' (8950 KB)...OKAY [  0.500s]writing 'boot'...OKAY [  0.784s]sending 'recovery' (9672 KB)...OKAY [  0.556s]writing 'recovery'...OKAY [  0.814s]erasing 'system'...OKAY [  1.166s]sending 'system' (328187 KB)...OKAY [ 10.501s]writing 'system'...OKAY [ 23.623s]erasing 'userdata'...OKAY [ 14.657s]sending 'userdata' (137318 KB)...OKAY [  4.520s]writing 'userdata'...OKAY [  9.776s]erasing 'cache'...OKAY [  0.618s]sending 'cache' (13348 KB)...OKAY [  0.630s]writing 'cache'...OKAY [  1.070s]rebooting...
finished. total time: 70.095s

本文链接:https://it72.com/1005.htm

推荐阅读
最新回复 (0)
    返回