1# Fastboot in GBL
2
3This document describes Fastboot in the [GBL UEFI bootloader](../efi/BUILD).
4
5## Transport
6
7The GBL UEFI bootloader supports both Fastboot over TCP and USB. To enable
8Fastboot over TCP, the UEFI loader needs to implement the
9`EFI_SIMPLE_NETWORK_PROTOCOL` protocol. To enable Fastboot over USB, the
10[EFI_ANDROID_BOOT_PROTOCOL](./EFI_ANDROID_BOOT_PROTOCOL.md) protocol is needed.
11GBL automatically establishes the corresponding transport channel if the needed
12protocol is available.
13
14## Definition of Partition
15
16Certain fastboot commands such as `fastboot flash`, `fastboot fetch` and
17`fastboot getvar partition-size` require to specify a partition. GBL Fastboot
18assumes that the platform may have multiple storage devices that may or may not
19use GPT partitions. Therefore, in the context of GBL Fastboot, the notion
20"partition" is defined to represent both GPT partitions or raw storage of any
21sub window and on any storage device. Specifically, the following semantics are
22introduced for specifying a partition:
23
24* GPT partitions
25  ```sh
26  <part>[:<block_id>]
27  <part>:[<block_id>][:<offset>]
28  <part>:[<block_id>]:[<offset>][:<size>]
29  ```
30  This specifies range `[offset, offset+size)` in GPT partition `part` on the
31  block device with ID `block id`. `block_id`, `offset` and `size` must be a
32  64bit integer hex string. If `block id` is not given, GBL will check and only
33  accept it if the GPT partition is unique among all devices. `offset` defaults
34  to 0 if not given. `size` defaults to the rest of the GPT partition after
35  `offset` if not given. The list of GPT partitions, block devices and IDs are
36  listed by `fastboot getvar all`
37
38  Examples:
39  * `fastboot flash boot_a` -- Checks that `boot_a` is a unique GPT partition
40  among all storage devices and flashes in the entire range of the partition.
41  * `fastboot flash boot_a:0x0` or `boot_a:0` -- Flashes in the entire range of
42  GPT partition "boot_a" on block device 0.
43  * `fastboot flash boot_a:0:200` -- Flashes only in range `[512, end)` of GPT
44  partition "boot_a" on block device 0.
45  * `fastboot flash boot_a:0:200:200` -- Flashes only in range `[512, 1024)` of
46  GPT partition "boot_a" on block device 0.
47  * `fastboot flash boot_a:::` -- Same as `"boot_a"`.
48
49* Raw storage
50  ```
51  :<block_id>
52  :<block_id>[:<offset>]
53  :<block_id>:[<offset>][:<size>]
54  ```
55  This is similar to the case of GPT partitions except that `part` is an empty
56  string and `block_id` is mandatory. It specifies range `[offset, offset+size)`
57  of the raw data on the block device with ID `block_id`. `offset` defaults to
58  0 if not given. `size` defaults to the rest of the storage after `offset` if
59  not given.
60