Fastboot is a tool and a protocol used to communicate with bootloaders. It exists as a binary and gets included in your path when you work with the Android sources. Fastboot is also a part of the standard SDK (under platform-tools
).
Before you can flash any software, you need to boot the device into fastboot mode. There are two ways of doing this:
Using key combinations:
First, power off the phone completely
(Nexus One) Passion: Press and hold the trackball, then press Power
(Nexus S) Crespo: Press and hold Volume Up, then press and hold Power
(Galaxy Nexus) Maguro: Press and hold both Volume Up and Volume Down, then press and hold Power
Using ADB commands: The following command reboots the device into recovery mode. This has the same effect as the key combinations.
adb reboot-bootloader
Unlock the bootloader: You can flash software only if the bootloader allows it. We need to unlock the bootloader with the following command once the device is in fastboot mode.
fastboot oem unlock
Note
Be sure to back up whatever files/data you need from the device, since this operation erases all device memory.
And follow the onscreen instructions.
To flash, you need to ensure you are connected to the device in fastboot mode. The following command will display the device's serial number on the terminal:
fastboot devices
Then, execute the following in order:
fastboot erase userdata fastboot erase cache fastboot flash boot boot.img fastboot flash recovery recovery.img fastboot flash system system.img fastboot reboot
The device will boot into the custom operation system. For additional information on different fastboot commands and the flashing process in general, refer to http://source.android.com/source/building-devices.html.
Note
After a successful build, the required system images will be available at
ANDROID_SRC/target/out/product/<NAME>/
.Here,
<NAME>
refers to the target. For the emulator, it isgeneric
, similarly, for the Nexus S, it will becrespo
. The available images will besystem.img
,boot.img
, andrecovery.img
.
Fastboot is a protocol to communicate with device bootloaders. This was designed such that flashing can be independent of the underlying bootloader. The process of unlocking the bootloader is available on developer devices. This is a recent feature starting with Nexus S. Relocking bootloaders allows you to lock the bootloader preventing the installation of new firmware.
Google developer phones can be loaded with custom software that we have been building in the previous recipes (Google developer phones are special devices designed for platform developers and not for the typical consumer). Firmware can be written to these devices' flash memory as the bootloader is unlocked. Consumer devices normally lock their bootloaders and flashing is not possible. The workflow for all three of the developer phones (Nexus One, Nexus S, and Galaxy Nexus) is, for the most part, identical. Fastboot is a protocol and a flashing tool used to write new software images to the device.
For more details on the fastboot protocol, refer ANDROID_SRC/bootable/bootloader/legacy/fastboot_protocol.txt
.