Sebastian Siewior | 3aab70a | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 1 | Android Fastboot |
| 2 | ~~~~~~~~~~~~~~~~ |
| 3 | |
| 4 | Overview |
| 5 | ======== |
| 6 | The protocol that is used over USB is described in |
| 7 | README.android-fastboot-protocol in same directory. |
| 8 | |
Dileep Katta | 8979238 | 2015-02-17 18:48:23 +0530 | [diff] [blame] | 9 | The current implementation is a minimal support of the erase command,the |
| 10 | "oem format" command and flash command;it only supports eMMC devices. |
Sebastian Siewior | 3aab70a | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 11 | |
| 12 | Client installation |
| 13 | =================== |
| 14 | The counterpart to this gadget is the fastboot client which can |
| 15 | be found in Android's platform/system/core repository in the fastboot |
| 16 | folder. It runs on Windows, Linux and even OSX. Linux user are lucky since |
| 17 | they only need libusb. |
| 18 | Windows users need to bring some time until they have Android SDK (currently |
| 19 | http://dl.google.com/android/installer_r12-windows.exe) installed. You |
| 20 | need to install ADB package which contains the required glue libraries for |
| 21 | accessing USB. Also you need "Google USB driver package" and "SDK platform |
| 22 | tools". Once installed the usb driver is placed in your SDK folder under |
| 23 | extras\google\usb_driver. The android_winusb.inf needs a line like |
| 24 | |
| 25 | %SingleBootLoaderInterface% = USB_Install, USB\VID_0451&PID_D022 |
| 26 | |
| 27 | either in the [Google.NTx86] section for 32bit Windows or [Google.NTamd64] |
| 28 | for 64bit Windows. VID and PID should match whatever the fastboot is |
| 29 | advertising. |
| 30 | |
| 31 | Board specific |
| 32 | ============== |
| 33 | The fastboot gadget relies on the USB download gadget, so the following |
| 34 | options must be configured: |
| 35 | |
Paul Kocialkowski | 01acd6a | 2015-06-12 19:56:58 +0200 | [diff] [blame] | 36 | CONFIG_USB_GADGET_DOWNLOAD |
Sebastian Siewior | 3aab70a | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 37 | CONFIG_G_DNL_VENDOR_NUM |
| 38 | CONFIG_G_DNL_PRODUCT_NUM |
| 39 | CONFIG_G_DNL_MANUFACTURER |
| 40 | |
Barnes, Clifton A | 183cbff | 2014-07-22 11:23:56 -0400 | [diff] [blame] | 41 | NOTE: The CONFIG_G_DNL_VENDOR_NUM must be one of the numbers supported by |
| 42 | the fastboot client. The list of vendor IDs supported can be found in the |
| 43 | fastboot client source code (fastboot.c) mentioned above. |
| 44 | |
Paul Kocialkowski | 17da3c0 | 2015-06-12 19:56:59 +0200 | [diff] [blame] | 45 | The fastboot function is enabled by defining CONFIG_USB_FUNCTION_FASTBOOT, |
| 46 | CONFIG_CMD_FASTBOOT and CONFIG_ANDROID_BOOT_IMAGE. |
Sebastian Siewior | 3aab70a | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 47 | |
| 48 | The fastboot protocol requires a large memory buffer for downloads. This |
| 49 | buffer should be as large as possible for a platform. The location of the |
Paul Kocialkowski | a588d99 | 2015-07-20 12:38:22 +0200 | [diff] [blame] | 50 | buffer and size are set with CONFIG_FASTBOOT_BUF_ADDR and |
| 51 | CONFIG_FASTBOOT_BUF_SIZE. |
Sebastian Siewior | 3aab70a | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 52 | |
Michael Scott | 8a41802 | 2015-03-11 10:02:31 -0700 | [diff] [blame] | 53 | Fastboot partition aliases can also be defined for devices where GPT |
| 54 | limitations prevent user-friendly partition names such as "boot", "system" |
| 55 | and "cache". Or, where the actual partition name doesn't match a standard |
| 56 | partition name used commonly with fastboot. Current implentation checks |
| 57 | aliases when accessing partitions by name (flash_write and erase functions). |
| 58 | To define a partition alias add an environment variable similar to: |
| 59 | fastboot_partition_alias_<alias partition name>=<actual partition name> |
| 60 | Example: fastboot_partition_alias_boot=LNX |
| 61 | |
Petr Kulhavy | b6dd69a | 2016-09-09 10:27:16 +0200 | [diff] [blame] | 62 | Partition Names |
| 63 | =============== |
| 64 | The Fastboot implementation in U-boot allows to write images into disk |
| 65 | partitions (currently on eMMC). Target partitions are referred on the host |
| 66 | computer by their names. |
| 67 | |
| 68 | For GPT/EFI the respective partition name is used. |
| 69 | |
| 70 | For MBR the partitions are referred by generic names according to the |
| 71 | following schema: |
| 72 | |
| 73 | <device type> <device index letter> <partition index> |
| 74 | |
| 75 | Example: hda3, sdb1, usbda1 |
| 76 | |
| 77 | The device type is as follows: |
| 78 | |
| 79 | * IDE, ATAPI and SATA disks: hd |
| 80 | * SCSI disks: sd |
| 81 | * USB media: usbd |
Petr Kulhavy | da2ee24 | 2016-09-09 10:27:17 +0200 | [diff] [blame] | 82 | * MMC and SD cards: mmcsd |
Petr Kulhavy | b6dd69a | 2016-09-09 10:27:16 +0200 | [diff] [blame] | 83 | * Disk on chip: docd |
| 84 | * other: xx |
| 85 | |
| 86 | The device index starts from 'a' and refers to the interface (e.g. USB |
| 87 | controller, SD/MMC controller) or disk index. The partition index starts |
| 88 | from 1 and describes the partition number on the particular device. |
| 89 | |
| 90 | Writing Partition Table |
| 91 | ======================= |
| 92 | Fastboot also allows to write the partition table to the media. This can be |
| 93 | done by writing the respective partition table image to a special target |
| 94 | "gpt" or "mbr". These names can be customized by defining the following |
| 95 | configuration options: |
| 96 | |
| 97 | CONFIG_FASTBOOT_GPT_NAME |
| 98 | CONFIG_FASTBOOT_MBR_NAME |
| 99 | |
Sebastian Siewior | 3aab70a | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 100 | In Action |
| 101 | ========= |
| 102 | Enter into fastboot by executing the fastboot command in u-boot and you |
| 103 | should see: |
| 104 | |GADGET DRIVER: usb_dnl_fastboot |
| 105 | |
| 106 | On the client side you can fetch the bootloader version for instance: |
| 107 | |>fastboot getvar bootloader-version |
| 108 | |bootloader-version: U-Boot 2014.04-00005-gd24cabc |
| 109 | |finished. total time: 0.000s |
| 110 | |
| 111 | or initiate a reboot: |
| 112 | |>fastboot reboot |
| 113 | |
| 114 | and once the client comes back, the board should reset. |
| 115 | |
| 116 | You can also specify a kernel image to boot. You have to either specify |
| 117 | the an image in Android format _or_ pass a binary kernel and let the |
| 118 | fastboot client wrap the Android suite around it. On OMAP for instance you |
| 119 | take zImage kernel and pass it to the fastboot client: |
| 120 | |
| 121 | |>fastboot -b 0x80000000 -c "console=ttyO2 earlyprintk root=/dev/ram0 |
| 122 | | mem=128M" boot zImage |
| 123 | |creating boot image... |
| 124 | |creating boot image - 1847296 bytes |
| 125 | |downloading 'boot.img'... |
| 126 | |OKAY [ 2.766s] |
| 127 | |booting... |
| 128 | |OKAY [ -0.000s] |
| 129 | |finished. total time: 2.766s |
| 130 | |
| 131 | and on the gadget side you should see: |
| 132 | |Starting download of 1847296 bytes |
| 133 | |........................................................ |
| 134 | |downloading of 1847296 bytes finished |
| 135 | |Booting kernel.. |
| 136 | |## Booting Android Image at 0x81000000 ... |
| 137 | |Kernel load addr 0x80008000 size 1801 KiB |
| 138 | |Kernel command line: console=ttyO2 earlyprintk root=/dev/ram0 mem=128M |
| 139 | | Loading Kernel Image ... OK |
| 140 | |OK |
| 141 | | |
| 142 | |Starting kernel ... |