Skip to contentSkip to conversation

Add fastboot UDP support

PATCH New Alex Kiernan 3 participants 21 messages May 29, 2018 – Jun 12, 2018

Subsystems (12)
Networking Arm (32-bit) VFS USB +8 more subsystems
lore
Share & tools
lore
#0 lore raw

v8 cover Add fastboot UDP support

This series merges the fastboot UDP support from AOSP into mainline U-Boot.

Changes in UDP behaviour from the AOSP code, so it follows the existing USB behaviour:

- 'boot' now follows the USB code and does 'bootm CONFIG_FASTBOOT_BUF_ADDR'. I've added 'fastboot_bootcmd' which if set overrides the boot command and allows the existing UDP behaviour to be preserved.
- 'continue' in UDP now exits the fastboot server rather than executing 'run bootcmd'
- 'reboot-bootloader' no longer writes 'reboot-bootloader' to CONFIG_FASTBOOT_BUF_ADDR as its marker for the subsequent boot. The code which is in AOSP common/android_bootloader.c expects this marker, but we have prior art in the USB code using the weak function fastboot_set_reboot_flag
- 'getvar' in the UDP path now supports fetching 'fastboot.' prefixed variables (inherited from the USB path), these override the defaults

I've pushed both USB and UDP into a single consolidated protocol layer now I've tested it on a BeagleBone Green.

Green Travis build: https://travis-ci.org/akiernan/u-boot/builds/383077278

Changes in v8:
- add Reviewed-by: tag
- add Reviewed-by: tag
- add Reviewed-by: tag

Changes in v7:
- set FASTBOOT_CMD_OEM_FORMAT for all existing users of FASTBOOT_FLASH_MMC_DEV that also have CMD_GPT

Changes in v6:
- accomodate master change and switch dependency on imx6dl_mamoj from FASTBOOT to USB_FUNCTION_FASTBOOT
- delete redundant FASTBOOT_FLASH_NAND_DEV symbol
- add docbook comments
- add docbook comments
- rename fastboot_download_data() to fastboot_data_download(), rename fastboot_get_bytes_remaining() to fastboot_data_remaining()
- split fastboot_data_complete() out from fastboot_data_download() so we can call it at the end of the transfer phase for USB
- merged from RFC USB fastboot series
- when entering the DATA phase ensure we actually install the correct handler
- on completion of DATA call new fastboot_data_complete()
- previous changes:
- remove redundant version.h
- use new fastboot_get_bytes_remaining() function
- new

Changes in v5:
- don't depend on UDP_FUNCTION_FASTBOOT until it exists
- squash in subsequent patch which updates defconfigs so we don't leave users of CONFIG_FASTBOOT without it enabled
- fix build in drivers/fastboot when we have CONFIG_FASTBOOT without flash or erase and we've not yet added fb_common.c to the build
- fix docbook formatting
- new
- new
- rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE and migrate it to Kconfig.
- make fastboot_bytes_received/expected static and add function fastboot_get_bytes_remaining()
- move fastboot_buf_addr/fastboot_buf_size/fastboot_progress_callback into fastboot-internal.h
- delete redundant fb_ prefixes from statics
- new

Changes in v4:
- add docbook comments
- leave strcmp_l1() in USB fastboot as we don't need it in UDP path
- add docbook comments
- new
- guard fb_getvar/fb_command with UDP_FUNCTION_FASTBOOT in Makefile
- add docbook comments
- remove parameter from fastboot_boot() since we always want fastboot_buf_addr (and if we're using fastboot_bootcmd then it's ignored)
- split oem format into new patch

Changes in v3:
- move imply ANDROID_BOOT_IMAGE, CMD_FASTBOOT to FASTBOOT from USB_FUNCTION_FASTBOOT
- add depend on USB_FUNCTION_FASTBOOT to FASTBOOT_USB_DEV
- leave images-sparse.c in common to acommodate 2f83f21
- refactor for changes in master
- Merge subsequent patch for formatting response strings into this one
- allow NULL to fastboot_okay() when there's no message to send
- guard FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME with EFI/DOS_PARTITION
- new
- new
- new
- new
- new
- new
- use FASTBOOT as our guard in Kconfig not a list of USB || UDP
- correct mis-translation from AOSP introduced when cleaning up for checkpatch - we should write when buffer is not NULL, rather than erasing, and erase when buffer is NULL
- use CMD_RET_USAGE from do_fastboot
- remove do_fastboot_udp from cmd/net.c and rewrite using net_loop()
- rename timed_send_info to fastboot_send_info, rename fastboot_send_info to fastboot_udp_send_info
- replace FASTBOOT_HEADER_SIZE with sizeof(struct fastboot_header)
- move start time into timed_send_info() rather than passing it in
- make calls to fastboot_udp_send_info a runtime dependency, not a compile time one
- set ${filesize} to size of downloaded image
- add progress meter from USB path during download
- add support for 'oem format' command from the USB path
- rename 'fastbootcmd' to 'fastboot_bootcmd' to make clear that this is the fastboot boot command
- make getvar implementation table driven
- add fastboot_buf_addr, fastboot_buf_size to override buffer address and size
- return correct filesystem type in getvar partition-type on MMC
- process "fastboot." prefixed env variables in getvar first so you can override the normal values (this also lets you set a fs type for NAND devices)
- squash subsequent patches which change this code into this one:
- If the fastboot flash/erase commands are disabled, remove that support so we still build correctly.
- Add NAND support to fastboot UDP flash/erase commands
- If we don't have a partition name passed, report it as not found.
- Change the behaviour of the fastboot net code such that "reboot-bootloader" is no longer written to CONFIG_FASTBOOT_BUF_ADDR for use as a marker on reboot (the AOSP code in common/android-bootloader.c uses this marker - this code could be reinstated there if that gets merged).
- Merge USB and UDP boot code. The USB implementation stays the same, but UDP no longer passes an fdt. We introduce a new environment variable 'fastboot_bootcmd' which if set overrides the hardcoded boot command, setting this then allows the UDP implementation to remain the same. If after running 'fastboot_bootcmd' the board has not booted, control is returned to U-Boot and the fastboot process ends.
- Separate the fastboot protocol handling from the fastboot UDP code in preparation for reusing it in the USB code.

Changes in v2:
- ensure fastboot syntax is backward compatible - 'fastboot 0' means 'fastboot usb 0'

Alex Kiernan (18):
fastboot: Move fastboot to drivers/fastboot
fastboot: Refactor fastboot_okay/fail to take response
fastboot: Extract fastboot_okay/fail to fb_common.c
fastboot: Correct dependencies in FASTBOOT_FLASH
fastboot: Add missing newlines
fastboot: Remove FIXME for CONFIG_FASTBOOT_...NAME
fastboot: Fix parameter types in _fb_nand_write
fastboot: Rename fb_set_reboot_flag to fastboot_set_reboot_flag
fastboot: Extract common definitions from USB fastboot
fastboot: Rename public fb_ functions to fastboot_
ti: fastboot: Move weak overrides to board files
fs: Add fs_get_type_name to return current filesystem name
fastboot: Migrate FASTBOOT_FLASH_NAND_TRIMFFS to Kconfig
mmc: Separate "mmc swrite" from fastboot
net: fastboot: Merge AOSP UDP fastboot
fastboot: Add support for 'oem format' command
usb: fastboot: Convert USB f_fastboot to shared fastboot
fastboot: Update fastboot documentation

 arch/arm/Kconfig                              |   2 -
 arch/arm/mach-omap2/boot-common.c             |  10 -
 arch/arm/mach-omap2/utils.c                   |   4 +-
 arch/arm/mach-rockchip/rk3128-board.c         |   4 +-
 arch/arm/mach-rockchip/rk322x-board.c         |   4 +-
 board/amazon/kc1/kc1.c                        |   2 +-
 board/lg/sniper/sniper.c                      |   2 +-
 board/ti/am57xx/board.c                       |  10 +
 board/ti/common/Kconfig                       |   1 -
 board/ti/dra7xx/evm.c                         |  10 +
 cmd/Kconfig                                   |  22 +-
 cmd/fastboot.c                                |  91 ++++-
 cmd/mmc.c                                     |  14 +-
 common/Makefile                               |  14 -
 configs/A13-OLinuXino_defconfig               |   1 +
 configs/A20-OLinuXino-Lime2-eMMC_defconfig    |   1 +
 configs/A20-OLinuXino-Lime2_defconfig         |   1 +
 configs/A20-Olimex-SOM204-EVB-eMMC_defconfig  |   1 +
 configs/A20-Olimex-SOM204-EVB_defconfig       |   1 +
 configs/Bananapi_m2m_defconfig                |   1 +
 configs/Cubietruck_defconfig                  |   1 +
 configs/Sinlinx_SinA33_defconfig              |   1 +
 configs/am335x_boneblack_defconfig            |   7 +-
 configs/am335x_boneblack_vboot_defconfig      |   2 +-
 configs/am335x_evm_defconfig                  |   2 +-
 configs/am335x_evm_nor_defconfig              |   2 +-
 configs/am335x_evm_norboot_defconfig          |   2 +-
 configs/am335x_evm_spiboot_defconfig          |   2 +-
 configs/am335x_evm_usbspl_defconfig           |   2 +-
 configs/am57xx_evm_defconfig                  |  13 +-
 configs/am57xx_hs_evm_defconfig               |  13 +-
 configs/bcm23550_w1d_defconfig                |   2 +-
 configs/bcm28155_ap_defconfig                 |   2 +-
 configs/birdland_bav335a_defconfig            |   2 +-
 configs/birdland_bav335b_defconfig            |   2 +-
 configs/cgtqmx6eval_defconfig                 |   2 +-
 configs/chromebit_mickey_defconfig            |   5 +-
 configs/chromebook_jerry_defconfig            |   5 +-
 configs/chromebook_minnie_defconfig           |   5 +-
 configs/dra7xx_evm_defconfig                  |  11 +-
 configs/dra7xx_hs_evm_defconfig               |  11 +-
 configs/evb-rk3036_defconfig                  |   5 +-
 configs/evb-rk3128_defconfig                  |   9 +-
 configs/evb-rk3229_defconfig                  |   5 +-
 configs/evb-rk3288_defconfig                  |   5 +-
 configs/evb-rk3328_defconfig                  |   7 +-
 configs/fennec-rk3288_defconfig               |   5 +-
 configs/firefly-rk3288_defconfig              |   5 +-
 configs/imx6dl_mamoj_defconfig                |   2 +-
 configs/kc1_defconfig                         |   2 +-
 configs/kylin-rk3036_defconfig                |   5 +-
 configs/miqi-rk3288_defconfig                 |   5 +-
 configs/mx6qsabrelite_defconfig               |   2 +-
 configs/mx6sabresd_defconfig                  |   2 +-
 configs/nitrogen6dl2g_defconfig               |   2 +-
 configs/nitrogen6dl_defconfig                 |   2 +-
 configs/nitrogen6q2g_defconfig                |   2 +-
 configs/nitrogen6q_defconfig                  |   2 +-
 configs/nitrogen6s1g_defconfig                |   2 +-
 configs/nitrogen6s_defconfig                  |   2 +-
 configs/omap3_beagle_defconfig                |   2 +-
 configs/omap3_evm_defconfig                   |   2 +-
 configs/omap3_logic_defconfig                 |   2 +-
 configs/parrot_r16_defconfig                  |   1 +
 configs/phycore-rk3288_defconfig              |   5 +-
 configs/popmetal-rk3288_defconfig             |   5 +-
 configs/rock2_defconfig                       |   5 +-
 configs/sniper_defconfig                      |   2 +-
 configs/stih410-b2260_defconfig               |  11 +-
 configs/tbs_a711_defconfig                    |   1 +
 configs/tinker-rk3288_defconfig               |   5 +-
 .../xilinx_zynqmp_zc1751_xm015_dc1_defconfig  |   7 +-
 .../xilinx_zynqmp_zc1751_xm016_dc2_defconfig  |   2 +-
 configs/xilinx_zynqmp_zcu102_rev1_0_defconfig |   7 +-
 configs/xilinx_zynqmp_zcu102_revA_defconfig   |   7 +-
 configs/xilinx_zynqmp_zcu102_revB_defconfig   |   7 +-
 configs/xilinx_zynqmp_zcu106_revA_defconfig   |   7 +-
 doc/README.android-fastboot                   | 240 +++++++-----
 drivers/Kconfig                               |   2 +
 drivers/Makefile                              |   1 +
 {cmd => drivers}/fastboot/Kconfig             |  63 ++--
 drivers/fastboot/Makefile                     |   7 +
 drivers/fastboot/fb_command.c                 | 335 +++++++++++++++++
 drivers/fastboot/fb_common.c                  | 169 +++++++++
 drivers/fastboot/fb_getvar.c                  | 230 ++++++++++++
 {common => drivers/fastboot}/fb_mmc.c         | 216 +++++++----
 {common => drivers/fastboot}/fb_nand.c        |  69 +++-
 drivers/usb/gadget/f_fastboot.c               | 347 ++----------------
 fs/fs.c                                       |  13 +
 include/fastboot-internal.h                   |  36 ++
 include/fastboot.h                            | 137 ++++++-
 include/fb_mmc.h                              |  35 +-
 include/fb_nand.h                             |  37 +-
 include/fs.h                                  |  10 +
 include/image-sparse.h                        |   4 +-
 include/net.h                                 |   2 +-
 include/net/fastboot.h                        |  21 ++
 lib/Kconfig                                   |  11 +
 lib/Makefile                                  |   1 +
 {common => lib}/image-sparse.c                |  38 +-
 net/Makefile                                  |   1 +
 net/fastboot.c                                | 317 ++++++++++++++++
 net/net.c                                     |   7 +
 scripts/config_whitelist.txt                  |   2 -
 104 files changed, 2094 insertions(+), 696 deletions(-)
 rename {cmd => drivers}/fastboot/Kconfig (78%)
 create mode 100644 drivers/fastboot/Makefile
 create mode 100644 drivers/fastboot/fb_command.c
 create mode 100644 drivers/fastboot/fb_common.c
 create mode 100644 drivers/fastboot/fb_getvar.c
 rename {common => drivers/fastboot}/fb_mmc.c (62%)
 rename {common => drivers/fastboot}/fb_nand.c (71%)
 create mode 100644 include/fastboot-internal.h
 create mode 100644 include/net/fastboot.h
 rename {common => lib}/image-sparse.c (88%)
 create mode 100644 net/fastboot.c
Signature · 1 line
2.17.0
#1 lore raw

PATCH v8 1/18 fastboot: Move fastboot to drivers/fastboot

Separate CMD_FASTBOOT from FASTBOOT and move code and configuration to drivers/fastboot.

Switch dependencies on FASTBOOT to USB_FUNCTION_FASTBOOT as anyone who wants FASTBOOT before this series wants USB_FUNCTION_FASTBOOT. Split USB_FUNCTION_FASTBOOT from FASTBOOT so they retain their existing behaviour.

---

Changes in v8: None
Changes in v7: None
Changes in v6:
- accomodate master change and switch dependency on imx6dl_mamoj from FASTBOOT to USB_FUNCTION_FASTBOOT

Changes in v5:
- don't depend on UDP_FUNCTION_FASTBOOT until it exists
- squash in subsequent patch which updates defconfigs so we don't leave users of CONFIG_FASTBOOT without it enabled
- fix build in drivers/fastboot when we have CONFIG_FASTBOOT without flash or erase and we've not yet added fb_common.c to the build

Changes in v4: None
Changes in v3:
- move imply ANDROID_BOOT_IMAGE, CMD_FASTBOOT to FASTBOOT from USB_FUNCTION_FASTBOOT
- add depend on USB_FUNCTION_FASTBOOT to FASTBOOT_USB_DEV
- leave images-sparse.c in common to acommodate 2f83f21

Changes in v2: None

 arch/arm/Kconfig                              |  2 --
 board/ti/common/Kconfig                       |  1 -
 cmd/Kconfig                                   | 14 ++++++--
 common/Makefile                               | 15 +-------
 configs/am335x_boneblack_defconfig            |  2 +-
 configs/am335x_boneblack_vboot_defconfig      |  2 +-
 configs/am335x_evm_defconfig                  |  2 +-
 configs/am335x_evm_nor_defconfig              |  2 +-
 configs/am335x_evm_norboot_defconfig          |  2 +-
 configs/am335x_evm_spiboot_defconfig          |  2 +-
 configs/am335x_evm_usbspl_defconfig           |  2 +-
 configs/am57xx_evm_defconfig                  |  2 +-
 configs/am57xx_hs_evm_defconfig               |  2 +-
 configs/bcm23550_w1d_defconfig                |  2 +-
 configs/bcm28155_ap_defconfig                 |  2 +-
 configs/birdland_bav335a_defconfig            |  2 +-
 configs/birdland_bav335b_defconfig            |  2 +-
 configs/cgtqmx6eval_defconfig                 |  2 +-
 configs/dra7xx_evm_defconfig                  |  2 +-
 configs/dra7xx_hs_evm_defconfig               |  2 +-
 configs/imx6dl_mamoj_defconfig                |  2 +-
 configs/kc1_defconfig                         |  2 +-
 configs/mx6qsabrelite_defconfig               |  2 +-
 configs/mx6sabresd_defconfig                  |  2 +-
 configs/nitrogen6dl2g_defconfig               |  2 +-
 configs/nitrogen6dl_defconfig                 |  2 +-
 configs/nitrogen6q2g_defconfig                |  2 +-
 configs/nitrogen6q_defconfig                  |  2 +-
 configs/nitrogen6s1g_defconfig                |  2 +-
 configs/nitrogen6s_defconfig                  |  2 +-
 configs/omap3_beagle_defconfig                |  2 +-
 configs/omap3_evm_defconfig                   |  2 +-
 configs/omap3_logic_defconfig                 |  2 +-
 configs/sniper_defconfig                      |  2 +-
 configs/stih410-b2260_defconfig               |  2 +-
 .../xilinx_zynqmp_zc1751_xm015_dc1_defconfig  |  2 +-
 .../xilinx_zynqmp_zc1751_xm016_dc2_defconfig  |  2 +-
 configs/xilinx_zynqmp_zcu102_rev1_0_defconfig |  2 +-
 configs/xilinx_zynqmp_zcu102_revA_defconfig   |  2 +-
 configs/xilinx_zynqmp_zcu102_revB_defconfig   |  2 +-
 configs/xilinx_zynqmp_zcu106_revA_defconfig   |  2 +-
 drivers/Kconfig                               |  2 ++
 drivers/Makefile                              |  3 ++
 {cmd => drivers}/fastboot/Kconfig             | 35 +++++++------------
 drivers/fastboot/Makefile                     |  8 +++++
 {common => drivers/fastboot}/fb_mmc.c         |  0
 {common => drivers/fastboot}/fb_nand.c        |  0
 47 files changed, 75 insertions(+), 79 deletions(-)
 rename {cmd => drivers}/fastboot/Kconfig (88%)
 create mode 100644 drivers/fastboot/Makefile
 rename {common => drivers/fastboot}/fb_mmc.c (100%)
 rename {common => drivers/fastboot}/fb_nand.c (100%)
arch/arm/Kconfig +0 -2
index 582e84cf40..dde422bc5d 100644
@@ -1258,9 +1258,7 @@ config ARCH_ROCKCHIP
 	select DM_REGULATOR
 	select ENABLE_ARM_SOC_BOOT0_HOOK
 	select SPI
-	imply CMD_FASTBOOT
 	imply DISTRO_DEFAULTS
-	imply FASTBOOT
 	imply FAT_WRITE
 	imply USB_FUNCTION_FASTBOOT
 	imply SPL_SYSRESET
board/ti/common/Kconfig +0 -1
index c21eb8c2d2..b1956b8100 100644
@@ -25,7 +25,6 @@ config TI_COMMON_CMD_OPTIONS
 	imply CMD_EXT2
 	imply CMD_EXT4
 	imply CMD_EXT4_WRITE
-	imply CMD_FASTBOOT if FASTBOOT
 	imply CMD_FAT
 	imply FAT_WRITE if CMD_FAT
 	imply CMD_FS_GENERIC
cmd/Kconfig +12 -2
index d532c9fc41..9848c067da 100644
@@ -137,8 +137,6 @@ config AUTOBOOT_STOP_STR_SHA256
 
 endmenu
 
-source "cmd/fastboot/Kconfig"
-
 config BUILD_BIN2C
 	bool
 
@@ -650,6 +648,18 @@ config CMD_DM
 	  can be useful to see the state of driver model for debugging or
 	  interest.
 
+config CMD_FASTBOOT
+	bool "fastboot - Android fastboot support"
+	depends on FASTBOOT
+	help
+	  This enables the command "fastboot" which enables the Android
+	  fastboot mode for the platform. Fastboot is a protocol for
+	  downloading images, flashing and device control used on
+	  Android devices. Fastboot requires support for acting as a USB
+	  device.
+
+	  See doc/README.android-fastboot for more information.
+
 config CMD_FDC
 	bool "fdcboot - Boot from floppy device"
 	help
common/Makefile +1 -14
index d0681c7dd9..9ec40b9d27 100644
@@ -29,7 +29,7 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
 
 obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
-
+obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o
 obj-$(CONFIG_MII) += miiphyutil.o
 obj-$(CONFIG_CMD_MII) += miiphyutil.o
 obj-$(CONFIG_PHYLIB) += miiphyutil.o
@@ -109,19 +109,6 @@ obj-$(CONFIG_IO_TRACE) += iotrace.o
 obj-y += memsize.o
 obj-y += stdio.o
 
-ifndef CONFIG_SPL_BUILD
-# This option is not just y/n - it can have a numeric value
-ifdef CONFIG_FASTBOOT_FLASH
-obj-y += image-sparse.o
-ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
-obj-y += fb_mmc.o
-endif
-ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
-obj-y += fb_nand.o
-endif
-endif
-endif
-
 ifdef CONFIG_CMD_EEPROM_LAYOUT
 obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o
 endif
configs/am335x_boneblack_defconfig +1 -1
index 5c01b20dff..bd3a37427d 100644
@@ -16,7 +16,7 @@ CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
 CONFIG_AUTOBOOT_DELAY_STR="d"
 CONFIG_AUTOBOOT_STOP_STR=" "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_CMD_SPL=y
configs/am335x_boneblack_vboot_defconfig +1 -1
index abbacdc77e..baaae36d28 100644
@@ -19,7 +19,7 @@ CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
 CONFIG_AUTOBOOT_DELAY_STR="d"
 CONFIG_AUTOBOOT_STOP_STR=" "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_CMD_SPL=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
configs/am335x_evm_defconfig +1 -1
index 6732013b03..cc556d1c3d 100644
@@ -13,7 +13,7 @@ CONFIG_ARCH_MISC_INIT=y
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_MUSB_NEW_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_CMD_SPL=y
 CONFIG_CMD_SPL_NAND_OFS=0x00080000
 # CONFIG_CMD_FLASH is not set
configs/am335x_evm_nor_defconfig +1 -1
index bbde07fb1d..41a5c79604 100644
@@ -12,7 +12,7 @@ CONFIG_ARCH_MISC_INIT=y
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_MUSB_NEW_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_CMD_SPL=y
 CONFIG_CMD_SPL_NAND_OFS=0x00080000
 CONFIG_CMD_NAND=y
configs/am335x_evm_norboot_defconfig +1 -1
index 3ddcf64942..75d0793f2d 100644
@@ -12,7 +12,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_ARCH_MISC_INIT=y
 CONFIG_BOARD_EARLY_INIT_F=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nor0=physmap-flash.0"
configs/am335x_evm_spiboot_defconfig +1 -1
index 10eb0fe1ee..b2678875ec 100644
@@ -15,7 +15,7 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_ARCH_MISC_INIT=y
 CONFIG_SPL_MUSB_NEW_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_MTDPARTS=y
configs/am335x_evm_usbspl_defconfig +1 -1
index dc9ac216c2..44012919a3 100644
@@ -19,7 +19,7 @@ CONFIG_SPL_OS_BOOT=y
 CONFIG_SPL_USB_GADGET_SUPPORT=y
 CONFIG_SPL_USB_ETHER=y
 # CONFIG_SPL_YMODEM_SUPPORT is not set
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_CMD_SPL=y
 CONFIG_CMD_SPL_NAND_OFS=0x00080000
 # CONFIG_CMD_FLASH is not set
configs/am57xx_evm_defconfig +1 -1
index 0e99268441..3b83b69e5f 100644
@@ -24,7 +24,7 @@ CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
 CONFIG_FASTBOOT_USB_DEV=1
configs/am57xx_hs_evm_defconfig +1 -1
index 165c2a40ba..9c2aef482f 100644
@@ -29,7 +29,7 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
 CONFIG_FASTBOOT_USB_DEV=1
configs/bcm23550_w1d_defconfig +1 -1
index 9a986ca9ae..de4fa60df7 100644
@@ -7,7 +7,7 @@ CONFIG_VERSION_VARIABLE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_HUSH_PARSER=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x80000000
 CONFIG_FASTBOOT_BUF_SIZE=0x1D000000
 CONFIG_FASTBOOT_FLASH=y
configs/bcm28155_ap_defconfig +1 -1
index d26cde5b0e..4f7a58e362 100644
@@ -8,7 +8,7 @@ CONFIG_VERSION_VARIABLE=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_HUSH_PARSER=y
 # CONFIG_AUTOBOOT is not set
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x80000000
 CONFIG_FASTBOOT_BUF_SIZE=0x7FF00000
 CONFIG_FASTBOOT_FLASH=y
configs/birdland_bav335a_defconfig +1 -1
index 51b3e6b4e1..3efd5669a7 100644
@@ -25,7 +25,7 @@ CONFIG_SPL_MUSB_NEW_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_SPL_POWER_SUPPORT=y
 CONFIG_SPL_YMODEM_SUPPORT=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 CONFIG_CMD_SPL=y
 CONFIG_CMD_ASKENV=y
configs/birdland_bav335b_defconfig +1 -1
index 29b223a580..2f98116873 100644
@@ -25,7 +25,7 @@ CONFIG_SPL_MUSB_NEW_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_SPL_POWER_SUPPORT=y
 CONFIG_SPL_YMODEM_SUPPORT=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 CONFIG_CMD_SPL=y
 CONFIG_CMD_ASKENV=y
configs/cgtqmx6eval_defconfig +1 -1
index d4204aa712..241e9582a5 100644
@@ -24,7 +24,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="CGT-QMX6-Quad U-Boot > "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
 CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_DFU=y
configs/dra7xx_evm_defconfig +1 -1
index 9b81b0cc71..b766ba27cd 100644
@@ -25,7 +25,7 @@ CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
 CONFIG_FASTBOOT_FLASH=y
configs/dra7xx_hs_evm_defconfig +1 -1
index 536946eb29..39a6801216 100644
@@ -30,7 +30,7 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
 CONFIG_FASTBOOT_FLASH=y
configs/imx6dl_mamoj_defconfig +1 -1
index 0001457f5d..40a128b8cb 100644
@@ -9,7 +9,7 @@ CONFIG_DEFAULT_DEVICE_TREE="imx6dl-mamoj"
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
 CONFIG_BOOTDELAY=3
 CONFIG_HUSH_PARSER=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
 CONFIG_FASTBOOT_BUF_SIZE=0x10000000
 CONFIG_FASTBOOT_FLASH=y
configs/kc1_defconfig +1 -1
index 534d60484a..ce71e37011 100644
@@ -12,7 +12,7 @@ CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=2
 CONFIG_SYS_PROMPT="kc1 # "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 CONFIG_FASTBOOT_BUF_SIZE=0x2000000
 CONFIG_FASTBOOT_FLASH=y
configs/mx6qsabrelite_defconfig +1 -1
index 966e823b40..a4740d49cf 100644
@@ -9,7 +9,7 @@ CONFIG_BOOTDELAY=3
 # CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_BOARD_EARLY_INIT_F=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
configs/mx6sabresd_defconfig +1 -1
index ca37d8bef8..5c8e9de081 100644
@@ -22,7 +22,7 @@ CONFIG_SPL_USB_HOST_SUPPORT=y
 CONFIG_SPL_USB_GADGET_SUPPORT=y
 CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_HUSH_PARSER=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
 CONFIG_FASTBOOT_BUF_SIZE=0x10000000
 CONFIG_FASTBOOT_FLASH=y
configs/nitrogen6dl2g_defconfig +1 -1
index 6ef4226db9..cfb2ed8889 100644
@@ -9,7 +9,7 @@ CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_HUSH_PARSER=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
 CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_MEMTEST=y
configs/nitrogen6dl_defconfig +1 -1
index b9784a2d23..9cb7ac22d5 100644
@@ -9,7 +9,7 @@ CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_HUSH_PARSER=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
 CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_MEMTEST=y
configs/nitrogen6q2g_defconfig +1 -1
index 61688ba49e..e31521a060 100644
@@ -9,7 +9,7 @@ CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_HUSH_PARSER=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
 CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_MEMTEST=y
configs/nitrogen6q_defconfig +1 -1
index cfee7ba889..85c352c6f0 100644
@@ -9,7 +9,7 @@ CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_HUSH_PARSER=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
 CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_MEMTEST=y
configs/nitrogen6s1g_defconfig +1 -1
index 0f29a56c46..1f3732019d 100644
@@ -9,7 +9,7 @@ CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_HUSH_PARSER=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
 CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_MEMTEST=y
configs/nitrogen6s_defconfig +1 -1
index 7ad1584af2..0696f09d5e 100644
@@ -9,7 +9,7 @@ CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_HUSH_PARSER=y
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
 CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_MEMTEST=y
configs/omap3_beagle_defconfig +1 -1
index 7b81b039c9..05dc73755f 100644
@@ -13,7 +13,7 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_SYS_PROMPT="BeagleBoard # "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 CONFIG_CMD_SPL=y
 CONFIG_CMD_SPL_NAND_OFS=0x280000
configs/omap3_evm_defconfig +1 -1
index 20795c3170..52285cc165 100644
@@ -12,7 +12,7 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_SYS_PROMPT="OMAP3_EVM # "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 CONFIG_CMD_SPL=y
 CONFIG_CMD_SPL_NAND_OFS=0x280000
configs/omap3_logic_defconfig +1 -1
index 5a31e46dba..953980c95c 100644
@@ -13,7 +13,7 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_SYS_PROMPT="OMAP Logic # "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 # CONFIG_CMD_IMI is not set
 CONFIG_CMD_SPL=y
configs/sniper_defconfig +1 -1
index ad22a1cbe2..70e485fab2 100644
@@ -13,7 +13,7 @@ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=2
 # CONFIG_SPL_EXT_SUPPORT is not set
 CONFIG_SYS_PROMPT="sniper # "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x82000000
 CONFIG_FASTBOOT_BUF_SIZE=0x2000000
 CONFIG_FASTBOOT_FLASH=y
configs/stih410-b2260_defconfig +1 -1
index 67391bdfdf..7d990f9a34 100644
@@ -10,7 +10,7 @@ CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyAS1,115200 CONSOLE=/dev/ttyAS1 consoleblank=0 root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait mem=992M at 0x40000000 vmalloc=256m"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SYS_PROMPT="stih410-b2260 => "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x40000000
 CONFIG_FASTBOOT_BUF_SIZE=0x3DF00000
 CONFIG_FASTBOOT_FLASH=y
configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig +1 -1
index f5a33342fa..9e4886d064 100644
@@ -19,7 +19,7 @@ CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_PROMPT="ZynqMP> "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_THOR_DOWNLOAD=y
configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig +1 -1
index 7f7ee558ee..9d9216f5fe 100644
@@ -20,7 +20,7 @@ CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_PROMPT="ZynqMP> "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_CMD_THOR_DOWNLOAD=y
 CONFIG_CMD_MEMTEST=y
configs/xilinx_zynqmp_zcu102_rev1_0_defconfig +1 -1
index 4cb3959f36..29743bdb1e 100644
@@ -19,7 +19,7 @@ CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_PROMPT="ZynqMP> "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_THOR_DOWNLOAD=y
configs/xilinx_zynqmp_zcu102_revA_defconfig +1 -1
index e989d1635c..cc4118230e 100644
@@ -19,7 +19,7 @@ CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_PROMPT="ZynqMP> "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_THOR_DOWNLOAD=y
configs/xilinx_zynqmp_zcu102_revB_defconfig +1 -1
index bd67df904a..ae791c3567 100644
@@ -19,7 +19,7 @@ CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_PROMPT="ZynqMP> "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_THOR_DOWNLOAD=y
configs/xilinx_zynqmp_zcu106_revA_defconfig +1 -1
index a5fa33e366..34e3c857e2 100644
@@ -18,7 +18,7 @@ CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_PROMPT="ZynqMP> "
-CONFIG_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_THOR_DOWNLOAD=y
drivers/Kconfig +2 -0
index c2e813f5ad..8424898dbd 100644
@@ -28,6 +28,8 @@ source "drivers/dfu/Kconfig"
 
 source "drivers/dma/Kconfig"
 
+source "drivers/fastboot/Kconfig"
+
 source "drivers/firmware/Kconfig"
 
 source "drivers/fpga/Kconfig"
drivers/Makefile +3 -0
index b3f1b600a5..a79ff2e6b0 100644
@@ -71,6 +71,9 @@ obj-y += block/
 obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/
 obj-$(CONFIG_CPU) += cpu/
 obj-y += crypto/
+ifneq ($(CONFIG_FASTBOOT_FLASH_MMC_DEV)$(CONFIG_FASTBOOT_FLASH_NAND_DEV),)
+obj-y += fastboot/
+endif
 obj-y += firmware/
 obj-$(CONFIG_FPGA) += fpga/
 obj-y += misc/
drivers/fastboot/Kconfig renamed from cmd/fastboot/Kconfig +12 -23
similarity index 88%
rename from cmd/fastboot/Kconfig
rename to drivers/fastboot/Kconfig
index 0d2c2f131e..93a8ac64e7 100644
@@ -1,32 +1,20 @@
-comment "FASTBOOT"
+menu "Fastboot support"
 
-menuconfig FASTBOOT
-	bool "Fastboot support"
-	depends on USB_GADGET
-	default y if ARCH_SUNXI && USB_MUSB_GADGET
-
-if FASTBOOT
+config FASTBOOT
+	bool
+	imply ANDROID_BOOT_IMAGE
+	imply CMD_FASTBOOT
 
 config USB_FUNCTION_FASTBOOT
 	bool "Enable USB fastboot gadget"
-	default y
+	depends on USB_GADGET
+	default y if ARCH_SUNXI && USB_MUSB_GADGET
+	select FASTBOOT
 	select USB_GADGET_DOWNLOAD
-	imply ANDROID_BOOT_IMAGE
-	imply CMD_FASTBOOT
 	help
 	  This enables the USB part of the fastboot gadget.
 
-config CMD_FASTBOOT
-	bool "Enable FASTBOOT command"
-	help
-	  This enables the command "fastboot" which enables the Android
-	  fastboot mode for the platform's USB device. Fastboot is a USB
-	  protocol for downloading images, flashing and device control
-	  used on Android devices.
-
-	  See doc/README.android-fastboot for more information.
-
-if USB_FUNCTION_FASTBOOT
+if FASTBOOT
 
 config FASTBOOT_BUF_ADDR
 	hex "Define FASTBOOT buffer address"
@@ -58,6 +46,7 @@ config FASTBOOT_BUF_SIZE
 
 config FASTBOOT_USB_DEV
 	int "USB controller number"
+	depends on USB_FUNCTION_FASTBOOT
 	default 0
 	help
 	  Some boards have USB OTG controller other than 0. Define this
@@ -129,6 +118,6 @@ config FASTBOOT_MBR_NAME
 	  specified on the "fastboot flash" command line matches the value
 	  defined here. The default target name for updating MBR is "mbr".
 
-endif # USB_FUNCTION_FASTBOOT
-
 endif # FASTBOOT
+
+endmenu
drivers/fastboot/Makefile new file +8 -0
new file mode 100644
index 0000000000..651fbf0935
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier:      GPL-2.0+
+
+ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+obj-y += fb_mmc.o
+endif
+ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
+obj-y += fb_nand.o
+endif
drivers/fastboot/fb_mmc.c renamed from common/fb_mmc.c +0 -0
similarity index 100%
rename from common/fb_mmc.c
rename to drivers/fastboot/fb_mmc.c
drivers/fastboot/fb_nand.c renamed from common/fb_nand.c +0 -0
similarity index 100%
rename from common/fb_nand.c
rename to drivers/fastboot/fb_nand.c
Signature · 1 line
2.17.0
#2 lore raw

PATCH v8 2/18 fastboot: Refactor fastboot_okay/fail to take response

In reply to Alex Kiernan

Add the response string as a parameter to fastboot_okay/fail, instead of modifying a global, to match the contract expected by the AOSP U-Boot code.

---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- refactor for changes in master

Changes in v2: None

 cmd/mmc.c                       |  2 +-
 common/image-sparse.c           | 32 +++++++------
 drivers/fastboot/fb_mmc.c       | 83 ++++++++++++++++++---------------
 drivers/fastboot/fb_nand.c      | 34 +++++++-------
 drivers/usb/gadget/f_fastboot.c | 35 ++++++--------
 include/fastboot.h              |  4 +-
 include/fb_mmc.h                |  4 +-
 include/fb_nand.h               |  4 +-
 include/image-sparse.h          |  4 +-
 9 files changed, 105 insertions(+), 97 deletions(-)
cmd/mmc.c +1 -1
index a3357eff8f..a5719b81eb 100644
@@ -367,7 +367,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp, int flag,
 	sparse.mssg = NULL;
 	sprintf(dest, "0x" LBAF, sparse.start * sparse.blksz);
 
-	if (write_sparse_image(&sparse, dest, addr))
+	if (write_sparse_image(&sparse, dest, addr, NULL))
 		return CMD_RET_FAILURE;
 	else
 		return CMD_RET_SUCCESS;
common/image-sparse.c +19 -13
index 9223b9a1b8..1ae7a4d0e8 100644
@@ -48,10 +48,10 @@
 #define CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE (1024 * 512)
 #endif
 
-static void default_log(const char *ignored) {}
+static void default_log(const char *ignored, char *response) {}
 
 int write_sparse_image(struct sparse_storage *info,
-		       const char *part_name, void *data)
+		       const char *part_name, void *data, char *response)
 {
 	lbaint_t blk;
 	lbaint_t blkcnt;
@@ -104,7 +104,7 @@ int write_sparse_image(struct sparse_storage *info,
 	if (offset) {
 		printf("%s: Sparse image block size issue [%u]\n",
 		       __func__, sparse_header->blk_sz);
-		info->mssg("sparse image block size issue");
+		info->mssg("sparse image block size issue", response);
 		return -1;
 	}
 
@@ -139,7 +139,8 @@ int write_sparse_image(struct sparse_storage *info,
 		case CHUNK_TYPE_RAW:
 			if (chunk_header->total_sz !=
 			    (sparse_header->chunk_hdr_sz + chunk_data_sz)) {
-				info->mssg("Bogus chunk size for chunk type Raw");
+				info->mssg("Bogus chunk size for chunk type Raw",
+					   response);
 				return -1;
 			}
 
@@ -147,7 +148,8 @@ int write_sparse_image(struct sparse_storage *info,
 				printf(
 				    "%s: Request would exceed partition size!\n",
 				    __func__);
-				info->mssg("Request would exceed partition size!");
+				info->mssg("Request would exceed partition size!",
+					   response);
 				return -1;
 			}
 
@@ -157,7 +159,7 @@ int write_sparse_image(struct sparse_storage *info,
 				printf("%s: %s" LBAFU " [" LBAFU "]\n",
 				       __func__, "Write failed, block #",
 				       blk, blks);
-				info->mssg("flash write failure");
+				info->mssg("flash write failure", response);
 				return -1;
 			}
 			blk += blks;
@@ -169,7 +171,7 @@ int write_sparse_image(struct sparse_storage *info,
 		case CHUNK_TYPE_FILL:
 			if (chunk_header->total_sz !=
 			    (sparse_header->chunk_hdr_sz + sizeof(uint32_t))) {
-				info->mssg("Bogus chunk size for chunk type FILL");
+				info->mssg("Bogus chunk size for chunk type FILL", response);
 				return -1;
 			}
 
@@ -179,7 +181,8 @@ int write_sparse_image(struct sparse_storage *info,
 						info->blksz * fill_buf_num_blks,
 						ARCH_DMA_MINALIGN));
 			if (!fill_buf) {
-				info->mssg("Malloc failed for: CHUNK_TYPE_FILL");
+				info->mssg("Malloc failed for: CHUNK_TYPE_FILL",
+					   response);
 				return -1;
 			}
 
@@ -196,7 +199,8 @@ int write_sparse_image(struct sparse_storage *info,
 				printf(
 				    "%s: Request would exceed partition size!\n",
 				    __func__);
-				info->mssg("Request would exceed partition size!");
+				info->mssg("Request would exceed partition size!",
+					   response);
 				return -1;
 			}
 
@@ -211,7 +215,8 @@ int write_sparse_image(struct sparse_storage *info,
 					       __func__,
 					       "Write failed, block #",
 					       blk, j);
-					info->mssg("flash write failure");
+					info->mssg("flash write failure",
+						   response);
 					free(fill_buf);
 					return -1;
 				}
@@ -231,7 +236,8 @@ int write_sparse_image(struct sparse_storage *info,
 		case CHUNK_TYPE_CRC32:
 			if (chunk_header->total_sz !=
 			    sparse_header->chunk_hdr_sz) {
-				info->mssg("Bogus chunk size for chunk type Dont Care");
+				info->mssg("Bogus chunk size for chunk type Dont Care",
+					   response);
 				return -1;
 			}
 			total_blocks += chunk_header->chunk_sz;
@@ -241,7 +247,7 @@ int write_sparse_image(struct sparse_storage *info,
 		default:
 			printf("%s: Unknown chunk type: %x\n", __func__,
 			       chunk_header->chunk_type);
-			info->mssg("Unknown chunk type");
+			info->mssg("Unknown chunk type", response);
 			return -1;
 		}
 	}
@@ -251,7 +257,7 @@ int write_sparse_image(struct sparse_storage *info,
 	printf("........ wrote %u bytes to '%s'\n", bytes_written, part_name);
 
 	if (total_blocks != sparse_header->total_blks) {
-		info->mssg("sparse image write failure");
+		info->mssg("sparse image write failure", response);
 		return -1;
 	}
 
drivers/fastboot/fb_mmc.c +46 -37

272 lines not on this page · raw message

drivers/fastboot/fb_nand.c +18 -16
index c07655e49e..2ee0d644e0 100644
@@ -31,7 +31,8 @@ __weak int board_fastboot_write_partition_setup(char *name)
 
 static int fb_nand_lookup(const char *partname,
 			  struct mtd_info **mtd,
-			  struct part_info **part)
+			  struct part_info **part,
+			  char *response)
 {
 	struct mtd_device *dev;
 	int ret;
@@ -40,21 +41,21 @@ static int fb_nand_lookup(const char *partname,
 	ret = mtdparts_init();
 	if (ret) {
 		pr_err("Cannot initialize MTD partitions\n");
-		fastboot_fail("cannot init mtdparts");
+		fastboot_fail("cannot init mtdparts", response);
 		return ret;
 	}
 
 	ret = find_dev_and_part(partname, &dev, &pnum, part);
 	if (ret) {
 		pr_err("cannot find partition: '%s'", partname);
-		fastboot_fail("cannot find partition");
+		fastboot_fail("cannot find partition", response);
 		return ret;
 	}
 
 	if (dev->id->type != MTD_DEV_TYPE_NAND) {
 		pr_err("partition '%s' is not stored on a NAND device",
 		      partname);
-		fastboot_fail("not a NAND device");
+		fastboot_fail("not a NAND device", response);
 		return -EINVAL;
 	}
 
@@ -145,16 +146,16 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info,
 }
 
 void fb_nand_flash_write(const char *cmd, void *download_buffer,
-			 unsigned int download_bytes)
+			 unsigned int download_bytes, char *response)
 {
 	struct part_info *part;
 	struct mtd_info *mtd = NULL;
 	int ret;
 
-	ret = fb_nand_lookup(cmd, &mtd, &part);
+	ret = fb_nand_lookup(cmd, &mtd, &part, response);
 	if (ret) {
 		pr_err("invalid NAND device");
-		fastboot_fail("invalid NAND device");
+		fastboot_fail("invalid NAND device", response);
 		return;
 	}
 
@@ -180,9 +181,10 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer,
 		       sparse.start);
 
 		sparse.priv = &sparse_priv;
-		ret = write_sparse_image(&sparse, cmd, download_buffer);
+		ret = write_sparse_image(&sparse, cmd, download_buffer,
+					 response);
 		if (!ret)
-			fastboot_okay("");
+			fastboot_okay(NULL, response);
 	} else {
 		printf("Flashing raw image at offset 0x%llx\n",
 		       part->offset);
@@ -195,23 +197,23 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer,
 	}
 
 	if (ret) {
-		fastboot_fail("error writing the image");
+		fastboot_fail("error writing the image", response);
 		return;
 	}
 
-	fastboot_okay("");
+	fastboot_okay(NULL, response);
 }
 
-void fb_nand_erase(const char *cmd)
+void fb_nand_erase(const char *cmd, char *response)
 {
 	struct part_info *part;
 	struct mtd_info *mtd = NULL;
 	int ret;
 
-	ret = fb_nand_lookup(cmd, &mtd, &part);
+	ret = fb_nand_lookup(cmd, &mtd, &part, response);
 	if (ret) {
 		pr_err("invalid NAND device");
-		fastboot_fail("invalid NAND device");
+		fastboot_fail("invalid NAND device", response);
 		return;
 	}
 
@@ -222,9 +224,9 @@ void fb_nand_erase(const char *cmd)
 	ret = _fb_nand_erase(mtd, part);
 	if (ret) {
 		pr_err("failed erasing from device %s", mtd->name);
-		fastboot_fail("failed erasing from device");
+		fastboot_fail("failed erasing from device", response);
 		return;
 	}
 
-	fastboot_okay("");
+	fastboot_okay(NULL, response);
 }
drivers/usb/gadget/f_fastboot.c +13 -22
index 3acadae8b1..bb60612647 100644
@@ -150,18 +150,16 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
 static int strcmp_l1(const char *s1, const char *s2);
 
 
-static char *fb_response_str;
-
-void fastboot_fail(const char *reason)
+void fastboot_fail(const char *reason, char *response)
 {
-	strncpy(fb_response_str, "FAIL\0", 5);
-	strncat(fb_response_str, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
+	strncpy(response, "FAIL\0", 5);
+	strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
 }
 
-void fastboot_okay(const char *reason)
+void fastboot_okay(const char *reason, char *response)
 {
-	strncpy(fb_response_str, "OKAY\0", 5);
-	strncat(fb_response_str, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
+	strncpy(response, "OKAY\0", 5);
+	strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
 }
 
 static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
@@ -597,18 +595,14 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req)
 		return;
 	}
 
-	/* initialize the response buffer */
-	fb_response_str = response;
-
-	fastboot_fail("no flash device defined");
+	fastboot_fail("no flash device defined", response);
 #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
 	fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
-			   download_bytes);
+			   download_bytes, response);
 #endif
 #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
-	fb_nand_flash_write(cmd,
-			    (void *)CONFIG_FASTBOOT_BUF_ADDR,
-			    download_bytes);
+	fb_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
+			    download_bytes, response);
 #endif
 	fastboot_tx_write_str(response);
 }
@@ -649,15 +643,12 @@ static void cb_erase(struct usb_ep *ep, struct usb_request *req)
 		return;
 	}
 
-	/* initialize the response buffer */
-	fb_response_str = response;
-
-	fastboot_fail("no flash device defined");
+	fastboot_fail("no flash device defined", response);
 #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
-	fb_mmc_erase(cmd);
+	fb_mmc_erase(cmd, response);
 #endif
 #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
-	fb_nand_erase(cmd);
+	fb_nand_erase(cmd, response);
 #endif
 	fastboot_tx_write_str(response);
 }
include/fastboot.h +2 -2
index 009f1a72e1..ed52daeb1b 100644
@@ -15,7 +15,7 @@
 /* The 64 defined bytes plus \0 */
 #define FASTBOOT_RESPONSE_LEN	(64 + 1)
 
-void fastboot_fail(const char *reason);
-void fastboot_okay(const char *reason);
+void fastboot_fail(const char *reason, char *response);
+void fastboot_okay(const char *reason, char *response);
 
 #endif /* _FASTBOOT_H_ */
include/fb_mmc.h +2 -2
index a2d7c4895f..39a960cc9d 100644
@@ -4,5 +4,5 @@
  */
 
 void fb_mmc_flash_write(const char *cmd, void *download_buffer,
-			unsigned int download_bytes);
-void fb_mmc_erase(const char *cmd);
+			unsigned int download_bytes, char *response);
+void fb_mmc_erase(const char *cmd, char *response);
include/fb_nand.h +2 -2
index 3daae8c4ca..2c92a4eb50 100644
@@ -5,5 +5,5 @@
  */
 
 void fb_nand_flash_write(const char *cmd, void *download_buffer,
-			 unsigned int download_bytes);
-void fb_nand_erase(const char *cmd);
+			 unsigned int download_bytes, char *response);
+void fb_nand_erase(const char *cmd, char *response);
include/image-sparse.h +2 -2
index f39dc16617..234c237b84 100644
@@ -23,7 +23,7 @@ struct sparse_storage {
 				 lbaint_t blk,
 				 lbaint_t blkcnt);
 
-	void		(*mssg)(const char *str);
+	void		(*mssg)(const char *str, char *response);
 };
 
 static inline int is_sparse_image(void *buf)
@@ -38,4 +38,4 @@ static inline int is_sparse_image(void *buf)
 }
 
 int write_sparse_image(struct sparse_storage *info, const char *part_name,
-		       void *data);
+		       void *data, char *response);
Signature · 1 line
2.17.0
#3 lore raw

PATCH v8 3/18 fastboot: Extract fastboot_okay/fail to fb_common.c

In reply to Alex Kiernan

Add drivers/fastboot/fb_common.c, where fastboot_okay/fail are implemented so we can call them from a non-USB implementation.

Introduce fastboot_response which takes varargs parameters so we can use it to generate formatted response strings. Refactor fastboot_okay/fail to use it.

---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5:
- fix docbook formatting

Changes in v4:
- add docbook comments

Changes in v3:
- Merge subsequent patch for formatting response strings into this one
- allow NULL to fastboot_okay() when there's no message to send

Changes in v2: None

 drivers/Makefile                |  4 +--
 drivers/fastboot/Makefile       |  2 ++
 drivers/fastboot/fb_common.c    | 61 +++++++++++++++++++++++++++++++++
 drivers/usb/gadget/f_fastboot.c | 13 -------
 include/fastboot.h              | 24 +++++++++++++
 5 files changed, 88 insertions(+), 16 deletions(-)
 create mode 100644 drivers/fastboot/fb_common.c
drivers/Makefile +1 -3
index a79ff2e6b0..d29a6e467b 100644
@@ -71,9 +71,7 @@ obj-y += block/
 obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/
 obj-$(CONFIG_CPU) += cpu/
 obj-y += crypto/
-ifneq ($(CONFIG_FASTBOOT_FLASH_MMC_DEV)$(CONFIG_FASTBOOT_FLASH_NAND_DEV),)
-obj-y += fastboot/
-endif
+obj-$(CONFIG_FASTBOOT) += fastboot/
 obj-y += firmware/
 obj-$(CONFIG_FPGA) += fpga/
 obj-y += misc/
drivers/fastboot/Makefile +2 -0
index 651fbf0935..b38dcff202 100644
@@ -1,5 +1,7 @@
 # SPDX-License-Identifier:      GPL-2.0+
 
+obj-y += fb_common.o
+
 ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
 obj-y += fb_mmc.o
 endif
drivers/fastboot/fb_common.c new file +61 -0

61 lines not on this page · raw message

drivers/usb/gadget/f_fastboot.c +0 -13
index bb60612647..2e6e1615bf 100644
@@ -149,19 +149,6 @@ static struct usb_gadget_strings *fastboot_strings[] = {
 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
 static int strcmp_l1(const char *s1, const char *s2);
 
-
-void fastboot_fail(const char *reason, char *response)
-{
-	strncpy(response, "FAIL\0", 5);
-	strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
-}
-
-void fastboot_okay(const char *reason, char *response)
-{
-	strncpy(response, "OKAY\0", 5);
-	strncat(response, reason, FASTBOOT_RESPONSE_LEN - 4 - 1);
-}
-
 static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
 {
 	int status = req->status;
include/fastboot.h +24 -0
index ed52daeb1b..6cd44d2ab9 100644
@@ -15,7 +15,31 @@
 /* The 64 defined bytes plus \0 */
 #define FASTBOOT_RESPONSE_LEN	(64 + 1)
 
+/**
+ * fastboot_response() - Writes a response of the form "$tag$reason".
+ *
+ * @tag: The first part of the response
+ * @response: Pointer to fastboot response buffer
+ * @format: printf style format string
+ */
+void fastboot_response(const char *tag, char *response,
+		       const char *format, ...)
+	__attribute__ ((format (__printf__, 3, 4)));
+
+/**
+ * fastboot_fail() - Write a FAIL response of the form "FAIL$reason".
+ *
+ * @reason: Pointer to returned reason string
+ * @response: Pointer to fastboot response buffer
+ */
 void fastboot_fail(const char *reason, char *response);
+
+/**
+ * fastboot_okay() - Write an OKAY response of the form "OKAY$reason".
+ *
+ * @reason: Pointer to returned reason string, or NULL to send a bare "OKAY"
+ * @response: Pointer to fastboot response buffer
+ */
 void fastboot_okay(const char *reason, char *response);
 
 #endif /* _FASTBOOT_H_ */
Signature · 1 line
2.17.0
#4 lore raw

PATCH v8 4/18 fastboot: Correct dependencies in FASTBOOT_FLASH

In reply to Alex Kiernan

Ensure that when selecting FASTBOOT_FLASH you end up with a buildable configuration. Prior to this you could select NAND without MTDPARTS and end up with an image which (surprisingly) excluded NAND.

Also fix dependencies on FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME which require you have EFI_PARTITION/DOS_PARTITION enabled.

Delete redundant FASTBOOT_FLASH_NAND_DEV from Kconfig - it was only ever used as a guard and the value was ignored in all cases, we're using FASTBOOT_FLASH_NAND as the guard now.

---

Changes in v8: None
Changes in v7: None
Changes in v6:
- delete redundant FASTBOOT_FLASH_NAND_DEV symbol

Changes in v5: None
Changes in v4: None
Changes in v3:
- guard FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME with EFI/DOS_PARTITION

Changes in v2: None

 arch/arm/mach-omap2/utils.c     |  4 ++--
 drivers/fastboot/Kconfig        | 17 ++++-------------
 drivers/fastboot/Makefile       |  8 ++------
 drivers/usb/gadget/f_fastboot.c | 14 +++++++-------
 4 files changed, 15 insertions(+), 28 deletions(-)
arch/arm/mach-omap2/utils.c +2 -2
index dc7b37f164..edf5edcb68 100644
@@ -85,7 +85,7 @@ static void omap_set_fastboot_board_rev(void)
 	env_set("fastboot.board_rev", board_rev);
 }
 
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
 static u32 omap_mmc_get_part_size(const char *part)
 {
 	int res;
@@ -128,7 +128,7 @@ static void omap_set_fastboot_userdata_size(void)
 static inline void omap_set_fastboot_userdata_size(void)
 {
 }
-#endif /* CONFIG_FASTBOOT_FLASH_MMC_DEV */
+#endif /* CONFIG_FASTBOOT_FLASH_MMC */
 void omap_set_fastboot_vars(void)
 {
 	omap_set_fastboot_cpu();
drivers/fastboot/Kconfig +4 -13
index 93a8ac64e7..9bbc5c661d 100644
@@ -56,6 +56,7 @@ config FASTBOOT_USB_DEV
 config FASTBOOT_FLASH
 	bool "Enable FASTBOOT FLASH command"
 	default y if ARCH_SUNXI
+	depends on MMC || (NAND && CMD_MTDPARTS)
 	help
 	  The fastboot protocol includes a "flash" command for writing
 	  the downloaded image to a non-volatile storage device. Define
@@ -71,7 +72,7 @@ config FASTBOOT_FLASH_MMC
 
 config FASTBOOT_FLASH_NAND
 	bool "FASTBOOT on NAND"
-	depends on NAND
+	depends on NAND && CMD_MTDPARTS
 
 endchoice
 
@@ -85,19 +86,9 @@ config FASTBOOT_FLASH_MMC_DEV
 	  regarding the non-volatile storage device. Define this to
 	  the eMMC device that fastboot should use to store the image.
 
-config FASTBOOT_FLASH_NAND_DEV
-	int "Define FASTBOOT NAND FLASH default device"
-	depends on FASTBOOT_FLASH_NAND
-	depends on CMD_MTDPARTS
-	default 0 if ARCH_SUNXI && NAND_SUNXI
-	help
-	  The fastboot "flash" command requires additional information
-	  regarding the non-volatile storage device. Define this to
-	  the NAND device that fastboot should use to store the image.
-
 config FASTBOOT_GPT_NAME
 	string "Target name for updating GPT"
-	depends on FASTBOOT_FLASH
+	depends on FASTBOOT_FLASH_MMC && EFI_PARTITION
 	default "gpt"
 	help
 	  The fastboot "flash" command supports writing the downloaded
@@ -110,7 +101,7 @@ config FASTBOOT_GPT_NAME
 
 config FASTBOOT_MBR_NAME
 	string "Target name for updating MBR"
-	depends on FASTBOOT_FLASH
+	depends on FASTBOOT_FLASH_MMC && DOS_PARTITION
 	default "mbr"
 	help
 	  The fastboot "flash" command allows to write the downloaded image
drivers/fastboot/Makefile +2 -6
index b38dcff202..e4bd389adf 100644
@@ -2,9 +2,5 @@
 
 obj-y += fb_common.o
 
-ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
-obj-y += fb_mmc.o
-endif
-ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
-obj-y += fb_nand.o
-endif
+obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o
+obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o
drivers/usb/gadget/f_fastboot.c +7 -7
index 2e6e1615bf..323ac89417 100644
@@ -20,10 +20,10 @@
 #include <linux/compiler.h>
 #include <version.h>
 #include <g_dnl.h>
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
 #include <fb_mmc.h>
 #endif
-#ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_NAND
 #include <fb_nand.h>
 #endif
 
@@ -583,11 +583,11 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req)
 	}
 
 	fastboot_fail("no flash device defined", response);
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
 	fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
 			   download_bytes, response);
 #endif
-#ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_NAND
 	fb_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
 			    download_bytes, response);
 #endif
@@ -598,7 +598,7 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req)
 static void cb_oem(struct usb_ep *ep, struct usb_request *req)
 {
 	char *cmd = req->buf;
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
 	if (strncmp("format", cmd + 4, 6) == 0) {
 		char cmdbuf[32];
                 sprintf(cmdbuf, "gpt write mmc %x $partitions",
@@ -631,10 +631,10 @@ static void cb_erase(struct usb_ep *ep, struct usb_request *req)
 	}
 
 	fastboot_fail("no flash device defined", response);
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_MMC
 	fb_mmc_erase(cmd, response);
 #endif
-#ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
+#ifdef CONFIG_FASTBOOT_FLASH_NAND
 	fb_nand_erase(cmd, response);
 #endif
 	fastboot_tx_write_str(response);
Signature · 1 line
2.17.0
#5 lore raw

PATCH v8 5/18 fastboot: Add missing newlines

In reply to Alex Kiernan

Add newlines so we format our output correctly.

---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/fastboot/fb_mmc.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/fastboot/fb_mmc.c +14 -14
index 1bcb2e52d4..b1db29684d 100644
@@ -125,7 +125,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc,
 	sector_size = info->blksz;
 	hdr_sectors = DIV_ROUND_UP(sizeof(struct andr_img_hdr), sector_size);
 	if (hdr_sectors == 0) {
-		pr_err("invalid number of boot sectors: 0");
+		pr_err("invalid number of boot sectors: 0\n");
 		fastboot_fail("invalid number of boot sectors: 0", response);
 		return 0;
 	}
@@ -133,7 +133,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc,
 	/* Read the boot image header */
 	res = blk_dread(dev_desc, info->start, hdr_sectors, (void *)hdr);
 	if (res != hdr_sectors) {
-		pr_err("cannot read header from boot partition");
+		pr_err("cannot read header from boot partition\n");
 		fastboot_fail("cannot read header from boot partition",
 			      response);
 		return 0;
@@ -142,7 +142,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc,
 	/* Check boot header magic string */
 	res = android_image_check_header(hdr);
 	if (res != 0) {
-		pr_err("bad boot image magic");
+		pr_err("bad boot image magic\n");
 		fastboot_fail("boot partition not initialized", response);
 		return 0;
 	}
@@ -181,7 +181,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
 	/* Get boot partition info */
 	res = part_get_info_by_name(dev_desc, BOOT_PARTITION_NAME, &info);
 	if (res < 0) {
-		pr_err("cannot find boot partition");
+		pr_err("cannot find boot partition\n");
 		fastboot_fail("cannot find boot partition", response);
 		return -1;
 	}
@@ -193,14 +193,14 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
 	/* Read boot image header */
 	hdr_sectors = fb_mmc_get_boot_header(dev_desc, &info, hdr, response);
 	if (hdr_sectors == 0) {
-		pr_err("unable to read boot image header");
+		pr_err("unable to read boot image header\n");
 		fastboot_fail("unable to read boot image header", response);
 		return -1;
 	}
 
 	/* Check if boot image has second stage in it (we don't support it) */
 	if (hdr->second_size > 0) {
-		pr_err("moving second stage is not supported yet");
+		pr_err("moving second stage is not supported yet\n");
 		fastboot_fail("moving second stage is not supported yet",
 			      response);
 		return -1;
@@ -219,7 +219,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
 	res = blk_dread(dev_desc, ramdisk_sector_start, ramdisk_sectors,
 			ramdisk_buffer);
 	if (res != ramdisk_sectors) {
-		pr_err("cannot read ramdisk from boot partition");
+		pr_err("cannot read ramdisk from boot partition\n");
 		fastboot_fail("cannot read ramdisk from boot partition",
 			      response);
 		return -1;
@@ -229,7 +229,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
 	hdr->kernel_size = download_bytes;
 	res = blk_dwrite(dev_desc, info.start, hdr_sectors, (void *)hdr);
 	if (res == 0) {
-		pr_err("cannot writeback boot image header");
+		pr_err("cannot writeback boot image header\n");
 		fastboot_fail("cannot write back boot image header", response);
 		return -1;
 	}
@@ -241,7 +241,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
 	res = blk_dwrite(dev_desc, kernel_sector_start, kernel_sectors,
 			 download_buffer);
 	if (res == 0) {
-		pr_err("cannot write new kernel");
+		pr_err("cannot write new kernel\n");
 		fastboot_fail("cannot write new kernel", response);
 		return -1;
 	}
@@ -253,7 +253,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
 	res = blk_dwrite(dev_desc, ramdisk_sector_start, ramdisk_sectors,
 			 ramdisk_buffer);
 	if (res == 0) {
-		pr_err("cannot write back original ramdisk");
+		pr_err("cannot write back original ramdisk\n");
 		fastboot_fail("cannot write back original ramdisk", response);
 		return -1;
 	}
@@ -371,21 +371,21 @@ void fb_mmc_erase(const char *cmd, char *response)
 	struct mmc *mmc = find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV);
 
 	if (mmc == NULL) {
-		pr_err("invalid mmc device");
+		pr_err("invalid mmc device\n");
 		fastboot_fail("invalid mmc device", response);
 		return;
 	}
 
 	dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
 	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-		pr_err("invalid mmc device");
+		pr_err("invalid mmc device\n");
 		fastboot_fail("invalid mmc device", response);
 		return;
 	}
 
 	ret = part_get_info_by_name_or_alias(dev_desc, cmd, &info);
 	if (ret < 0) {
-		pr_err("cannot find partition: '%s'", cmd);
+		pr_err("cannot find partition: '%s'\n", cmd);
 		fastboot_fail("cannot find partition", response);
 		return;
 	}
@@ -404,7 +404,7 @@ void fb_mmc_erase(const char *cmd, char *response)
 
 	blks = blk_derase(dev_desc, blks_start, blks_size);
 	if (blks != blks_size) {
-		pr_err("failed erasing from device %d", dev_desc->devnum);
+		pr_err("failed erasing from device %d\n", dev_desc->devnum);
 		fastboot_fail("failed erasing from device", response);
 		return;
 	}
Signature · 1 line
2.17.0
#6 lore raw

PATCH v8 6/18 fastboot: Remove FIXME for CONFIG_FASTBOOT_...NAME

In reply to Alex Kiernan

CONFIG_FASTBOOT_GPT_NAME and CONFIG_FASTBOOT_MBR_NAME are always defined by Kconfig if you're compiling this code, so remove these redundant defaults.

---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- new

Changes in v2: None

 drivers/fastboot/fb_mmc.c | 13 -------------
 1 file changed, 13 deletions(-)
drivers/fastboot/fb_mmc.c +0 -13
index b1db29684d..038905face 100644
@@ -15,19 +15,6 @@
 #include <linux/compat.h>
 #include <android_image.h>
 
-/*
- * FIXME: Ensure we always set these names via Kconfig once xxx_PARTITION is
- * migrated
- */
-#ifndef CONFIG_FASTBOOT_GPT_NAME
-#define CONFIG_FASTBOOT_GPT_NAME "gpt"
-#endif
-
-
-#ifndef CONFIG_FASTBOOT_MBR_NAME
-#define CONFIG_FASTBOOT_MBR_NAME "mbr"
-#endif
-
 #define BOOT_PARTITION_NAME "boot"
 
 struct fb_mmc_sparse {
Signature · 1 line
2.17.0
#7 lore raw

PATCH v8 7/18 fastboot: Fix parameter types in _fb_nand_write

In reply to Alex Kiernan

Compiling on a 64 bit target the arguments to _fb_nand_write are incompatible:

drivers/fastboot/fb_nand.c: In function ‘_fb_nand_write’:
drivers/fastboot/fb_nand.c:101:42: warning: passing argument 3 of ‘nand_write_skip_bad’ from incompatible pointer type [-Wincompatible-pointer-types]
return nand_write_skip_bad(mtd, offset, &length, written,
^
In file included from drivers/fastboot/fb_nand.c:16:0:
include/nand.h:107:5: note: expected ‘size_t * {aka long unsigned int *}’ but argument is of type ‘unsigned int *’
int nand_write_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length,

       ^~~~~~~~~~~~~~~~~~~

---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- new

Changes in v2: None

 drivers/fastboot/fb_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fastboot/fb_nand.c +1 -1
index 2ee0d644e0..849a6f16a5 100644
@@ -89,7 +89,7 @@ static int _fb_nand_erase(struct mtd_info *mtd, struct part_info *part)
 
 static int _fb_nand_write(struct mtd_info *mtd, struct part_info *part,
 			  void *buffer, unsigned int offset,
-			  unsigned int length, size_t *written)
+			  size_t length, size_t *written)
 {
 	int flags = WITH_WR_VERIFY;
 
Signature · 1 line
2.17.0
#8 lore raw

PATCH v8 8/18 fastboot: Rename fb_set_reboot_flag to fastboot_set_reboot_flag

In reply to Alex Kiernan

Rename fb_set_reboot_flag to fastboot_set_reboot_flag so it matches all other fastboot code in the global name space. Fix the guards around them so that they're dependent on FASTBOOT, not just USB_FUNCTION_FASTBOOT.

Move the weak implementation of fastboot_set_reboot_flag to fb_common.c so we can call it from non-USB fastboot code.

---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- new

Changes in v2: None

 arch/arm/mach-omap2/boot-common.c     |  4 ++--
 arch/arm/mach-rockchip/rk3128-board.c |  4 ++--
 arch/arm/mach-rockchip/rk322x-board.c |  4 ++--
 board/amazon/kc1/kc1.c                |  2 +-
 board/lg/sniper/sniper.c              |  2 +-
 drivers/fastboot/fb_common.c          | 15 +++++++++++++++
 drivers/usb/gadget/f_fastboot.c       |  7 +------
 include/fastboot.h                    |  2 +-
 8 files changed, 25 insertions(+), 15 deletions(-)
arch/arm/mach-omap2/boot-common.c +2 -2
index 0e9fd03fef..b22b6713e5 100644
@@ -237,8 +237,8 @@ void arch_preboot_os(void)
 }
 #endif
 
-#if defined(CONFIG_USB_FUNCTION_FASTBOOT) && !defined(CONFIG_ENV_IS_NOWHERE)
-int fb_set_reboot_flag(void)
+#if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
+int fastboot_set_reboot_flag(void)
 {
 	printf("Setting reboot to fastboot flag ...\n");
 	env_set("dofastboot", "1");
arch/arm/mach-rockchip/rk3128-board.c +2 -2
index 48cd8ba81e..7fd667a0b8 100644
@@ -111,8 +111,8 @@ int board_usb_cleanup(int index, enum usb_init_type init)
 }
 #endif
 
-#if defined(CONFIG_USB_FUNCTION_FASTBOOT)
-int fb_set_reboot_flag(void)
+#if CONFIG_IS_ENABLED(FASTBOOT)
+int fastboot_set_reboot_flag(void)
 {
 	struct rk3128_grf *grf;
 
arch/arm/mach-rockchip/rk322x-board.c +2 -2
index 99a60c4e2e..7366d45ab6 100644
@@ -139,8 +139,8 @@ int board_usb_cleanup(int index, enum usb_init_type init)
 }
 #endif
 
-#if defined(CONFIG_USB_FUNCTION_FASTBOOT)
-int fb_set_reboot_flag(void)
+#if CONFIG_IS_ENABLED(FASTBOOT)
+int fastboot_set_reboot_flag(void)
 {
 	struct rk322x_grf *grf;
 
board/amazon/kc1/kc1.c +1 -1
index d9ca18363c..031fd11092 100644
@@ -161,7 +161,7 @@ void get_board_serial(struct tag_serialnr *serialnr)
 	omap_die_id_get_board_serial(serialnr);
 }
 
-int fb_set_reboot_flag(void)
+int fastboot_set_reboot_flag(void)
 {
 	return omap_reboot_mode_store("b");
 }
board/lg/sniper/sniper.c +1 -1
index 34a7a11f05..a7de4c2167 100644
@@ -173,7 +173,7 @@ void reset_misc(void)
 	omap_reboot_mode_store(reboot_mode);
 }
 
-int fb_set_reboot_flag(void)
+int fastboot_set_reboot_flag(void)
 {
 	return omap_reboot_mode_store("b");
 }
drivers/fastboot/fb_common.c +15 -0
index c4a7702bb3..79e080ac87 100644
@@ -59,3 +59,18 @@ void fastboot_okay(const char *reason, char *response)
 	else
 		fastboot_response("OKAY", response, NULL);
 }
+
+/**
+ * fastboot_set_reboot_flag() - Set flag to indicate reboot-bootloader
+ *
+ * Set flag which indicates that we should reboot into the bootloader
+ * following the reboot that fastboot executes after this function.
+ *
+ * This function should be overridden in your board file with one
+ * which sets whatever flag your board specific Android bootloader flow
+ * requires in order to re-enter the bootloader.
+ */
+int __weak fastboot_set_reboot_flag(void)
+{
+	return -ENOSYS;
+}
drivers/usb/gadget/f_fastboot.c +1 -6
index 323ac89417..697eee57d0 100644
@@ -357,16 +357,11 @@ static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
 	do_reset(NULL, 0, 0, NULL);
 }
 
-int __weak fb_set_reboot_flag(void)
-{
-	return -ENOSYS;
-}
-
 static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
 {
 	char *cmd = req->buf;
 	if (!strcmp_l1("reboot-bootloader", cmd)) {
-		if (fb_set_reboot_flag()) {
+		if (fastboot_set_reboot_flag()) {
 			fastboot_tx_write_str("FAILCannot set reboot flag");
 			return;
 		}
include/fastboot.h +1 -1
index 6cd44d2ab9..816e71b4d0 100644
@@ -41,5 +41,5 @@ void fastboot_fail(const char *reason, char *response);
  * @response: Pointer to fastboot response buffer
  */
 void fastboot_okay(const char *reason, char *response);
-
+int fastboot_set_reboot_flag(void);
 #endif /* _FASTBOOT_H_ */
Signature · 1 line
2.17.0
#9 lore raw

PATCH v8 9/18 fastboot: Extract common definitions from USB fastboot

In reply to Alex Kiernan

Move FASTBOOT_VERSION to include/fastboot.h so when we merge the UDP code we only have one definition.

---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
- leave strcmp_l1() in USB fastboot as we don't need it in UDP path

Changes in v3:
- new

Changes in v2: None

 drivers/usb/gadget/f_fastboot.c | 2 --
 include/fastboot.h              | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/f_fastboot.c +0 -2
index 697eee57d0..25784a193e 100644
@@ -27,8 +27,6 @@
 #include <fb_nand.h>
 #endif
 
-#define FASTBOOT_VERSION		"0.4"
-
 #define FASTBOOT_INTERFACE_CLASS	0xff
 #define FASTBOOT_INTERFACE_SUB_CLASS	0x42
 #define FASTBOOT_INTERFACE_PROTOCOL	0x03
include/fastboot.h +2 -0
index 816e71b4d0..bf3d9e2f67 100644
@@ -12,6 +12,8 @@
 #ifndef _FASTBOOT_H_
 #define _FASTBOOT_H_
 
+#define FASTBOOT_VERSION	"0.4"
+
 /* The 64 defined bytes plus \0 */
 #define FASTBOOT_RESPONSE_LEN	(64 + 1)
 
Signature · 1 line
2.17.0
#10 lore raw

PATCH v8 10/18 fastboot: Rename public fb_ functions to fastboot_

In reply to Alex Kiernan

Rename fb_mmc_flash_write/fb_mmc_erase/fb_nand_flash_write/fb_nand_erase to fastboot_... as they form a public interface

---

Changes in v8: None
Changes in v7: None
Changes in v6:
- add docbook comments

Changes in v5:
- new

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/fastboot/fb_mmc.c       | 20 +++++++++++++++++---
 drivers/fastboot/fb_nand.c      | 20 +++++++++++++++++---
 drivers/usb/gadget/f_fastboot.c | 12 ++++++------
 include/fb_mmc.h                | 21 ++++++++++++++++++---
 include/fb_nand.h               | 20 +++++++++++++++++---
 5 files changed, 75 insertions(+), 18 deletions(-)
drivers/fastboot/fb_mmc.c +17 -3
index 038905face..47fcf74b69 100644
@@ -251,8 +251,16 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
 }
 #endif
 
-void fb_mmc_flash_write(const char *cmd, void *download_buffer,
-			unsigned int download_bytes, char *response)
+/**
+ * fastboot_mmc_flash_write() - Write image to eMMC for fastboot
+ *
+ * @cmd: Named partition to write image to
+ * @download_buffer: Pointer to image data
+ * @download_bytes: Size of image data
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
+			      unsigned int download_bytes, char *response)
 {
 	struct blk_desc *dev_desc;
 	disk_partition_t info;
@@ -349,7 +357,13 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
 	}
 }
 
-void fb_mmc_erase(const char *cmd, char *response)
+/**
+ * fastboot_mmc_flash_erase() - Erase eMMC for fastboot
+ *
+ * @cmd: Named partition to erase
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_mmc_erase(const char *cmd, char *response)
 {
 	int ret;
 	struct blk_desc *dev_desc;
drivers/fastboot/fb_nand.c +17 -3
index 849a6f16a5..535f541eb8 100644
@@ -145,8 +145,16 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info,
 	return blkcnt + bad_blocks;
 }
 
-void fb_nand_flash_write(const char *cmd, void *download_buffer,
-			 unsigned int download_bytes, char *response)
+/**
+ * fastboot_nand_flash_write() - Write image to NAND for fastboot
+ *
+ * @cmd: Named device to write image to
+ * @download_buffer: Pointer to image data
+ * @download_bytes: Size of image data
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_nand_flash_write(const char *cmd, void *download_buffer,
+			       unsigned int download_bytes, char *response)
 {
 	struct part_info *part;
 	struct mtd_info *mtd = NULL;
@@ -204,7 +212,13 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer,
 	fastboot_okay(NULL, response);
 }
 
-void fb_nand_erase(const char *cmd, char *response)
+/**
+ * fastboot_nand_flash_erase() - Erase NAND for fastboot
+ *
+ * @cmd: Named device to erase
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_nand_erase(const char *cmd, char *response)
 {
 	struct part_info *part;
 	struct mtd_info *mtd = NULL;
drivers/usb/gadget/f_fastboot.c +6 -6
index 25784a193e..07d6a62155 100644
@@ -577,12 +577,12 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req)
 
 	fastboot_fail("no flash device defined", response);
 #ifdef CONFIG_FASTBOOT_FLASH_MMC
-	fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
-			   download_bytes, response);
+	fastboot_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
+				 download_bytes, response);
 #endif
 #ifdef CONFIG_FASTBOOT_FLASH_NAND
-	fb_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
-			    download_bytes, response);
+	fastboot_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
+				  download_bytes, response);
 #endif
 	fastboot_tx_write_str(response);
 }
@@ -625,10 +625,10 @@ static void cb_erase(struct usb_ep *ep, struct usb_request *req)
 
 	fastboot_fail("no flash device defined", response);
 #ifdef CONFIG_FASTBOOT_FLASH_MMC
-	fb_mmc_erase(cmd, response);
+	fastboot_mmc_erase(cmd, response);
 #endif
 #ifdef CONFIG_FASTBOOT_FLASH_NAND
-	fb_nand_erase(cmd, response);
+	fastboot_nand_erase(cmd, response);
 #endif
 	fastboot_tx_write_str(response);
 }
include/fb_mmc.h +18 -3
index 39a960cc9d..daca81a201 100644
@@ -3,6 +3,21 @@
  * Copyright 2014 Broadcom Corporation.
  */
 
-void fb_mmc_flash_write(const char *cmd, void *download_buffer,
-			unsigned int download_bytes, char *response);
-void fb_mmc_erase(const char *cmd, char *response);
+/**
+ * fastboot_mmc_flash_write() - Write image to eMMC for fastboot
+ *
+ * @cmd: Named partition to write image to
+ * @download_buffer: Pointer to image data
+ * @download_bytes: Size of image data
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
+			      unsigned int download_bytes, char *response);
+
+/**
+ * fastboot_mmc_flash_erase() - Erase eMMC for fastboot
+ *
+ * @cmd: Named partition to erase
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_mmc_erase(const char *cmd, char *response);
include/fb_nand.h +17 -3
index 2c92a4eb50..b5d4c0cc5f 100644
@@ -4,6 +4,20 @@
  * Copyright 2015 Free Electrons.
  */
 
-void fb_nand_flash_write(const char *cmd, void *download_buffer,
-			 unsigned int download_bytes, char *response);
-void fb_nand_erase(const char *cmd, char *response);
+/**
+ * fastboot_nand_flash_write() - Write image to NAND for fastboot
+ *
+ * @cmd: Named device to write image to
+ * @download_buffer: Pointer to image data
+ * @download_bytes: Size of image data
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_nand_flash_write(const char *cmd, void *download_buffer,
+			       unsigned int download_bytes, char *response);
+/**
+ * fastboot_nand_flash_erase() - Erase NAND for fastboot
+ *
+ * @cmd: Named device to erase
+ * @response: Pointer to fastboot response buffer
+ */
+void fastboot_nand_erase(const char *cmd, char *response);
Signature · 1 line
2.17.0
#11 lore raw

PATCH v8 11/18 ti: fastboot: Move weak overrides to board files

In reply to Alex Kiernan

Overriding fastboot_set_reboot_flag() in arch/arm/mach-omap2/boot-common.c leaves it applying all boards that derive from this, not just the ones which have support for Android bootloader flow. Move the weak function override to the relevant board files.

---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- new

Changes in v2: None

 arch/arm/mach-omap2/boot-common.c | 10 ----------
 board/ti/am57xx/board.c           | 10 ++++++++++
 board/ti/dra7xx/evm.c             | 10 ++++++++++
 3 files changed, 20 insertions(+), 10 deletions(-)
arch/arm/mach-omap2/boot-common.c +0 -10
index b22b6713e5..d4a1e2e42c 100644
@@ -236,13 +236,3 @@ void arch_preboot_os(void)
 	ahci_reset((void __iomem *)DWC_AHSATA_BASE);
 }
 #endif
-
-#if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
-int fastboot_set_reboot_flag(void)
-{
-	printf("Setting reboot to fastboot flag ...\n");
-	env_set("dofastboot", "1");
-	env_save();
-	return 0;
-}
-#endif
board/ti/am57xx/board.c +10 -0
index fd9d20779b..177a3246c3 100644
@@ -1178,5 +1178,15 @@ void board_tee_image_process(ulong tee_image, size_t tee_size)
 	secure_tee_install((u32)tee_image);
 }
 
+#if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
+int fastboot_set_reboot_flag(void)
+{
+	printf("Setting reboot to fastboot flag ...\n");
+	env_set("dofastboot", "1");
+	env_save();
+	return 0;
+}
+#endif
+
 U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);
 #endif
board/ti/dra7xx/evm.c +10 -0
index 6918f4de01..bbe54450ae 100644
@@ -1188,5 +1188,15 @@ void board_tee_image_process(ulong tee_image, size_t tee_size)
 	secure_tee_install((u32)tee_image);
 }
 
+#if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE)
+int fastboot_set_reboot_flag(void)
+{
+	printf("Setting reboot to fastboot flag ...\n");
+	env_set("dofastboot", "1");
+	env_save();
+	return 0;
+}
+#endif
+
 U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);
 #endif
Signature · 1 line
2.17.0
#12 lore raw

PATCH v8 12/18 fs: Add fs_get_type_name to return current filesystem name

In reply to Alex Kiernan

Add fs_get_type_name so we can get the current filesystem type.

---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
- add docbook comments

Changes in v3:
- new

Changes in v2: None

 fs/fs.c      | 13 +++++++++++++
 include/fs.h | 10 ++++++++++
 2 files changed, 23 insertions(+)
fs/fs.c +13 -0
index 94cdc37deb..33808d549e 100644
@@ -265,6 +265,19 @@ static struct fstype_info *fs_get_info(int fstype)
 	return info;
 }
 
+/**
+ * fs_get_type_name() - Get type of current filesystem
+ *
+ * Return: Pointer to filesystem name
+ *
+ * Returns a string describing the current filesystem, or the sentinel
+ * "unsupported" for any unrecognised filesystem.
+ */
+const char *fs_get_type_name(void)
+{
+	return fs_get_info(fs_type)->name;
+}
+
 int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)
 {
 	struct fstype_info *info;
include/fs.h +10 -0
index d703ed5027..163da103b4 100644
@@ -37,6 +37,16 @@ int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype);
  */
 int fs_set_blk_dev_with_part(struct blk_desc *desc, int part);
 
+/**
+ * fs_get_type_name() - Get type of current filesystem
+ *
+ * Return: Pointer to filesystem name
+ *
+ * Returns a string describing the current filesystem, or the sentinel
+ * "unsupported" for any unrecognised filesystem.
+ */
+const char *fs_get_type_name(void);
+
 /*
  * Print the list of files on the partition previously set by fs_set_blk_dev(),
  * in directory "dirname".
Signature · 1 line
2.17.0
#13 lore raw

PATCH v8 13/18 fastboot: Migrate FASTBOOT_FLASH_NAND_TRIMFFS to Kconfig

In reply to Alex Kiernan

Add FASTBOOT_FLASH_NAND_TRIMFFS to Kconfig; note there are no in-tree users of it.

---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5:
- new

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/fastboot/Kconfig     | 7 +++++++
 scripts/config_whitelist.txt | 1 -
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/fastboot/Kconfig +7 -0
index 9bbc5c661d..1d7caaff99 100644
@@ -86,6 +86,13 @@ config FASTBOOT_FLASH_MMC_DEV
 	  regarding the non-volatile storage device. Define this to
 	  the eMMC device that fastboot should use to store the image.
 
+config FASTBOOT_FLASH_NAND_TRIMFFS
+	bool "Skip empty pages when flashing NAND"
+	depends on FASTBOOT_FLASH_NAND
+	help
+	  When flashing NAND enable the DROP_FFS flag to drop trailing all-0xff
+	  pages.
+
 config FASTBOOT_GPT_NAME
 	string "Target name for updating GPT"
 	depends on FASTBOOT_FLASH_MMC && EFI_PARTITION
scripts/config_whitelist.txt +0 -1
index 705ed89a65..117ed2e152 100644
@@ -590,7 +590,6 @@ CONFIG_EXYNOS_SPL
 CONFIG_EXYNOS_TMU
 CONFIG_FACTORYSET
 CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE
-CONFIG_FASTBOOT_FLASH_NAND_TRIMFFS
 CONFIG_FAST_FLASH_BIT
 CONFIG_FB_ADDR
 CONFIG_FB_BACKLIGHT
Signature · 1 line
2.17.0
#14 lore raw

PATCH v8 14/18 mmc: Separate "mmc swrite" from fastboot

In reply to Alex Kiernan

Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc swrite" command is separated from the fastboot code.

Move image-sparse from common to lib so it's clear it's library code.

Rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE and migrate it to Kconfig.

---

Changes in v8:
- add Reviewed-by: tag

Changes in v7: None
Changes in v6: None
Changes in v5:
- rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE and migrate it to Kconfig.

Changes in v4:
- new

Changes in v3: None
Changes in v2: None

 cmd/Kconfig                    |  8 ++++++++
 cmd/mmc.c                      | 12 ++++++------
 common/Makefile                |  1 -
 drivers/fastboot/Kconfig       |  1 +
 lib/Kconfig                    | 11 +++++++++++
 lib/Makefile                   |  1 +
 {common => lib}/image-sparse.c |  6 +-----
 scripts/config_whitelist.txt   |  1 -
 8 files changed, 28 insertions(+), 13 deletions(-)
 rename {common => lib}/image-sparse.c (97%)
cmd/Kconfig +8 -0
index 9848c067da..30cf63f172 100644
@@ -833,6 +833,14 @@ config CMD_MMC_RPMB
 	  Enable the commands for reading, writing and programming the
 	  key for the Replay Protection Memory Block partition in eMMC.
 
+config CMD_MMC_SWRITE
+	bool "mmc swrite"
+	depends on CMD_MMC && MMC_WRITE
+	select IMAGE_SPARSE
+	help
+	  Enable support for the "mmc swrite" command to write Android sparse
+	  images to eMMC.
+
 config CMD_NAND
 	bool "nand"
 	default y if NAND_SUNXI
cmd/mmc.c +6 -6
index a5719b81eb..c2ee2d9c0a 100644
@@ -308,8 +308,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
 	return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
 }
 
-#if CONFIG_IS_ENABLED(MMC_WRITE)
-#if defined(CONFIG_FASTBOOT_FLASH)
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
 static lbaint_t mmc_sparse_write(struct sparse_storage *info, lbaint_t blk,
 				 lbaint_t blkcnt, const void *buffer)
 {
@@ -374,6 +373,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp, int flag,
 }
 #endif
 
+#if CONFIG_IS_ENABLED(MMC_WRITE)
 static int do_mmc_write(cmd_tbl_t *cmdtp, int flag,
 			int argc, char * const argv[])
 {
@@ -868,10 +868,10 @@ static cmd_tbl_t cmd_mmc[] = {
 	U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
 #if CONFIG_IS_ENABLED(MMC_WRITE)
 	U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""),
-#if defined(CONFIG_FASTBOOT_FLASH)
-	U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
-#endif
 	U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""),
+#endif
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
+	U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
 #endif
 	U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""),
 	U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""),
@@ -927,7 +927,7 @@ U_BOOT_CMD(
 	"info - display info of the current MMC device\n"
 	"mmc read addr blk# cnt\n"
 	"mmc write addr blk# cnt\n"
-#if defined(CONFIG_FASTBOOT_FLASH)
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
 	"mmc swrite addr blk#\n"
 #endif
 	"mmc erase blk# cnt\n"
common/Makefile +0 -1
index 9ec40b9d27..b3da72ebb2 100644
@@ -29,7 +29,6 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
 
 obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
-obj-$(CONFIG_FASTBOOT_FLASH) += image-sparse.o
 obj-$(CONFIG_MII) += miiphyutil.o
 obj-$(CONFIG_CMD_MII) += miiphyutil.o
 obj-$(CONFIG_PHYLIB) += miiphyutil.o
drivers/fastboot/Kconfig +1 -0
index 1d7caaff99..0c9ced53de 100644
@@ -57,6 +57,7 @@ config FASTBOOT_FLASH
 	bool "Enable FASTBOOT FLASH command"
 	default y if ARCH_SUNXI
 	depends on MMC || (NAND && CMD_MTDPARTS)
+	select IMAGE_SPARSE
 	help
 	  The fastboot protocol includes a "flash" command for writing
 	  the downloaded image to a non-volatile storage device. Define
lib/Kconfig +11 -0
index 1590f7afa4..15c6a52d4a 100644
@@ -61,6 +61,17 @@ config SPL_STRTO
 config TPL_STRTO
 	bool
 
+config IMAGE_SPARSE
+	bool
+
+config IMAGE_SPARSE_FILLBUF_SIZE
+	hex "Android sparse image CHUNK_TYPE_FILL buffer size"
+	default 0x80000
+	depends on IMAGE_SPARSE
+	help
+	  Set the size of the fill buffer used when processing CHUNK_TYPE_FILL
+	  chunks.
+
 config USE_PRIVATE_LIBGCC
 	bool "Use private libgcc"
 	depends on HAVE_PRIVATE_LIBGCC
lib/Makefile +1 -0
index e6cb4afc23..c0511cbff8 100644
@@ -29,6 +29,7 @@ obj-$(CONFIG_FIT) += fdtdec_common.o
 obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
 obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
 obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
+obj-$(CONFIG_IMAGE_SPARSE) += image-sparse.o
 obj-y += initcall.o
 obj-$(CONFIG_LMB) += lmb.o
 obj-y += ldiv.o
lib/image-sparse.c renamed from common/image-sparse.c +1 -5
similarity index 97%
rename from common/image-sparse.c
rename to lib/image-sparse.c
index 1ae7a4d0e8..036062139b 100644
@@ -44,10 +44,6 @@
 
 #include <linux/math64.h>
 
-#ifndef CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE
-#define CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE (1024 * 512)
-#endif
-
 static void default_log(const char *ignored, char *response) {}
 
 int write_sparse_image(struct sparse_storage *info,
@@ -69,7 +65,7 @@ int write_sparse_image(struct sparse_storage *info,
 	int i;
 	int j;
 
-	fill_buf_num_blks = CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE / info->blksz;
+	fill_buf_num_blks = CONFIG_IMAGE_SPARSE_FILLBUF_SIZE / info->blksz;
 
 	/* Read and skip over sparse image header */
 	sparse_header = (sparse_header_t *)data;
scripts/config_whitelist.txt +0 -1
index 117ed2e152..5304f9577d 100644
@@ -589,7 +589,6 @@ CONFIG_EXYNOS_RELOCATE_CODE_BASE
 CONFIG_EXYNOS_SPL
 CONFIG_EXYNOS_TMU
 CONFIG_FACTORYSET
-CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE
 CONFIG_FAST_FLASH_BIT
 CONFIG_FB_ADDR
 CONFIG_FB_BACKLIGHT
Signature · 1 line
2.17.0
#15 lore raw

PATCH v8 15/18 net: fastboot: Merge AOSP UDP fastboot

In reply to Alex Kiernan

Merge UDP fastboot support from AOSP:

https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8

---

Changes in v8: None
Changes in v7: None
Changes in v6:
- add docbook comments
- rename fastboot_download_data() to fastboot_data_download(), rename fastboot_get_bytes_remaining() to fastboot_data_remaining()
- split fastboot_data_complete() out from fastboot_data_download() so we can call it at the end of the transfer phase for USB

Changes in v5:
- make fastboot_bytes_received/expected static and add function fastboot_get_bytes_remaining()
- move fastboot_buf_addr/fastboot_buf_size/fastboot_progress_callback into fastboot-internal.h
- delete redundant fb_ prefixes from statics

Changes in v4:
- guard fb_getvar/fb_command with UDP_FUNCTION_FASTBOOT in Makefile
- add docbook comments
- remove parameter from fastboot_boot() since we always want fastboot_buf_addr (and if we're using fastboot_bootcmd then it's ignored)
- split oem format into new patch

Changes in v3:
- use FASTBOOT as our guard in Kconfig not a list of USB || UDP
- correct mis-translation from AOSP introduced when cleaning up for checkpatch - we should write when buffer is not NULL, rather than erasing, and erase when buffer is NULL
- use CMD_RET_USAGE from do_fastboot
- remove do_fastboot_udp from cmd/net.c and rewrite using net_loop()
- rename timed_send_info to fastboot_send_info, rename fastboot_send_info to fastboot_udp_send_info
- replace FASTBOOT_HEADER_SIZE with sizeof(struct fastboot_header)
- move start time into timed_send_info() rather than passing it in
- make calls to fastboot_udp_send_info a runtime dependency, not a compile time one
- set ${filesize} to size of downloaded image
- add progress meter from USB path during download
- add support for 'oem format' command from the USB path
- rename 'fastbootcmd' to 'fastboot_bootcmd' to make clear that this is the fastboot boot command
- make getvar implementation table driven
- add fastboot_buf_addr, fastboot_buf_size to override buffer address and size
- return correct filesystem type in getvar partition-type on MMC
- process "fastboot." prefixed env variables in getvar first so you can override the normal values (this also lets you set a fs type for NAND devices)
- squash subsequent patches which change this code into this one:
- If the fastboot flash/erase commands are disabled, remove that support so we still build correctly.
- Add NAND support to fastboot UDP flash/erase commands
- If we don't have a partition name passed, report it as not found.
- Change the behaviour of the fastboot net code such that "reboot-bootloader" is no longer written to CONFIG_FASTBOOT_BUF_ADDR for use as a marker on reboot (the AOSP code in common/android-bootloader.c uses this marker - this code could be reinstated there if that gets merged).
- Merge USB and UDP boot code. The USB implementation stays the same, but UDP no longer passes an fdt. We introduce a new environment variable 'fastboot_bootcmd' which if set overrides the hardcoded boot command, setting this then allows the UDP implementation to remain the same. If after running 'fastboot_bootcmd' the board has not booted, control is returned to U-Boot and the fastboot process ends.
- Separate the fastboot protocol handling from the fastboot UDP code in preparation for reusing it in the USB code.

Changes in v2:
- ensure fastboot syntax is backward compatible - 'fastboot 0' means 'fastboot usb 0'

 cmd/Kconfig                   |   4 +-
 cmd/fastboot.c                |  91 +++++++++-
 drivers/fastboot/Kconfig      |   7 +
 drivers/fastboot/Makefile     |   3 +-
 drivers/fastboot/fb_command.c | 302 ++++++++++++++++++++++++++++++++
 drivers/fastboot/fb_common.c  |  93 ++++++++++
 drivers/fastboot/fb_getvar.c  | 230 ++++++++++++++++++++++++
 drivers/fastboot/fb_mmc.c     |  84 ++++++++-
 drivers/fastboot/fb_nand.c    |  19 +-
 include/fastboot-internal.h   |  36 ++++
 include/fastboot.h            | 104 +++++++++++
 include/fb_mmc.h              |  18 +-
 include/fb_nand.h             |  19 +-
 include/net.h                 |   2 +-
 include/net/fastboot.h        |  21 +++
 net/Makefile                  |   1 +
 net/fastboot.c                | 317 ++++++++++++++++++++++++++++++++++
 net/net.c                     |   7 +
 18 files changed, 1338 insertions(+), 20 deletions(-)
 create mode 100644 drivers/fastboot/fb_command.c
 create mode 100644 drivers/fastboot/fb_getvar.c
 create mode 100644 include/fastboot-internal.h
 create mode 100644 include/net/fastboot.h
 create mode 100644 net/fastboot.c
cmd/Kconfig +2 -2
index 30cf63f172..17ca0bb267 100644
@@ -655,8 +655,8 @@ config CMD_FASTBOOT
 	  This enables the command "fastboot" which enables the Android
 	  fastboot mode for the platform. Fastboot is a protocol for
 	  downloading images, flashing and device control used on
-	  Android devices. Fastboot requires support for acting as a USB
-	  device.
+	  Android devices. Fastboot requires either the network stack
+	  enabled or support for acting as a USB device.
 
 	  See doc/README.android-fastboot for more information.
 
cmd/fastboot.c +86 -5

107 lines not on this page · raw message

drivers/fastboot/Kconfig +7 -0
index 0c9ced53de..625f016600 100644
@@ -14,6 +14,13 @@ config USB_FUNCTION_FASTBOOT
 	help
 	  This enables the USB part of the fastboot gadget.
 
+config UDP_FUNCTION_FASTBOOT
+	depends on NET
+	select FASTBOOT
+	bool "Enable fastboot protocol over UDP"
+	help
+	  This enables the fastboot protocol over UDP.
+
 if FASTBOOT
 
 config FASTBOOT_BUF_ADDR
drivers/fastboot/Makefile +2 -1
index e4bd389adf..8831096181 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier:      GPL-2.0+
 
 obj-y += fb_common.o
-
+obj-$(CONFIG_UDP_FUNCTION_FASTBOOT) += fb_getvar.o
+obj-$(CONFIG_UDP_FUNCTION_FASTBOOT) += fb_command.o
 obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o
 obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o
drivers/fastboot/fb_command.c new file +302 -0

302 lines not on this page · raw message

drivers/fastboot/fb_common.c +93 -0

102 lines not on this page · raw message

drivers/fastboot/fb_getvar.c new file +230 -0

230 lines not on this page · raw message

drivers/fastboot/fb_mmc.c +78 -6

144 lines not on this page · raw message

drivers/fastboot/fb_nand.c +17 -2
index 535f541eb8..526bc12307 100644
@@ -88,7 +88,7 @@ static int _fb_nand_erase(struct mtd_info *mtd, struct part_info *part)
 }
 
 static int _fb_nand_write(struct mtd_info *mtd, struct part_info *part,
-			  void *buffer, unsigned int offset,
+			  void *buffer, u32 offset,
 			  size_t length, size_t *written)
 {
 	int flags = WITH_WR_VERIFY;
@@ -145,6 +145,21 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info,
 	return blkcnt + bad_blocks;
 }
 
+/**
+ * fastboot_nand_get_part_info() - Lookup NAND partion by name
+ *
+ * @part_name: Named device to lookup
+ * @part_info: Pointer to returned part_info pointer
+ * @response: Pointer to fastboot response buffer
+ */
+int fastboot_nand_get_part_info(char *part_name, struct part_info **part_info,
+				char *response)
+{
+	struct mtd_info *mtd = NULL;
+
+	return fb_nand_lookup(part_name, &mtd, part_info, response);
+}
+
 /**
  * fastboot_nand_flash_write() - Write image to NAND for fastboot
  *
@@ -154,7 +169,7 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info,
  * @response: Pointer to fastboot response buffer
  */
 void fastboot_nand_flash_write(const char *cmd, void *download_buffer,
-			       unsigned int download_bytes, char *response)
+			       u32 download_bytes, char *response)
 {
 	struct part_info *part;
 	struct mtd_info *mtd = NULL;
include/fastboot-internal.h new file +36 -0
new file mode 100644
index 0000000000..bf2f2b3c89
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _FASTBOOT_INTERNAL_H_
+#define _FASTBOOT_INTERNAL_H_
+
+/**
+ * fastboot_buf_addr - base address of the fastboot download buffer
+ */
+extern void *fastboot_buf_addr;
+
+/**
+ * fastboot_buf_size - size of the fastboot download buffer
+ */
+extern u32 fastboot_buf_size;
+
+/**
+ * fastboot_progress_callback - callback executed during long operations
+ */
+extern void (*fastboot_progress_callback)(const char *msg);
+
+/**
+ * fastboot_getvar() - Writes variable indicated by cmd_parameter to response.
+ *
+ * @cmd_parameter: Pointer to command parameter
+ * @response: Pointer to fastboot response buffer
+ *
+ * Look up cmd_parameter first as an environment variable of the form
+ * fastboot.<cmd_parameter>, if that exists return use its value to set
+ * response.
+ *
+ * Otherwise lookup the name of variable and execute the appropriate
+ * function to return the requested value.
+ */
+void fastboot_getvar(char *cmd_parameter, char *response);
+
+#endif
include/fastboot.h +104 -0

117 lines not on this page · raw message

include/fb_mmc.h +16 -2
index daca81a201..fd5db9eac8 100644
@@ -3,6 +3,20 @@
  * Copyright 2014 Broadcom Corporation.
  */
 
+#ifndef _FB_MMC_H_
+#define _FB_MMC_H_
+
+/**
+ * fastboot_mmc_get_part_info() - Lookup eMMC partion by name
+ *
+ * @part_name: Named partition to lookup
+ * @dev_desc: Pointer to returned blk_desc pointer
+ * @part_info: Pointer to returned disk_partition_t
+ * @response: Pointer to fastboot response buffer
+ */
+int fastboot_mmc_get_part_info(char *part_name, struct blk_desc **dev_desc,
+			       disk_partition_t *part_info, char *response);
+
 /**
  * fastboot_mmc_flash_write() - Write image to eMMC for fastboot
  *
@@ -12,8 +26,7 @@
  * @response: Pointer to fastboot response buffer
  */
 void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
-			      unsigned int download_bytes, char *response);
-
+			      u32 download_bytes, char *response);
 /**
  * fastboot_mmc_flash_erase() - Erase eMMC for fastboot
  *
@@ -21,3 +34,4 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
  * @response: Pointer to fastboot response buffer
  */
 void fastboot_mmc_erase(const char *cmd, char *response);
+#endif
include/fb_nand.h +18 -1
index b5d4c0cc5f..08ab0e28a6 100644
@@ -4,6 +4,21 @@
  * Copyright 2015 Free Electrons.
  */
 
+#ifndef _FB_NAND_H_
+#define _FB_NAND_H_
+
+#include <jffs2/load_kernel.h>
+
+/**
+ * fastboot_nand_get_part_info() - Lookup NAND partion by name
+ *
+ * @part_name: Named device to lookup
+ * @part_info: Pointer to returned part_info pointer
+ * @response: Pointer to fastboot response buffer
+ */
+int fastboot_nand_get_part_info(char *part_name, struct part_info **part_info,
+				char *response);
+
 /**
  * fastboot_nand_flash_write() - Write image to NAND for fastboot
  *
@@ -13,7 +28,8 @@
  * @response: Pointer to fastboot response buffer
  */
 void fastboot_nand_flash_write(const char *cmd, void *download_buffer,
-			       unsigned int download_bytes, char *response);
+			       u32 download_bytes, char *response);
+
 /**
  * fastboot_nand_flash_erase() - Erase NAND for fastboot
  *
@@ -21,3 +37,4 @@ void fastboot_nand_flash_write(const char *cmd, void *download_buffer,
  * @response: Pointer to fastboot response buffer
  */
 void fastboot_nand_erase(const char *cmd, char *response);
+#endif
include/net.h +1 -1
index 65f51d77a5..5760685556 100644
@@ -535,7 +535,7 @@ extern int		net_restart_wrap;	/* Tried all network devices */
 
 enum proto_t {
 	BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
-	TFTPSRV, TFTPPUT, LINKLOCAL
+	TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT
 };
 
 extern char	net_boot_file_name[1024];/* Boot File name */
include/net/fastboot.h new file +21 -0
new file mode 100644
index 0000000000..68602095d2
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2016 The Android Open Source Project
+ */
+
+#ifndef __NET_FASTBOOT_H__
+#define __NET_FASTBOOT_H__
+
+/**********************************************************************/
+/*
+ *	Global functions and variables.
+ */
+
+/**
+ * Wait for incoming fastboot comands.
+ */
+void fastboot_start_server(void);
+
+/**********************************************************************/
+
+#endif /* __NET_FASTBOOT_H__ */
net/Makefile +1 -0
index d1e8e01f62..07466879f5 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_CMD_PING) += ping.o
 obj-$(CONFIG_CMD_RARP) += rarp.o
 obj-$(CONFIG_CMD_SNTP) += sntp.o
 obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o
+obj-$(CONFIG_UDP_FUNCTION_FASTBOOT)  += fastboot.o
 
 # Disable this warning as it is triggered by:
 # sprintf(buf, index ? "foo%d" : "foo", index)
net/fastboot.c new file +317 -0

317 lines not on this page · raw message

net/net.c +7 -0
index 7f85211442..a4932f46d9 100644
@@ -87,6 +87,7 @@
 #include <environment.h>
 #include <errno.h>
 #include <net.h>
+#include <net/fastboot.h>
 #include <net/tftp.h>
 #if defined(CONFIG_LED_STATUS)
 #include <miiphy.h>
@@ -451,6 +452,11 @@ restart:
 			tftp_start_server();
 			break;
 #endif
+#ifdef CONFIG_UDP_FUNCTION_FASTBOOT
+		case FASTBOOT:
+			fastboot_start_server();
+			break;
+#endif
 #if defined(CONFIG_CMD_DHCP)
 		case DHCP:
 			bootp_reset();
@@ -1322,6 +1328,7 @@ common:
 		/* Fall through */
 
 	case NETCONS:
+	case FASTBOOT:
 	case TFTPSRV:
 		if (net_ip.s_addr == 0) {
 			puts("*** ERROR: `ipaddr' not set\n");
Signature · 1 line
2.17.0
#17 lore raw

PATCH v8 16/18 fastboot: Add support for 'oem format' command

In reply to Alex Kiernan

Introduce 'oem format' which matches the USB implementation, guard this with CONFIG_FASTBOOT_CMD_OEM_FORMAT so that you can configure it out.

---

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5:
- new

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/fastboot/Kconfig      |  8 ++++++++
 drivers/fastboot/fb_command.c | 33 +++++++++++++++++++++++++++++++++
 include/fastboot.h            |  3 +++
 3 files changed, 44 insertions(+)
drivers/fastboot/Kconfig +8 -0
index 625f016600..bc25ea1d9c 100644
@@ -124,6 +124,14 @@ config FASTBOOT_MBR_NAME
 	  specified on the "fastboot flash" command line matches the value
 	  defined here. The default target name for updating MBR is "mbr".
 
+config FASTBOOT_CMD_OEM_FORMAT
+	bool "Enable the 'oem format' command"
+	depends on FASTBOOT_FLASH_MMC && CMD_GPT
+	help
+	  Add support for the "oem format" command from a client. This
+	  relies on the env variable partitions to contain the list of
+	  partitions as required by the gpt command.
+
 endif # FASTBOOT
 
 endmenu
drivers/fastboot/fb_command.c +33 -0
index af4f500694..200f9910c5 100644
@@ -34,6 +34,9 @@ static void flash(char *, char *);
 static void erase(char *, char *);
 #endif
 static void reboot_bootloader(char *, char *);
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+static void oem_format(char *, char *);
+#endif
 
 static const struct {
 	const char *command;
@@ -77,6 +80,12 @@ static const struct {
 		.command = "set_active",
 		.dispatch = okay
 	},
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+	[FASTBOOT_COMMAND_OEM_FORMAT] = {
+		.command = "oem format",
+		.dispatch = oem_format,
+	},
+#endif
 };
 
 /**
@@ -300,3 +309,27 @@ static void reboot_bootloader(char *cmd_parameter, char *response)
 	else
 		fastboot_okay(NULL, response);
 }
+
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+/**
+ * oem_format() - Execute the OEM format command
+ *
+ * @cmd_parameter: Pointer to command parameter
+ * @response: Pointer to fastboot response buffer
+ */
+static void oem_format(char *cmd_parameter, char *response)
+{
+	char cmdbuf[32];
+
+	if (!env_get("partitions")) {
+		fastboot_fail("partitions not set", response);
+	} else {
+		sprintf(cmdbuf, "gpt write mmc %x $partitions",
+			CONFIG_FASTBOOT_FLASH_MMC_DEV);
+		if (run_command(cmdbuf, 0))
+			fastboot_fail("", response);
+		else
+			fastboot_okay(NULL, response);
+	}
+}
+#endif
include/fastboot.h +3 -0
index 9a3d5ba693..1933b1d98e 100644
@@ -33,6 +33,9 @@ enum {
 	FASTBOOT_COMMAND_REBOOT,
 	FASTBOOT_COMMAND_REBOOT_BOOTLOADER,
 	FASTBOOT_COMMAND_SET_ACTIVE,
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+	FASTBOOT_COMMAND_OEM_FORMAT,
+#endif
 
 	FASTBOOT_COMMAND_COUNT
 };
Signature · 1 line
2.17.0
#18 lore raw

PATCH v8 17/18 usb: fastboot: Convert USB f_fastboot to shared fastboot

In reply to Alex Kiernan

Convert USB fastboot code to use shared fastboot protocol.

---

Changes in v8:
- add Reviewed-by: tag

Changes in v7:
- set FASTBOOT_CMD_OEM_FORMAT for all existing users of FASTBOOT_FLASH_MMC_DEV that also have CMD_GPT

Changes in v6:
- merged from RFC USB fastboot series
- when entering the DATA phase ensure we actually install the correct handler
- on completion of DATA call new fastboot_data_complete()
- previous changes:
- remove redundant version.h
- use new fastboot_get_bytes_remaining() function

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 configs/A13-OLinuXino_defconfig               |   1 +
 configs/A20-OLinuXino-Lime2-eMMC_defconfig    |   1 +
 configs/A20-OLinuXino-Lime2_defconfig         |   1 +
 configs/A20-Olimex-SOM204-EVB-eMMC_defconfig  |   1 +
 configs/A20-Olimex-SOM204-EVB_defconfig       |   1 +
 configs/Bananapi_m2m_defconfig                |   1 +
 configs/Cubietruck_defconfig                  |   1 +
 configs/Sinlinx_SinA33_defconfig              |   1 +
 configs/am335x_boneblack_defconfig            |   7 +-
 configs/am57xx_evm_defconfig                  |  13 +-
 configs/am57xx_hs_evm_defconfig               |  13 +-
 configs/chromebit_mickey_defconfig            |   5 +-
 configs/chromebook_jerry_defconfig            |   5 +-
 configs/chromebook_minnie_defconfig           |   5 +-
 configs/dra7xx_evm_defconfig                  |  11 +-
 configs/dra7xx_hs_evm_defconfig               |  11 +-
 configs/evb-rk3036_defconfig                  |   5 +-
 configs/evb-rk3128_defconfig                  |   9 +-
 configs/evb-rk3229_defconfig                  |   5 +-
 configs/evb-rk3288_defconfig                  |   5 +-
 configs/evb-rk3328_defconfig                  |   7 +-
 configs/fennec-rk3288_defconfig               |   5 +-
 configs/firefly-rk3288_defconfig              |   5 +-
 configs/kylin-rk3036_defconfig                |   5 +-
 configs/miqi-rk3288_defconfig                 |   5 +-
 configs/parrot_r16_defconfig                  |   1 +
 configs/phycore-rk3288_defconfig              |   5 +-
 configs/popmetal-rk3288_defconfig             |   5 +-
 configs/rock2_defconfig                       |   5 +-
 configs/stih410-b2260_defconfig               |  11 +-
 configs/tbs_a711_defconfig                    |   1 +
 configs/tinker-rk3288_defconfig               |   5 +-
 .../xilinx_zynqmp_zc1751_xm015_dc1_defconfig  |   7 +-
 configs/xilinx_zynqmp_zcu102_rev1_0_defconfig |   7 +-
 configs/xilinx_zynqmp_zcu102_revA_defconfig   |   7 +-
 configs/xilinx_zynqmp_zcu102_revB_defconfig   |   7 +-
 configs/xilinx_zynqmp_zcu106_revA_defconfig   |   7 +-
 drivers/fastboot/Makefile                     |   4 +-
 drivers/usb/gadget/f_fastboot.c               | 318 ++----------------
 39 files changed, 156 insertions(+), 363 deletions(-)
configs/A13-OLinuXino_defconfig +1 -0
index 8e160d7cc4..b8ec1e54db 100644
@@ -22,6 +22,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_DFU_RAM=y
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_AXP_ALDO3_VOLT=3300
 CONFIG_CONS_INDEX=2
 CONFIG_USB_EHCI_HCD=y
configs/A20-OLinuXino-Lime2-eMMC_defconfig +1 -0
index 9d043e856a..5657fc2594 100644
@@ -20,6 +20,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_SCSI_AHCI=y
 CONFIG_DFU_RAM=y
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
configs/A20-OLinuXino-Lime2_defconfig +1 -0
index f2997c6fe5..134d1d3fef 100644
@@ -19,6 +19,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_SCSI_AHCI=y
 CONFIG_DFU_RAM=y
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
configs/A20-Olimex-SOM204-EVB-eMMC_defconfig +1 -0
index 847945b649..3bb8c4c7e6 100644
@@ -18,6 +18,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_SCSI_AHCI=y
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_PHY_ADDR=3
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
configs/A20-Olimex-SOM204-EVB_defconfig +1 -0
index e56f2c7110..cfb7ffa556 100644
@@ -17,6 +17,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_SCSI_AHCI=y
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_PHY_ADDR=3
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
configs/Bananapi_m2m_defconfig +1 -0
index 2032a4aef8..2316437c94 100644
@@ -13,6 +13,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-r16-bananapi-m2m"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_USB_FUNCTION_MASS_STORAGE=y
configs/Cubietruck_defconfig +1 -0
index f0bb4c9d5c..601eb3ca0c 100644
@@ -21,6 +21,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_SCSI_AHCI=y
 CONFIG_DFU_RAM=y
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
configs/Sinlinx_SinA33_defconfig +1 -0
index 9e6267200b..394534b8b5 100644
@@ -18,6 +18,7 @@ CONFIG_CMD_DFU=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_DFU_RAM=y
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
configs/am335x_boneblack_defconfig +4 -3
index bd3a37427d..31d2fe9cbf 100644
@@ -16,9 +16,6 @@ CONFIG_AUTOBOOT_KEYED=y
 CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
 CONFIG_AUTOBOOT_DELAY_STR="d"
 CONFIG_AUTOBOOT_STOP_STR=" "
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_CMD_SPL=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
@@ -28,6 +25,10 @@ CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_DFU_TFTP=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_WINBOND=y
configs/am57xx_evm_defconfig +7 -6
index 3b83b69e5f..2d8e64e613 100644
@@ -24,12 +24,6 @@ CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_BUF_ADDR=0x82000000
-CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
-CONFIG_FASTBOOT_USB_DEV=1
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_CMD_SPL=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
@@ -45,6 +39,13 @@ CONFIG_SCSI_AHCI=y
 # CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x82000000
+CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
+CONFIG_FASTBOOT_USB_DEV=1
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
configs/am57xx_hs_evm_defconfig +7 -6
index 9c2aef482f..3a73fdb2ca 100644
@@ -29,12 +29,6 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_BUF_ADDR=0x82000000
-CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
-CONFIG_FASTBOOT_USB_DEV=1
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -48,6 +42,13 @@ CONFIG_SCSI_AHCI=y
 # CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x82000000
+CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
+CONFIG_FASTBOOT_USB_DEV=1
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
configs/chromebit_mickey_defconfig +3 -2
index d1728ef639..72ecdc69f6 100644
@@ -16,8 +16,6 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
@@ -44,6 +42,9 @@ CONFIG_SPL_SYSCON=y
 # CONFIG_SPL_SIMPLE_BUS is not set
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
 CONFIG_SYS_I2C_ROCKCHIP=y
configs/chromebook_jerry_defconfig +3 -2
index 43d93f4637..fb8400d06e 100644
@@ -18,8 +18,6 @@ CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
@@ -46,6 +44,9 @@ CONFIG_SPL_SYSCON=y
 # CONFIG_SPL_SIMPLE_BUS is not set
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
 CONFIG_SYS_I2C_ROCKCHIP=y
configs/chromebook_minnie_defconfig +3 -2
index 706809ca53..a8776c9adf 100644
@@ -17,8 +17,6 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
@@ -45,6 +43,9 @@ CONFIG_SPL_SYSCON=y
 # CONFIG_SPL_SIMPLE_BUS is not set
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
 CONFIG_SYS_I2C_ROCKCHIP=y
configs/dra7xx_evm_defconfig +6 -5
index b766ba27cd..182f9a9ebf 100644
@@ -25,11 +25,6 @@ CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_OS_BOOT=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_BUF_ADDR=0x82000000
-CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_CMD_SPL=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
@@ -50,6 +45,12 @@ CONFIG_DWC_AHCI=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_SF=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x82000000
+CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_DM_GPIO=y
 CONFIG_PCF8575_GPIO=y
 CONFIG_DM_I2C=y
configs/dra7xx_hs_evm_defconfig +6 -5
index 39a6801216..8584d41f1a 100644
@@ -30,11 +30,6 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_DMA_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_BUF_ADDR=0x82000000
-CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -50,6 +45,12 @@ CONFIG_DWC_AHCI=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_SF=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x82000000
+CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_DM_GPIO=y
 CONFIG_PCF8575_GPIO=y
 CONFIG_DM_I2C=y
configs/evb-rk3036_defconfig +3 -2
index 33775e8cdd..b9242e83e0 100644
@@ -15,8 +15,6 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x0
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 # CONFIG_SPL_FRAMEWORK is not set
 CONFIG_SPL_STACK_R=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
@@ -31,6 +29,9 @@ CONFIG_SPL_PARTITION_UUIDS=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_LED=y
configs/evb-rk3128_defconfig +5 -4
index 796d0ec92e..9c8252e95f 100644
@@ -7,10 +7,6 @@ CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
-CONFIG_FASTBOOT_BUF_ADDR=0x60800800
-CONFIG_FASTBOOT_BUF_SIZE=0x04000000
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -20,6 +16,11 @@ CONFIG_CMD_TIME=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_CLK=y
+CONFIG_FASTBOOT_BUF_ADDR=0x60800800
+CONFIG_FASTBOOT_BUF_SIZE=0x04000000
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MMC_DW=y
configs/evb-rk3229_defconfig +3 -2
index 710b0b4e1a..7298bf1963 100644
@@ -14,8 +14,6 @@ CONFIG_DEBUG_UART=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x200
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 # CONFIG_CMD_SETEXPR is not set
@@ -30,6 +28,9 @@ CONFIG_SYSCON=y
 CONFIG_SPL_SYSCON=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MMC_DW=y
configs/evb-rk3288_defconfig +3 -2
index 7695277daf..a7beaa6728 100644
@@ -14,8 +14,6 @@ CONFIG_SILENT_CONSOLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
@@ -41,6 +39,9 @@ CONFIG_SYSCON=y
 CONFIG_SPL_SYSCON=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_LED=y
configs/evb-rk3328_defconfig +4 -3
index 78ae24b56b..59bf9e5197 100644
@@ -8,9 +8,6 @@ CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
-CONFIG_FASTBOOT_BUF_ADDR=0x800800
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
@@ -23,6 +20,10 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_CLK=y
+CONFIG_FASTBOOT_BUF_ADDR=0x800800
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MMC_DW=y
configs/fennec-rk3288_defconfig +3 -2
index efdd583cf6..dbd6be55e2 100644
@@ -15,8 +15,6 @@ CONFIG_CONSOLE_MUX=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
@@ -42,6 +40,9 @@ CONFIG_SPL_SYSCON=y
 # CONFIG_SPL_SIMPLE_BUS is not set
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MMC_DW=y
configs/firefly-rk3288_defconfig +3 -2
index b252d27464..83b4968c4a 100644
@@ -14,8 +14,6 @@ CONFIG_SILENT_CONSOLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
@@ -42,6 +40,9 @@ CONFIG_SPL_SYSCON=y
 # CONFIG_SPL_SIMPLE_BUS is not set
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_DM_KEYBOARD=y
configs/kylin-rk3036_defconfig +3 -2
index ca53005ecb..373764aaf1 100644
@@ -14,8 +14,6 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x0
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 # CONFIG_SPL_FRAMEWORK is not set
 CONFIG_SPL_STACK_R=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
@@ -31,6 +29,9 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_LED=y
configs/miqi-rk3288_defconfig +3 -2
index f44537c88f..5bfcb0c90b 100644
@@ -14,8 +14,6 @@ CONFIG_SILENT_CONSOLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
@@ -42,6 +40,9 @@ CONFIG_SPL_SYSCON=y
 # CONFIG_SPL_SIMPLE_BUS is not set
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MMC_DW=y
configs/parrot_r16_defconfig +1 -0
index 991e9b99aa..553a8d6572 100644
@@ -15,6 +15,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-r16-parrot"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_CONS_INDEX=5
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
configs/phycore-rk3288_defconfig +3 -2
index d78b6d57b6..fc3b81c43c 100644
@@ -17,8 +17,6 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_POWER_SUPPORT=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
@@ -44,6 +42,9 @@ CONFIG_SPL_SYSCON=y
 # CONFIG_SPL_SIMPLE_BUS is not set
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MISC=y
configs/popmetal-rk3288_defconfig +3 -2
index 2670b4b75a..84c099560f 100644
@@ -15,8 +15,6 @@ CONFIG_CONSOLE_MUX=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
@@ -42,6 +40,9 @@ CONFIG_SPL_SYSCON=y
 # CONFIG_SPL_SIMPLE_BUS is not set
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MMC_DW=y
configs/rock2_defconfig +3 -2
index cd9a821974..01d53ac1c3 100644
@@ -14,8 +14,6 @@ CONFIG_SILENT_CONSOLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
@@ -42,6 +40,9 @@ CONFIG_SPL_SYSCON=y
 # CONFIG_SPL_SIMPLE_BUS is not set
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MMC_DW=y
configs/stih410-b2260_defconfig +6 -5
index 7d990f9a34..ba1ff25d35 100644
@@ -10,11 +10,6 @@ CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyAS1,115200 CONSOLE=/dev/ttyAS1 consoleblank=0 root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait mem=992M at 0x40000000 vmalloc=256m"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SYS_PROMPT="stih410-b2260 => "
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_BUF_ADDR=0x40000000
-CONFIG_FASTBOOT_BUF_SIZE=0x3DF00000
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -26,6 +21,12 @@ CONFIG_OF_CONTROL=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_CLK=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x40000000
+CONFIG_FASTBOOT_BUF_SIZE=0x3DF00000
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_MISC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_STI=y
configs/tbs_a711_defconfig +1 -0
index 3e3de4fbb3..5d58f5ceb4 100644
@@ -16,6 +16,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-a83t-tbs-a711"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_AXP_DCDC5_VOLT=1200
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
configs/tinker-rk3288_defconfig +3 -2
index fb6bfa57ad..e1c99c3828 100644
@@ -16,8 +16,6 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
 CONFIG_SPL_I2C_SUPPORT=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
@@ -43,6 +41,9 @@ CONFIG_SPL_SYSCON=y
 # CONFIG_SPL_SIMPLE_BUS is not set
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MISC=y
configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig +4 -3
index 9e4886d064..b4521aab43 100644
@@ -19,9 +19,6 @@ CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_PROMPT="ZynqMP> "
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_THOR_DOWNLOAD=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
@@ -47,6 +44,10 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_CLK_ZYNQMP=y
 CONFIG_DFU_RAM=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_FPGA_XILINX=y
 CONFIG_FPGA_ZYNQMPPL=y
 CONFIG_DM_GPIO=y
configs/xilinx_zynqmp_zcu102_rev1_0_defconfig +4 -3
index 29743bdb1e..976640cae0 100644
@@ -19,9 +19,6 @@ CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_PROMPT="ZynqMP> "
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_THOR_DOWNLOAD=y
 CONFIG_CMD_EEPROM=y
 CONFIG_CMD_MEMTEST=y
@@ -50,6 +47,10 @@ CONFIG_SCSI_AHCI=y
 CONFIG_SATA_CEVA=y
 CONFIG_CLK_ZYNQMP=y
 CONFIG_DFU_RAM=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_FPGA_XILINX=y
 CONFIG_FPGA_ZYNQMPPL=y
 CONFIG_DM_GPIO=y
configs/xilinx_zynqmp_zcu102_revA_defconfig +4 -3
index cc4118230e..3420ce5dc3 100644
@@ -19,9 +19,6 @@ CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_PROMPT="ZynqMP> "
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_THOR_DOWNLOAD=y
 CONFIG_CMD_EEPROM=y
 CONFIG_CMD_MEMTEST=y
@@ -50,6 +47,10 @@ CONFIG_SCSI_AHCI=y
 CONFIG_SATA_CEVA=y
 CONFIG_CLK_ZYNQMP=y
 CONFIG_DFU_RAM=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_FPGA_XILINX=y
 CONFIG_FPGA_ZYNQMPPL=y
 CONFIG_DM_GPIO=y
configs/xilinx_zynqmp_zcu102_revB_defconfig +4 -3
index ae791c3567..a9ba4a17e9 100644
@@ -19,9 +19,6 @@ CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_PROMPT="ZynqMP> "
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_THOR_DOWNLOAD=y
 CONFIG_CMD_EEPROM=y
 CONFIG_CMD_MEMTEST=y
@@ -50,6 +47,10 @@ CONFIG_SCSI_AHCI=y
 CONFIG_SATA_CEVA=y
 CONFIG_CLK_ZYNQMP=y
 CONFIG_DFU_RAM=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_FPGA_XILINX=y
 CONFIG_FPGA_ZYNQMPPL=y
 CONFIG_DM_GPIO=y
configs/xilinx_zynqmp_zcu106_revA_defconfig +4 -3
index 34e3c857e2..32c6f23210 100644
@@ -18,9 +18,6 @@ CONFIG_SPL_RAM_SUPPORT=y
 CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_PROMPT="ZynqMP> "
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_CMD_THOR_DOWNLOAD=y
 CONFIG_CMD_EEPROM=y
 CONFIG_CMD_MEMTEST=y
@@ -48,6 +45,10 @@ CONFIG_SCSI_AHCI=y
 CONFIG_SATA_CEVA=y
 CONFIG_CLK_ZYNQMP=y
 CONFIG_DFU_RAM=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_FPGA_XILINX=y
 CONFIG_FPGA_ZYNQMPPL=y
 CONFIG_DM_GPIO=y
drivers/fastboot/Makefile +2 -2
index 8831096181..a2421565e2 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier:      GPL-2.0+
 
 obj-y += fb_common.o
-obj-$(CONFIG_UDP_FUNCTION_FASTBOOT) += fb_getvar.o
-obj-$(CONFIG_UDP_FUNCTION_FASTBOOT) += fb_command.o
+obj-y += fb_getvar.o
+obj-y += fb_command.o
 obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o
 obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o
drivers/usb/gadget/f_fastboot.c +37 -281

395 lines not on this page · raw message

Signature · 1 line
2.17.0
#19 lore raw

PATCH v8 18/18 fastboot: Update fastboot documentation

In reply to Alex Kiernan

Update fastboot documentation to reflect merged USB/UDP implementation.

---

Changes in v8:
- add Reviewed-by: tag

Changes in v7: None
Changes in v6:
- new

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 doc/README.android-fastboot | 240 +++++++++++++++++++++++-------------
 1 file changed, 156 insertions(+), 84 deletions(-)
doc/README.android-fastboot +156 -84
index 2c3ee7810a..431191c473 100644
@@ -1,142 +1,214 @@
+================
 Android Fastboot
-~~~~~~~~~~~~~~~~
+================
 
 Overview
 ========
-The protocol that is used over USB is described in
-README.android-fastboot-protocol in same directory.
 
-The current implementation is a minimal support of the erase command,the
-"oem format" command and flash command;it only supports eMMC devices.
+The protocol that is used over USB and UDP is described in the
+``README.android-fastboot-protocol`` file in the same directory.
+
+The current implementation supports the following standard commands:
+
+- ``boot``
+- ``continue``
+- ``download``
+- ``erase`` (if enabled)
+- ``flash`` (if enabled)
+- ``getvar``
+- ``reboot``
+- ``reboot-bootloader``
+- ``set_active`` (only a stub implementation which always succeeds)
+
+The following OEM commands are supported (if enabled):
+
+- oem format - this executes ``gpt write mmc %x $partitions``
+
+Support for both eMMC and NAND devices is included.
 
 Client installation
 ===================
-The counterpart to this gadget is the fastboot client which can
-be found in Android's platform/system/core repository in the fastboot
-folder. It runs on Windows, Linux and even OSX. Linux user are lucky since
-they only need libusb.
-Windows users need to bring some time until they have Android SDK (currently
-http://dl.google.com/android/installer_r12-windows.exe) installed. You
-need to install ADB package which contains the required glue libraries for
-accessing USB. Also you need "Google USB driver package" and "SDK platform
-tools". Once installed the usb driver is placed in your SDK folder under
-extras\google\usb_driver. The android_winusb.inf needs a line like
-
-   %SingleBootLoaderInterface% = USB_Install, USB\VID_0451&PID_D022
-
-either in the [Google.NTx86] section for 32bit Windows or [Google.NTamd64]
-for 64bit Windows. VID and PID should match whatever the fastboot is
-advertising.
+
+The counterpart to this is the fastboot client which can be found in
+Android's ``platform/system/core`` repository in the fastboot
+folder. It runs on Windows, Linux and OSX. The fastboot client is
+part of the Android SDK Platform-Tools and can be downloaded from:
+
+https://developer.android.com/studio/releases/platform-tools
 
 Board specific
 ==============
+
+USB configuration
+-----------------
+
 The fastboot gadget relies on the USB download gadget, so the following
 options must be configured:
 
-CONFIG_USB_GADGET_DOWNLOAD
-CONFIG_USB_GADGET_VENDOR_NUM
-CONFIG_USB_GADGET_PRODUCT_NUM
-CONFIG_USB_GADGET_MANUFACTURER
+::
+
+   CONFIG_USB_GADGET_DOWNLOAD
+   CONFIG_USB_GADGET_VENDOR_NUM
+   CONFIG_USB_GADGET_PRODUCT_NUM
+   CONFIG_USB_GADGET_MANUFACTURER
 
-NOTE: The CONFIG_USB_GADGET_VENDOR_NUM must be one of the numbers supported by
-the fastboot client. The list of vendor IDs supported can be found in the
-fastboot client source code (fastboot.c) mentioned above.
+NOTE: The ``CONFIG_USB_GADGET_VENDOR_NUM`` must be one of the numbers
+supported by the fastboot client. The list of vendor IDs supported can
+be found in the fastboot client source code.
 
-The fastboot function is enabled by defining CONFIG_USB_FUNCTION_FASTBOOT,
-CONFIG_CMD_FASTBOOT and CONFIG_ANDROID_BOOT_IMAGE.
+General configuration
+---------------------
 
-The fastboot protocol requires a large memory buffer for downloads. This
-buffer should be as large as possible for a platform. The location of the
-buffer and size are set with CONFIG_FASTBOOT_BUF_ADDR and
-CONFIG_FASTBOOT_BUF_SIZE.
+The fastboot protocol requires a large memory buffer for
+downloads. This buffer should be as large as possible for a
+platform. The location of the buffer and size are set with
+``CONFIG_FASTBOOT_BUF_ADDR`` and ``CONFIG_FASTBOOT_BUF_SIZE``. These
+may be overridden on the fastboot command line using ``-l`` and
+``-s``.
+
+Fastboot environment variables
+==============================
+
+Partition aliases
+-----------------
 
 Fastboot partition aliases can also be defined for devices where GPT
 limitations prevent user-friendly partition names such as "boot", "system"
 and "cache".  Or, where the actual partition name doesn't match a standard
-partition name used commonly with fastboot.  Current implentation checks
-aliases when accessing partitions by name (flash_write and erase functions).
-To define a partition alias add an environment variable similar to:
-fastboot_partition_alias_<alias partition name>=<actual partition name>
-Example: fastboot_partition_alias_boot=LNX
+partition name used commonly with fastboot.
+
+The current implementation checks aliases when accessing partitions by
+name (flash_write and erase functions).  To define a partition alias
+add an environment variable similar to:
+
+``fastboot_partition_alias_<alias partition name>=<actual partition name>``
+
+for example:
+
+``fastboot_partition_alias_boot=LNX``
+
+Variable overrides
+------------------
+
+Variables retrived through ``getvar`` can be overridden by defining
+environment variables of the form ``fastboot.<variable>``. These are
+looked up first so can be used to override values which would
+otherwise be returned. Using this mechanism you can also return types
+for NAND filesystems, as the fully parameterised variable is looked
+up, e.g.
+
+``fastboot.partition-type:boot=jffs2``
+
+Boot command
+------------
+
+When executing the fastboot ``boot`` command, if ``fastboot_bootcmd`` is set then
+that will be executed in place of ``bootm <CONFIG_FASTBOOT_BUF_ADDR>``.
 
 Partition Names
 ===============
-The Fastboot implementation in U-boot allows to write images into disk
-partitions (currently on eMMC). Target partitions are referred on the host
-computer by their names.
+
+The Fastboot implementation in U-Boot allows to write images into disk
+partitions. Target partitions are referred on the host computer by
+their names.
 
 For GPT/EFI the respective partition name is used.
 
 For MBR the partitions are referred by generic names according to the
 following schema:
 
-  <device type> <device index letter> <partition index>
+  <device type><device index letter><partition index>
 
-Example: hda3, sdb1, usbda1
+Example: ``hda3``, ``sdb1``, ``usbda1``
 
 The device type is as follows:
 
-  * IDE, ATAPI and SATA disks: hd
-  * SCSI disks: sd
-  * USB media: usbd
-  * MMC and SD cards: mmcsd
-  * Disk on chip: docd
-  * other: xx
+  * IDE, ATAPI and SATA disks: ``hd``
+  * SCSI disks: ``sd``
+  * USB media: ``usbd``
+  * MMC and SD cards: ``mmcsd``
+  * Disk on chip: ``docd``
+  * other: ``xx``
 
-The device index starts from 'a' and refers to the interface (e.g. USB
+The device index starts from ``a`` and refers to the interface (e.g. USB
 controller, SD/MMC controller) or disk index. The partition index starts
-from 1 and describes the partition number on the particular device.
+from ``1`` and describes the partition number on the particular device.
 
 Writing Partition Table
 =======================
+
 Fastboot also allows to write the partition table to the media. This can be
 done by writing the respective partition table image to a special target
 "gpt" or "mbr". These names can be customized by defining the following
 configuration options:
 
-CONFIG_FASTBOOT_GPT_NAME
-CONFIG_FASTBOOT_MBR_NAME
+::
+
+   CONFIG_FASTBOOT_GPT_NAME
+   CONFIG_FASTBOOT_MBR_NAME
 
 In Action
 =========
-Enter into fastboot by executing the fastboot command in u-boot and you
-should see:
-|GADGET DRIVER: usb_dnl_fastboot
+
+Enter into fastboot by executing the fastboot command in U-Boot for either USB:
+
+::
+
+   => fastboot usb 0
+
+or UDP:
+
+::
+
+   => fastboot udp
+   link up on port 0, speed 100, full duplex
+   Using ethernet at 4a100000 device
+   Listening for fastboot command on 192.168.0.102
 
 On the client side you can fetch the bootloader version for instance:
-|>fastboot getvar bootloader-version
-|bootloader-version: U-Boot 2014.04-00005-gd24cabc
-|finished. total time: 0.000s
+
+::
+
+   $ fastboot getvar bootloader-version
+   bootloader-version: U-Boot 2014.04-00005-gd24cabc
+   finished. total time: 0.000s
 
 or initiate a reboot:
-|>fastboot reboot
+
+::
+
+   $ fastboot reboot
 
 and once the client comes back, the board should reset.
 
 You can also specify a kernel image to boot. You have to either specify
-the an image in Android format _or_ pass a binary kernel and let the
+the an image in Android format *or* pass a binary kernel and let the
 fastboot client wrap the Android suite around it. On OMAP for instance you
 take zImage kernel and pass it to the fastboot client:
 
-|>fastboot -b 0x80000000 -c "console=ttyO2 earlyprintk root=/dev/ram0
-|	mem=128M" boot zImage
-|creating boot image...
-|creating boot image - 1847296 bytes
-|downloading 'boot.img'...
-|OKAY [  2.766s]
-|booting...
-|OKAY [ -0.000s]
-|finished. total time: 2.766s
-
-and on the gadget side you should see:
-|Starting download of 1847296 bytes
-|........................................................
-|downloading of 1847296 bytes finished
-|Booting kernel..
-|## Booting Android Image at 0x81000000 ...
-|Kernel load addr 0x80008000 size 1801 KiB
-|Kernel command line: console=ttyO2 earlyprintk root=/dev/ram0 mem=128M
-|   Loading Kernel Image ... OK
-|OK
-|
-|Starting kernel ...
+::
+
+   $ fastboot -b 0x80000000 -c "console=ttyO2 earlyprintk root=/dev/ram0 mem=128M" boot zImage
+   creating boot image...
+   creating boot image - 1847296 bytes
+   downloading 'boot.img'...
+   OKAY [  2.766s]
+   booting...
+   OKAY [ -0.000s]
+   finished. total time: 2.766s
+
+and on the U-Boot side you should see:
+
+::
+
+   Starting download of 1847296 bytes
+   ........................................................
+   downloading of 1847296 bytes finished
+   Booting kernel..
+   ## Booting Android Image at 0x81000000 ...
+   Kernel load addr 0x80008000 size 1801 KiB
+   Kernel command line: console=ttyO2 earlyprintk root=/dev/ram0 mem=128M
+      Loading Kernel Image ... OK
+   OK
+
+   Starting kernel ...
Signature · 1 line
2.17.0
#20 lore raw

v8 cover Add fastboot UDP support

In reply to Alex Kiernan
Quoted 23 lines · Alex Kiernan

This series merges the fastboot UDP support from AOSP into mainline U-Boot.

Changes in UDP behaviour from the AOSP code, so it follows the existing USB behaviour:

- 'boot' now follows the USB code and does 'bootm CONFIG_FASTBOOT_BUF_ADDR'. I've added 'fastboot_bootcmd' which if set overrides the boot command and allows the existing UDP behaviour to be preserved.
- 'continue' in UDP now exits the fastboot server rather than executing 'run bootcmd'
- 'reboot-bootloader' no longer writes 'reboot-bootloader' to CONFIG_FASTBOOT_BUF_ADDR as its marker for the subsequent boot. The code which is in AOSP common/android_bootloader.c expects this marker, but we have prior art in the USB code using the weak function fastboot_set_reboot_flag
- 'getvar' in the UDP path now supports fetching 'fastboot.' prefixed variables (inherited from the USB path), these override the defaults

I've pushed both USB and UDP into a single consolidated protocol layer now I've tested it on a BeagleBone Green.

Quoted 7 lines

Green Travis build: https://travis-ci.org/akiernan/u-boot/builds/383077278

Changes in v8:
- add Reviewed-by: tag
- add Reviewed-by: tag
- add Reviewed-by: tag

For the whole v8 series:

Tested on TI X15 board. Tested next commands (work fine via USB, the same as before the series):
- fastboot oem format
- fastboot flash
- fastboot devices
- fastboot reboot

Sorry for the delay, was in business trip.

Thanks.

Quoted 254 lines

Changes in v7:
- set FASTBOOT_CMD_OEM_FORMAT for all existing users of FASTBOOT_FLASH_MMC_DEV that also have CMD_GPT

Changes in v6:
- accomodate master change and switch dependency on imx6dl_mamoj from FASTBOOT to USB_FUNCTION_FASTBOOT
- delete redundant FASTBOOT_FLASH_NAND_DEV symbol
- add docbook comments
- add docbook comments
- rename fastboot_download_data() to fastboot_data_download(), rename fastboot_get_bytes_remaining() to fastboot_data_remaining()
- split fastboot_data_complete() out from fastboot_data_download() so we can call it at the end of the transfer phase for USB
- merged from RFC USB fastboot series
- when entering the DATA phase ensure we actually install the correct handler
- on completion of DATA call new fastboot_data_complete()
- previous changes:
- remove redundant version.h
- use new fastboot_get_bytes_remaining() function
- new

Changes in v5:
- don't depend on UDP_FUNCTION_FASTBOOT until it exists
- squash in subsequent patch which updates defconfigs so we don't leave users of CONFIG_FASTBOOT without it enabled
- fix build in drivers/fastboot when we have CONFIG_FASTBOOT without flash or erase and we've not yet added fb_common.c to the build
- fix docbook formatting
- new
- new
- rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE and migrate it to Kconfig.
- make fastboot_bytes_received/expected static and add function fastboot_get_bytes_remaining()
- move fastboot_buf_addr/fastboot_buf_size/fastboot_progress_callback into fastboot-internal.h
- delete redundant fb_ prefixes from statics
- new

Changes in v4:
- add docbook comments
- leave strcmp_l1() in USB fastboot as we don't need it in UDP path
- add docbook comments
- new
- guard fb_getvar/fb_command with UDP_FUNCTION_FASTBOOT in Makefile
- add docbook comments
- remove parameter from fastboot_boot() since we always want fastboot_buf_addr (and if we're using fastboot_bootcmd then it's ignored)
- split oem format into new patch

Changes in v3:
- move imply ANDROID_BOOT_IMAGE, CMD_FASTBOOT to FASTBOOT from USB_FUNCTION_FASTBOOT
- add depend on USB_FUNCTION_FASTBOOT to FASTBOOT_USB_DEV
- leave images-sparse.c in common to acommodate 2f83f21
- refactor for changes in master
- Merge subsequent patch for formatting response strings into this one
- allow NULL to fastboot_okay() when there's no message to send
- guard FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME with EFI/DOS_PARTITION
- new
- new
- new
- new
- new
- new
- use FASTBOOT as our guard in Kconfig not a list of USB || UDP
- correct mis-translation from AOSP introduced when cleaning up for checkpatch - we should write when buffer is not NULL, rather than erasing, and erase when buffer is NULL
- use CMD_RET_USAGE from do_fastboot
- remove do_fastboot_udp from cmd/net.c and rewrite using net_loop()
- rename timed_send_info to fastboot_send_info, rename fastboot_send_info to fastboot_udp_send_info
- replace FASTBOOT_HEADER_SIZE with sizeof(struct fastboot_header)
- move start time into timed_send_info() rather than passing it in
- make calls to fastboot_udp_send_info a runtime dependency, not a compile time one
- set ${filesize} to size of downloaded image
- add progress meter from USB path during download
- add support for 'oem format' command from the USB path
- rename 'fastbootcmd' to 'fastboot_bootcmd' to make clear that this is the fastboot boot command
- make getvar implementation table driven
- add fastboot_buf_addr, fastboot_buf_size to override buffer address and size
- return correct filesystem type in getvar partition-type on MMC
- process "fastboot." prefixed env variables in getvar first so you can override the normal values (this also lets you set a fs type for NAND devices)
- squash subsequent patches which change this code into this one:
- If the fastboot flash/erase commands are disabled, remove that support so we still build correctly.
- Add NAND support to fastboot UDP flash/erase commands
- If we don't have a partition name passed, report it as not found.
- Change the behaviour of the fastboot net code such that "reboot-bootloader" is no longer written to CONFIG_FASTBOOT_BUF_ADDR for use as a marker on reboot (the AOSP code in common/android-bootloader.c uses this marker - this code could be reinstated there if that gets merged).
- Merge USB and UDP boot code. The USB implementation stays the same, but UDP no longer passes an fdt. We introduce a new environment variable 'fastboot_bootcmd' which if set overrides the hardcoded boot command, setting this then allows the UDP implementation to remain the same. If after running 'fastboot_bootcmd' the board has not booted, control is returned to U-Boot and the fastboot process ends.
- Separate the fastboot protocol handling from the fastboot UDP code in preparation for reusing it in the USB code.

Changes in v2:
- ensure fastboot syntax is backward compatible - 'fastboot 0' means 'fastboot usb 0'

Alex Kiernan (18):
fastboot: Move fastboot to drivers/fastboot
fastboot: Refactor fastboot_okay/fail to take response
fastboot: Extract fastboot_okay/fail to fb_common.c
fastboot: Correct dependencies in FASTBOOT_FLASH
fastboot: Add missing newlines
fastboot: Remove FIXME for CONFIG_FASTBOOT_...NAME
fastboot: Fix parameter types in _fb_nand_write
fastboot: Rename fb_set_reboot_flag to fastboot_set_reboot_flag
fastboot: Extract common definitions from USB fastboot
fastboot: Rename public fb_ functions to fastboot_
ti: fastboot: Move weak overrides to board files
fs: Add fs_get_type_name to return current filesystem name
fastboot: Migrate FASTBOOT_FLASH_NAND_TRIMFFS to Kconfig
mmc: Separate "mmc swrite" from fastboot
net: fastboot: Merge AOSP UDP fastboot
fastboot: Add support for 'oem format' command
usb: fastboot: Convert USB f_fastboot to shared fastboot
fastboot: Update fastboot documentation

 arch/arm/Kconfig                              |   2 -
 arch/arm/mach-omap2/boot-common.c             |  10 -
 arch/arm/mach-omap2/utils.c                   |   4 +-
 arch/arm/mach-rockchip/rk3128-board.c         |   4 +-
 arch/arm/mach-rockchip/rk322x-board.c         |   4 +-
 board/amazon/kc1/kc1.c                        |   2 +-
 board/lg/sniper/sniper.c                      |   2 +-
 board/ti/am57xx/board.c                       |  10 +
 board/ti/common/Kconfig                       |   1 -
 board/ti/dra7xx/evm.c                         |  10 +
 cmd/Kconfig                                   |  22 +-
 cmd/fastboot.c                                |  91 ++++-
 cmd/mmc.c                                     |  14 +-
 common/Makefile                               |  14 -
 configs/A13-OLinuXino_defconfig               |   1 +
 configs/A20-OLinuXino-Lime2-eMMC_defconfig    |   1 +
 configs/A20-OLinuXino-Lime2_defconfig         |   1 +
 configs/A20-Olimex-SOM204-EVB-eMMC_defconfig  |   1 +
 configs/A20-Olimex-SOM204-EVB_defconfig       |   1 +
 configs/Bananapi_m2m_defconfig                |   1 +
 configs/Cubietruck_defconfig                  |   1 +
 configs/Sinlinx_SinA33_defconfig              |   1 +
 configs/am335x_boneblack_defconfig            |   7 +-
 configs/am335x_boneblack_vboot_defconfig      |   2 +-
 configs/am335x_evm_defconfig                  |   2 +-
 configs/am335x_evm_nor_defconfig              |   2 +-
 configs/am335x_evm_norboot_defconfig          |   2 +-
 configs/am335x_evm_spiboot_defconfig          |   2 +-
 configs/am335x_evm_usbspl_defconfig           |   2 +-
 configs/am57xx_evm_defconfig                  |  13 +-
 configs/am57xx_hs_evm_defconfig               |  13 +-
 configs/bcm23550_w1d_defconfig                |   2 +-
 configs/bcm28155_ap_defconfig                 |   2 +-
 configs/birdland_bav335a_defconfig            |   2 +-
 configs/birdland_bav335b_defconfig            |   2 +-
 configs/cgtqmx6eval_defconfig                 |   2 +-
 configs/chromebit_mickey_defconfig            |   5 +-
 configs/chromebook_jerry_defconfig            |   5 +-
 configs/chromebook_minnie_defconfig           |   5 +-
 configs/dra7xx_evm_defconfig                  |  11 +-
 configs/dra7xx_hs_evm_defconfig               |  11 +-
 configs/evb-rk3036_defconfig                  |   5 +-
 configs/evb-rk3128_defconfig                  |   9 +-
 configs/evb-rk3229_defconfig                  |   5 +-
 configs/evb-rk3288_defconfig                  |   5 +-
 configs/evb-rk3328_defconfig                  |   7 +-
 configs/fennec-rk3288_defconfig               |   5 +-
 configs/firefly-rk3288_defconfig              |   5 +-
 configs/imx6dl_mamoj_defconfig                |   2 +-
 configs/kc1_defconfig                         |   2 +-
 configs/kylin-rk3036_defconfig                |   5 +-
 configs/miqi-rk3288_defconfig                 |   5 +-
 configs/mx6qsabrelite_defconfig               |   2 +-
 configs/mx6sabresd_defconfig                  |   2 +-
 configs/nitrogen6dl2g_defconfig               |   2 +-
 configs/nitrogen6dl_defconfig                 |   2 +-
 configs/nitrogen6q2g_defconfig                |   2 +-
 configs/nitrogen6q_defconfig                  |   2 +-
 configs/nitrogen6s1g_defconfig                |   2 +-
 configs/nitrogen6s_defconfig                  |   2 +-
 configs/omap3_beagle_defconfig                |   2 +-
 configs/omap3_evm_defconfig                   |   2 +-
 configs/omap3_logic_defconfig                 |   2 +-
 configs/parrot_r16_defconfig                  |   1 +
 configs/phycore-rk3288_defconfig              |   5 +-
 configs/popmetal-rk3288_defconfig             |   5 +-
 configs/rock2_defconfig                       |   5 +-
 configs/sniper_defconfig                      |   2 +-
 configs/stih410-b2260_defconfig               |  11 +-
 configs/tbs_a711_defconfig                    |   1 +
 configs/tinker-rk3288_defconfig               |   5 +-
 .../xilinx_zynqmp_zc1751_xm015_dc1_defconfig  |   7 +-
 .../xilinx_zynqmp_zc1751_xm016_dc2_defconfig  |   2 +-
 configs/xilinx_zynqmp_zcu102_rev1_0_defconfig |   7 +-
 configs/xilinx_zynqmp_zcu102_revA_defconfig   |   7 +-
 configs/xilinx_zynqmp_zcu102_revB_defconfig   |   7 +-
 configs/xilinx_zynqmp_zcu106_revA_defconfig   |   7 +-
 doc/README.android-fastboot                   | 240 +++++++-----
 drivers/Kconfig                               |   2 +
 drivers/Makefile                              |   1 +
 {cmd => drivers}/fastboot/Kconfig             |  63 ++--
 drivers/fastboot/Makefile                     |   7 +
 drivers/fastboot/fb_command.c                 | 335 +++++++++++++++++
 drivers/fastboot/fb_common.c                  | 169 +++++++++
 drivers/fastboot/fb_getvar.c                  | 230 ++++++++++++
 {common => drivers/fastboot}/fb_mmc.c         | 216 +++++++----
 {common => drivers/fastboot}/fb_nand.c        |  69 +++-
 drivers/usb/gadget/f_fastboot.c               | 347 ++----------------
 fs/fs.c                                       |  13 +
 include/fastboot-internal.h                   |  36 ++
 include/fastboot.h                            | 137 ++++++-
 include/fb_mmc.h                              |  35 +-
 include/fb_nand.h                             |  37 +-
 include/fs.h                                  |  10 +
 include/image-sparse.h                        |   4 +-
 include/net.h                                 |   2 +-
 include/net/fastboot.h                        |  21 ++
 lib/Kconfig                                   |  11 +
 lib/Makefile                                  |   1 +
 {common => lib}/image-sparse.c                |  38 +-
 net/Makefile                                  |   1 +
 net/fastboot.c                                | 317 ++++++++++++++++
 net/net.c                                     |   7 +
 scripts/config_whitelist.txt                  |   2 -
 104 files changed, 2094 insertions(+), 696 deletions(-)
 rename {cmd => drivers}/fastboot/Kconfig (78%)
 create mode 100644 drivers/fastboot/Makefile
 create mode 100644 drivers/fastboot/fb_command.c
 create mode 100644 drivers/fastboot/fb_common.c
 create mode 100644 drivers/fastboot/fb_getvar.c
 rename {common => drivers/fastboot}/fb_mmc.c (62%)
 rename {common => drivers/fastboot}/fb_nand.c (71%)
 create mode 100644 include/fastboot-internal.h
 create mode 100644 include/net/fastboot.h
 rename {common => lib}/image-sparse.c (88%)
 create mode 100644 net/fastboot.c

--
2.17.0