fastboot-protocol.txt 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. FastBoot Version 0.4
  2. ----------------------
  3. The fastboot protocol is a mechanism for communicating with bootloaders
  4. over USB. It is designed to be very straightforward to implement, to
  5. allow it to be used across a wide range of devices and from hosts running
  6. Linux, Windows, or OSX.
  7. Basic Requirements
  8. ------------------
  9. * Two bulk endpoints (in, out) are required
  10. * Max packet size must be 64 bytes for full-speed and 512 bytes for
  11. high-speed USB
  12. * The protocol is entirely host-driven and synchronous (unlike the
  13. multi-channel, bi-directional, asynchronous ADB protocol)
  14. Transport and Framing
  15. ---------------------
  16. 1. Host sends a command, which is an ascii string in a single
  17. packet no greater than 64 bytes.
  18. 2. Client response with a single packet no greater than 64 bytes.
  19. The first four bytes of the response are "OKAY", "FAIL", "DATA",
  20. or "INFO". Additional bytes may contain an (ascii) informative
  21. message.
  22. a. INFO -> the remaining 60 bytes are an informative message
  23. (providing progress or diagnostic messages). They should
  24. be displayed and then step #2 repeats
  25. b. FAIL -> the requested command failed. The remaining 60 bytes
  26. of the response (if present) provide a textual failure message
  27. to present to the user. Stop.
  28. c. OKAY -> the requested command completed successfully. Go to #5
  29. d. DATA -> the requested command is ready for the data phase.
  30. A DATA response packet will be 12 bytes long, in the form of
  31. DATA00000000 where the 8 digit hexidecimal number represents
  32. the total data size to transfer.
  33. 3. Data phase. Depending on the command, the host or client will
  34. send the indicated amount of data. Short packets are always
  35. acceptable and zero-length packets are ignored. This phase continues
  36. until the client has sent or received the number of bytes indicated
  37. in the "DATA" response above.
  38. 4. Client responds with a single packet no greater than 64 bytes.
  39. The first four bytes of the response are "OKAY", "FAIL", or "INFO".
  40. Similar to #2:
  41. a. INFO -> display the remaining 60 bytes and return to #4
  42. b. FAIL -> display the remaining 60 bytes (if present) as a failure
  43. reason and consider the command failed. Stop.
  44. c. OKAY -> success. Go to #5
  45. 5. Success. Stop.
  46. Example Session
  47. ---------------
  48. Host: "getvar:version" request version variable
  49. Client: "OKAY0.4" return version "0.4"
  50. Host: "getvar:nonexistant" request some undefined variable
  51. Client: "OKAY" return value ""
  52. Host: "download:00001234" request to send 0x1234 bytes of data
  53. Client: "DATA00001234" ready to accept data
  54. Host: < 0x1234 bytes > send data
  55. Client: "OKAY" success
  56. Host: "flash:bootloader" request to flash the data to the bootloader
  57. Client: "INFOerasing flash" indicate status / progress
  58. "INFOwriting flash"
  59. "OKAY" indicate success
  60. Host: "powerdown" send a command
  61. Client: "FAILunknown command" indicate failure
  62. Command Reference
  63. -----------------
  64. * Command parameters are indicated by printf-style escape sequences.
  65. * Commands are ascii strings and sent without the quotes (which are
  66. for illustration only here) and without a trailing 0 byte.
  67. * Commands that begin with a lowercase letter are reserved for this
  68. specification. OEM-specific commands should not begin with a
  69. lowercase letter, to prevent incompatibilities with future specs.
  70. "getvar:%s" Read a config/version variable from the bootloader.
  71. The variable contents will be returned after the
  72. OKAY response.
  73. "download:%08x" Write data to memory which will be later used
  74. by "boot", "ramdisk", "flash", etc. The client
  75. will reply with "DATA%08x" if it has enough
  76. space in RAM or "FAIL" if not. The size of
  77. the download is remembered.
  78. "verify:%08x" Send a digital signature to verify the downloaded
  79. data. Required if the bootloader is "secure"
  80. otherwise "flash" and "boot" will be ignored.
  81. "flash:%s" Write the previously downloaded image to the
  82. named partition (if possible).
  83. "erase:%s" Erase the indicated partition (clear to 0xFFs)
  84. "boot" The previously downloaded data is a boot.img
  85. and should be booted according to the normal
  86. procedure for a boot.img
  87. "continue" Continue booting as normal (if possible)
  88. "reboot" Reboot the device.
  89. "reboot-bootloader" Reboot back into the bootloader.
  90. Useful for upgrade processes that require upgrading
  91. the bootloader and then upgrading other partitions
  92. using the new bootloader.
  93. "powerdown" Power off the device.
  94. Client Variables
  95. ----------------
  96. The "getvar:%s" command is used to read client variables which
  97. represent various information about the device and the software
  98. on it.
  99. The various currently defined names are:
  100. version Version of FastBoot protocol supported.
  101. It should be "0.3" for this document.
  102. version-bootloader Version string for the Bootloader.
  103. version-baseband Version string of the Baseband Software
  104. product Name of the product
  105. serialno Product serial number
  106. secure If the value is "yes", this is a secure
  107. bootloader requiring a signature before
  108. it will install or boot images.
  109. Names starting with a lowercase character are reserved by this
  110. specification. OEM-specific names should not start with lowercase
  111. characters.