1*277b1333SAlex Kiernan================ 23aab70afSSebastian SiewiorAndroid Fastboot 3*277b1333SAlex Kiernan================ 43aab70afSSebastian Siewior 53aab70afSSebastian SiewiorOverview 63aab70afSSebastian Siewior======== 73aab70afSSebastian Siewior 8*277b1333SAlex KiernanThe protocol that is used over USB and UDP is described in the 9*277b1333SAlex Kiernan``README.android-fastboot-protocol`` file in the same directory. 10*277b1333SAlex Kiernan 11*277b1333SAlex KiernanThe current implementation supports the following standard commands: 12*277b1333SAlex Kiernan 13*277b1333SAlex Kiernan- ``boot`` 14*277b1333SAlex Kiernan- ``continue`` 15*277b1333SAlex Kiernan- ``download`` 16*277b1333SAlex Kiernan- ``erase`` (if enabled) 17*277b1333SAlex Kiernan- ``flash`` (if enabled) 18*277b1333SAlex Kiernan- ``getvar`` 19*277b1333SAlex Kiernan- ``reboot`` 20*277b1333SAlex Kiernan- ``reboot-bootloader`` 21*277b1333SAlex Kiernan- ``set_active`` (only a stub implementation which always succeeds) 22*277b1333SAlex Kiernan 23*277b1333SAlex KiernanThe following OEM commands are supported (if enabled): 24*277b1333SAlex Kiernan 25*277b1333SAlex Kiernan- oem format - this executes ``gpt write mmc %x $partitions`` 26*277b1333SAlex Kiernan 27*277b1333SAlex KiernanSupport for both eMMC and NAND devices is included. 283aab70afSSebastian Siewior 293aab70afSSebastian SiewiorClient installation 303aab70afSSebastian Siewior=================== 313aab70afSSebastian Siewior 32*277b1333SAlex KiernanThe counterpart to this is the fastboot client which can be found in 33*277b1333SAlex KiernanAndroid's ``platform/system/core`` repository in the fastboot 34*277b1333SAlex Kiernanfolder. It runs on Windows, Linux and OSX. The fastboot client is 35*277b1333SAlex Kiernanpart of the Android SDK Platform-Tools and can be downloaded from: 363aab70afSSebastian Siewior 37*277b1333SAlex Kiernanhttps://developer.android.com/studio/releases/platform-tools 383aab70afSSebastian Siewior 393aab70afSSebastian SiewiorBoard specific 403aab70afSSebastian Siewior============== 41*277b1333SAlex Kiernan 42*277b1333SAlex KiernanUSB configuration 43*277b1333SAlex Kiernan----------------- 44*277b1333SAlex Kiernan 453aab70afSSebastian SiewiorThe fastboot gadget relies on the USB download gadget, so the following 463aab70afSSebastian Siewioroptions must be configured: 473aab70afSSebastian Siewior 48*277b1333SAlex Kiernan:: 49*277b1333SAlex Kiernan 5001acd6abSPaul Kocialkowski CONFIG_USB_GADGET_DOWNLOAD 51a95aee6aSMaxime Ripard CONFIG_USB_GADGET_VENDOR_NUM 52a95aee6aSMaxime Ripard CONFIG_USB_GADGET_PRODUCT_NUM 53a95aee6aSMaxime Ripard CONFIG_USB_GADGET_MANUFACTURER 543aab70afSSebastian Siewior 55*277b1333SAlex KiernanNOTE: The ``CONFIG_USB_GADGET_VENDOR_NUM`` must be one of the numbers 56*277b1333SAlex Kiernansupported by the fastboot client. The list of vendor IDs supported can 57*277b1333SAlex Kiernanbe found in the fastboot client source code. 58183cbff7SBarnes, Clifton A 59*277b1333SAlex KiernanGeneral configuration 60*277b1333SAlex Kiernan--------------------- 613aab70afSSebastian Siewior 62*277b1333SAlex KiernanThe fastboot protocol requires a large memory buffer for 63*277b1333SAlex Kiernandownloads. This buffer should be as large as possible for a 64*277b1333SAlex Kiernanplatform. The location of the buffer and size are set with 65*277b1333SAlex Kiernan``CONFIG_FASTBOOT_BUF_ADDR`` and ``CONFIG_FASTBOOT_BUF_SIZE``. These 66*277b1333SAlex Kiernanmay be overridden on the fastboot command line using ``-l`` and 67*277b1333SAlex Kiernan``-s``. 68*277b1333SAlex Kiernan 69*277b1333SAlex KiernanFastboot environment variables 70*277b1333SAlex Kiernan============================== 71*277b1333SAlex Kiernan 72*277b1333SAlex KiernanPartition aliases 73*277b1333SAlex Kiernan----------------- 743aab70afSSebastian Siewior 758a41802fSMichael ScottFastboot partition aliases can also be defined for devices where GPT 768a41802fSMichael Scottlimitations prevent user-friendly partition names such as "boot", "system" 778a41802fSMichael Scottand "cache". Or, where the actual partition name doesn't match a standard 78*277b1333SAlex Kiernanpartition name used commonly with fastboot. 79*277b1333SAlex Kiernan 80*277b1333SAlex KiernanThe current implementation checks aliases when accessing partitions by 81*277b1333SAlex Kiernanname (flash_write and erase functions). To define a partition alias 82*277b1333SAlex Kiernanadd an environment variable similar to: 83*277b1333SAlex Kiernan 84*277b1333SAlex Kiernan``fastboot_partition_alias_<alias partition name>=<actual partition name>`` 85*277b1333SAlex Kiernan 86*277b1333SAlex Kiernanfor example: 87*277b1333SAlex Kiernan 88*277b1333SAlex Kiernan``fastboot_partition_alias_boot=LNX`` 89*277b1333SAlex Kiernan 90*277b1333SAlex KiernanVariable overrides 91*277b1333SAlex Kiernan------------------ 92*277b1333SAlex Kiernan 93*277b1333SAlex KiernanVariables retrived through ``getvar`` can be overridden by defining 94*277b1333SAlex Kiernanenvironment variables of the form ``fastboot.<variable>``. These are 95*277b1333SAlex Kiernanlooked up first so can be used to override values which would 96*277b1333SAlex Kiernanotherwise be returned. Using this mechanism you can also return types 97*277b1333SAlex Kiernanfor NAND filesystems, as the fully parameterised variable is looked 98*277b1333SAlex Kiernanup, e.g. 99*277b1333SAlex Kiernan 100*277b1333SAlex Kiernan``fastboot.partition-type:boot=jffs2`` 101*277b1333SAlex Kiernan 102*277b1333SAlex KiernanBoot command 103*277b1333SAlex Kiernan------------ 104*277b1333SAlex Kiernan 105*277b1333SAlex KiernanWhen executing the fastboot ``boot`` command, if ``fastboot_bootcmd`` is set then 106*277b1333SAlex Kiernanthat will be executed in place of ``bootm <CONFIG_FASTBOOT_BUF_ADDR>``. 1078a41802fSMichael Scott 108b6dd69a4SPetr KulhavyPartition Names 109b6dd69a4SPetr Kulhavy=============== 110*277b1333SAlex Kiernan 111*277b1333SAlex KiernanThe Fastboot implementation in U-Boot allows to write images into disk 112*277b1333SAlex Kiernanpartitions. Target partitions are referred on the host computer by 113*277b1333SAlex Kiernantheir names. 114b6dd69a4SPetr Kulhavy 115b6dd69a4SPetr KulhavyFor GPT/EFI the respective partition name is used. 116b6dd69a4SPetr Kulhavy 117b6dd69a4SPetr KulhavyFor MBR the partitions are referred by generic names according to the 118b6dd69a4SPetr Kulhavyfollowing schema: 119b6dd69a4SPetr Kulhavy 120b6dd69a4SPetr Kulhavy <device type><device index letter><partition index> 121b6dd69a4SPetr Kulhavy 122*277b1333SAlex KiernanExample: ``hda3``, ``sdb1``, ``usbda1`` 123b6dd69a4SPetr Kulhavy 124b6dd69a4SPetr KulhavyThe device type is as follows: 125b6dd69a4SPetr Kulhavy 126*277b1333SAlex Kiernan * IDE, ATAPI and SATA disks: ``hd`` 127*277b1333SAlex Kiernan * SCSI disks: ``sd`` 128*277b1333SAlex Kiernan * USB media: ``usbd`` 129*277b1333SAlex Kiernan * MMC and SD cards: ``mmcsd`` 130*277b1333SAlex Kiernan * Disk on chip: ``docd`` 131*277b1333SAlex Kiernan * other: ``xx`` 132b6dd69a4SPetr Kulhavy 133*277b1333SAlex KiernanThe device index starts from ``a`` and refers to the interface (e.g. USB 134b6dd69a4SPetr Kulhavycontroller, SD/MMC controller) or disk index. The partition index starts 135*277b1333SAlex Kiernanfrom ``1`` and describes the partition number on the particular device. 136b6dd69a4SPetr Kulhavy 137b6dd69a4SPetr KulhavyWriting Partition Table 138b6dd69a4SPetr Kulhavy======================= 139*277b1333SAlex Kiernan 140b6dd69a4SPetr KulhavyFastboot also allows to write the partition table to the media. This can be 141b6dd69a4SPetr Kulhavydone by writing the respective partition table image to a special target 142b6dd69a4SPetr Kulhavy"gpt" or "mbr". These names can be customized by defining the following 143b6dd69a4SPetr Kulhavyconfiguration options: 144b6dd69a4SPetr Kulhavy 145*277b1333SAlex Kiernan:: 146*277b1333SAlex Kiernan 147b6dd69a4SPetr Kulhavy CONFIG_FASTBOOT_GPT_NAME 148b6dd69a4SPetr Kulhavy CONFIG_FASTBOOT_MBR_NAME 149b6dd69a4SPetr Kulhavy 1503aab70afSSebastian SiewiorIn Action 1513aab70afSSebastian Siewior========= 152*277b1333SAlex Kiernan 153*277b1333SAlex KiernanEnter into fastboot by executing the fastboot command in U-Boot for either USB: 154*277b1333SAlex Kiernan 155*277b1333SAlex Kiernan:: 156*277b1333SAlex Kiernan 157*277b1333SAlex Kiernan => fastboot usb 0 158*277b1333SAlex Kiernan 159*277b1333SAlex Kiernanor UDP: 160*277b1333SAlex Kiernan 161*277b1333SAlex Kiernan:: 162*277b1333SAlex Kiernan 163*277b1333SAlex Kiernan => fastboot udp 164*277b1333SAlex Kiernan link up on port 0, speed 100, full duplex 165*277b1333SAlex Kiernan Using ethernet@4a100000 device 166*277b1333SAlex Kiernan Listening for fastboot command on 192.168.0.102 1673aab70afSSebastian Siewior 1683aab70afSSebastian SiewiorOn the client side you can fetch the bootloader version for instance: 169*277b1333SAlex Kiernan 170*277b1333SAlex Kiernan:: 171*277b1333SAlex Kiernan 172*277b1333SAlex Kiernan $ fastboot getvar bootloader-version 173*277b1333SAlex Kiernan bootloader-version: U-Boot 2014.04-00005-gd24cabc 174*277b1333SAlex Kiernan finished. total time: 0.000s 1753aab70afSSebastian Siewior 1763aab70afSSebastian Siewioror initiate a reboot: 177*277b1333SAlex Kiernan 178*277b1333SAlex Kiernan:: 179*277b1333SAlex Kiernan 180*277b1333SAlex Kiernan $ fastboot reboot 1813aab70afSSebastian Siewior 1823aab70afSSebastian Siewiorand once the client comes back, the board should reset. 1833aab70afSSebastian Siewior 1843aab70afSSebastian SiewiorYou can also specify a kernel image to boot. You have to either specify 185*277b1333SAlex Kiernanthe an image in Android format *or* pass a binary kernel and let the 1863aab70afSSebastian Siewiorfastboot client wrap the Android suite around it. On OMAP for instance you 1873aab70afSSebastian Siewiortake zImage kernel and pass it to the fastboot client: 1883aab70afSSebastian Siewior 189*277b1333SAlex Kiernan:: 1903aab70afSSebastian Siewior 191*277b1333SAlex Kiernan $ fastboot -b 0x80000000 -c "console=ttyO2 earlyprintk root=/dev/ram0 mem=128M" boot zImage 192*277b1333SAlex Kiernan creating boot image... 193*277b1333SAlex Kiernan creating boot image - 1847296 bytes 194*277b1333SAlex Kiernan downloading 'boot.img'... 195*277b1333SAlex Kiernan OKAY [ 2.766s] 196*277b1333SAlex Kiernan booting... 197*277b1333SAlex Kiernan OKAY [ -0.000s] 198*277b1333SAlex Kiernan finished. total time: 2.766s 199*277b1333SAlex Kiernan 200*277b1333SAlex Kiernanand on the U-Boot side you should see: 201*277b1333SAlex Kiernan 202*277b1333SAlex Kiernan:: 203*277b1333SAlex Kiernan 204*277b1333SAlex Kiernan Starting download of 1847296 bytes 205*277b1333SAlex Kiernan ........................................................ 206*277b1333SAlex Kiernan downloading of 1847296 bytes finished 207*277b1333SAlex Kiernan Booting kernel.. 208*277b1333SAlex Kiernan ## Booting Android Image at 0x81000000 ... 209*277b1333SAlex Kiernan Kernel load addr 0x80008000 size 1801 KiB 210*277b1333SAlex Kiernan Kernel command line: console=ttyO2 earlyprintk root=/dev/ram0 mem=128M 211*277b1333SAlex Kiernan Loading Kernel Image ... OK 212*277b1333SAlex Kiernan OK 213*277b1333SAlex Kiernan 214*277b1333SAlex Kiernan Starting kernel ... 215