fastboot

Overview

Fastboot is the method that Android uses to flash the Android build onto the target. If you really want the details, the Fastboot protocol specification is found in the Android source fastboot_protocol.txt. Fastboot abstracts the details of the memory type, error correction code used, etc, so the user does not need to know them. The user can simply run commands such as "fastboot flash" and "fastboot erase" in order to flash or remove the files stored in the target's eMMC or NAND internal memory.

What's with the name 'fastboot' or how are you booting faster? This feature should be renamed 'making-the-bootloader-simple-to-use'. Fastboot speeds up your development, NOT the time it takes to boot.

The Fastboot client is built as part of a normal Android build and is built automatically when you compile the mydroid source. It is located in $MYDROID/out/host/linux-x86/bin/fastboot.

[edit]Flashing with Fastboot

The biggest benefit of Fastboot is that it automates the manual steps of flashing to the eMMC or NAND partitions. Fastboot allows flashing of unsigned partition images.

For example, you can flash the kernel image with the command:

$ sudo fastboot flash boot path-to-kernel/boot.img

The later versions of the TI u-boot allow you to flash the zImage directly, without having to create the boot.img first:

$ sudo fastboot flash zimage path-to-kernel/arch/arm/boot/zImage

Similarly for the rootfs:

$ sudo fastboot flash system path-to-system/system.img

The general form to flash is:

$ sudo fastboot flash  

That is it; all the details are taken care of for you. You do not have to know how to unlock the eMMC, which flavor of ECC to use, which method of writing to eMMC or even where the flash happens. It is all done for you.

You may also erase partitions with commands such as:

$ sudo fastboot erase boot
$ sudo fastboot erase system
$ sudo fastboot erase data
$ sudo fastboot erase cache

The above will wipe each individual partition, which can be combined into the single command:

$ sudo fastboot erase system -w

[edit]Partitions Setup

Regions in eMMC are given names. Their offsets and sizes are set in u-boot in the mmc.c file of the board directory that you are using. For example, for the Blaze, this file is u-boot/board/omap4430sdp/mmc.c:

static struct partition partitions[] = {
	{ "-", 128 },
	{ "xloader", 128 },
	{ "bootloader", 256 },
	/* "misc" partition is required for recovery */
	{ "misc", 128 },
	{ "-", 384 },
	{ "efs", 16384 },
	{ "recovery", 8*1024 },
	{ "boot", 8*1024 },
	{ "system", 512*1024 },
	{ "cache", 256*1024 },
	{ "userdata", 0},
	{ 0, 0 },
};

The partitions used are shown here: http://www.omappedia.com/wiki/Android_eMMC_Booting If you want to change the name, size, or location of any of the partitions, you could make the changes in this mmc.c file and run the command:

$ sudo fastboot oem format

[edit]Fastboot on the Blaze

Note that "Blaze" in the below instructions can refer to either the Blaze or Blaze Tablet board, as Fastboot works in the same way.

1. Connect the Blaze to the PC with the mini USB cable for UART connection and start a terminal program. Power on the Blaze and press a key to stop the boot in the u-boot. Enter "fastboot" at the terminal prompt.

2. Connect the Blaze to the PC with the micro USB cable for OTG connection.

3. Go to the location of the "fastboot" binary on your Linux Host PC, and enter commands in order to flash a file to the desired partition in eMMC, such as:

$ sudo ./fastboot flash xloader MLO

Note: If the eMMC has never been flased before on this Blaze, or you wish to reset/change the name, size, or locations of any of the partitions, then first run the command:

$ sudo ./fastboot oem format

The script file fastboot.sh is included with the TI Android releases in $MYDROID/device/ti/blaze/boot/fastboot.sh and automatically flashes all of the partitions of the eMMC. It assumes that the required files are located in the same directory as fastboot.sh and the fastboot binary. It also automatically detects the device type and uses the correct MLO. The usage is simply:

$ sudo ./fastboot.sh

4. Reboot the board either by removing the power, or by running the command:

$ sudo ./fastboot reboot

[edit]Troubleshooting

If you get a message "waiting for device" when trying to run Fastboot commands from the host, confirm that you are running the commands as "sudo."

[edit]Flashing NAND on the Zoom II

If you are using the Zoom II (TI OMAP3 development board), use these steps to put the Zoom II into the Fastboot preboot mode by holding down two keys while the board is booting. Note that NAND is used instead of eMMC on the Zoom II, but the Fastboot commands work in the same way as Fastboot is abstracted from the memory details.

  1. Disconnect the debug board from Zoom II
  2. Disconnect the power and usb cables to Zoom II
  3. Reset the board with the small button on back, interior of the Zoom II.
  4. Hold down the large center 'OK' button
  5. You only have about 1/2 second between steps 3 & 4 before normal booting continues. Holding the 'Ok' button before step 3 is helpful.

You should see:

  • LED briefly blink red to off
  • LED stay on red

The continuous red LED means that fastboot command has started. Next you should connect the USB cable from the host to the Zoom II.

You should see:

  • LED blink red to blue
  • Continous blue

This means that USB discovery by the host was successful. You are ready to go! If you do not see a continous blue LED, repeat the setup steps.

[edit]Booting with Fastboot

In addition to flashing the eMMC, Fastboot can also be used to boot from files already flashed to the eMMC. To do, so start Fastboot on the target, and then run a command on the host PC, for example to boot the u-boot:

# sudo fastboot boot u-boot.bin

[edit]Exiting Fastboot

In addition to disconnecting the USB cable, the user can exit Fastboot when a user-defined timeout expires or when a Ctrl-C is seen from the console.

This is the new fastboot help:

# help fastboot fastboot [inactive timeout]     
- Run as a fastboot usb device. The optional inactive timeout is the decimal seconds before the normal console resumes.

To run fastboot with a timeout of 100 seconds, do:

# fastboot 100

The console prints out:

Fastboot inactivity timeout 100 seconds 
Disconnect USB cable to finish fastboot.. 
Fastboot inactivity detected

You can still do:

# fastboot

It will behave as it did before. If you want to stop it, now you can use the Ctrl-C on the console. The timeout happens when inactivity is seen during the fastboot command, and the timeout is reset after each command. If the command takes longer than timeout, like reflashing the system image, it will not timeout during the command. Because host discovery of the fastboot device can take a couple of seconds, it is recommended that the timeout be at least 10 seconds.


Fastboot 是用于更新安卓设备的 Flash 文件系统一种协议,它通过USB数据线和电脑相连,可以刷各个分区的映像 (image) 文件。但是很多手机在出厂的时候都把 Fastboot 锁起来了,这样用户就无法使用它了。 Fastboot 升级模式供开发人员使用,它可以升级系统的单个组件。使用 Fastboot 模式升级必须有“fastboot”程序和USB线。 Fastboot 是 Google 提供的控制台程序,可以在 Google 提供的 Android SDK 中找到这个程序,所以通过这种方式升级需要安装 Google 提供的 Android SDK。


资料:

http://www.omappedia.org/wiki/Android_Fastboot#Updating_system_image_on_NAND

http://blog.csdn.net/coolkids_2008/article/details/7720988


你可能感兴趣的:(android,system)