13aab70afSSebastian SiewiorAndroid Fastboot 23aab70afSSebastian Siewior~~~~~~~~~~~~~~~~ 33aab70afSSebastian Siewior 43aab70afSSebastian SiewiorOverview 53aab70afSSebastian Siewior======== 63aab70afSSebastian SiewiorThe protocol that is used over USB is described in 73aab70afSSebastian SiewiorREADME.android-fastboot-protocol in same directory. 83aab70afSSebastian Siewior 989792381SDileep KattaThe current implementation is a minimal support of the erase command,the 1089792381SDileep Katta"oem format" command and flash command;it only supports eMMC devices. 113aab70afSSebastian Siewior 123aab70afSSebastian SiewiorClient installation 133aab70afSSebastian Siewior=================== 143aab70afSSebastian SiewiorThe counterpart to this gadget is the fastboot client which can 153aab70afSSebastian Siewiorbe found in Android's platform/system/core repository in the fastboot 163aab70afSSebastian Siewiorfolder. It runs on Windows, Linux and even OSX. Linux user are lucky since 173aab70afSSebastian Siewiorthey only need libusb. 183aab70afSSebastian SiewiorWindows users need to bring some time until they have Android SDK (currently 193aab70afSSebastian Siewiorhttp://dl.google.com/android/installer_r12-windows.exe) installed. You 203aab70afSSebastian Siewiorneed to install ADB package which contains the required glue libraries for 213aab70afSSebastian Siewioraccessing USB. Also you need "Google USB driver package" and "SDK platform 223aab70afSSebastian Siewiortools". Once installed the usb driver is placed in your SDK folder under 233aab70afSSebastian Siewiorextras\google\usb_driver. The android_winusb.inf needs a line like 243aab70afSSebastian Siewior 253aab70afSSebastian Siewior %SingleBootLoaderInterface% = USB_Install, USB\VID_0451&PID_D022 263aab70afSSebastian Siewior 273aab70afSSebastian Siewioreither in the [Google.NTx86] section for 32bit Windows or [Google.NTamd64] 283aab70afSSebastian Siewiorfor 64bit Windows. VID and PID should match whatever the fastboot is 293aab70afSSebastian Siewioradvertising. 303aab70afSSebastian Siewior 313aab70afSSebastian SiewiorBoard specific 323aab70afSSebastian Siewior============== 333aab70afSSebastian SiewiorThe fastboot gadget relies on the USB download gadget, so the following 343aab70afSSebastian Siewioroptions must be configured: 353aab70afSSebastian Siewior 3601acd6abSPaul KocialkowskiCONFIG_USB_GADGET_DOWNLOAD 37*a95aee6aSMaxime RipardCONFIG_USB_GADGET_VENDOR_NUM 38*a95aee6aSMaxime RipardCONFIG_USB_GADGET_PRODUCT_NUM 39*a95aee6aSMaxime RipardCONFIG_USB_GADGET_MANUFACTURER 403aab70afSSebastian Siewior 41*a95aee6aSMaxime RipardNOTE: The CONFIG_USB_GADGET_VENDOR_NUM must be one of the numbers supported by 42183cbff7SBarnes, Clifton Athe fastboot client. The list of vendor IDs supported can be found in the 43183cbff7SBarnes, Clifton Afastboot client source code (fastboot.c) mentioned above. 44183cbff7SBarnes, Clifton A 4517da3c0cSPaul KocialkowskiThe fastboot function is enabled by defining CONFIG_USB_FUNCTION_FASTBOOT, 4617da3c0cSPaul KocialkowskiCONFIG_CMD_FASTBOOT and CONFIG_ANDROID_BOOT_IMAGE. 473aab70afSSebastian Siewior 483aab70afSSebastian SiewiorThe fastboot protocol requires a large memory buffer for downloads. This 493aab70afSSebastian Siewiorbuffer should be as large as possible for a platform. The location of the 50a588d99aSPaul Kocialkowskibuffer and size are set with CONFIG_FASTBOOT_BUF_ADDR and 51a588d99aSPaul KocialkowskiCONFIG_FASTBOOT_BUF_SIZE. 523aab70afSSebastian Siewior 538a41802fSMichael ScottFastboot partition aliases can also be defined for devices where GPT 548a41802fSMichael Scottlimitations prevent user-friendly partition names such as "boot", "system" 558a41802fSMichael Scottand "cache". Or, where the actual partition name doesn't match a standard 568a41802fSMichael Scottpartition name used commonly with fastboot. Current implentation checks 578a41802fSMichael Scottaliases when accessing partitions by name (flash_write and erase functions). 588a41802fSMichael ScottTo define a partition alias add an environment variable similar to: 598a41802fSMichael Scottfastboot_partition_alias_<alias partition name>=<actual partition name> 608a41802fSMichael ScottExample: fastboot_partition_alias_boot=LNX 618a41802fSMichael Scott 62b6dd69a4SPetr KulhavyPartition Names 63b6dd69a4SPetr Kulhavy=============== 64b6dd69a4SPetr KulhavyThe Fastboot implementation in U-boot allows to write images into disk 65b6dd69a4SPetr Kulhavypartitions (currently on eMMC). Target partitions are referred on the host 66b6dd69a4SPetr Kulhavycomputer by their names. 67b6dd69a4SPetr Kulhavy 68b6dd69a4SPetr KulhavyFor GPT/EFI the respective partition name is used. 69b6dd69a4SPetr Kulhavy 70b6dd69a4SPetr KulhavyFor MBR the partitions are referred by generic names according to the 71b6dd69a4SPetr Kulhavyfollowing schema: 72b6dd69a4SPetr Kulhavy 73b6dd69a4SPetr Kulhavy <device type> <device index letter> <partition index> 74b6dd69a4SPetr Kulhavy 75b6dd69a4SPetr KulhavyExample: hda3, sdb1, usbda1 76b6dd69a4SPetr Kulhavy 77b6dd69a4SPetr KulhavyThe device type is as follows: 78b6dd69a4SPetr Kulhavy 79b6dd69a4SPetr Kulhavy * IDE, ATAPI and SATA disks: hd 80b6dd69a4SPetr Kulhavy * SCSI disks: sd 81b6dd69a4SPetr Kulhavy * USB media: usbd 82da2ee24dSPetr Kulhavy * MMC and SD cards: mmcsd 83b6dd69a4SPetr Kulhavy * Disk on chip: docd 84b6dd69a4SPetr Kulhavy * other: xx 85b6dd69a4SPetr Kulhavy 86b6dd69a4SPetr KulhavyThe device index starts from 'a' and refers to the interface (e.g. USB 87b6dd69a4SPetr Kulhavycontroller, SD/MMC controller) or disk index. The partition index starts 88b6dd69a4SPetr Kulhavyfrom 1 and describes the partition number on the particular device. 89b6dd69a4SPetr Kulhavy 90b6dd69a4SPetr KulhavyWriting Partition Table 91b6dd69a4SPetr Kulhavy======================= 92b6dd69a4SPetr KulhavyFastboot also allows to write the partition table to the media. This can be 93b6dd69a4SPetr Kulhavydone by writing the respective partition table image to a special target 94b6dd69a4SPetr Kulhavy"gpt" or "mbr". These names can be customized by defining the following 95b6dd69a4SPetr Kulhavyconfiguration options: 96b6dd69a4SPetr Kulhavy 97b6dd69a4SPetr KulhavyCONFIG_FASTBOOT_GPT_NAME 98b6dd69a4SPetr KulhavyCONFIG_FASTBOOT_MBR_NAME 99b6dd69a4SPetr Kulhavy 1003aab70afSSebastian SiewiorIn Action 1013aab70afSSebastian Siewior========= 1023aab70afSSebastian SiewiorEnter into fastboot by executing the fastboot command in u-boot and you 1033aab70afSSebastian Siewiorshould see: 1043aab70afSSebastian Siewior|GADGET DRIVER: usb_dnl_fastboot 1053aab70afSSebastian Siewior 1063aab70afSSebastian SiewiorOn the client side you can fetch the bootloader version for instance: 1073aab70afSSebastian Siewior|>fastboot getvar bootloader-version 1083aab70afSSebastian Siewior|bootloader-version: U-Boot 2014.04-00005-gd24cabc 1093aab70afSSebastian Siewior|finished. total time: 0.000s 1103aab70afSSebastian Siewior 1113aab70afSSebastian Siewioror initiate a reboot: 1123aab70afSSebastian Siewior|>fastboot reboot 1133aab70afSSebastian Siewior 1143aab70afSSebastian Siewiorand once the client comes back, the board should reset. 1153aab70afSSebastian Siewior 1163aab70afSSebastian SiewiorYou can also specify a kernel image to boot. You have to either specify 1173aab70afSSebastian Siewiorthe an image in Android format _or_ pass a binary kernel and let the 1183aab70afSSebastian Siewiorfastboot client wrap the Android suite around it. On OMAP for instance you 1193aab70afSSebastian Siewiortake zImage kernel and pass it to the fastboot client: 1203aab70afSSebastian Siewior 1213aab70afSSebastian Siewior|>fastboot -b 0x80000000 -c "console=ttyO2 earlyprintk root=/dev/ram0 1223aab70afSSebastian Siewior| mem=128M" boot zImage 1233aab70afSSebastian Siewior|creating boot image... 1243aab70afSSebastian Siewior|creating boot image - 1847296 bytes 1253aab70afSSebastian Siewior|downloading 'boot.img'... 1263aab70afSSebastian Siewior|OKAY [ 2.766s] 1273aab70afSSebastian Siewior|booting... 1283aab70afSSebastian Siewior|OKAY [ -0.000s] 1293aab70afSSebastian Siewior|finished. total time: 2.766s 1303aab70afSSebastian Siewior 1313aab70afSSebastian Siewiorand on the gadget side you should see: 1323aab70afSSebastian Siewior|Starting download of 1847296 bytes 1333aab70afSSebastian Siewior|........................................................ 1343aab70afSSebastian Siewior|downloading of 1847296 bytes finished 1353aab70afSSebastian Siewior|Booting kernel.. 1363aab70afSSebastian Siewior|## Booting Android Image at 0x81000000 ... 1373aab70afSSebastian Siewior|Kernel load addr 0x80008000 size 1801 KiB 1383aab70afSSebastian Siewior|Kernel command line: console=ttyO2 earlyprintk root=/dev/ram0 mem=128M 1393aab70afSSebastian Siewior| Loading Kernel Image ... OK 1403aab70afSSebastian Siewior|OK 1413aab70afSSebastian Siewior| 1423aab70afSSebastian Siewior|Starting kernel ... 143