fastboot.rst 5.8 KB

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