1menu "Fastboot support"
2	depends on CMDLINE
3
4config FASTBOOT
5	bool
6	imply ANDROID_BOOT_IMAGE
7	imply CMD_FASTBOOT
8	help
9	  Fastboot is a protocol used in Android devices for
10	  communicating between the device and a computer during
11	  the bootloader stage. It allows the user to flash the
12	  device firmware and unlock the bootloader.
13	  More information about the protocol and usecases:
14	  https://android.googlesource.com/platform/system/core/+/refs/heads/master/fastboot/
15
16	  Note that enabling CMDLINE is recommended since fastboot allows U-Boot
17	  commands to be executed on request. The CMDLINE option is required
18	  for anything other than simply booting the OS.
19
20config USB_FUNCTION_FASTBOOT
21	bool "Enable USB fastboot gadget"
22	depends on USB_GADGET
23	default y if ARCH_SUNXI && USB_MUSB_GADGET
24	select FASTBOOT
25	select USB_GADGET_DOWNLOAD
26	help
27	  This enables the USB part of the fastboot gadget.
28
29config UDP_FUNCTION_FASTBOOT
30	depends on NET
31	select FASTBOOT
32	bool "Enable fastboot protocol over UDP"
33	help
34	  This enables the fastboot protocol over UDP.
35
36config UDP_FUNCTION_FASTBOOT_PORT
37	depends on UDP_FUNCTION_FASTBOOT
38	int "Define FASTBOOT UDP port"
39	default 5554
40	help
41	  The fastboot protocol requires a UDP port number.
42
43config TCP_FUNCTION_FASTBOOT
44	depends on NET
45	select FASTBOOT
46	bool "Enable fastboot protocol over TCP"
47	help
48	  This enables the fastboot protocol over TCP.
49
50if FASTBOOT
51
52config FASTBOOT_BUF_ADDR
53	hex "Define FASTBOOT buffer address"
54	default 0x82000000 if MX6SX || MX6SL || MX6UL || MX6SLL
55	default 0x81000000 if ARCH_OMAP2PLUS
56	default 0x42000000 if ARCH_SUNXI && !MACH_SUN9I
57	default 0x22000000 if ARCH_SUNXI && MACH_SUN9I
58	default 0x60800800 if ROCKCHIP_RK3036 || ROCKCHIP_RK3188 || \
59				ROCKCHIP_RK322X
60	default 0x800800 if ROCKCHIP_RK3288 || ROCKCHIP_RK3329 || \
61				ROCKCHIP_RK3399
62	default 0x280000 if ROCKCHIP_RK3368
63	default 0x100000 if ARCH_ZYNQMP
64	default 0x0 if SANDBOX
65	help
66	  The fastboot protocol requires a large memory buffer for
67	  downloads. Define this to the starting RAM address to use for
68	  downloaded images.
69
70config FASTBOOT_BUF_SIZE
71	hex "Define FASTBOOT buffer size"
72	default 0x8000000 if ARCH_ROCKCHIP
73	default 0x6000000 if ARCH_ZYNQMP
74	default 0x2000000 if ARCH_SUNXI
75	default 0x8192 if SANDBOX
76	default 0x7000000
77	help
78	  The fastboot protocol requires a large memory buffer for
79	  downloads. This buffer should be as large as possible for a
80	  platform. Define this to the size available RAM for fastboot.
81
82config FASTBOOT_USB_DEV
83	int "USB controller number"
84	depends on USB_FUNCTION_FASTBOOT
85	default 0
86	help
87	  Some boards have USB OTG controller other than 0. Define this
88	  option so it can be used in compiled environment (e.g. in
89	  CONFIG_BOOTCOMMAND).
90
91config FASTBOOT_FLASH
92	bool "Enable FASTBOOT FLASH command"
93	default y if ARCH_SUNXI || ARCH_ROCKCHIP
94	depends on MMC || (MTD_RAW_NAND && CMD_MTDPARTS) || DM_SPI_FLASH
95	select IMAGE_SPARSE
96	help
97	  The fastboot protocol includes a "flash" command for writing
98	  the downloaded image to a non-volatile storage device. Define
99	  this to enable the "fastboot flash" command.
100
101config FASTBOOT_UUU_SUPPORT
102	bool "Enable UUU support"
103	help
104	  This extends the fastboot protocol with the "UCmd" and "ACmd"
105	  commands, which are used by NXP's "universal update utility" (UUU).
106	  These commands allow running any shell command. Do not enable this
107	  feature if you are using verified boot, as it will allow an attacker
108	  to bypass any restrictions you have in place.
109
110choice
111	prompt "Flash provider for FASTBOOT"
112	depends on FASTBOOT_FLASH
113
114config FASTBOOT_FLASH_MMC
115	bool "FASTBOOT on MMC"
116	depends on MMC
117
118config FASTBOOT_FLASH_NAND
119	bool "FASTBOOT on NAND"
120	depends on MTD_RAW_NAND && CMD_MTDPARTS
121
122config FASTBOOT_FLASH_SPI
123	bool "FASTBOOT on SPI flash"
124	depends on DM_SPI_FLASH
125
126endchoice
127
128config FASTBOOT_FLASH_MMC_DEV
129	int "Define FASTBOOT MMC FLASH default device"
130	depends on FASTBOOT_FLASH_MMC
131	default 0 if ARCH_ROCKCHIP
132	default 0 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1
133	default 1 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1
134	help
135	  The fastboot "flash" command requires additional information
136	  regarding the non-volatile storage device. Define this to
137	  the eMMC device that fastboot should use to store the image.
138
139config FASTBOOT_FLASH_NAND_TRIMFFS
140	bool "Skip empty pages when flashing NAND"
141	depends on FASTBOOT_FLASH_NAND
142	help
143	  When flashing NAND enable the DROP_FFS flag to drop trailing all-0xff
144	  pages.
145
146config FASTBOOT_MMC_BOOT_SUPPORT
147	bool "Enable EMMC_BOOT flash/erase"
148	depends on FASTBOOT_FLASH_MMC
149	help
150	  The fastboot "flash" and "erase" commands normally does operations
151	  on eMMC userdata. Define this to enable the special commands to
152	  flash/erase eMMC boot partition.
153	  The default target name for updating eMMC boot partition 1/2 is
154	  CONFIG_FASTBOOT_MMC_BOOT1_NAME/CONFIG_FASTBOOT_MMC_BOOT2_NAME.
155
156config FASTBOOT_MMC_BOOT1_NAME
157	string "Target name for updating EMMC_BOOT1"
158	depends on FASTBOOT_MMC_BOOT_SUPPORT
159	default "mmc0boot0"
160	help
161	  The fastboot "flash" and "erase" commands support operations on
162	  EMMC_BOOT1. This occurs when the specified "EMMC_BOOT1 name" on
163	  the "fastboot flash" and "fastboot erase" commands match the value
164	  defined here.
165	  The default target name for updating EMMC_BOOT1 is "mmc0boot0".
166
167config FASTBOOT_MMC_BOOT2_NAME
168	string "Target name for updating EMMC_BOOT2"
169	depends on FASTBOOT_MMC_BOOT_SUPPORT
170	default "mmc0boot1"
171	help
172	  The fastboot "flash" and "erase" commands support operations on
173	  EMMC_BOOT2. This occurs when the specified "EMMC_BOOT2 name" on
174	  the "fastboot flash" and "fastboot erase" commands match the value
175	  defined here.
176	  The default target name for updating EMMC_BOOT2 is "mmc0boot1".
177
178config FASTBOOT_MMC_USER_SUPPORT
179	bool "Enable eMMC userdata partition flash/erase"
180	depends on FASTBOOT_FLASH_MMC
181	help
182	  Define this to enable the support "flash" and "erase" command on
183	  eMMC userdata. The "flash" command only update the MBR and GPT
184	  header when CONFIG_EFI_PARTITION is supported.
185	  The "erase" command erase all the userdata.
186	  This occurs when the specified "partition name" on the
187	  fastboot command line matches the value CONFIG_FASTBOOT_MMC_USER_NAME.
188
189config FASTBOOT_MMC_USER_NAME
190	string "Target name for updating EMMC_USER"
191	depends on FASTBOOT_MMC_USER_SUPPORT
192	default "mmc0"
193	help
194	  The fastboot "flash" and "erase" command supports EMMC_USER.
195	  This occurs when the specified "EMMC_USER name" on the
196	  "fastboot flash" and the "fastboot erase" commands match the value
197	  defined here.
198	  The default target name for erasing EMMC_USER is "mmc0".
199
200config FASTBOOT_GPT_NAME
201	string "Target name for updating GPT"
202	depends on FASTBOOT_FLASH_MMC && EFI_PARTITION
203	default "gpt"
204	help
205	  The fastboot "flash" command supports writing the downloaded
206	  image to the Protective MBR and the Primary GUID Partition
207	  Table. (Additionally, this downloaded image is post-processed
208	  to generate and write the Backup GUID Partition Table.)
209	  This occurs when the specified "partition name" on the
210	  "fastboot flash" command line matches the value defined here.
211	  The default target name for updating GPT is "gpt".
212
213config FASTBOOT_MBR_NAME
214	string "Target name for updating MBR"
215	depends on FASTBOOT_FLASH_MMC && DOS_PARTITION
216	default "mbr"
217	help
218	  The fastboot "flash" command allows to write the downloaded image
219	  to the Master Boot Record. This occurs when the "partition name"
220	  specified on the "fastboot flash" command line matches the value
221	  defined here. The default target name for updating MBR is "mbr".
222
223config FASTBOOT_CMD_OEM_FORMAT
224	bool "Enable the 'oem format' command"
225	depends on FASTBOOT_FLASH_MMC && CMD_GPT
226	help
227	  Add support for the "oem format" command from a client. This
228	  relies on the env variable partitions to contain the list of
229	  partitions as required by the gpt command.
230
231config FASTBOOT_CMD_OEM_PARTCONF
232	bool "Enable the 'oem partconf' command"
233	depends on FASTBOOT_FLASH_MMC && SUPPORT_EMMC_BOOT
234	help
235	  Add support for the "oem partconf" command from a client. This set
236	  the mmc boot-partition for the selecting eMMC device.
237
238config FASTBOOT_CMD_OEM_BOOTBUS
239	bool "Enable the 'oem bootbus' command"
240	depends on FASTBOOT_FLASH_MMC && SUPPORT_EMMC_BOOT
241	help
242	  Add support for the "oem bootbus" command from a client. This set
243	  the mmc boot configuration for the selecting eMMC device.
244
245config FASTBOOT_OEM_RUN
246	bool "Enable the 'oem run' command"
247	help
248	  This extends the fastboot protocol with an "oem run" command. This
249	  command allows running arbitrary U-Boot shell commands. Do not enable
250	  this feature if you are using verified boot, as it will allow an
251	  attacker to bypass any restrictions you have in place.
252
253config FASTBOOT_CMD_OEM_CONSOLE
254	bool "Enable the 'oem console' command"
255	depends on CONSOLE_RECORD
256	help
257	  Add support for the "oem console" command to input and read console
258	  record buffer.
259
260config FASTBOOT_OEM_BOARD
261	bool "Enable the 'oem board' command"
262	help
263	  This extends the fastboot protocol with an "oem board" command. This
264	  command allows running vendor custom code defined in board/ files.
265	  Otherwise, it will do nothing and send fastboot fail.
266
267endif # FASTBOOT
268
269endmenu
270