1page.title=Running Builds
2@jd:body
3
4<!--
5    Copyright 2015 The Android Open Source Project
6
7    Licensed under the Apache License, Version 2.0 (the "License");
8    you may not use this file except in compliance with the License.
9    You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18-->
19<div id="qv-wrapper">
20  <div id="qv">
21    <h2>In this document</h2>
22    <ol id="auto-toc">
23    </ol>
24  </div>
25</div>
26
27<p>This page provides details for running builds on specific devices and is
28designed to complement the information in
29<a href="{@docRoot}source/building.html">Building the System</a>.</p>
30
31<h2 id="building-fastboot-and-adb">Building fastboot and adb</h2>
32<p>If you don't already have fastboot and adb, you can build them with the
33regular build system. Use the instructions in
34<a href="{@docRoot}source/building.html">Building a System</a> and replace the
35main <code>make</code> command with:</p>
36<pre><code>$ make fastboot adb
37</code></pre>
38
39<h2 id="booting-into-fastboot-mode">Booting into fastboot mode</h2>
40<p><em>Fastboot</em> is a bootloader mode in which you can flash a device.
41During a cold boot of a device, use the following key combinations to boot into
42fastboot mode:</p>
43<table>
44<thead>
45<tr>
46<th>Codename</th>
47<th>Device</th>
48<th>Keys</th>
49</tr>
50</thead>
51<tbody>
52<tr>
53<td>marlin</td><td>Pixel XL</td>
54<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
55</tr>
56<tr>
57<td>sailfish</td>
58<td>Pixel</td>
59<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
60</tr>
61<tr>
62<td>hikey</td>
63<td>hikey</td>
64<td>Link pins 1 - 2 and 5 - 6 of J15</td>
65</tr>
66<tr>
67<td>angler</td>
68<td>Nexus 6P</td>
69<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
70</tr>
71<tr>
72<td>bullhead</td>
73<td>Nexus 5X</td>
74<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
75</tr>
76<tr>
77<td>shamu</td>
78<td>Nexus 6</td>
79<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
80</tr>
81<tr>
82<td>fugu</td>
83<td>Nexus Player</td>
84<td>Press and hold <em>Power</em></td>
85</tr>
86<tr>
87<td>volantis</td>
88<td>Nexus 9</td>
89<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
90</tr>
91<tr>
92<td>hammerhead</td>
93<td>Nexus 5</td>
94<td>Press and hold both <em>Volume Up</em> and <em>Volume Down</em>, then press
95and hold <em>Power</em></td>
96</tr>
97<tr>
98<td>flo</td>
99<td>Nexus 7</td>
100<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
101</tr>
102<tr>
103<td>deb</td>
104<td>Nexus 7 3G</td>
105<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
106</tr>
107<tr>
108<td>manta</td>
109<td>Nexus 10</td>
110<td>Press and hold both <em>Volume Up</em> and <em>Volume Down</em>, then press
111and hold <em>Power</em></td>
112</tr>
113<tr>
114<td>mako</td>
115<td>Nexus 4</td>
116<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
117</tr>
118<tr>
119<td>grouper</td>
120<td>Nexus 7 (2012)</td>
121<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
122</tr>
123<tr>
124<td>tilapia</td>
125<td>Nexus 7 3G (2012)</td>
126<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
127</tr>
128<tr>
129<td>phantasm</td>
130<td>Nexus Q</td>
131<td>Power the device, cover it with one hand after the LEDs light up and until
132they turn red</td>
133</tr>
134<tr>
135<td>maguro</td>
136<td>Galaxy Nexus GSM</td>
137<td>Press and hold both <em>Volume Up</em> and <em>Volume Down</em>, then press
138and hold <em>Power</em></td>
139</tr>
140<tr>
141<td>toro</td>
142<td>Galaxy Nexus (Verizon)</td>
143<td>Press and hold both <em>Volume Up</em> and <em>Volume Down</em>, then press
144and hold <em>Power</em></td>
145</tr>
146<tr>
147<td>toroplus</td>
148<td>Galaxy Nexus (Sprint)</td>
149<td>Press and hold both <em>Volume Up</em> and <em>Volume Down</em>, then press
150and hold <em>Power</em></td>
151</tr>
152<tr>
153<td>wingray</td>
154<td>Motorola Xoom</td>
155<td>Press and hold <em>Volume Down</em>, then press and hold <em>Power</em></td>
156</tr>
157<tr>
158<td>crespo</td>
159<td>Nexus S</td>
160<td>Press and hold <em>Volume Up</em>, then press and hold <em>Power</em></td>
161</tr>
162<tr>
163<td>crespo4g</td>
164<td>Nexus SG</td>
165<td>Press and hold <em>Volume Up</em>, then press and hold <em>Power</em></td>
166</tr>
167</tbody>
168</table>
169<p>You can also use the command <code>adb reboot bootloader</code> to reboot
170from Android directly into the bootloader with no key combinations.</p>
171
172<h2 id="unlocking-the-bootloader">Unlocking the bootloader</h2>
173
174<p>You can flash a custom system only if the bootloader allows it, and the
175bootloader is locked by default. You can unlock the bootloader, but doing so
176deletes user data for privacy reasons. After unlocking, <em>all</em> data on the
177device is erased, i.e. both application private data and shared data accessible
178over USB (including photos and movies). Before attempting to unlock the
179bootloader, be sure to back up any important files on the device.</p>
180
181<p>You need to unlock the bootloader only once, and you can re-lock it if
182necessary.</p>
183
184<h3>Unlocking recent devices</h3>
185<p>All Nexus and Pixel devices released since 2014 (starting with Nexus 6 and
186Nexus 9) have factory reset protection and require a multi-step process to
187unlock the bootloader.</p>
188
189<ol>
190<li>Enable OEM unlocking on the device:
191<ol style="list-style-type:lower-alpha">
192<li>In Settings, tap <strong>About phone</strong>, then tap <strong>Build
193number</strong> seven (7) times.</li>
194<li>When you see the message "You are a developer", tap the back button.</li>
195<li>Tap <strong>Developer options</strong> and enable
196<strong>OEM unlocking</strong> and <strong>USB debugging</strong>.
197(If OEM unlocking is disabled, connect to the Internet so the device can check
198in at least once. If it remains disabled, your device may be SIM locked by your
199carrier and the bootloader cannot be unlocked.)</li></ol></li>
200<li>Reboot into the bootloader and use fastboot to unlock it.
201<ul>
202<li>For new devices (2015 and later): <code>$ fastboot flashing unlock</code>
203</li>
204<li>For older devices (2014 and earlier): <code>$ fastboot oem
205unlock</code></li></ul>
206You must confirm the unlock onscreen.</li></ol>
207
208<p class="note"><strong>Note</strong> On Nexus 10, after unlocking the
209bootloader, the internal storage remains unformatted. You can format the device
210using:
211<pre><code>$ fastboot format cache
212$ fastboot format userdata
213</code></pre></p>
214
215<h3 id="relocking-the-bootloader">Re-locking the bootloader</h3>
216<p>To re-lock the bootloader:</p>
217<ul>
218<li>For new devices (2015 and later): <code>$ fastboot flashing lock</code></li>
219<li>For older devices (2014 and earlier): <code>$ fastboot oem lock</code></li>
220</ul>
221
222<p class="note"><strong>Note</strong>: Re-locking the bootloading on a Motorola
223Xoom erases user data (including the shared USB data).</p>
224
225<h2 id="flash-unlock">Using Flash Unlock</h2>
226
227<p>Android 7.0 includes a new system API, <code>getFlashLockState()</code>, to
228transmit bootloader state, as well as the following system API that returns the
229bootloader’s lock status on compliant devices:</p>
230
231<pre>
232PersistentDataBlockManager.getFlashLockState()
233</pre>
234
235<table>
236<tr>
237<th>Return value</th>
238<th>Conditions</th>
239</tr>
240<tr>
241<td><code>FLASH_LOCK_UNKNOWN</code>
242</td>
243<td><p>Returned only by devices upgrading to Android 7.0 that have not supported
244bootloader changes required to get the flash lock status if they support
245flashing lock/unlock capability.</p>
246<p>New Android 7.0 devices must be in either <code>FLASH_LOCK_LOCKED</code> or
247<code>FLASH_LOCK_UNLOCKED</code> state. If a device is upgrading to Android 7.0
248and does not support flashing unlock/lock capability, it should simply return
249<code>FLASH_LOCK_LOCKED</code> state.</p>
250</td>
251</tr>
252<tr>
253<td><code>FLASH_LOCK_LOCKED</code>
254</td>
255<td>Should be returned by any device that does not support flashing
256lock/unlock (i.e. the device is always locked), or any device that does support
257flashing lock/unlock and is in the locked state.
258</td>
259</tr>
260<tr>
261<td><code>FLASH_LOCK_UNLOCKED</code>
262</td>
263<td>Returned by any device that supports flashing lock/unlock and is
264currently in the unlocked state.
265</td>
266</tr>
267</table>
268
269<h3 id="examples-and-source">Examples and source</h3>
270
271<p>AOSP contains a reference implementation that returns a value based on the
272<code>ro.boot.flash.locked</code> boot property. The code lives in the following
273directories:</p>
274
275<pre>
276frameworks/base/services/core/java/com/android/server/PersistentDataBlockService.java
277frameworks/base/core/java/android/service/persistentdata/PersistentDataBlockManager.java
278</pre>
279
280<h3 id="validation">Validation</h3>
281<p>Manufacturers should test the values returned by devices with locked and
282unlocked bootloaders.</p>
283
284<h2 id="selecting-device-build">Selecting a device build</h2>
285
286<p>The recommended builds for devices are available from the lunch menu,
287accessed when running the <code>lunch</code> command with no arguments. You can
288download factory images and binaries for Nexus devices from
289developers.google.com:</p>
290
291<ul>
292<li><a href="https://developers.google.com/android/nexus/blobs-preview">Preview
293binaries (blobs)</a></li>
294<li><a href="https://developers.google.com/android/nexus/images">Factory images
295for released devices</a></li>
296<li><a href="https://developers.google.com/android/nexus/drivers">Support
297binaries (drivers) for release devices</a></li>
298</ul>
299
300<p>For details and additional resources, see
301<a href="building.html#obtaining-proprietary-binaries">Obtaining proprietary
302binaries</a> and <a href="requirements.html#binaries">Device binaries
303requirements</a>.</p>
304
305<table>
306<thead>
307<tr>
308<th>Device</th>
309<th>Code name</th>
310<th>Build configuration</th>
311</tr>
312</thead>
313<tbody>
314<tr>
315<td>Pixel XL</td>
316<td>marlin</td>
317<td>aosp_marlin-userdebug</td>
318</tr>
319<tr>
320<td>Pixel</td>
321<td>sailfish</td>
322<td>aosp_sailfish-userdebug</td>
323</tr>
324<tr>
325<td>HiKey</td>
326<td>hikey</td>
327<td>hikey-userdebug</td>
328</tr>
329<tr>
330<td>Nexus 6P</td>
331<td>angler</td>
332<td>aosp_angler-userdebug</td>
333</tr>
334<tr>
335<td>Nexus 5X</td>
336<td>bullhead</td>
337<td>aosp_bullhead-userdebug</td>
338</tr>
339<tr>
340<td>Nexus 6</td>
341<td>shamu</td>
342<td>aosp_shamu-userdebug</td>
343</tr>
344<tr>
345<td>Nexus Player</td>
346<td>fugu</td>
347<td>aosp_fugu-userdebug</td>
348</tr>
349<tr>
350<td>Nexus 9</td>
351<td>volantis (flounder)</td>
352<td>aosp_flounder-userdebug</td>
353</tr>
354<tr>
355<td>Nexus 5 (GSM/LTE)</td>
356<td>hammerhead</td>
357<td>aosp_hammerhead-userdebug</td>
358</tr>
359<tr>
360<td>Nexus 7 (Wi-Fi)</td>
361<td>razor (flo)</td>
362<td>aosp_flo-userdebug</td>
363</tr>
364<tr>
365<td>Nexus 7 (Mobile)</td>
366<td>razorg (deb)</td>
367<td>aosp_deb-userdebug</td>
368</tr>
369<tr>
370<td>Nexus 10</td>
371<td>mantaray (manta)</td>
372<td>full_manta-userdebug</td>
373</tr>
374<tr>
375<td>Nexus 4</td>
376<td>occam (mako)</td>
377<td>full_mako-userdebug</td>
378</tr>
379<tr>
380<td>Nexus 7 (Wi-Fi)</td>
381<td>nakasi (grouper)</td>
382<td>full_grouper-userdebug</td>
383</tr>
384<tr>
385<td>Nexus 7 (Mobile)</td>
386<td>nakasig (tilapia)</td>
387<td>full_tilapia-userdebug</td>
388</tr>
389<tr>
390<td>Galaxy Nexus (GSM/HSPA+)</td>
391<td>yakju (maguro)</td>
392<td>full_maguro-userdebug</td>
393</tr>
394<tr>
395<td>Galaxy Nexus (Verizon)</td>
396<td>mysid (toro)</td>
397<td>aosp_toro-userdebug</td>
398</tr>
399<tr>
400<td>Galaxy Nexus (Experimental)</td>
401<td>mysidspr (toroplus)</td>
402<td>aosp_toroplus-userdebug</td>
403</tr>
404<tr>
405<td>Motorola Xoom (U.S. Wi-Fi)</td>
406<td>wingray</td>
407<td>full_wingray-userdebug</td>
408</tr>
409<tr>
410<td>Nexus S</td>
411<td>soju (crespo)</td>
412<td>full_crespo-userdebug</td>
413</tr>
414<tr>
415<td>Nexus S 4G</td>
416<td>sojus (crespo4g)</td>
417<td>full_crespo4g-userdebug</td>
418</tr>
419</tbody>
420</table>
421
422<p class="note"><b>Note</b>: Do not use Android 4.1.1 on a Nexus 7 originally
423sold with Android 4.1.2 or newer.</p>
424
425<h2 id="flashing-a-device">Flashing a device</h2>
426
427<p>You can flash an entire Android system in a single command; doing so verifies
428the system being flashed is compatible with the installed bootloader and radio,
429writes the boot, recovery, and system partitions together, then reboots the
430system. Flashing also erases all user data, similarly to <code>fastboot oem
431unlock</code>.</p>
432
433<p>Place the device in fastboot mode either manually by holding the appropriate
434key combination at boot, or from the shell with:</p>
435
436<pre>
437$ adb reboot bootloader
438</pre>
439
440<p>After the device is in fastboot mode, run:</p>
441
442<pre>
443$ fastboot flashall -w
444</pre>
445
446<p>The <code>-w</code> option wipes the <code>/data</code> partition on the
447device; this is useful for your first time flashing a particular device but is
448otherwise unnecessary.</p>
449
450<p class="note"><strong>Note</strong>: Filesystems created via fastboot on
451Motorola Xoom do not function optimally. We recommend re-creating filesystems
452through recovery, using: <code>$ adb reboot recovery</code>. While in recovery,
453open the menu (press Power + Volume Up), wipe the cache partition, then wipe
454data.</p>
455
456
457<h2 id="restoring-devices-to-factory-state">Restoring devices to factory
458state</h2>
459
460<p>Factory images for Nexus 5, Nexus 10, Nexus 4, Nexus Q, Nexus 7, Galaxy Nexus
461(GSM/HSPA+ "yakju" and "takju", and CDMA/LTE "mysid" and "mysidspr"), Nexus S,
462and Nexus S 4G are available from
463<a href="https://developers.google.com/android/nexus/images">Google's factory
464image</a> page.</p>
465
466<p>Factory images for the Motorola Xoom are distributed directly by Motorola.</p>
467