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