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