fastboot.rst 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. .. SPDX-License-Identifier: GPL-2.0+
  2. Android Fastboot
  3. ================
  4. Overview
  5. --------
  6. The protocol that is used over USB and UDP is described in [1]_.
  7. The current implementation supports the following standard commands:
  8. - ``boot``
  9. - ``continue``
  10. - ``download``
  11. - ``erase`` (if enabled)
  12. - ``flash`` (if enabled)
  13. - ``getvar``
  14. - ``reboot``
  15. - ``reboot-bootloader``
  16. - ``set_active`` (only a stub implementation which always succeeds)
  17. - ``ucmd`` (if enabled)
  18. - ``acmd`` (if enabled)
  19. The following OEM commands are supported (if enabled):
  20. - ``oem format`` - this executes ``gpt write mmc %x $partitions``
  21. - ``oem partconf`` - this executes ``mmc partconf %x <arg> 0`` to configure eMMC
  22. with <arg> = boot_ack boot_partition
  23. - ``oem bootbus`` - this executes ``mmc bootbus %x %s`` to configure eMMC
  24. Support for both eMMC and NAND devices is included.
  25. Client installation
  26. -------------------
  27. The counterpart to this is the fastboot client which can be found in
  28. Android's ``platform/system/core`` repository in the fastboot
  29. folder. It runs on Windows, Linux and OSX. The fastboot client is
  30. part of the Android SDK Platform-Tools and can be downloaded from [2]_.
  31. Board specific
  32. --------------
  33. USB configuration
  34. ^^^^^^^^^^^^^^^^^
  35. The fastboot gadget relies on the USB download gadget, so the following
  36. options must be configured:
  37. ::
  38. CONFIG_USB_GADGET_DOWNLOAD
  39. CONFIG_USB_GADGET_VENDOR_NUM
  40. CONFIG_USB_GADGET_PRODUCT_NUM
  41. CONFIG_USB_GADGET_MANUFACTURER
  42. NOTE: The ``CONFIG_USB_GADGET_VENDOR_NUM`` must be one of the numbers
  43. supported by the fastboot client. The list of vendor IDs supported can
  44. be found in the fastboot client source code.
  45. General configuration
  46. ^^^^^^^^^^^^^^^^^^^^^
  47. The fastboot protocol requires a large memory buffer for
  48. downloads. This buffer should be as large as possible for a
  49. platform. The location of the buffer and size are set with
  50. ``CONFIG_FASTBOOT_BUF_ADDR`` and ``CONFIG_FASTBOOT_BUF_SIZE``. These
  51. may be overridden on the fastboot command line using ``-l`` and
  52. ``-s``.
  53. Fastboot environment variables
  54. ------------------------------
  55. Partition aliases
  56. ^^^^^^^^^^^^^^^^^
  57. Fastboot partition aliases can also be defined for devices where GPT
  58. limitations prevent user-friendly partition names such as ``boot``, ``system``
  59. and ``cache``. Or, where the actual partition name doesn't match a standard
  60. partition name used commonly with fastboot.
  61. The current implementation checks aliases when accessing partitions by
  62. name (flash_write and erase functions). To define a partition alias
  63. add an environment variable similar to::
  64. fastboot_partition_alias_<alias partition name>=<actual partition name>
  65. for example::
  66. fastboot_partition_alias_boot=LNX
  67. Raw partition descriptors
  68. ^^^^^^^^^^^^^^^^^^^^^^^^^
  69. In cases where no partition table is present, a raw partition descriptor can be
  70. defined, specifying the offset, size, and optionally the MMC hardware partition
  71. number for a given partition name.
  72. This is useful when using fastboot to flash files (e.g. SPL or U-Boot) to a
  73. specific offset in the eMMC boot partition, without having to update the entire
  74. boot partition.
  75. To define a raw partition descriptor, add an environment variable similar to::
  76. fastboot_raw_partition_<raw partition name>=<offset> <size> [mmcpart <num>]
  77. for example::
  78. fastboot_raw_partition_boot=0x100 0x1f00 mmcpart 1
  79. Variable overrides
  80. ^^^^^^^^^^^^^^^^^^
  81. Variables retrived through ``getvar`` can be overridden by defining
  82. environment variables of the form ``fastboot.<variable>``. These are
  83. looked up first so can be used to override values which would
  84. otherwise be returned. Using this mechanism you can also return types
  85. for NAND filesystems, as the fully parameterised variable is looked
  86. up, e.g.::
  87. fastboot.partition-type:boot=jffs2
  88. Boot command
  89. ^^^^^^^^^^^^
  90. When executing the fastboot ``boot`` command, if ``fastboot_bootcmd`` is set
  91. then that will be executed in place of ``bootm <CONFIG_FASTBOOT_BUF_ADDR>``.
  92. Partition Names
  93. ---------------
  94. The Fastboot implementation in U-Boot allows to write images into disk
  95. partitions. Target partitions are referred on the host computer by
  96. their names.
  97. For GPT/EFI the respective partition name is used.
  98. For MBR the partitions are referred by generic names according to the
  99. following schema::
  100. <device type><device index letter><partition index>
  101. Example: ``hda3``, ``sdb1``, ``usbda1``.
  102. The device type is as follows:
  103. * IDE, ATAPI and SATA disks: ``hd``
  104. * SCSI disks: ``sd``
  105. * USB media: ``usbd``
  106. * MMC and SD cards: ``mmcsd``
  107. * Disk on chip: ``docd``
  108. * other: ``xx``
  109. The device index starts from ``a`` and refers to the interface (e.g. USB
  110. controller, SD/MMC controller) or disk index. The partition index starts
  111. from ``1`` and describes the partition number on the particular device.
  112. Alternatively, partition types may be specified using :ref:`U-Boot's partition
  113. syntax <partitions>`. This allows specifying partitions like ``0.1``,
  114. ``0#boot``, or ``:3``. The interface is always ``mmc``.
  115. Writing Partition Table
  116. -----------------------
  117. Fastboot also allows to write the partition table to the media. This can be
  118. done by writing the respective partition table image to a special target
  119. "gpt" or "mbr". These names can be customized by defining the following
  120. configuration options:
  121. ::
  122. CONFIG_FASTBOOT_GPT_NAME
  123. CONFIG_FASTBOOT_MBR_NAME
  124. In Action
  125. ---------
  126. Enter into fastboot by executing the fastboot command in U-Boot for either USB::
  127. => fastboot usb 0
  128. or UDP::
  129. => fastboot udp
  130. link up on port 0, speed 100, full duplex
  131. Using ethernet@4a100000 device
  132. Listening for fastboot command on 192.168.0.102
  133. On the client side you can fetch the bootloader version for instance::
  134. $ fastboot getvar version-bootloader
  135. version-bootloader: U-Boot 2019.07-rc4-00240-g00c9f2a2ec
  136. Finished. Total time: 0.005s
  137. or initiate a reboot::
  138. $ fastboot reboot
  139. and once the client comes back, the board should reset.
  140. You can also specify a kernel image to boot. You have to either specify
  141. the an image in Android format *or* pass a binary kernel and let the
  142. fastboot client wrap the Android suite around it. On OMAP for instance you
  143. take zImage kernel and pass it to the fastboot client::
  144. $ fastboot -b 0x80000000 -c "console=ttyO2 earlyprintk root=/dev/ram0 mem=128M" boot zImage
  145. creating boot image...
  146. creating boot image - 1847296 bytes
  147. downloading 'boot.img'...
  148. OKAY [ 2.766s]
  149. booting...
  150. OKAY [ -0.000s]
  151. finished. total time: 2.766s
  152. and on the U-Boot side you should see::
  153. Starting download of 1847296 bytes
  154. ........................................................
  155. downloading of 1847296 bytes finished
  156. Booting kernel..
  157. ## Booting Android Image at 0x81000000 ...
  158. Kernel load addr 0x80008000 size 1801 KiB
  159. Kernel command line: console=ttyO2 earlyprintk root=/dev/ram0 mem=128M
  160. Loading Kernel Image ... OK
  161. OK
  162. Starting kernel ...
  163. References
  164. ----------
  165. .. [1] :doc:`fastboot-protocol`
  166. .. [2] https://developer.android.com/studio/releases/platform-tools