Running Builds

This page provides details for running builds on specific devices and is designed to complement the information in Building the System.

Building fastboot and adb

If you don't already have fastboot and adb, you can build them with the regular build system. Use the instructions in Building a System and replace the main make command with:

$ make fastboot adb

Booting into fastboot mode

Fastboot is a bootloader mode in which you can flash a device. During a cold boot of a device, use the following key combinations to boot into fastboot mode:

Codename Device Keys
marlinPixel XL Press and hold Volume Down, then press and hold Power
sailfish Pixel Press and hold Volume Down, then press and hold Power
hikey hikey Link pins 1 - 2 and 5 - 6 of J15
angler Nexus 6P Press and hold Volume Down, then press and hold Power
bullhead Nexus 5X Press and hold Volume Down, then press and hold Power
shamu Nexus 6 Press and hold Volume Down, then press and hold Power
fugu Nexus Player Press and hold Power
volantis Nexus 9 Press and hold Volume Down, then press and hold Power
hammerhead Nexus 5 Press and hold both Volume Up and Volume Down, then press and hold Power
flo Nexus 7 Press and hold Volume Down, then press and hold Power
deb Nexus 7 3G Press and hold Volume Down, then press and hold Power
manta Nexus 10 Press and hold both Volume Up and Volume Down, then press and hold Power
mako Nexus 4 Press and hold Volume Down, then press and hold Power
grouper Nexus 7 (2012) Press and hold Volume Down, then press and hold Power
tilapia Nexus 7 3G (2012) Press and hold Volume Down, then press and hold Power
phantasm Nexus Q Power the device, cover it with one hand after the LEDs light up and until they turn red
maguro Galaxy Nexus GSM Press and hold both Volume Up and Volume Down, then press and hold Power
toro Galaxy Nexus (Verizon) Press and hold both Volume Up and Volume Down, then press and hold Power
toroplus Galaxy Nexus (Sprint) Press and hold both Volume Up and Volume Down, then press and hold Power
wingray Motorola Xoom Press and hold Volume Down, then press and hold Power
crespo Nexus S Press and hold Volume Up, then press and hold Power
crespo4g Nexus SG Press and hold Volume Up, then press and hold Power

You can also use the command adb reboot bootloader to reboot from Android directly into the bootloader with no key combinations.

Unlocking the bootloader

You can flash a custom system only if the bootloader allows it, and the bootloader is locked by default. You can unlock the bootloader, but doing so deletes user data for privacy reasons. After unlocking, all data on the device is erased, i.e. both application private data and shared data accessible over USB (including photos and movies). Before attempting to unlock the bootloader, be sure to back up any important files on the device.

You need to unlock the bootloader only once, and you can re-lock it if necessary.

Unlocking recent devices

All Nexus and Pixel devices released since 2014 (starting with Nexus 6 and Nexus 9) have factory reset protection and require a multi-step process to unlock the bootloader.

  1. Enable OEM unlocking on the device:
    1. In Settings, tap About phone, then tap Build number seven (7) times.
    2. When you see the message "You are a developer", tap the back button.
    3. Tap Developer options and enable OEM unlocking and USB debugging. (If OEM unlocking is disabled, connect to the Internet so the device can check in at least once. If it remains disabled, your device may be SIM locked by your carrier and the bootloader cannot be unlocked.)
  2. Reboot into the bootloader and use fastboot to unlock it.
    • For new devices (2015 and later): $ fastboot flashing unlock
    • For older devices (2014 and earlier): $ fastboot oem unlock
    You must confirm the unlock onscreen.

Note On Nexus 10, after unlocking the bootloader, the internal storage remains unformatted. You can format the device using fastboot format cache followed by fastboot format userdata

Re-locking the bootloader

To re-lock the bootloader:

  • For new devices (2015 and later): $ fastboot flashing lock
  • For older devices (2014 and earlier): $ fastboot oem lock

Note: Re-locking the bootloading on a Motorola Xoom erases user data (including the shared USB data).

Using Flash Unlock

Android 7.0 includes a new system API, getFlashLockState(), to transmit bootloader state, as well as the following system API that returns the bootloader’s lock status on compliant devices:

PersistentDataBlockManager.getFlashLockState()
Return value Conditions
FLASH_LOCK_UNKNOWN

Returned only by devices upgrading to Android 7.0 that have not supported bootloader changes required to get the flash lock status if they support flashing lock/unlock capability.

New Android 7.0 devices must be in either FLASH_LOCK_LOCKED or FLASH_LOCK_UNLOCKED state. If a device is upgrading to Android 7.0 and does not support flashing unlock/lock capability, it should simply return FLASH_LOCK_LOCKED state.

FLASH_LOCK_LOCKED Should be returned by any device that does not support flashing lock/unlock (i.e. the device is always locked), or any device that does support flashing lock/unlock and is in the locked state.
FLASH_LOCK_UNLOCKED Returned by any device that supports flashing lock/unlock and is currently in the unlocked state.

Examples and source

AOSP contains a reference implementation that returns a value based on the ro.boot.flash.locked boot property. The code lives in the following directories:

frameworks/base/services/core/java/com/android/server/PersistentDataBlockService.java
frameworks/base/core/java/android/service/persistentdata/PersistentDataBlockManager.java

Validation

Manufacturers should test the values returned by devices with locked and unlocked bootloaders.

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.com:

For details and additional resources, see Obtaining proprietary binaries and Device binaries requirements.

Device Code name Build configuration
Pixel XL marlin aosp_marlin-userdebug
Pixel sailfish aosp_sailfish-userdebug
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
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.

Flashing a device

You can flash an entire Android system in a single command; doing so verifies the system being flashed is compatible with the installed bootloader and radio, writes the boot, recovery, and system partitions together, then reboots the system. Flashing also erases all user data, similarly to fastboot oem unlock.

Place the device in fastboot mode either manually by holding the appropriate key combination at boot, or from the shell with:

$ adb reboot bootloader

After the device is in fastboot mode, run:

$ fastboot flashall -w

The -w option wipes the /data partition on the device; this is useful for your first time flashing a particular device but is otherwise unnecessary.

Note: Filesystems created via fastboot on Motorola Xoom do not function optimally. We recommend re-creating filesystems through recovery, using: $ adb reboot recovery. While in recovery, open the menu (press Power + Volume Up), wipe the cache partition, then wipe data.

Restoring devices to factory state

Factory images for Nexus 5, Nexus 10, Nexus 4, Nexus Q, Nexus 7, Galaxy Nexus (GSM/HSPA+ "yakju" and "takju", and CDMA/LTE "mysid" and "mysidspr"), Nexus S, and Nexus S 4G are available from Google's factory image page.

Factory images for the Motorola Xoom are distributed directly by Motorola.