blob: 358a448829bc1c8fe04887f4ba680900e4051df3 [file] [log] [blame]
Scott Anderson9bfecb02012-12-06 09:34:34 -08001
2FastBoot Version 0.4
3----------------------
4
5The fastboot protocol is a mechanism for communicating with bootloaders
David Pursell2ec418a2016-01-20 08:32:08 -08006over USB or ethernet. It is designed to be very straightforward to implement,
7to allow it to be used across a wide range of devices and from hosts running
Scott Anderson9bfecb02012-12-06 09:34:34 -08008Linux, Windows, or OSX.
9
10
11Basic Requirements
12------------------
13
David Pursell2ec418a2016-01-20 08:32:08 -080014* USB
15 * Two bulk endpoints (in, out) are required
16 * Max packet size must be 64 bytes for full-speed, 512 bytes for
17 high-speed and 1024 bytes for Super Speed USB.
18 * The protocol is entirely host-driven and synchronous (unlike the
19 multi-channel, bi-directional, asynchronous ADB protocol)
20
21* TCP
22 * Device must be reachable via IP.
23 * Device will act as the TCP server, fastboot will be the client.
24 * Fastboot data is wrapped in a simple protocol; see below for details.
Scott Anderson9bfecb02012-12-06 09:34:34 -080025
26
27Transport and Framing
28---------------------
29
301. Host sends a command, which is an ascii string in a single
31 packet no greater than 64 bytes.
32
332. Client response with a single packet no greater than 64 bytes.
34 The first four bytes of the response are "OKAY", "FAIL", "DATA",
35 or "INFO". Additional bytes may contain an (ascii) informative
36 message.
37
38 a. INFO -> the remaining 60 bytes are an informative message
39 (providing progress or diagnostic messages). They should
40 be displayed and then step #2 repeats
41
42 b. FAIL -> the requested command failed. The remaining 60 bytes
43 of the response (if present) provide a textual failure message
44 to present to the user. Stop.
45
46 c. OKAY -> the requested command completed successfully. Go to #5
47
48 d. DATA -> the requested command is ready for the data phase.
49 A DATA response packet will be 12 bytes long, in the form of
Elliott Hughesfc797672015-04-07 20:12:50 -070050 DATA00000000 where the 8 digit hexadecimal number represents
Scott Anderson9bfecb02012-12-06 09:34:34 -080051 the total data size to transfer.
52
533. Data phase. Depending on the command, the host or client will
54 send the indicated amount of data. Short packets are always
55 acceptable and zero-length packets are ignored. This phase continues
56 until the client has sent or received the number of bytes indicated
57 in the "DATA" response above.
58
594. Client responds with a single packet no greater than 64 bytes.
60 The first four bytes of the response are "OKAY", "FAIL", or "INFO".
61 Similar to #2:
62
63 a. INFO -> display the remaining 60 bytes and return to #4
64
65 b. FAIL -> display the remaining 60 bytes (if present) as a failure
66 reason and consider the command failed. Stop.
67
68 c. OKAY -> success. Go to #5
69
705. Success. Stop.
71
72
73Example Session
74---------------
75
76Host: "getvar:version" request version variable
77
78Client: "OKAY0.4" return version "0.4"
79
80Host: "getvar:nonexistant" request some undefined variable
81
82Client: "OKAY" return value ""
83
84Host: "download:00001234" request to send 0x1234 bytes of data
85
86Client: "DATA00001234" ready to accept data
87
88Host: < 0x1234 bytes > send data
89
90Client: "OKAY" success
91
92Host: "flash:bootloader" request to flash the data to the bootloader
93
94Client: "INFOerasing flash" indicate status / progress
95 "INFOwriting flash"
96 "OKAY" indicate success
97
98Host: "powerdown" send a command
99
100Client: "FAILunknown command" indicate failure
101
102
103Command Reference
104-----------------
105
106* Command parameters are indicated by printf-style escape sequences.
107
108* Commands are ascii strings and sent without the quotes (which are
109 for illustration only here) and without a trailing 0 byte.
110
111* Commands that begin with a lowercase letter are reserved for this
112 specification. OEM-specific commands should not begin with a
113 lowercase letter, to prevent incompatibilities with future specs.
114
115 "getvar:%s" Read a config/version variable from the bootloader.
116 The variable contents will be returned after the
117 OKAY response.
118
119 "download:%08x" Write data to memory which will be later used
120 by "boot", "ramdisk", "flash", etc. The client
121 will reply with "DATA%08x" if it has enough
122 space in RAM or "FAIL" if not. The size of
123 the download is remembered.
124
125 "verify:%08x" Send a digital signature to verify the downloaded
126 data. Required if the bootloader is "secure"
127 otherwise "flash" and "boot" will be ignored.
128
129 "flash:%s" Write the previously downloaded image to the
130 named partition (if possible).
131
132 "erase:%s" Erase the indicated partition (clear to 0xFFs)
133
134 "boot" The previously downloaded data is a boot.img
135 and should be booted according to the normal
136 procedure for a boot.img
137
138 "continue" Continue booting as normal (if possible)
139
140 "reboot" Reboot the device.
141
142 "reboot-bootloader" Reboot back into the bootloader.
143 Useful for upgrade processes that require upgrading
144 the bootloader and then upgrading other partitions
145 using the new bootloader.
146
147 "powerdown" Power off the device.
148
149
150
151Client Variables
152----------------
153
154The "getvar:%s" command is used to read client variables which
155represent various information about the device and the software
156on it.
157
158The various currently defined names are:
159
160 version Version of FastBoot protocol supported.
161 It should be "0.3" for this document.
162
163 version-bootloader Version string for the Bootloader.
164
165 version-baseband Version string of the Baseband Software
166
167 product Name of the product
168
169 serialno Product serial number
170
171 secure If the value is "yes", this is a secure
172 bootloader requiring a signature before
173 it will install or boot images.
174
175Names starting with a lowercase character are reserved by this
176specification. OEM-specific names should not start with lowercase
177characters.
178
179
David Pursell2ec418a2016-01-20 08:32:08 -0800180TCP Protocol v1
181---------------
182
183The TCP protocol is designed to be a simple way to use the fastboot protocol
184over ethernet if USB is not available.
185
186The device will open a TCP server on port 5554 and wait for a fastboot client
187to connect.
188
189-- Handshake --
190Upon connecting, both sides will send a 4-byte handshake message to ensure they
191are speaking the same protocol. This consists of the ASCII characters "FB"
192followed by a 2-digit base-10 ASCII version number. For example, the version 1
193handshake message will be [FB01].
194
195If either side detects a malformed handshake, it should disconnect.
196
197The protocol version to use must be the minimum of the versions sent by each
198side; if either side cannot speak this protocol version, it should disconnect.
199
200-- Fastboot Data --
201Once the handshake is complete, fastboot data will be sent as follows:
202
203 [data_size][data]
204
205Where data_size is an unsigned 8-byte big-endian binary value, and data is the
206fastboot packet. The 8-byte length is intended to provide future-proofing even
207though currently fastboot packets have a 4-byte maximum length.
208
209-- Example --
210In this example the fastboot host queries the device for two variables,
211"version" and "none".
212
213Host <connect to the device on port 5555>
214Host FB01
215Device FB01
216Host [0x00][0x00][0x00][0x00][0x00][0x00][0x00][0x0E]getvar:version
217Device [0x00][0x00][0x00][0x00][0x00][0x00][0x00][0x07]OKAY0.4
218Host [0x00][0x00][0x00][0x00][0x00][0x00][0x00][0x0B]getvar:none
219Device [0x00][0x00][0x00][0x00][0x00][0x00][0x00][0x04]OKAY
220Host <disconnect>