admin管理员组文章数量:1659744
本文博客地址:http://blog.csdn/qq1084283172/article/details/54562606
网上关于编译Android源码的教程已经很多了,但是讲怎么编译Android源码刷到真机上的教程不是很多并且也没有讲清楚,仅仅编译Android源码不部署到真机上折腾一下是不愉快的。在Android安全学习的过程不免涉及到修改Android源码过各种对抗的事情,今天有空来学习一下如何编译Android源码部署到谷歌的Nexus 5 手机上,以Android 4.4.4 r1的源码为例子,在Ubuntu 14.04.5版本系统上编译Android 4.4.4 r1 的镜像文件刷到Nexus 5手机上。
一、获取Android源码对应的驱动设备
1.)从谷歌网址 https://source.android/source/build-numbers.html 知道 Android 4.4.4 r1 源码编译成功后的镜像文件的编号为 KTU84P。
2.)通过获取到的Android 4.4.4 r1源码的编号 KTU84P ,在谷歌网址 https://developers.google/android/drivers 上,查询到编号 KTU84P 对应的Nexus 5设备刷机需要的驱动设备文件的下载地址 https://developers.google/android/drivers#hammerheadktu84p 。
Nexus 5 (GSM/LTE) binaries for Android 4.4.4 (KTU84P)
Hardware Component | Company | Download | SHA-256 Checksum |
---|---|---|---|
NFC, Bluetooth, Wi-Fi | Broadcom | Link | f258605e24c9c3d4e78c9af934f3516a4f8d3410da697005fad42cad36c5ed5c |
Camera, Sensors, Audio | LG | Link | fc72704e0fba9c51c6505ae009e474570de27ee8565d51483368d8dae6c0f44e |
Graphics, GSM, Camera, GPS, Sensors, Media, DSP, USB | Qualcomm | Link | 8603d85ad511346d65c27c3747919da280523b86d55a39dfce657a4ca1b0685b |
通过上面的下载链接下载到编号 KTU84P 对应的Nexus 5的驱动文件 broadcom-hammerhead-ktu84p-5a5bf60e.tgz、lge-hammerhead-ktu84p-49419c39.tgz、qcom-hammerhead-ktu84p-f159eadf.tgz,将这3个文件解压到Android 4.4.4 r1源码的根目录下,其实该怎么使用这些驱动文件,在谷歌官方网址 https://source.android/source/building.html 中已经提到并说的很清楚了。
Obtain proprietary binaries
AOSP cannot be used from pure source code only and requires additional hardware-related proprietary libraries to run, such as for hardware graphics acceleration. See the sections below for download links and Device binaries requirements for additional resources.
Download proprietary binaries
You can download official binaries for the supported devices running tagged AOSP release branches from Google's Nexus driver page. These binaries add access to additional hardware capabilities with non-open source code. To instead build the AOSP master branch, use the Binaries Preview for Nexus Devices. When building the master branch for a device, use the binaries for themost recent numbered release or with the most recent date.
Extract proprietary binaries
Each set of binaries comes as aself-extracting script in a compressed archive.Uncompress each archive,run the included self-extracting script from the root of the source tree, thenconfirm that you agree to the terms of the enclosed license agreement.The binaries and their matching makefiles will be installed in the vendor/
hierarchy of the source tree
3.)解压下载的驱动文件 broadcom-hammerhead-ktu84p-5a5bf60e.tgz、lge-hammerhead-ktu84p-49419c39.tgz、qcom-hammerhead-ktu84p-f159eadf.tgz 到Android 4.4.4 r1源码的根目录下得到3个.sh的脚本文件。
4.)先 sudo chmod u+x 赋予3个脚本以可执行权限,然后执行3个脚本文件;在脚本的执行过程中需要同意相关的协议,按照执行的提示在协议的结束位置输入 I ACCEPT 即可完成脚本的运行。
5.)3个驱动相关的脚本文件执行解压缩成功,会在Android 4.4.4 r1源码的根目录下创建 vendor 文件,将编译需要的驱动文件释放到 vendor 文件中。
驱动文件释放成功以后的截图:
二、Android源码的编译
1.)关于Android源码编译环境的配置,可以参考谷歌官方的链接:https://source.android/source/initializing.html 和 https://source.android/source/requirements.html 进行操作也可以参考前面的博客 ubuntu 14.04.5 编译Android 4.4.4 r1源码(最新) 的步骤进行Android源码编译环境的配置也可以参考其他大牛的博客。不想走弯路,最好还是按照google官方的说明文档来进行配置操作。
2.)Android 4.4.4 r1源码的编译步骤按照google官方的操作来
Android源码编译的步骤可以参考谷歌官方的文档:https://source.android/source/building.html 。
Clean up
To ensure the newly installed binaries are properly taken into account after being extracted, delete the existing output of any previous build using:
$ make clobber
注意:这一步一定要,否则在后面的源码编译中就会掉坑里爬不起来;具体的错误,后面我会单独拿出来说。
Set up environment
Initialize the environment with the envsetup.sh
script. Note that replacing source
with .
(a single dot) saves a few characters, and the short form is more commonly used in documentation.
$ source build/envsetup.sh
or
$ . build/envsetup.sh
Choose a target
Choose which target to build with lunch
. The exact configuration can be passed as an argument. For example, the following command:
$ lunch aosp_arm-eng
refers to a complete buildfor the emulator, with all debugging enabled.
If run with no arguments lunch
will prompt you to choose a target from the menu.
All build targets take the form BUILD-BUILDTYPE
, where the BUILD
isa codename referring to the particular feature combination.
The BUILDTYPE is one of the following:
Buildtype | Use |
---|---|
user | limited access; suited for production |
userdebug | like "user" but with root access and debuggability; preferred for debugging |
eng | development configuration with additional debugging tools |
For more information about building for and running on actual hardware, see Running Builds.
基于Nexus 5手机的机型考虑,lunch 9 选择 编译类型为 aosp_hammerhead-userdebug ,为什么选择该编译类型呢?可以参考google官方文档 https://source.android/source/running.html 给出的说明。
Selecting a device build
The recommended builds for devices are available from the lunch menu, accessed when running the lunch
command with no arguments. You can download factory images and binaries for Nexus devices from developers.google:
- Preview binaries (blobs)
- Factory images for released devices
- Support binaries (drivers) for release devices
See Obtaining proprietary binaries for more details and Device binaries requirements for other resources.
Device | Code name | Build configuration |
---|---|---|
HiKey | hikey | hikey-userdebug |
Nexus 6P | angler | aosp_angler-userdebug |
Nexus 5X | bullhead | aosp_bullhead-userdebug |
Nexus 6 | shamu | aosp_shamu-userdebug |
Nexus Player | fugu | aosp_fugu-userdebug |
Nexus 9 | volantis (flounder) | aosp_flounder-userdebug |
Nexus 5 (GSM/LTE) | hammerhead | aosp_hammerhead-userdebug |
Nexus 7 (Wi-Fi) | razor (flo) | aosp_flo-userdebug |
Nexus 7 (Mobile) | razorg (deb) | aosp_deb-userdebug |
Nexus 10 | mantaray (manta) | full_manta-userdebug |
Nexus 4 | occam (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) | panda | aosp_panda-userdebug |
Motorola Xoom (U.S. Wi-Fi) | wingray | full_wingray-userdebug |
Nexus S | soju (crespo) | full_crespo-userdebug |
Nexus S 4G | sojus (crespo4g) | full_crespo4g-userdebug |
Note: Do not use Android 4.1.1 on a Nexus 7 originally sold with Android 4.1.2 or newer.
选择 Android 4.4.4 r1 源码编译的类型为 aosp_hamme
版权声明:本文标题:编译Android 4.4.4 r1的源码刷Nexus 5手机详细教程 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1729838149a1214551.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论