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


Android Fastboot

Contents

[hide]
  • 1Overview
  • 2Flashing with Fastboot
  • 3Getting fastboot client
  • 4Supported Partitions
  • 5Text file format
  • 6Kernel Nand_offset and Nand_size
  • 7Fastboot on the Zoom II
    • 7.1On Target
    • 7.2On Host
  • 8Trouble Shooting
  • 9Use Cases
    • 9.1On target
    • 9.2On host side
  • 10Flashing NAND w/o debug board
  • 11Updating only kernel on NAND
    • 11.1On target
    • 11.2On Host
  • 12Updating system image on NAND
    • 12.1On target
    • 12.2On Host
  • 13Updating bootloader image on NAND
    • 13.1On target
    • 13.2On Host
  • 14Updating linux kernel and yaffs2 filesystem on NAND
    • 14.1On target
    • 14.2On Host
  • 15Rebooting the board
    • 15.1On target
    • 15.2On Host
  • 16Booting a test kernel from memory, no flashing
    • 16.1On target
    • 16.2On Host
  • 17Rebooting a test bootloader from memory, no flashing
    • 17.1On target
    • 17.2On Host
  • 18Issues
  • 19Pending Changes
    • 19.1Runtime Partitions
  • 20Timeout and user exiting of fastboot

[edit]Overview

Fastboot is the method 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

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.

[edit]Flashing with Fastboot

The biggest benifit of fastboot is that it automates the manual steps of flashing nand. Look back on the manual steps here. As an example In fastboot all you need to do to flash the kernel is from your host machine.

The fastboot client is built as part of a normal android build, it is located ./out/host/linux-x86/bin/fastboot'

# sudo fastboot flash kernel path-to-kernel/uImage

Similarly for the rootfs

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

The general form to flash is

# sudo fastboot flash <partition name> <file>

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

[edit]Getting fastboot client

The fastboot client is part of Android. It is built when you build Android. You wil find fastboot in out/host/linux-x86/bin/fastboot.


[edit]Supported Partitions

Regions in NAND are given names. Their offsets and sizes are set in U-boot. To run most fastboot client commands, you need to know what partition name corresponds to which file.


NAND partition names
name offset size
xloader 0x00000000 0x00080000
bootloader 0x00080000 0x00180000
environment 0x001C0000 0x00040000
kernel 0x00200000 0x01D00000
system 0x02000000 0x0A000000
userdata 0x0C000000 0x02000000
cache 0x0E000000 0x02000000


NAND partition input files
name type of file usual file
xloader xloader binary MLO
bootloader uboot binary u-boot.bin
environment text file list of variables to set
kernel kernel or kernel + ramdisk uImage, uMulti
system yaffs2 system.img
userdata yaffs2 userdata.img
cache yaffs2 ?

[edit]Text file format

Instead of setting the environment manually, a text file is used set and unset environment variables. The text file is list of variable / value pairs. One variable per line. The setting and unsetting are similar to the u-boot setenv command.

  • To set
variable value
  • To unset
variable 
  • This is an example of the minimal environment file needed to boot an android uMulti image and system.img
bootdelay 10bootargs console=ttyS3,115200n8bootcmd nand unlock; nand read.i 81000000 ${kernel_nand_offset} ${kernel_nand_size}; bootm 81000000
  • Fastboot supports comments in environment files
The comments in environment files are now similar to bash. The '#' is the comment character.The limitation is that the '#' must be in used before any other non-whitespace character.This is valid:# Use this oneThis is not valid:bootcmd bootm 81000000 # My boot command

[edit]Kernel Nand_offset and Nand_size

In general when fastboot flashes a partition, it saves the nand offset and size of the image as enviroment variables. The format of the names are

  • <partition name>_nand_offset
  • <partition name>_nand_size

As and example when the kernel is flashed, you can view the u-boot environment and see that

  • kernel_nand_offset=0x140000
  • kernel_nand_size=0x1f70000

The benifit of these variables is that you can write general environment files.


[edit]Fastboot on the Zoom II

[edit]On Target

Connect the board to allow for USBOTG to work y as described here. On u-boot prompt, enter command fastboot. (this can also be done automatically in u-boot through setenv bootcmd 'fastboot') During usb setup, the large LED in the top left of the Zoom II binks red and blue. When the setup is complete, the blue LED should be on.


[edit]On Host

# lsusb Bus 008 Device 030: ID 0451:cafe Texas Instruments, Inc. <----- fastboot Bus 008 Device 005: ID 0d8c:000c C-Media Electronics, Inc. Audio AdapterBus 008 Device 004: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUBBus 008 Device 003: ID 2001:3c05 D-Link Corp. [hex] DUB-E100 Fast Ethernet [asix]


For more detail, look in proc fs.

# cat /proc/bus/usb/devicesT:  Bus=01 Lev=01 Prnt=01 Port=05 Cnt=02 Dev#= 85 Spd=480 MxCh= 0D:  Ver= 1.10 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs=  1P:  Vendor=0451 ProdID=cafe Rev= 3.11S:  Manufacturer=Texas InstrumentsS:  Product=Zoom2S:  SerialNumber=00123C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mAI:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=03 Driver=(none)E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0msE:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms


[edit]Trouble Shooting

If you fail to see the fastboot device on the host or the Zoom II red LED remains on First check the usb cable is connected to Zoom II usb and battery or AC power is connected to Zoom II

If you are connected, then follow these steps:

  1. Remove power from the Zoom II
  2. Unplug usb from Zoom II
  3. Remove Zoom II from debug board
  4. Plug AC power to zoom II
  5. Press the power button on the top right of zoom II
  6. Wait for top left LED to flash blue
  7. Put Zoom II on the debug board board
  8. Cycle power from debug board
  9. Verify u boot on serial console connected to left most usb on debug board
  10. Restart the serial console if console is unresponsive
  11. Type fastboot on uboot console
  12. Plug in usb to zoom II


Verifying if fast boot client recognizes the Zoom2 device:

sudo sudo fastboot devicesOutput: 00123   fastboot


[edit]Use Cases

NOTE: All features of fastboot have been implemented in v1.1 u-boot and x-loader. Please upgrade to v1.1 from here

Flashing Android on NAND

[edit]On target

  • start fastboot
# fastboot


[edit]On host side

# sudo fastboot flash xloader MLO-Zoom2# sudo fastboot flash bootloader uboot-Zoom2# sudo fastboot flash kernel uMulti-Image# sudo fastboot flash system system.img# sudo fastboot flash userdata userdata.img# sudo fastboot erase cache# sudo fastboot flash environment environment_vars.txt

The environment_vars.txt file is

bootdelay 10bootargs console=ttyS3,115200n8bootcmd nand unlock; nand read.i 81000000 ${kernel_nand_offset} ${kernel_nand_size}; bootm 81000000

The locations of the images relative to the top of the android source tree is

 xloader : bootloader/MLObootloader: bootloader/u-boot.binuMulti-Image: See bellowkernel: kernel/arch/arm/boot/zImageramdisk.img: out/target/product/zoom2/ramdisk.imgsystem: out/target/product/zoom2/system.imguserdata: out/target/product/zoom2/userdata.img

uMulti-Image = combine the Android ramdisk with the kernel, use the u-boot utility mkimage

 mkimage -A arm -O linux -T multi -C none \    -a 0x80008000 -e 0x80008000 -n 'Name_Of_Your_Release'' \    -d <path-to-kernel>/arch/arm/boot/zImage:<path-to-android-out-dir>/ramdisk.img \    uMulti-2


[edit]Flashing NAND w/o debug board

This usecase assumes you only have a Zoom II and still want to flash your board. To do this you need to put the Zoom II into the fastboot preboot mode by holding down two keys while the board is booting. Follow these steps.

  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. The instructions from the host side are the same as the use case with the debug board.

[edit]Updating only kernel on NAND

[edit]On target

  • start fastboot
# fastboot


[edit]On Host

# sudo fastboot flash kernel uMulti-Image


[edit]Updating system image on NAND

[edit]On target

  • start fastboot
# fastboot


[edit]On Host

# sudo fastboot flash system system.img


[edit]Updating bootloader image on NAND

[edit]On target

  • start fastboot
# fastboot


[edit]On Host

# sudo fastboot flash bootloader uboot-Zoom2# sudo fastboot flash environment environment_vars.txt


[edit]Updating linux kernel and yaffs2 filesystem on NAND

[edit]On target

  • start fastboot
# fastboot


[edit]On Host

# sudo fastboot flash xloader MLO-Zoom2# sudo fastboot flash bootloader uboot-Zoom2# sudo fastboot flash kernel uImage# sudo fastboot flash system filesystem.yaff2# sudo fastboot erase userdata# sudo fastboot erase cache# sudo fastboot flash environment Kernel_rootfs

The Kernel_rootfs file is

bootdelay 10bootargs console=ttyS3,115200n8 root=/dev/mtdblock4 rw rootfstype=yaffs2 init=/sbin/initbootcmd nand unlock; nand read.i 80000000 ${kernel_nand_offset} ${kernel_nand_size}; bootm


[edit]Rebooting the board

[edit]On target

  • start fastboot
# fastboot


[edit]On Host

# sudo fastboot reboot


[edit]Booting a test kernel from memory, no flashing

[edit]On target

  • start fastboot
# fastboot


[edit]On Host

# sudo fastboot boot uImage


[edit]Rebooting a test bootloader from memory, no flashing

[edit]On target

  • start fastboot
# fastboot


[edit]On Host

# sudo fastboot boot u-boot.bin


[edit]Issues

  • The use of nand unlock in the bootargs is intended for development only.
  • The maximum download size is 240M.
  • fastboot_client flashall is not implemented


[edit]Pending Changes

[edit]Runtime Partitions

How do you customize the NAND layout by adding or deleting partitions?


Fastboot reuses the kernel's method of customizing the NAND partitions and most of the partitions are changable. This is the list of the unchangable or static partitions.


Static NAND partition names
name offset size
xloader 0x00000000 0x00080000
bootloader 0x00080000 0x00180000
environment 0x001C0000 0x00040000


The runtime partitions are defined by the u-boot environment variable fbparts. Its format is simlar to the kernel's boot command line variable mtdparts. Here is an example of how the system partition is defined at runtime for fastboot and for the kernel.


  • Fastboot: fbparts 160m@32m(system)yaffs|swecc
  • Kernel: mtdparts=omap2-nand.0:160m@32m(system)


For fastboot, 160m@32m(system)yaffs|swecc, means create a partition at 32M with a size of 160M, name it 'system' and use the fastboot flags yaffs and swecc.


For the kernel, omap2-nand.0:160m@32m(system), means for the omap2-nand.0 device, create a partition at 32M with a size of 160M and name it 'system'


Format of fbparts The format is:

<size>@<offset>(<name>)<optional-flags>,
  • <size> = is the extent of the nand partition, in bytes. This should be a multiple of the NAND block size.
  • <offset> = is where the nand partition begins, in bytes. This should be a multiple of the NAND block size.
  • <name> = is the same as what is used by the fastboot client.


The supported flags control how the data is written into nand they are

i       : use nand write.iyaffs   : use nand write.yaffsswecc   : use nand software ecchwecc   : use nand hardware ecc

Multiple flags can be or-ed together with a '|'

[edit]Timeout and user exiting of 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.<pre>To run fastboot with a timeout of 100 seconds, do <pre># 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. 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.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. [置顶] Android(安卓)Studio 配置
  2. Android(安卓)linux adc驱动(s5pv210)
  3. android popupwindow 中listview 无法点
  4. Android中dp和px之间进行转换
  5. android 上传/下载 图片
  6. Android(安卓)如何给Dialog设置宽、高
  7. android Diglog去除边框和默认背景
  8. android 获取设备IMEI与序列号
  9. 体育迷的工作:安卓开发,上海,国内排名第一体
  10. android 通知栏处理