blob: de3f6c37d7d52c7749be8fe8d625dd867239a675 [file] [log] [blame]
Sam Protsenkocd43fa12020-01-24 17:53:44 +02001.. SPDX-License-Identifier: GPL-2.0+
2
Sebastian Siewior9d4471e2014-05-05 15:08:10 -05003Android Fastboot
Alex Kiernana59e9132018-05-29 15:30:56 +00004================
Sebastian Siewior9d4471e2014-05-05 15:08:10 -05005
6Overview
Sam Protsenkocd43fa12020-01-24 17:53:44 +02007--------
Sebastian Siewior9d4471e2014-05-05 15:08:10 -05008
Sam Protsenkocd43fa12020-01-24 17:53:44 +02009The protocol that is used over USB and UDP is described in [1]_.
Alex Kiernana59e9132018-05-29 15:30:56 +000010
11The current implementation supports the following standard commands:
12
13- ``boot``
14- ``continue``
15- ``download``
16- ``erase`` (if enabled)
17- ``flash`` (if enabled)
18- ``getvar``
19- ``reboot``
20- ``reboot-bootloader``
21- ``set_active`` (only a stub implementation which always succeeds)
22
23The following OEM commands are supported (if enabled):
24
Sam Protsenkocd43fa12020-01-24 17:53:44 +020025- ``oem format`` - this executes ``gpt write mmc %x $partitions``
Alex Kiernana59e9132018-05-29 15:30:56 +000026
27Support for both eMMC and NAND devices is included.
Sebastian Siewior9d4471e2014-05-05 15:08:10 -050028
29Client installation
Sam Protsenkocd43fa12020-01-24 17:53:44 +020030-------------------
Sebastian Siewior9d4471e2014-05-05 15:08:10 -050031
Alex Kiernana59e9132018-05-29 15:30:56 +000032The counterpart to this is the fastboot client which can be found in
33Android's ``platform/system/core`` repository in the fastboot
34folder. It runs on Windows, Linux and OSX. The fastboot client is
Sam Protsenkocd43fa12020-01-24 17:53:44 +020035part of the Android SDK Platform-Tools and can be downloaded from [2]_.
Sebastian Siewior9d4471e2014-05-05 15:08:10 -050036
37Board specific
Sam Protsenkocd43fa12020-01-24 17:53:44 +020038--------------
Alex Kiernana59e9132018-05-29 15:30:56 +000039
40USB configuration
Sam Protsenkocd43fa12020-01-24 17:53:44 +020041^^^^^^^^^^^^^^^^^
Alex Kiernana59e9132018-05-29 15:30:56 +000042
Sebastian Siewior9d4471e2014-05-05 15:08:10 -050043The fastboot gadget relies on the USB download gadget, so the following
44options must be configured:
45
Alex Kiernana59e9132018-05-29 15:30:56 +000046::
47
48 CONFIG_USB_GADGET_DOWNLOAD
49 CONFIG_USB_GADGET_VENDOR_NUM
50 CONFIG_USB_GADGET_PRODUCT_NUM
51 CONFIG_USB_GADGET_MANUFACTURER
52
53NOTE: The ``CONFIG_USB_GADGET_VENDOR_NUM`` must be one of the numbers
54supported by the fastboot client. The list of vendor IDs supported can
55be found in the fastboot client source code.
Sebastian Siewior9d4471e2014-05-05 15:08:10 -050056
Alex Kiernana59e9132018-05-29 15:30:56 +000057General configuration
Sam Protsenkocd43fa12020-01-24 17:53:44 +020058^^^^^^^^^^^^^^^^^^^^^
Barnes, Clifton A1f9f3212014-07-22 11:23:56 -040059
Alex Kiernana59e9132018-05-29 15:30:56 +000060The fastboot protocol requires a large memory buffer for
61downloads. This buffer should be as large as possible for a
62platform. The location of the buffer and size are set with
63``CONFIG_FASTBOOT_BUF_ADDR`` and ``CONFIG_FASTBOOT_BUF_SIZE``. These
64may be overridden on the fastboot command line using ``-l`` and
65``-s``.
Sebastian Siewior9d4471e2014-05-05 15:08:10 -050066
Alex Kiernana59e9132018-05-29 15:30:56 +000067Fastboot environment variables
Sam Protsenkocd43fa12020-01-24 17:53:44 +020068------------------------------
Alex Kiernana59e9132018-05-29 15:30:56 +000069
70Partition aliases
Sam Protsenkocd43fa12020-01-24 17:53:44 +020071^^^^^^^^^^^^^^^^^
Sebastian Siewior9d4471e2014-05-05 15:08:10 -050072
Michael Scottced33492015-03-11 10:02:31 -070073Fastboot partition aliases can also be defined for devices where GPT
Sam Protsenkocd43fa12020-01-24 17:53:44 +020074limitations prevent user-friendly partition names such as ``boot``, ``system``
75and ``cache``. Or, where the actual partition name doesn't match a standard
Alex Kiernana59e9132018-05-29 15:30:56 +000076partition name used commonly with fastboot.
77
78The current implementation checks aliases when accessing partitions by
79name (flash_write and erase functions). To define a partition alias
Sam Protsenkocd43fa12020-01-24 17:53:44 +020080add an environment variable similar to::
Alex Kiernana59e9132018-05-29 15:30:56 +000081
Sam Protsenkocd43fa12020-01-24 17:53:44 +020082 fastboot_partition_alias_<alias partition name>=<actual partition name>
Alex Kiernana59e9132018-05-29 15:30:56 +000083
Sam Protsenkocd43fa12020-01-24 17:53:44 +020084for example::
Alex Kiernana59e9132018-05-29 15:30:56 +000085
Sam Protsenkocd43fa12020-01-24 17:53:44 +020086 fastboot_partition_alias_boot=LNX
Alex Kiernana59e9132018-05-29 15:30:56 +000087
88Variable overrides
Sam Protsenkocd43fa12020-01-24 17:53:44 +020089^^^^^^^^^^^^^^^^^^
Alex Kiernana59e9132018-05-29 15:30:56 +000090
91Variables retrived through ``getvar`` can be overridden by defining
92environment variables of the form ``fastboot.<variable>``. These are
93looked up first so can be used to override values which would
94otherwise be returned. Using this mechanism you can also return types
95for NAND filesystems, as the fully parameterised variable is looked
Sam Protsenkocd43fa12020-01-24 17:53:44 +020096up, e.g.::
Alex Kiernana59e9132018-05-29 15:30:56 +000097
Sam Protsenkocd43fa12020-01-24 17:53:44 +020098 fastboot.partition-type:boot=jffs2
Alex Kiernana59e9132018-05-29 15:30:56 +000099
100Boot command
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200101^^^^^^^^^^^^
Alex Kiernana59e9132018-05-29 15:30:56 +0000102
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200103When executing the fastboot ``boot`` command, if ``fastboot_bootcmd`` is set
104then that will be executed in place of ``bootm <CONFIG_FASTBOOT_BUF_ADDR>``.
Michael Scottced33492015-03-11 10:02:31 -0700105
Petr Kulhavy9f174c92016-09-09 10:27:16 +0200106Partition Names
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200107---------------
Alex Kiernana59e9132018-05-29 15:30:56 +0000108
109The Fastboot implementation in U-Boot allows to write images into disk
110partitions. Target partitions are referred on the host computer by
111their names.
Petr Kulhavy9f174c92016-09-09 10:27:16 +0200112
113For GPT/EFI the respective partition name is used.
114
115For MBR the partitions are referred by generic names according to the
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200116following schema::
Petr Kulhavy9f174c92016-09-09 10:27:16 +0200117
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200118 <device type><device index letter><partition index>
Petr Kulhavy9f174c92016-09-09 10:27:16 +0200119
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200120Example: ``hda3``, ``sdb1``, ``usbda1``.
Petr Kulhavy9f174c92016-09-09 10:27:16 +0200121
122The device type is as follows:
123
Alex Kiernana59e9132018-05-29 15:30:56 +0000124 * IDE, ATAPI and SATA disks: ``hd``
125 * SCSI disks: ``sd``
126 * USB media: ``usbd``
127 * MMC and SD cards: ``mmcsd``
128 * Disk on chip: ``docd``
129 * other: ``xx``
Petr Kulhavy9f174c92016-09-09 10:27:16 +0200130
Alex Kiernana59e9132018-05-29 15:30:56 +0000131The device index starts from ``a`` and refers to the interface (e.g. USB
Petr Kulhavy9f174c92016-09-09 10:27:16 +0200132controller, SD/MMC controller) or disk index. The partition index starts
Alex Kiernana59e9132018-05-29 15:30:56 +0000133from ``1`` and describes the partition number on the particular device.
Petr Kulhavy9f174c92016-09-09 10:27:16 +0200134
135Writing Partition Table
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200136-----------------------
Alex Kiernana59e9132018-05-29 15:30:56 +0000137
Petr Kulhavy9f174c92016-09-09 10:27:16 +0200138Fastboot also allows to write the partition table to the media. This can be
139done by writing the respective partition table image to a special target
140"gpt" or "mbr". These names can be customized by defining the following
141configuration options:
142
Alex Kiernana59e9132018-05-29 15:30:56 +0000143::
144
145 CONFIG_FASTBOOT_GPT_NAME
146 CONFIG_FASTBOOT_MBR_NAME
Petr Kulhavy9f174c92016-09-09 10:27:16 +0200147
Sebastian Siewior9d4471e2014-05-05 15:08:10 -0500148In Action
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200149---------
Alex Kiernana59e9132018-05-29 15:30:56 +0000150
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200151Enter into fastboot by executing the fastboot command in U-Boot for either USB::
Alex Kiernana59e9132018-05-29 15:30:56 +0000152
153 => fastboot usb 0
154
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200155or UDP::
Alex Kiernana59e9132018-05-29 15:30:56 +0000156
157 => fastboot udp
158 link up on port 0, speed 100, full duplex
159 Using ethernet@4a100000 device
160 Listening for fastboot command on 192.168.0.102
Sebastian Siewior9d4471e2014-05-05 15:08:10 -0500161
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200162On the client side you can fetch the bootloader version for instance::
Alex Kiernana59e9132018-05-29 15:30:56 +0000163
Sam Protsenkoac21e742019-07-03 19:34:07 +0300164 $ fastboot getvar version-bootloader
165 version-bootloader: U-Boot 2019.07-rc4-00240-g00c9f2a2ec
166 Finished. Total time: 0.005s
Sebastian Siewior9d4471e2014-05-05 15:08:10 -0500167
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200168or initiate a reboot::
Alex Kiernana59e9132018-05-29 15:30:56 +0000169
170 $ fastboot reboot
Sebastian Siewior9d4471e2014-05-05 15:08:10 -0500171
172and once the client comes back, the board should reset.
173
174You can also specify a kernel image to boot. You have to either specify
Alex Kiernana59e9132018-05-29 15:30:56 +0000175the an image in Android format *or* pass a binary kernel and let the
Sebastian Siewior9d4471e2014-05-05 15:08:10 -0500176fastboot client wrap the Android suite around it. On OMAP for instance you
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200177take zImage kernel and pass it to the fastboot client::
Alex Kiernana59e9132018-05-29 15:30:56 +0000178
179 $ fastboot -b 0x80000000 -c "console=ttyO2 earlyprintk root=/dev/ram0 mem=128M" boot zImage
180 creating boot image...
181 creating boot image - 1847296 bytes
182 downloading 'boot.img'...
183 OKAY [ 2.766s]
184 booting...
185 OKAY [ -0.000s]
186 finished. total time: 2.766s
187
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200188and on the U-Boot side you should see::
Alex Kiernana59e9132018-05-29 15:30:56 +0000189
190 Starting download of 1847296 bytes
191 ........................................................
192 downloading of 1847296 bytes finished
193 Booting kernel..
194 ## Booting Android Image at 0x81000000 ...
195 Kernel load addr 0x80008000 size 1801 KiB
196 Kernel command line: console=ttyO2 earlyprintk root=/dev/ram0 mem=128M
197 Loading Kernel Image ... OK
198 OK
Sebastian Siewior9d4471e2014-05-05 15:08:10 -0500199
Alex Kiernana59e9132018-05-29 15:30:56 +0000200 Starting kernel ...
Sam Protsenkocd43fa12020-01-24 17:53:44 +0200201
202References
203----------
204
205.. [1] :doc:`fastboot-protocol`
206.. [2] https://developer.android.com/studio/releases/platform-tools