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)
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
122endchoice
123
124config FASTBOOT_FLASH_MMC_DEV
125	int "Define FASTBOOT MMC FLASH default device"
126	depends on FASTBOOT_FLASH_MMC
127	default 0 if ARCH_ROCKCHIP
128	default 0 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1
129	default 1 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1
130	help
131	  The fastboot "flash" command requires additional information
132	  regarding the non-volatile storage device. Define this to
133	  the eMMC device that fastboot should use to store the image.
134
135config FASTBOOT_FLASH_NAND_TRIMFFS
136	bool "Skip empty pages when flashing NAND"
137	depends on FASTBOOT_FLASH_NAND
138	help
139	  When flashing NAND enable the DROP_FFS flag to drop trailing all-0xff
140	  pages.
141
142config FASTBOOT_MMC_BOOT_SUPPORT
143	bool "Enable EMMC_BOOT flash/erase"
144	depends on FASTBOOT_FLASH_MMC
145	help
146	  The fastboot "flash" and "erase" commands normally does operations
147	  on eMMC userdata. Define this to enable the special commands to
148	  flash/erase eMMC boot partition.
149	  The default target name for updating eMMC boot partition 1/2 is
150	  CONFIG_FASTBOOT_MMC_BOOT1_NAME/CONFIG_FASTBOOT_MMC_BOOT2_NAME.
151
152config FASTBOOT_MMC_BOOT1_NAME
153	string "Target name for updating EMMC_BOOT1"
154	depends on FASTBOOT_MMC_BOOT_SUPPORT
155	default "mmc0boot0"
156	help
157	  The fastboot "flash" and "erase" commands support operations on
158	  EMMC_BOOT1. This occurs when the specified "EMMC_BOOT1 name" on
159	  the "fastboot flash" and "fastboot erase" commands match the value
160	  defined here.
161	  The default target name for updating EMMC_BOOT1 is "mmc0boot0".
162
163config FASTBOOT_MMC_BOOT2_NAME
164	string "Target name for updating EMMC_BOOT2"
165	depends on FASTBOOT_MMC_BOOT_SUPPORT
166	default "mmc0boot1"
167	help
168	  The fastboot "flash" and "erase" commands support operations on
169	  EMMC_BOOT2. This occurs when the specified "EMMC_BOOT2 name" on
170	  the "fastboot flash" and "fastboot erase" commands match the value
171	  defined here.
172	  The default target name for updating EMMC_BOOT2 is "mmc0boot1".
173
174config FASTBOOT_MMC_USER_SUPPORT
175	bool "Enable eMMC userdata partition flash/erase"
176	depends on FASTBOOT_FLASH_MMC
177	help
178	  Define this to enable the support "flash" and "erase" command on
179	  eMMC userdata. The "flash" command only update the MBR and GPT
180	  header when CONFIG_EFI_PARTITION is supported.
181	  The "erase" command erase all the userdata.
182	  This occurs when the specified "partition name" on the
183	  fastboot command line matches the value CONFIG_FASTBOOT_MMC_USER_NAME.
184
185config FASTBOOT_MMC_USER_NAME
186	string "Target name for updating EMMC_USER"
187	depends on FASTBOOT_MMC_USER_SUPPORT
188	default "mmc0"
189	help
190	  The fastboot "flash" and "erase" command supports EMMC_USER.
191	  This occurs when the specified "EMMC_USER name" on the
192	  "fastboot flash" and the "fastboot erase" commands match the value
193	  defined here.
194	  The default target name for erasing EMMC_USER is "mmc0".
195
196config FASTBOOT_GPT_NAME
197	string "Target name for updating GPT"
198	depends on FASTBOOT_FLASH_MMC && EFI_PARTITION
199	default "gpt"
200	help
201	  The fastboot "flash" command supports writing the downloaded
202	  image to the Protective MBR and the Primary GUID Partition
203	  Table. (Additionally, this downloaded image is post-processed
204	  to generate and write the Backup GUID Partition Table.)
205	  This occurs when the specified "partition name" on the
206	  "fastboot flash" command line matches the value defined here.
207	  The default target name for updating GPT is "gpt".
208
209config FASTBOOT_MBR_NAME
210	string "Target name for updating MBR"
211	depends on FASTBOOT_FLASH_MMC && DOS_PARTITION
212	default "mbr"
213	help
214	  The fastboot "flash" command allows to write the downloaded image
215	  to the Master Boot Record. This occurs when the "partition name"
216	  specified on the "fastboot flash" command line matches the value
217	  defined here. The default target name for updating MBR is "mbr".
218
219config FASTBOOT_CMD_OEM_FORMAT
220	bool "Enable the 'oem format' command"
221	depends on FASTBOOT_FLASH_MMC && CMD_GPT
222	help
223	  Add support for the "oem format" command from a client. This
224	  relies on the env variable partitions to contain the list of
225	  partitions as required by the gpt command.
226
227config FASTBOOT_CMD_OEM_PARTCONF
228	bool "Enable the 'oem partconf' command"
229	depends on FASTBOOT_FLASH_MMC && SUPPORT_EMMC_BOOT
230	help
231	  Add support for the "oem partconf" command from a client. This set
232	  the mmc boot-partition for the selecting eMMC device.
233
234config FASTBOOT_CMD_OEM_BOOTBUS
235	bool "Enable the 'oem bootbus' command"
236	depends on FASTBOOT_FLASH_MMC && SUPPORT_EMMC_BOOT
237	help
238	  Add support for the "oem bootbus" command from a client. This set
239	  the mmc boot configuration for the selecting eMMC device.
240
241config FASTBOOT_OEM_RUN
242	bool "Enable the 'oem run' command"
243	help
244	  This extends the fastboot protocol with an "oem run" command. This
245	  command allows running arbitrary U-Boot shell commands. Do not enable
246	  this feature if you are using verified boot, as it will allow an
247	  attacker to bypass any restrictions you have in place.
248
249config FASTBOOT_CMD_OEM_CONSOLE
250	bool "Enable the 'oem console' command"
251	depends on CONSOLE_RECORD
252	help
253	  Add support for the "oem console" command to input and read console
254	  record buffer.
255
256config FASTBOOT_OEM_BOARD
257	bool "Enable the 'oem board' command"
258	help
259	  This extends the fastboot protocol with an "oem board" command. This
260	  command allows running vendor custom code defined in board/ files.
261	  Otherwise, it will do nothing and send fastboot fail.
262
263endif # FASTBOOT
264
265endmenu
266