1*4882a593SmuzhiyunAndroid Fastboot 2*4882a593Smuzhiyun~~~~~~~~~~~~~~~~ 3*4882a593Smuzhiyun 4*4882a593SmuzhiyunOverview 5*4882a593Smuzhiyun======== 6*4882a593SmuzhiyunThe protocol that is used over USB is described in 7*4882a593SmuzhiyunREADME.android-fastboot-protocol in same directory. 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunThe current implementation is a minimal support of the erase command,the 10*4882a593Smuzhiyun"oem format" command and flash command;it only supports eMMC devices. 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunClient installation 13*4882a593Smuzhiyun=================== 14*4882a593SmuzhiyunThe counterpart to this gadget is the fastboot client which can 15*4882a593Smuzhiyunbe found in Android's platform/system/core repository in the fastboot 16*4882a593Smuzhiyunfolder. It runs on Windows, Linux and even OSX. Linux user are lucky since 17*4882a593Smuzhiyunthey only need libusb. 18*4882a593SmuzhiyunWindows users need to bring some time until they have Android SDK (currently 19*4882a593Smuzhiyunhttp://dl.google.com/android/installer_r12-windows.exe) installed. You 20*4882a593Smuzhiyunneed to install ADB package which contains the required glue libraries for 21*4882a593Smuzhiyunaccessing USB. Also you need "Google USB driver package" and "SDK platform 22*4882a593Smuzhiyuntools". Once installed the usb driver is placed in your SDK folder under 23*4882a593Smuzhiyunextras\google\usb_driver. The android_winusb.inf needs a line like 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun %SingleBootLoaderInterface% = USB_Install, USB\VID_0451&PID_D022 26*4882a593Smuzhiyun 27*4882a593Smuzhiyuneither in the [Google.NTx86] section for 32bit Windows or [Google.NTamd64] 28*4882a593Smuzhiyunfor 64bit Windows. VID and PID should match whatever the fastboot is 29*4882a593Smuzhiyunadvertising. 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunBoard specific 32*4882a593Smuzhiyun============== 33*4882a593SmuzhiyunThe fastboot gadget relies on the USB download gadget, so the following 34*4882a593Smuzhiyunoptions must be configured: 35*4882a593Smuzhiyun 36*4882a593SmuzhiyunCONFIG_USB_GADGET_DOWNLOAD 37*4882a593SmuzhiyunCONFIG_USB_GADGET_VENDOR_NUM 38*4882a593SmuzhiyunCONFIG_USB_GADGET_PRODUCT_NUM 39*4882a593SmuzhiyunCONFIG_USB_GADGET_MANUFACTURER 40*4882a593Smuzhiyun 41*4882a593SmuzhiyunNOTE: The CONFIG_USB_GADGET_VENDOR_NUM must be one of the numbers supported by 42*4882a593Smuzhiyunthe fastboot client. The list of vendor IDs supported can be found in the 43*4882a593Smuzhiyunfastboot client source code (fastboot.c) mentioned above. 44*4882a593Smuzhiyun 45*4882a593SmuzhiyunThe fastboot function is enabled by defining CONFIG_USB_FUNCTION_FASTBOOT, 46*4882a593SmuzhiyunCONFIG_CMD_FASTBOOT and CONFIG_ANDROID_BOOT_IMAGE. 47*4882a593Smuzhiyun 48*4882a593SmuzhiyunThe fastboot protocol requires a large memory buffer for downloads. This 49*4882a593Smuzhiyunbuffer should be as large as possible for a platform. The location of the 50*4882a593Smuzhiyunbuffer and size are set with CONFIG_FASTBOOT_BUF_ADDR and 51*4882a593SmuzhiyunCONFIG_FASTBOOT_BUF_SIZE. 52*4882a593Smuzhiyun 53*4882a593SmuzhiyunFastboot partition aliases can also be defined for devices where GPT 54*4882a593Smuzhiyunlimitations prevent user-friendly partition names such as "boot", "system" 55*4882a593Smuzhiyunand "cache". Or, where the actual partition name doesn't match a standard 56*4882a593Smuzhiyunpartition name used commonly with fastboot. Current implentation checks 57*4882a593Smuzhiyunaliases when accessing partitions by name (flash_write and erase functions). 58*4882a593SmuzhiyunTo define a partition alias add an environment variable similar to: 59*4882a593Smuzhiyunfastboot_partition_alias_<alias partition name>=<actual partition name> 60*4882a593SmuzhiyunExample: fastboot_partition_alias_boot=LNX 61*4882a593Smuzhiyun 62*4882a593SmuzhiyunPartition Names 63*4882a593Smuzhiyun=============== 64*4882a593SmuzhiyunThe Fastboot implementation in U-boot allows to write images into disk 65*4882a593Smuzhiyunpartitions (currently on eMMC). Target partitions are referred on the host 66*4882a593Smuzhiyuncomputer by their names. 67*4882a593Smuzhiyun 68*4882a593SmuzhiyunFor GPT/EFI the respective partition name is used. 69*4882a593Smuzhiyun 70*4882a593SmuzhiyunFor MBR the partitions are referred by generic names according to the 71*4882a593Smuzhiyunfollowing schema: 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun <device type> <device index letter> <partition index> 74*4882a593Smuzhiyun 75*4882a593SmuzhiyunExample: hda3, sdb1, usbda1 76*4882a593Smuzhiyun 77*4882a593SmuzhiyunThe device type is as follows: 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun * IDE, ATAPI and SATA disks: hd 80*4882a593Smuzhiyun * SCSI disks: sd 81*4882a593Smuzhiyun * USB media: usbd 82*4882a593Smuzhiyun * MMC and SD cards: mmcsd 83*4882a593Smuzhiyun * Disk on chip: docd 84*4882a593Smuzhiyun * other: xx 85*4882a593Smuzhiyun 86*4882a593SmuzhiyunThe device index starts from 'a' and refers to the interface (e.g. USB 87*4882a593Smuzhiyuncontroller, SD/MMC controller) or disk index. The partition index starts 88*4882a593Smuzhiyunfrom 1 and describes the partition number on the particular device. 89*4882a593Smuzhiyun 90*4882a593SmuzhiyunWriting Partition Table 91*4882a593Smuzhiyun======================= 92*4882a593SmuzhiyunFastboot also allows to write the partition table to the media. This can be 93*4882a593Smuzhiyundone by writing the respective partition table image to a special target 94*4882a593Smuzhiyun"gpt" or "mbr". These names can be customized by defining the following 95*4882a593Smuzhiyunconfiguration options: 96*4882a593Smuzhiyun 97*4882a593SmuzhiyunCONFIG_FASTBOOT_GPT_NAME 98*4882a593SmuzhiyunCONFIG_FASTBOOT_MBR_NAME 99*4882a593Smuzhiyun 100*4882a593SmuzhiyunIn Action 101*4882a593Smuzhiyun========= 102*4882a593SmuzhiyunEnter into fastboot by executing the fastboot command in u-boot and you 103*4882a593Smuzhiyunshould see: 104*4882a593Smuzhiyun|GADGET DRIVER: usb_dnl_fastboot 105*4882a593Smuzhiyun 106*4882a593SmuzhiyunOn the client side you can fetch the bootloader version for instance: 107*4882a593Smuzhiyun|>fastboot getvar bootloader-version 108*4882a593Smuzhiyun|bootloader-version: U-Boot 2014.04-00005-gd24cabc 109*4882a593Smuzhiyun|finished. total time: 0.000s 110*4882a593Smuzhiyun 111*4882a593Smuzhiyunor initiate a reboot: 112*4882a593Smuzhiyun|>fastboot reboot 113*4882a593Smuzhiyun 114*4882a593Smuzhiyunand once the client comes back, the board should reset. 115*4882a593Smuzhiyun 116*4882a593SmuzhiyunYou can also specify a kernel image to boot. You have to either specify 117*4882a593Smuzhiyunthe an image in Android format _or_ pass a binary kernel and let the 118*4882a593Smuzhiyunfastboot client wrap the Android suite around it. On OMAP for instance you 119*4882a593Smuzhiyuntake zImage kernel and pass it to the fastboot client: 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun|>fastboot -b 0x80000000 -c "console=ttyO2 earlyprintk root=/dev/ram0 122*4882a593Smuzhiyun| mem=128M" boot zImage 123*4882a593Smuzhiyun|creating boot image... 124*4882a593Smuzhiyun|creating boot image - 1847296 bytes 125*4882a593Smuzhiyun|downloading 'boot.img'... 126*4882a593Smuzhiyun|OKAY [ 2.766s] 127*4882a593Smuzhiyun|booting... 128*4882a593Smuzhiyun|OKAY [ -0.000s] 129*4882a593Smuzhiyun|finished. total time: 2.766s 130*4882a593Smuzhiyun 131*4882a593Smuzhiyunand on the gadget side you should see: 132*4882a593Smuzhiyun|Starting download of 1847296 bytes 133*4882a593Smuzhiyun|........................................................ 134*4882a593Smuzhiyun|downloading of 1847296 bytes finished 135*4882a593Smuzhiyun|Booting kernel.. 136*4882a593Smuzhiyun|## Booting Android Image at 0x81000000 ... 137*4882a593Smuzhiyun|Kernel load addr 0x80008000 size 1801 KiB 138*4882a593Smuzhiyun|Kernel command line: console=ttyO2 earlyprintk root=/dev/ram0 mem=128M 139*4882a593Smuzhiyun| Loading Kernel Image ... OK 140*4882a593Smuzhiyun|OK 141*4882a593Smuzhiyun| 142*4882a593Smuzhiyun|Starting kernel ... 143