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