Android system source code download and compile, Brush MACHINE--NEXUS6 measurement

Source: Internet
Author: User
<span id="Label3"></p>Objective<p><p>This blog post records the entire process of Android downloading from the system source to the brush machine.</p></p><p><p>(https://source.android.com/source/build-numbers.html Page list information to find their own device corresponding to the Android version to choose, blog post Select MOB301)</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs scss"><span class="hljs-function">Nexus6(<span class="hljs-string">"shamu"</span>)</span>Android系统:选择了Android官网上的MOB301对应的android-6<span class="hljs-class">.0</span><span class="hljs-class">.1_r42</span>驱动:自然就是MOB301_Nexus6对应的驱动了编译系统:Ubuntu14<span class="hljs-class">.0</span><span class="hljs-class">.4</span></code></pre></pre><p><p>PS: a little Wordy ~</p></p><pre><pre><code> 我们知道仅仅看代码,提高是比较有限的,而且理解起来也比较肤浅,往往过目就忘. 而自己写过的代码,往往会印象比较深刻,在写的时候也会比较容易理解流程. 所以我们在看代码的同时, 如果能修改代码, 在手机上跑起来并看到修改的效果,这无疑会加快看代码的效率和积极性. 所以这篇文章,就讲解一下如何自己编译Android M的源码,并且在Nexus 6上跑起来. 至于为何需要自己编译固件,而不是直接安装Google给出的工厂固件?原因是Google给出的工厂固件是User版本,是没法随心所欲Push东西进去的. 所以我们需要编译自己的Userdebug版本. 另外你需要知道AOSP,AOSP即Android Open Source Project 汉语意思是:谷歌开放源代码项目.我们通过Google官方下载的源代码,就是AOSP的代码, 其中是不包含Google开发的那些个应用的,各个厂商拿到的也是这个版本,在这个版本的基础上进行修改. 而Google发布的工厂固件则是包含全套Google服务的. 厂商如果想安装Google服务,就需要过Google的那一套认证,比较麻烦,而且价格不菲,鉴于Google在国内的尴尬地位,国内很多厂商都没有过这个认证. 因此有人会说刷出来的ROM和Google发布的user版本的ROM看起来界面不一致的原因就在于此。</code></pre></pre>Body<p><p>Let's start by knowing a few points first:<br>1. What is the phone model on hand?<br>Is there a system source code and driver to support the phone on the 2.Android website?</p></p><p><p><strong>This article takes Nexus 6 as an example, and the following content is no longer duplicated.</strong></p></p><p><p><strong>Ubuntu Compilation Environment Configuration</strong></p></p><p><p>This article is based on the Android system, so do not write about VirtualBox Ubuntu14.04 content (online search, a bunch of information)</p></p><p><p>After the Ubuntu system is installed, we execute it under the command window:</p></p><p><p>1. Download the compilation-related components by executing the following command:</p></p><pre class="prettyprint"><code class=" hljs lasso">sudo apt<span class="hljs-attribute"><span class="hljs-attribute">-get</span></span>Install Flex Bison GPERF Build<span class="hljs-attribute"><span class="hljs-attribute">-essential</span></span>Curl ZLIB1G<span class="hljs-attribute"><span class="hljs-attribute">-dev</span></span>G<span class="hljs-subst"><span class="hljs-subst">++-</span></span>Multilib g<span class="hljs-subst"><span class="hljs-subst">++-</span></span><span class="hljs-number"><span class="hljs-number">4.4</span></span><span class="hljs-attribute"><span class="hljs-attribute">-multilib</span></span>Libc6<span class="hljs-attribute"><span class="hljs-attribute">-dev</span></span><span class="hljs-attribute"><span class="hljs-attribute">-i386</span></span>Lib32ncurses5<span class="hljs-attribute"><span class="hljs-attribute">-dev</span></span>LIB32Z1 lib32ncurses5 lib32bz2<span class="hljs-subst"><span class="hljs-subst">-</span></span><span class="hljs-number"><span class="hljs-number">1.0</span></span>X11proto<span class="hljs-attribute"><span class="hljs-attribute">-core</span></span><span class="hljs-attribute"><span class="hljs-attribute">-dev</span></span>Libx11<span class="hljs-attribute"><span class="hljs-attribute">-dev</span></span>Lib32readline<span class="hljs-attribute"><span class="hljs-attribute">-gplv2</span></span><span class="hljs-attribute"><span class="hljs-attribute">-dev</span></span>Lib32z1<span class="hljs-attribute"><span class="hljs-attribute">-dev</span></span>Mingw32 LIBXML2<span class="hljs-attribute"><span class="hljs-attribute">-utils</span></span>GnuPG zip Xsltproc python<span class="hljs-attribute"><span class="hljs-attribute">-markdown</span></span>Wine Tofrodos</code></pre><p><p>2.java Environment Configuration (1.7)<br>Switch ubuntu to 163 source, download and install openjdk-7 related JRE and JDK<br>sudo apt-get install corresponding OPENJDK component name</p></p><p><p><strong>Android system source code download and drive SH script download</strong></p></p><p><p>1.Android system source code download (the Next steps are best done based on the flip Wall)</p></p><p><p>This section can also refer to the Andorid official website Introduction (HTTP://SOURCE.ANDROID.COM/SOURCE/DOWNLOADING.HTML)</p></p><p><p>(1). Install the command line mode to work with the file Transfer tool Curl.</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs bash"><span class="hljs-built_in">sudo</span> apt-get install curl</code></pre></pre><p><p>(2). Open Source Distributed version control system git (android project using git management).</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs bash"><span class="hljs-built_in">sudo</span> apt-get install git</code></pre></pre><p><p>(3). Install the Repo command-line tool (repo is a google-developed tool to better manage Android projects based on Git)</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs perl"><span class="hljs-keyword">mkdir</span> ~<span class="hljs-regexp">/binPATH=~/bin</span>:<span class="hljs-variable">$PATH</span>curl http:<span class="hljs-regexp">//commondatastorage</span>.googleapis.com/git-repo-downloads/repo > ~<span class="hljs-regexp">/bin/repo</span><span class="hljs-keyword">chmod</span> a+<span class="hljs-keyword">x</span> ~<span class="hljs-regexp">/bin/repo</span></code></pre></pre><p><p>(4). Initializing the Repo client</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs livecodeserver"><span class="hljs-keyword">https</span>://android.googlesource.com/<span class="hljs-built_in">platform</span>/manifest -b 你所要选择的android系统对应的Branch (MOB301对应android-<span class="hljs-number">6.0</span><span class="hljs-number">.1</span><span class="hljs-keyword">https</span>://android.googlesource.com/<span class="hljs-built_in">platform</span>/manifest -b android-<span class="hljs-number">6.0</span><span class="hljs-number">.1</span>_r42</code></pre></pre><p><p>List of branch in: Http://source.android.com/source/build-numbers.html#source-code-tags-and-builds Web site to see related list information<br></p></p><p><p>(5). download Android source code</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs ">repo sync</code></pre></pre><p><p>After the execution into a long wait, the system probably has more than 20 g to download, so you can put the download at night (remember to be in the wall can access the network state yo ~)</p></p><p><p>When You're done, It's ready.<br></p></p><p><p><strong>(PS: this time there is a folder in the Android Directory. repo, This folder probably takes up 30G of space, assuming you do not need to update the system later, then this folder can be Deleted)</strong></p></p><p><p></p></p><p><p><strong>Locate the appropriate driver SH script in the device driver page and download</strong><br>Nexus Driver Page: Https://developers.google.com/android/nexus/drivers</p></p><p><p></p></p><p><p>After downloading the three compressed packages, extract the three sh files.<br>Copy the three SH files to the Android compilation Directory.</p></p><p><p></p></p><p><p>Executing these 3 sh files will download the relevant driver files to the vendor directory</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs lasso"><span class="hljs-built_in">.</span>/extract<span class="hljs-attribute">-broadcom</span><span class="hljs-attribute">-shamu</span><span class="hljs-built_in">.</span>sh<span class="hljs-built_in">.</span>/extract<span class="hljs-attribute">-moto</span><span class="hljs-attribute">-shamu</span><span class="hljs-built_in">.</span>sh<span class="hljs-built_in">.</span>/extract<span class="hljs-attribute">-qcom</span><span class="hljs-attribute">-shamu</span><span class="hljs-built_in">.</span>sh</code></pre></pre><p><p>The process will let us look at some of the statement information, after reading the input I accept can:<br></p></p><p><p><strong>Compiling Android system</strong></p></p><p><p>(1). Environment Initialization</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs bash"><span class="hljs-built_in">source</span> build/envsetup.sh</code></pre></pre><p><p>After execution, some files are included:</p></p><pre class="prettyprint"><code class=" hljs avrasm">[email protected]:~/android$ Source./build/envsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/asus/deb/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/asus/flo/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/asus/fugu/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/generic/mini-emulator-arm64/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/generic/mini-emulator-armv7-a-neon/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/generic/mini-emulator-mips/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/generic/mini-emulator-x86_64/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/generic/mini-emulator-x86/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/htc/flounder/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/huawei/angler/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/lge/bullhead/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/lge/hammerhead/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including Device/moto/shamu/vendorsetup<span class="hljs-preprocessor"><span class="hljs-preprocessor">. SH</span></span>including SDK/BASH_COMPLETION/ADB<span class="hljs-preprocessor"><span class="hljs-preprocessor">. Bash</span></span></code></pre><p><p>(2) Lunch Select the type to build</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs ">lunch</code></pre></pre><p><p>After the command is executed, the build type that is currently available for selection is listed, corresponding to the one you want</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs ruby">panghu<span class="hljs-variable">@panghu</span><span class="hljs-symbol">:~/Android</span><span class="hljs-variable">$ </span>lunch<span class="hljs-constant">You</span><span class="hljs-string">‘re building on LinuxLunch 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_deb-userdebug 8. aosp_flo-userdebug 9. full_fugu-userdebug 10. aosp_fugu-userdebug 11. mini_emulator_arm64-userdebug 12. m_e_arm-userdebug 13. mini_emulator_mips-userdebug 14. mini_emulator_x86_64-userdebug 15. mini_emulator_x86-userdebug 16. aosp_flounder-userdebug 17. aosp_angler-userdebug 18. aosp_bullhead-userdebug 19. aosp_hammerhead-userdebug 20. aosp_hammerhead_fp-userdebug 21. aosp_shamu-userdebugWhich would you like? [aosp_arm-eng] 21 </span></code></pre></pre><p><p></p></p><p><p><strong>Model Comparison</strong><br></p></p><p><p>(3) Start compiling</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs lasso"><span class="hljs-attribute">-j8</span></code></pre></pre><p><p>Wait for compilation to end ... Ash is often long. the machine is good about 1-2 hours, the machine is bad, that acid cool ...!!!!!</p></p><p><p>After compiling, you will be prompted as Follows:<br># # # #make completed successfully # # #</p></p><p><p><strong>Brush Machine</strong></p></p><p><p>NEXUS6 off, Press and hold the volume down + power, Enter recovery mode</p></p><p><p>then, under the source root directory (android root), execute the following command:</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs lasso"><span class="hljs-attribute">-w</span> flashall</code></pre></pre><p><p>If you are prompted:< waiting for device >, prove that your virtual machine VirtualBox does not recognize your phone, can be in the VirtualBox menu, "device", "assign USB device", Select the device name that corresponds to your phone.</p></p><pre class="prettyprint"><code class=" hljs r">[email protected]:~/android$ fastboot-w flashall< waiting<span class="hljs-keyword"><span class="hljs-keyword"></span> for</span>Device >target reported max download size of<span class="hljs-number"><span class="hljs-number">536870912</span></span>bytescreating filesystem with Parameters:size:<span class="hljs-number"><span class="hljs-number">28474998784</span></span>Block size:<span class="hljs-number"><span class="hljs-number">4096</span></span>Blocks per group:<span class="hljs-number"><span class="hljs-number">32768</span></span>Inodes per group:<span class="hljs-number"><span class="hljs-number">8160</span></span>Inode size:<span class="hljs-number"><span class="hljs-number"></span> the</span>Journal blocks:<span class="hljs-number"><span class="hljs-number">32768</span></span>Label:blocks:<span class="hljs-number"><span class="hljs-number">6951904</span></span>Block groups:<span class="hljs-number"><span class="hljs-number">213</span></span>Reserved Block Group Size:<span class="hljs-number"><span class="hljs-number">1024x768</span></span>Created filesystem with<span class="hljs-number"><span class="hljs-number"></span> one</span>/<span class="hljs-number"><span class="hljs-number">1738080</span></span>Inodes and<span class="hljs-number"><span class="hljs-number">153124</span></span>/<span class="hljs-number"><span class="hljs-number">6951904</span></span>blockscreating filesystem with Parameters:size:<span class="hljs-number"><span class="hljs-number">268435456</span></span>Block size:<span class="hljs-number"><span class="hljs-number">4096</span></span>Blocks per group:<span class="hljs-number"><span class="hljs-number">32768</span></span>Inodes per group:<span class="hljs-number"><span class="hljs-number">8192</span></span>Inode size:<span class="hljs-number"><span class="hljs-number"></span> the</span>Journal blocks:<span class="hljs-number"><span class="hljs-number">1024x768</span></span>Label:blocks:<span class="hljs-number"><span class="hljs-number">65536</span></span>Block groups:<span class="hljs-number"><span class="hljs-number">2</span></span>Reserved Block Group Size:<span class="hljs-number"><span class="hljs-number"></span> the</span>Created filesystem with<span class="hljs-number"><span class="hljs-number"></span> one</span>/<span class="hljs-number"><span class="hljs-number">16384</span></span>Inodes and<span class="hljs-number"><span class="hljs-number">2089</span></span>/<span class="hljs-number"><span class="hljs-number">65536</span></span>Blocks--------------------------------------------Bootloader Version ...: moto-apq8084-<span class="hljs-number"><span class="hljs-number">71.18</span></span>Baseband Version ...: d4.01-<span class="hljs-number"><span class="hljs-number">9625</span></span>-<span class="hljs-number"><span class="hljs-number">05.34</span></span>+fsg-<span class="hljs-number"><span class="hljs-number">9625</span></span>-<span class="hljs-number"><span class="hljs-number">02.111</span></span>Serial number ....: zy222wqn82--------------------------------------------checking product ... OKAY [<span class="hljs-number"><span class="hljs-number">0.</span></span>004s]sending<span class="hljs-string"><span class="hljs-string">' Boot '</span></span>(<span class="hljs-number"><span class="hljs-number">8201</span></span>KB)<span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">1.</span></span>291s]writing<span class="hljs-string"><span class="hljs-string">' Boot '</span></span><span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">0.</span></span>153s]sending<span class="hljs-string"><span class="hljs-string">' recovery '</span></span>(<span class="hljs-number"><span class="hljs-number">8917</span></span>KB)<span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">1.</span></span>403s]writing<span class="hljs-string"><span class="hljs-string">' recovery '</span></span><span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">0.</span></span>126s]sending Sparse<span class="hljs-string"><span class="hljs-string">' System '</span></span>(<span class="hljs-number"><span class="hljs-number">516549</span></span>KB)<span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">.</span></span>029s]writing<span class="hljs-string"><span class="hljs-string">' System '</span></span><span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">7.</span></span>818s]sending Sparse<span class="hljs-string"><span class="hljs-string">' System '</span></span>(<span class="hljs-number"><span class="hljs-number">137398</span></span>KB)<span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">.</span></span>156s]writing<span class="hljs-string"><span class="hljs-string">' System '</span></span><span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">2.</span></span>137s]erasing<span class="hljs-string"><span class="hljs-string">' UserData '</span></span><span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">2.</span></span>898s]sending<span class="hljs-string"><span class="hljs-string">' UserData '</span></span>(<span class="hljs-number"><span class="hljs-number">139061</span></span>KB)<span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">.</span></span>777s]writing<span class="hljs-string"><span class="hljs-string">' UserData '</span></span><span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">2.</span></span>672s]erasing<span class="hljs-string"><span class="hljs-string">' Cache '</span></span><span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">0.</span></span>045s]sending<span class="hljs-string"><span class="hljs-string">' Cache '</span></span>(<span class="hljs-number"><span class="hljs-number">6248</span></span>KB)<span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">0.</span></span>983s]writing<span class="hljs-string"><span class="hljs-string">' Cache '</span></span><span class="hljs-keyword"><span class="hljs-keyword">...</span></span>OKAY [<span class="hljs-number"><span class="hljs-number">0.</span></span>107s]rebooting...finished. Total Time:<span class="hljs-number"><span class="hljs-number">149.</span></span>323s</code></pre>Conclusion<p><p>OK, so far, android system download, compile, The brush machine is all over, you can start your own Android system customization Tour. (PS: after the original is finished, it is recommended to try to get cm system, cm did some optimization, feel better!) )</p></p> <p><p>Android system source code download and compile, Brush MACHINE--NEXUS6 measurement</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.