fastboot.txt 5.8 KB

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