Add fastboot UDP support
Subsystems (11)
v4 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'll post the USB migration as a separate patch.
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)
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
- move Kconfig changes to previous patch
- 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
- 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)
- make global variables static and add accessors for the things which the transport layers need
- 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 (14):
fastboot: Move fastboot to drivers/fastboot
fastboot: Switch dependencies on FASTBOOT to USB_FUNCTION_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
ti: fastboot: Move weak overrides to board files
fs: Add fs_get_type_name to return current filesystem name
mmc: Separate "mmc swrite" from fastboot
net: fastboot: Merge AOSP UDP fastboot
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/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/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 +-
configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig | 2 +-
configs/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 | 1 +
{cmd => drivers}/fastboot/Kconfig | 53 ++--
drivers/fastboot/Makefile | 7 +
drivers/fastboot/fb_command.c | 327 +++++++++++++++++++++++
drivers/fastboot/fb_common.c | 190 +++++++++++++
drivers/fastboot/fb_getvar.c | 229 ++++++++++++++++
{common => drivers/fastboot}/fb_mmc.c | 192 ++++++++-----
{common => drivers/fastboot}/fb_nand.c | 46 ++--
drivers/usb/gadget/f_fastboot.c | 59 ++--
fs/fs.c | 13 +
include/fastboot.h | 167 +++++++++++-
include/fb_mmc.h | 10 +-
include/fb_nand.h | 12 +-
include/fs.h | 10 +
include/image-sparse.h | 4 +-
include/net.h | 2 +-
include/net/fastboot.h | 21 ++
lib/Kconfig | 3 +
lib/Makefile | 1 +
{common => lib}/image-sparse.c | 32 ++-
net/Makefile | 1 +
net/fastboot.c | 312 +++++++++++++++++++++
net/net.c | 7 +
74 files changed, 1704 insertions(+), 259 deletions(-)
rename {cmd => drivers}/fastboot/Kconfig (83%)
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 (66%)
rename {common => drivers/fastboot}/fb_nand.c (81%)
create mode 100644 include/net/fastboot.h
rename {common => lib}/image-sparse.c (89%)
create mode 100644 net/fastboot.cSignature · 1 line
2.7.4
PATCH v4 1/14 fastboot: Move fastboot to drivers/fastboot
Separate CMD_FASTBOOT from FASTBOOT and move code and configuration to drivers/fastboot.
---
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 +--------------
drivers/Kconfig | 2 ++
drivers/Makefile | 1 +
{cmd => drivers}/fastboot/Kconfig | 35 ++++++++++++----------------------
drivers/fastboot/Makefile | 8 ++++++++
{common => drivers/fastboot}/fb_mmc.c | 0
{common => drivers/fastboot}/fb_nand.c | 0
10 files changed, 36 insertions(+), 42 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
@@ -1246,9 +1246,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
@@ -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
@@ -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 USB_FUNCTION_FASTBOOT || UDP_FUNCTION_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 either network stack + enabled or 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
@@ -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
drivers/Kconfig +2 -0
@@ -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 +1 -0
@@ -71,6 +71,7 @@ obj-y += block/ obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_CPU) += cpu/ obj-y += crypto/ +obj-$(CONFIG_FASTBOOT) += fastboot/ obj-y += firmware/ obj-$(CONFIG_FPGA) += fpga/ obj-y += misc/
drivers/fastboot/Kconfig renamed from cmd/fastboot/Kconfig +12 -23
@@ -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
@@ -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
drivers/fastboot/fb_nand.c renamed from common/fb_nand.c +0 -0
Signature · 1 line
2.7.4
PATCH v4 2/14 fastboot: Switch dependencies on FASTBOOT to USB_FUNCTION_FASTBOOT
In reply to Alex KiernanAnyone who wants FASTBOOT before this series wants USB_FUNCTION_FASTBOOT. Split USB_FUNCTION_FASTBOOT from FASTBOOT so they retain their existing behaviour.
---
Changes in v4: None
Changes in v3:
- move Kconfig changes to previous patch
Changes in v2: None
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/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 +- configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig | 2 +- configs/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 +- 36 files changed, 36 insertions(+), 36 deletions(-)
configs/am335x_boneblack_defconfig +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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/kc1_defconfig +1 -1
@@ -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
@@ -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/mx6sabresd_defconfig +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Signature · 1 line
2.7.4
PATCH v4 3/14 fastboot: Refactor fastboot_okay/fail to take response
In reply to Alex KiernanAdd 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 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.7.4
PATCH v4 4/14 fastboot: Extract fastboot_okay/fail to fb_common.c
In reply to Alex KiernanAdd 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 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/fastboot/Makefile | 2 ++ drivers/fastboot/fb_common.c | 62 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/gadget/f_fastboot.c | 13 --------- include/fastboot.h | 4 +++ 4 files changed, 68 insertions(+), 13 deletions(-) create mode 100644 drivers/fastboot/fb_common.c
drivers/fastboot/Makefile +2 -0
@@ -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 +62 -0
62 lines not on this page · raw message
drivers/usb/gadget/f_fastboot.c +0 -13
@@ -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 +4 -0
@@ -15,6 +15,10 @@/* The 64 defined bytes plus \0 */ #define FASTBOOT_RESPONSE_LEN (64 + 1) +void fastboot_response (const char *tag,char *response, +const char *format, ...) + __attribute__ ((format (__printf__,3 ,4 ))); +void fastboot_fail (const char *reason,char *response);void fastboot_okay (const char *reason,char *response);
Signature · 1 line
2.7.4
PATCH v4 5/14 fastboot: Correct dependencies in FASTBOOT_FLASH
In reply to Alex KiernanEnsure 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.
---
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 | 8 ++++---- drivers/fastboot/Makefile | 8 ++------ drivers/usb/gadget/f_fastboot.c | 14 +++++++------- 4 files changed, 15 insertions(+), 19 deletions(-)
arch/arm/mach-omap2/utils.c +2 -2
@@ -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 -4
@@ -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
@@ -88,7 +89,6 @@ config FASTBOOT_FLASH_MMC_DEV 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
@@ -97,7 +97,7 @@ config FASTBOOT_FLASH_NAND_DEV 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 +110,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
@@ -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
@@ -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.7.4
PATCH v4 6/14 fastboot: Add missing newlines
In reply to Alex KiernanAdd newlines so we format our output correctly.
---
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
@@ -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.7.4
PATCH v4 7/14 fastboot: Remove FIXME for CONFIG_FASTBOOT_...NAME
In reply to Alex KiernanCONFIG_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 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
@@ -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.7.4
PATCH v4 8/14 fastboot: Fix parameter types in _fb_nand_write
In reply to Alex KiernanCompiling 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 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
@@ -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.7.4
PATCH v4 9/14 fastboot: Rename fb_set_reboot_flag to fastboot_set_reboot_flag
In reply to Alex KiernanRename 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 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -60,3 +60,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
@@ -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
@@ -21,5 +21,5 @@ void fastboot_response(const char *tag, char *response,void fastboot_fail (const char *reason,char *response);void fastboot_okay (const char *reason,char *response); - +int fastboot_set_reboot_flag (void );#endif /* _FASTBOOT_H_ */
Signature · 1 line
2.7.4
PATCH v4 10/14 fastboot: Extract common definitions from USB fastboot
In reply to Alex KiernanMove FASTBOOT_VERSION to include/fastboot.h so when we merge the UDP code we only have one definition.
---
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
@@ -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
@@ -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.7.4
PATCH v4 11/14 ti: fastboot: Move weak overrides to board files
In reply to Alex KiernanOverriding 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 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
@@ -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
@@ -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
@@ -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.7.4
PATCH v4 12/14 fs: Add fs_get_type_name to return current filesystem name
In reply to Alex KiernanAdd fs_get_type_name so we can get the current filesystem type.
---
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
@@ -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
@@ -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.7.4
PATCH v4 13/14 mmc: Separate "mmc swrite" from fastboot
In reply to Alex KiernanIntroduce 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.
---
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 | 3 +++
lib/Makefile | 1 +
{common => lib}/image-sparse.c | 0
7 files changed, 19 insertions(+), 7 deletions(-)
rename {common => lib}/image-sparse.c (100%)cmd/Kconfig +8 -0
@@ -826,6 +826,14 @@ config CMD_MMC help MMC memory mapped support. +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
@@ -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,11 +868,11 @@ 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, "", ""), -#endifU_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,"" ,"" ), +#endifU_BOOT_CMD_MKENT (rescan,1 ,1 , do_mmc_rescan,"" ,"" ),U_BOOT_CMD_MKENT (part,1 ,1 , do_mmc_part,"" ,"" ), U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),
@@ -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
@@ -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
@@ -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 +3 -0
@@ -61,6 +61,9 @@ config SPL_STRTO config TPL_STRTO bool +config IMAGE_SPARSE + bool + config USE_PRIVATE_LIBGCC bool "Use private libgcc" depends on HAVE_PRIVATE_LIBGCC
lib/Makefile +1 -0
@@ -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 +0 -0
Signature · 1 line
2.7.4
PATCH v4 14/14 net: fastboot: Merge AOSP UDP fastboot
In reply to Alex KiernanMerge UDP fastboot support from AOSP:
https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8
---
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)
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)
- make global variables static and add accessors for the things which the transport layers need
- 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/fastboot.c | 91 +++++++++++- drivers/fastboot/Kconfig | 15 ++ drivers/fastboot/Makefile | 3 +- drivers/fastboot/fb_command.c | 327 ++++++++++++++++++++++++++++++++++++++++++ drivers/fastboot/fb_common.c | 113 +++++++++++++++ drivers/fastboot/fb_getvar.c | 229 +++++++++++++++++++++++++++++ drivers/fastboot/fb_mmc.c | 76 +++++++++- drivers/fastboot/fb_nand.c | 12 +- include/fastboot.h | 157 ++++++++++++++++++++ include/fb_mmc.h | 8 +- include/fb_nand.h | 10 +- include/net.h | 2 +- include/net/fastboot.h | 21 +++ net/Makefile | 1 + net/fastboot.c | 312 ++++++++++++++++++++++++++++++++++++++++ net/net.c | 7 + 16 files changed, 1367 insertions(+), 17 deletions(-) create mode 100644 drivers/fastboot/fb_command.c create mode 100644 drivers/fastboot/fb_getvar.c create mode 100644 include/net/fastboot.h create mode 100644 net/fastboot.c
cmd/fastboot.c +86 -5
@@ -10,10 +10,32 @@#include <command.h> #include <console.h> #include <g_dnl.h> +#include <fastboot.h> +#include <net.h> #include <usb.h> -static int do_fastboot (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_fastboot_udp (int argc,char *const argv[], +uintptr_t buf_addr,size_t buf_size) { +#if CONFIG_IS_ENABLED (UDP_FUNCTION_FASTBOOT ) +int err =net_loop (FASTBOOT ); + +if (err <0 ) { +printf ("fastboot udp error: %d\n" , err); +return CMD_RET_FAILURE ; + } + +return CMD_RET_SUCCESS ; +#else +pr_err ("Fastboot UDP not enabled\n" ); +return CMD_RET_FAILURE ; +#endif +} + +static int do_fastboot_usb (int argc,char *const argv[], +uintptr_t buf_addr,size_t buf_size) +{ +#if CONFIG_IS_ENABLED (USB_FUNCTION_FASTBOOT )int controller_index;char *usb_controller;int ret;
@@ -58,11 +80,70 @@ exit:board_usb_cleanup (controller_index,USB_INIT_DEVICE );return ret; +#else +pr_err ("Fastboot USB not enabled\n" ); +return CMD_RET_FAILURE ; +#endif +} + +static int do_fastboot (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +uintptr_t buf_addr = (uintptr_t )NULL ; +size_t buf_size =0 ; + +if (argc <2 ) +return CMD_RET_USAGE ; + +while (argc >1 && **(argv +1 ) =='-' ) { +char *arg = *++argv; + + --argc; +while (*++arg) { +switch (*arg) { +case 'l' : +if (--argc <=0 ) +return CMD_RET_USAGE ; + buf_addr =simple_strtoul (*++argv,NULL ,16 ); + goto NXTARG; + +case 's' : +if (--argc <=0 ) +return CMD_RET_USAGE ; + buf_size =simple_strtoul (*++argv,NULL ,16 ); + goto NXTARG; + +default : +return CMD_RET_USAGE ; + } + } +NXTARG: + ; + } + +fastboot_init ((void *)buf_addr, buf_size); + +if (!strcmp (argv[1 ],"udp" )) +return do_fastboot_udp (argc, argv, buf_addr, buf_size); + +if (!strcmp (argv[1 ],"usb" )) { + argv++; + argc--; + } + +return do_fastboot_usb (argc, argv, buf_addr, buf_size); } +#ifdef CONFIG_SYS_LONGHELP +static char fastboot_help_text[] = +"[-l addr] [-s size] usb <controller> | udp\n" +"\taddr - address of buffer used during data transfers (" + __stringify(CONFIG_FASTBOOT_BUF_ADDR) ")\n" +"\tsize - size of buffer used during data transfers (" + __stringify(CONFIG_FASTBOOT_BUF_SIZE) ")" + ; +#endif +U_BOOT_CMD ( - fastboot,2 ,1 , do_fastboot, -"use USB Fastboot protocol" , -"<USB_controller>\n" -" - run as a fastboot usb device" + fastboot,CONFIG_SYS_MAXARGS ,1 , do_fastboot, +"run as a fastboot usb or udp device" , fastboot_help_text );
drivers/fastboot/Kconfig +15 -0
@@ -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
@@ -119,6 +126,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/Makefile +2 -1
@@ -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 +327 -0
327 lines not on this page · raw message
drivers/fastboot/fb_common.c +113 -0
122 lines not on this page · raw message
drivers/fastboot/fb_getvar.c new file +229 -0
229 lines not on this page · raw message
drivers/fastboot/fb_mmc.c +70 -6
125 lines not on this page · raw message
drivers/fastboot/fb_nand.c +10 -2
@@ -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,8 +145,16 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info,return blkcnt + bad_blocks; } +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); +} +void fb_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.h +157 -0
170 lines not on this page · raw message
include/fb_mmc.h +7 -1
@@ -3,6 +3,12 @@* Copyright 2014 Broadcom Corporation. */ +#ifndef _FB_MMC_H_ +#define _FB_MMC_H_ + +int fastboot_mmc_get_part_info (char *part_name,struct blk_desc **dev_desc, +disk_partition_t *part_info,char *response);void fb_mmc_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes,char *response); +u32 download_bytes,char *response);void fb_mmc_erase (const char *cmd,char *response); +#endif
include/fb_nand.h +9 -1
@@ -4,6 +4,14 @@* Copyright 2015 Free Electrons. */ +#ifndef _FB_NAND_H_ +#define _FB_NAND_H_ + +#include <jffs2/load_kernel.h> + +int fastboot_nand_get_part_info (char *part_name,struct part_info **part_info, +char *response);void fb_nand_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes,char *response); +u32 download_bytes,char *response);void fb_nand_erase (const char *cmd,char *response); +#endif
include/net.h +1 -1
@@ -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
@@ -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
@@ -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 +312 -0
312 lines not on this page · raw message
net/net.c +7 -0
@@ -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.7.4
PATCH v4 10/14 fastboot: Extract common definitions from USB fastboot
In reply to Alex KiernanQuoted 10 lines · Alex Kiernan
Move
FASTBOOT_VERSIONtoinclude/fastboot.hso when we merge the UDP code we only have one definition.Signed-off-by Alex Kiernan <[email protected]>---
Changes in v4:
- leavestrcmp_l1()in USB fastboot as we don't need it in UDP path
Quoted 8 lines
Changes in v3:
- newChanges in v2: None
drivers/usb/gadget/f_fastboot.c | 2 -- include/fastboot.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
v4 cover Add fastboot UDP support
In reply to Alex KiernanQuoted 4 lines · Alex Kiernan
This series merges the fastboot UDP support from AOSP into mainline U-Boot.
Hi Alex,
Can you tell me which platforms you verified these patches on? From what I see, it shouldn't affect regular fastboot operation, but just in case: do you have some public Git tree with these patches, so that I can verify them on TI boards? I can also verify UDP functionality as well, if you want me to. In that case, please provide instructions (or link to documentation) which I can use for testing.
Thanks.
Quoted 193 lines
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' toCONFIG_FASTBOOT_BUF_ADDRas its marker for the subsequent boot. The code which is in AOSPcommon/android_bootloader.cexpects this marker, but we have prior art in the USB code using the weak functionfastboot_set_reboot_flag
- 'getvar' in the UDP path now supports fetching 'fastboot.' prefixed variables (inherited from the USB path), these override the defaultsI'll post the USB migration as a separate patch.
Changes in v4:
- add docbook comments
- leavestrcmp_l1()in USB fastboot as we don't need it in UDP path
- add docbook comments
- new
- guard fb_getvar/fb_command withUDP_FUNCTION_FASTBOOTinMakefile
- add docbook comments
- remove parameter fromfastboot_boot()since we always wantfastboot_buf_addr(and if we're usingfastboot_bootcmdthen it's ignored)Changes in v3:
- move implyANDROID_BOOT_IMAGE,CMD_FASTBOOTto FASTBOOT fromUSB_FUNCTION_FASTBOOT
- add depend onUSB_FUNCTION_FASTBOOTtoFASTBOOT_USB_DEV
- leaveimages-sparse.cin common to acommodate 2f83f21
- moveKconfigchanges to previous patch
- refactor for changes in master
- Merge subsequent patch for formatting response strings into this one
- allow NULL tofastboot_okay()when there's no message to send
- guard FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME with EFI/DOS_PARTITION
- use FASTBOOT as our guard inKconfignot 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
- useCMD_RET_USAGEfromdo_fastboot
- removedo_fastboot_udpfromcmd/net.cand rewrite usingnet_loop()
- renametimed_send_infotofastboot_send_info, renamefastboot_send_infotofastboot_udp_send_info
- replaceFASTBOOT_HEADER_SIZEwithsizeof(struct fastboot_header)
- move start time intotimed_send_info()rather than passing it in
- make calls tofastboot_udp_send_infoa 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
- addfastboot_buf_addr,fastboot_buf_sizeto 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)
- make global variables static and add accessors for the things which the transport layers need
- 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 toCONFIG_FASTBOOT_BUF_ADDRfor use as a marker on reboot (the AOSP code incommon/android-bootloader.cuses 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 (14):
fastboot: Move fastboot todrivers/fastboot
fastboot: Switch dependencies on FASTBOOT toUSB_FUNCTION_FASTBOOT
fastboot: Refactor fastboot_okay/fail to take response
fastboot: Extract fastboot_okay/fail tofb_common.c
fastboot: Correct dependencies inFASTBOOT_FLASH
fastboot: Add missing newlines
fastboot: Remove FIXME for CONFIG_FASTBOOT_...NAME
fastboot: Fix parameter types in_fb_nand_write
fastboot: Renamefb_set_reboot_flagtofastboot_set_reboot_flag
fastboot: Extract common definitions from USB fastboot
ti: fastboot: Move weak overrides to board files
fs: Addfs_get_type_nameto return current filesystem name
mmc: Separate "mmc swrite" from fastboot
net: fastboot: Merge AOSP UDP fastbootarch/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/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/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 +- configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig | 2 +- configs/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 | 1 + {cmd => drivers}/fastboot/Kconfig | 53 ++-- drivers/fastboot/Makefile | 7 + drivers/fastboot/fb_command.c | 327 +++++++++++++++++++++++ drivers/fastboot/fb_common.c | 190 +++++++++++++ drivers/fastboot/fb_getvar.c | 229 ++++++++++++++++ {common => drivers/fastboot}/fb_mmc.c | 192 ++++++++----- {common => drivers/fastboot}/fb_nand.c | 46 ++-- drivers/usb/gadget/f_fastboot.c | 59 ++-- fs/fs.c | 13 + include/fastboot.h | 167 +++++++++++- include/fb_mmc.h | 10 +- include/fb_nand.h | 12 +- include/fs.h | 10 + include/image-sparse.h | 4 +- include/net.h | 2 +- include/net/fastboot.h | 21 ++ lib/Kconfig | 3 + lib/Makefile | 1 + {common => lib}/image-sparse.c | 32 ++- net/Makefile | 1 + net/fastboot.c | 312 +++++++++++++++++++++ net/net.c | 7 + 74 files changed, 1704 insertions(+), 259 deletions(-) rename {cmd => drivers}/fastboot/Kconfig (83%) 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 (66%) rename {common => drivers/fastboot}/fb_nand.c (81%) create mode 100644 include/net/fastboot.h rename {common => lib}/image-sparse.c (89%) create mode 100644 net/fastboot.c--
2.7.4
v4 cover Add fastboot UDP support
Hi Sam
Quoted 9 lines · Sam Protsenko
Quoted 4 lines · Alex Kiernan
This series merges the fastboot UDP support from AOSP into mainline U-Boot.
Hi Alex,
Can you tell me which platforms you verified these patches on?
Sure... it's an internal board, but derived from a BeagleBone Black (just with many of the components missing). I think I've also managed to track down a BBB internally, so hopefully should be able to test on that in a day or so.
Quoted 2 lines
From
what I see, it shouldn't affect regular fastboot operation,
That's what I was aiming for, there's a separate final RFC patch to migrate the USB path across which I left out of this series as I doubt I've got it completely right.
Quoted 3 lines
but just
in case: do you have some public Git tree with these patches, so that I can verify them on TI boards?
That'd be awesome, thanks!
Repo is here:
https://github.com/akiernan/u-boot/tree/us-fastboot-udp-v4
If you're trying to test this series, you'll want to pop the final commit off it, as that's the USB migration patch.
Quoted 3 lines
I can also verify UDP functionality as
well, if you want me to. In that case, please provide instructions (or link to documentation) which I can use for testing.
It's pretty much the same as driving the USB side... start the fastboot server:
setenv autoload no; dhcp; fastboot udp
And then from the client use something like:
fastboot -s udp:<target-ip-address> getvar serialno
If you're trying it on a board using the CPSW driver, if you send the continue command, you'll see the server exit and the client hang doing resends for a minute, which is this problem:
http://patchwork.ozlabs.org/patch/912382/
Whether that fix is correct is a different question, but it solved the problem for me.
Quoted 3 lines
Thanks.
Quoted 1 line
Changes in UDP behaviour from the AOSP code, so it follows the existing
USB
Quoted 3 lines
Quoted 3 lines
behaviour:
- 'boot' now follows the USB code and does 'bootm
CONFIG_FASTBOOT_BUF_ADDR'.
Quoted 1 line
Quoted 1 line
I've added '
fastboot_bootcmd' which if set overrides the boot command
and
Quoted 5 lines
Quoted 5 lines
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' toCONFIG_FASTBOOT_BUF_ADDRas its marker for the subsequent boot. The
code
Quoted 28 lines
Quoted 28 lines
which is in AOSP
common/android_bootloader.cexpects this marker, but we have prior art in the USB code using the weak functionfastboot_set_reboot_flag
- 'getvar' in the UDP path now supports fetching 'fastboot.' prefixed variables (inherited from the USB path), these override the defaultsI'll post the USB migration as a separate patch.
Changes in v4:
- add docbook comments
- leavestrcmp_l1()in USB fastboot as we don't need it in UDP path
- add docbook comments
- new
- guard fb_getvar/fb_command withUDP_FUNCTION_FASTBOOTinMakefile
- add docbook comments
- remove parameter fromfastboot_boot()since we always wantfastboot_buf_addr(and if we're usingfastboot_bootcmdthen it's ignored)Changes in v3:
- move implyANDROID_BOOT_IMAGE,CMD_FASTBOOTto FASTBOOT fromUSB_FUNCTION_FASTBOOT
- add depend onUSB_FUNCTION_FASTBOOTtoFASTBOOT_USB_DEV
- leaveimages-sparse.cin common to acommodate 2f83f21
- moveKconfigchanges to previous patch
- refactor for changes in master
- Merge subsequent patch for formatting response strings into this one
- allow NULL tofastboot_okay()when there's no message to send
Quoted 8 lines
Quoted 8 lines
- guard FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME with EFI/DOS_PARTITION
- use FASTBOOT as our guard inKconfignot 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
- useCMD_RET_USAGEfromdo_fastboot
- removedo_fastboot_udpfromcmd/net.cand rewrite usingnet_loop()
- renametimed_send_infotofastboot_send_info, rename
fastboot_send_info to
Quoted 4 lines
Quoted 4 lines
fastboot_udp_send_info
- replaceFASTBOOT_HEADER_SIZEwithsizeof(struct fastboot_header)
- move start time intotimed_send_info()rather than passing it in
- make calls tofastboot_udp_send_infoa runtime dependency, not a
compile
Quoted 5 lines
Quoted 5 lines
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
Quoted 3 lines
Quoted 3 lines
fastboot boot command
- make getvar implementation table driven
- addfastboot_buf_addr,fastboot_buf_sizeto override buffer address
and
Quoted 9 lines
Quoted 9 lines
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)
- make global variables static and add accessors for the things which the transport layers need
- squash subsequent patches which change this code into this one:
- If the fastboot flash/erase commands are disabled, remove that
support
Quoted 5 lines
Quoted 5 lines
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
Quoted 1 line
Quoted 1 line
use as a marker on reboot (the AOSP code in
common/android-bootloader.c
Quoted 3 lines
Quoted 3 lines
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
Quoted 2 lines
Quoted 2 lines
UDP no longer passes an fdt. We introduce a new environment variable '
fastboot_bootcmd' which if set overrides the hardcoded boot
command,
Quoted 1 line
Quoted 1 line
setting this then allows the UDP implementation to remain the same.
If
Quoted 1 line
Quoted 1 line
after running '
fastboot_bootcmd' the board has not booted, control
is
Quoted 2 lines
Quoted 2 lines
returned to U-Boot and the fastboot process ends.
- Separate the fastboot protocol handling from the fastboot UDP code
in
Quoted 69 lines
Quoted 69 lines
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 (14):
fastboot: Move fastboot todrivers/fastboot
fastboot: Switch dependencies on FASTBOOT toUSB_FUNCTION_FASTBOOT
fastboot: Refactor fastboot_okay/fail to take response
fastboot: Extract fastboot_okay/fail tofb_common.c
fastboot: Correct dependencies inFASTBOOT_FLASH
fastboot: Add missing newlines
fastboot: Remove FIXME for CONFIG_FASTBOOT_...NAME
fastboot: Fix parameter types in_fb_nand_write
fastboot: Renamefb_set_reboot_flagtofastboot_set_reboot_flag
fastboot: Extract common definitions from USB fastboot
ti: fastboot: Move weak overrides to board files
fs: Addfs_get_type_nameto return current filesystem name
mmc: Separate "mmc swrite" from fastboot
net: fastboot: Merge AOSP UDP fastbootarch/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/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/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 +- configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig | 2 +- configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig | 2 +- configs/xilinx_zynqmp_zcu102_rev1_0_defconfig | 2 +-
Quoted 8 lines
Quoted 8 lines
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 | 1 + {cmd => drivers}/fastboot/Kconfig | 53 ++-- drivers/fastboot/Makefile | 7 + drivers/fastboot/fb_command.c | 327
+++++++++++++++++++++++
Quoted 10 lines
Quoted 10 lines
drivers/fastboot/fb_common.c | 190 +++++++++++++ drivers/fastboot/fb_getvar.c | 229 ++++++++++++++++ {common => drivers/fastboot}/fb_mmc.c | 192 ++++++++----- {common => drivers/fastboot}/fb_nand.c | 46 ++-- drivers/usb/gadget/f_fastboot.c | 59 ++-- fs/fs.c | 13 + include/fastboot.h | 167 +++++++++++- include/fb_mmc.h | 10 +- include/fb_nand.h | 12 +- include/fs.h | 10 +
Quoted 8 lines
Quoted 8 lines
include/image-sparse.h | 4 +- include/net.h | 2 +- include/net/fastboot.h | 21 ++ lib/Kconfig | 3 + lib/Makefile | 1 + {common => lib}/image-sparse.c | 32 ++- net/Makefile | 1 + net/fastboot.c | 312
+++++++++++++++++++++
Quoted 16 lines
Quoted 16 lines
net/net.c | 7 + 74 files changed, 1704 insertions(+), 259 deletions(-) rename {cmd => drivers}/fastboot/Kconfig (83%) 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 (66%) rename {common => drivers/fastboot}/fb_nand.c (81%) create mode 100644 include/net/fastboot.h rename {common => lib}/image-sparse.c (89%) create mode 100644 net/fastboot.c--
2.7.4
Signature · 1 line
Alex Kiernan
PATCH v4 1/14 fastboot: Move fastboot to drivers/fastboot
In reply to Alex KiernanQuoted 5 lines · Alex Kiernan
Separate
CMD_FASTBOOTfrom FASTBOOT and move code and configuration todrivers/fastboot.Signed-off-by Alex Kiernan <[email protected]>Reviewed-by Simon Glass <[email protected]>
Nit below, but otherwise,
Quoted 67 lines
---
Changes in v4: None
Changes in v3:
- move implyANDROID_BOOT_IMAGE,CMD_FASTBOOTto FASTBOOT fromUSB_FUNCTION_FASTBOOT
- add depend onUSB_FUNCTION_FASTBOOTtoFASTBOOT_USB_DEV
- leaveimages-sparse.cin common to acommodate 2f83f21Changes in v2: None
arch/arm/Kconfig | 2 -- board/ti/common/Kconfig | 1 - cmd/Kconfig | 14 ++++++++++++-- common/Makefile | 15 +-------------- drivers/Kconfig | 2 ++ drivers/Makefile | 1 + {cmd => drivers}/fastboot/Kconfig | 35 ++++++++++++---------------------- drivers/fastboot/Makefile | 8 ++++++++ {common => drivers/fastboot}/fb_mmc.c | 0 {common => drivers/fastboot}/fb_nand.c | 0 10 files changed, 36 insertions(+), 42 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@@ -1246,9 +1246,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_SYSRESETboard/ti/common/Kconfig +0
-1@@ -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_GENERICcmd/Kconfig +0
-2@@ -137,8 +137,6 @@ config AUTOBOOT_STOP_STR_SHA256 endmenu -source "cmd/fastboot/Kconfig" - config BUILD_BIN2C bool
cmd/Kconfig config CMD_DM · line 653
Quoted 6 lines
cmd/Kconfig +3
-0@@ -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 USB_FUNCTION_FASTBOOT || UDP_FUNCTION_FASTBOOT
You got a little ahead of yourself here... UDP_FUNCTION_FASTBOOT doesn't exist, so don't depend on it yet.
cmd/Kconfig config CMD_DM · line 659
Quoted 6 lines
cmd/Kconfig +6
-0+ 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 either network stack + enabled or support for acting as a USB device.
Also here... as of now, it just requires a USB device.
Quoted 159 lines
cmd/Kconfig +3
-0+ + See doc/README.android-fastboot for more information. + config CMD_FDC bool "fdcboot - Boot from floppy device" helpcommon/Makefile +1
-14@@ -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 endifdrivers/Kconfig +2
-0@@ -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 +1
-0@@ -71,6 +71,7 @@ obj-y += block/ obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_CPU) += cpu/ obj-y += crypto/ +obj-$(CONFIG_FASTBOOT) += fastboot/ obj-y += firmware/ obj-$(CONFIG_FPGA) += fpga/ obj-y += misc/drivers/fastboot/Kconfig renamed from cmd/fastboot/Kconfig +12
-23@@ -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 + +endmenudrivers/fastboot/Makefile new file +8
-0@@ -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 +endifdrivers/fastboot/fb_mmc.c renamed from common/fb_mmc.c +0
-0drivers/fastboot/fb_nand.c renamed from common/fb_nand.c +0
-1--2.7.4
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v4 2/14 fastboot: Switch dependencies on FASTBOOT to USB_FUNCTION_FASTBOOT
In reply to Alex KiernanQuoted 6 lines · Alex Kiernan
Anyone who wants FASTBOOT before this series wants
USB_FUNCTION_FASTBOOT. SplitUSB_FUNCTION_FASTBOOTfrom FASTBOOT so they retain their existing behaviour.Signed-off-by Alex Kiernan <[email protected]>Reviewed-by Joe Hershberger <[email protected]>
Yup.
PATCH v4 7/14 fastboot: Remove FIXME for CONFIG_FASTBOOT_...NAME
In reply to Alex KiernanQuoted 6 lines · Alex Kiernan
CONFIG_FASTBOOT_GPT_NAMEandCONFIG_FASTBOOT_MBR_NAMEare always defined byKconfigif you're compiling this code, so remove these redundant defaults.Signed-off-by Alex Kiernan <[email protected]>Reviewed-by Simon Glass <[email protected]>
PATCH v4 8/14 fastboot: Fix parameter types in _fb_nand_write
In reply to Alex KiernanQuoted 10 lines · Alex Kiernan
Compiling on a 64 bit target the arguments to
_fb_nand_writeare 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 fromdrivers/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(structmtd_info*mtd,loff_toffset,size_t*length,
Quoted 4 lines
^~~~~~~~~~~~~~~~~~~Signed-off-by Alex Kiernan <[email protected]>Reviewed-by Simon Glass <[email protected]>
PATCH v4 9/14 fastboot: Rename fb_set_reboot_flag to fastboot_set_reboot_flag
In reply to Alex KiernanQuoted 9 lines · Alex Kiernan
Rename
fb_set_reboot_flagtofastboot_set_reboot_flagso it matches all other fastboot code in the global name space. Fix the guards around them so that they're dependent on FASTBOOT, not justUSB_FUNCTION_FASTBOOT.Move the weak implementation of
fastboot_set_reboot_flagtofb_common.cso we can call it from non-USB fastboot code.Signed-off-by Alex Kiernan <[email protected]>Reviewed-by Simon Glass <[email protected]>
PATCH v4 10/14 fastboot: Extract common definitions from USB fastboot
In reply to Alex KiernanQuoted 4 lines · Alex Kiernan
Move
FASTBOOT_VERSIONtoinclude/fastboot.hso when we merge the UDP code we only have one definition.Signed-off-by Alex Kiernan <[email protected]>
PATCH v4 12/14 fs: Add fs_get_type_name to return current filesystem name
In reply to Alex KiernanQuoted 4 lines · Alex Kiernan
Add
fs_get_type_nameso we can get the current filesystem type.Signed-off-by Alex Kiernan <[email protected]>Reviewed-by Simon Glass <[email protected]>
PATCH v4 13/14 mmc: Separate "mmc swrite" from fastboot
In reply to Alex KiernanQuoted 106 lines · Alex Kiernan
Introduce
CONFIG_IMAGE_SPARSEandCONFIG_CMD_MMC_SWRITEso 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.
Signed-off-by Alex Kiernan <[email protected]>---
Changes in v4:
- newChanges in v3: None
Changes in v2: Nonecmd/Kconfig | 8 ++++++++ cmd/mmc.c | 12 ++++++------ common/Makefile | 1 - drivers/fastboot/Kconfig | 1 + lib/Kconfig | 3 +++ lib/Makefile | 1 + {common => lib}/image-sparse.c | 0 7 files changed, 19 insertions(+), 7 deletions(-) rename {common => lib}/image-sparse.c (100%)cmd/Kconfig +8
-0@@ -826,6 +826,14 @@ config CMD_MMC help MMC memory mapped support. +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_SUNXIcmd/mmc.c +6
-6@@ -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,11 +868,11 @@ 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, "", ""), -#endifU_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,"" ,"" ), +#endifU_BOOT_CMD_MKENT (rescan,1 ,1 , do_mmc_rescan,"" ,"" ),U_BOOT_CMD_MKENT (part,1 ,1 , do_mmc_part,"" ,"" ), U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),@@ -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@@ -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.odrivers/fastboot/Kconfig +0
-0
drivers/fastboot/Kconfig config FASTBOOT_FLASH · line 60
Quoted 4 lines
drivers/fastboot/Kconfig +1
-0@@ -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
Is this useful if we are NAND and not MMC? It seems no.
Quoted 40 lines
drivers/fastboot/Kconfig +0
-0help The fastboot protocol includes a "flash" command for writing the downloaded image to a non-volatile storage device. Definelib/Kconfig +3
-0@@ -61,6 +61,9 @@ config SPL_STRTO config TPL_STRTO bool +config IMAGE_SPARSE + bool + config USE_PRIVATE_LIBGCC bool "Use private libgcc" depends on HAVE_PRIVATE_LIBGCClib/Makefile +1
-0@@ -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.olib/image-sparse.c renamed from common/image-sparse.c +0
-1--2.7.4
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v4 13/14 mmc: Separate "mmc swrite" from fastboot
Quoted 1 line · Joe Hershberger
On Tue, May 15, 2018 at 9:48 AM, Alex Kiernan <[email protected]>
Quoted 32 lines · wrote:
Quoted 32 lines
Introduce
CONFIG_IMAGE_SPARSEandCONFIG_CMD_MMC_SWRITEso 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.
Signed-off-by Alex Kiernan <[email protected]>---
Changes in v4:
- newChanges in v3: None
Changes in v2: Nonecmd/Kconfig | 8 ++++++++ cmd/mmc.c | 12 ++++++------ common/Makefile | 1 - drivers/fastboot/Kconfig | 1 + lib/Kconfig | 3 +++ lib/Makefile | 1 + {common => lib}/image-sparse.c | 0 7 files changed, 19 insertions(+), 7 deletions(-) rename {common => lib}/image-sparse.c (100%)cmd/Kconfig +0
-0@@ -826,6 +826,14 @@ config CMD_MMC help MMC memory mapped support.
Quoted 6 lines
cmd/Kconfig config CMD_MMC
Quoted 6 lines
cmd/Kconfig +6
-0+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
Quoted 13 lines
Quoted 13 lines
cmd/Kconfig +2
-0+ images to eMMC. + config CMD_NAND bool "nand" default y if NAND_SUNXIcmd/mmc.c +0
-0@@ -308,8 +308,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,return (n == cnt) ?CMD_RET_SUCCESS :CMD_RET_FAILURE ; }
Quoted 4 lines
cmd/mmc.c static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
Quoted 4 lines
cmd/mmc.c +1
-2-#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,
Quoted 3 lines
cmd/mmc.c static int do_mmc_sparse_write(cmd_tbl_t *cmdtp,
Quoted 3 lines
cmd/mmc.c +0
-0lbaint_t blkcnt, const void *buffer) {@@ -374,6 +373,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp,
int flag,
Quoted 46 lines
Quoted 46 lines
cmd/mmc.c +5
-4}#endif +#if CONFIG_IS_ENABLED (MMC_WRITE )static int do_mmc_write (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {@@ -868,11 +868,11 @@ 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, "", ""), -#endifU_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,"" ,"" ), +#endifU_BOOT_CMD_MKENT (rescan,1 ,1 , do_mmc_rescan,"" ,"" ),U_BOOT_CMD_MKENT (part,1 ,1 , do_mmc_part,"" ,"" ), U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),@@ -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@@ -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.odrivers/fastboot/Kconfig +0
-1--- a/drivers/fastboot/Kconfig
Quoted 8 lines
drivers/fastboot/Kconfig config FASTBOOT_FLASH · line 60
Quoted 6 lines
+++ b/drivers/fastboot/Kconfig
drivers/fastboot/Kconfig +1
-0@@ -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_SPARSEIs this useful if we are NAND and not MMC? It seems no.
There's code in drivers/fastboot/fb_nand.c which will write sparse images, so I think the select is right.
That said, there's nothings in configs/ which actually selects FASTBOOT_FLASH_NAND
--
Alex Kiernan
PATCH v4 13/14 mmc: Separate "mmc swrite" from fastboot
Quoted 121 lines · Alex Kiernan
Quoted 1 line · Joe Hershberger
On Tue, May 15, 2018 at 9:48 AM, Alex Kiernan <[email protected]>
Quoted 32 lines · wrote:
Quoted 32 lines
Introduce
CONFIG_IMAGE_SPARSEandCONFIG_CMD_MMC_SWRITEso 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.
Signed-off-by Alex Kiernan <[email protected]>---
Changes in v4:
- newChanges in v3: None
Changes in v2: Nonecmd/Kconfig | 8 ++++++++ cmd/mmc.c | 12 ++++++------ common/Makefile | 1 - drivers/fastboot/Kconfig | 1 + lib/Kconfig | 3 +++ lib/Makefile | 1 + {common => lib}/image-sparse.c | 0 7 files changed, 19 insertions(+), 7 deletions(-) rename {common => lib}/image-sparse.c (100%)cmd/Kconfig +0
-0@@ -826,6 +826,14 @@ config CMD_MMC help MMC memory mapped support.Quoted 6 lines
cmd/Kconfig config CMD_MMC
Quoted 6 lines
cmd/Kconfig +6
-0+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 Androidsparse
Quoted 13 lines
Quoted 13 lines
cmd/Kconfig +2
-0+ images to eMMC. + config CMD_NAND bool "nand" default y if NAND_SUNXIcmd/mmc.c +0
-0@@ -308,8 +308,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,return (n == cnt) ?CMD_RET_SUCCESS :CMD_RET_FAILURE ; }Quoted 4 lines
cmd/mmc.c static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
Quoted 4 lines
cmd/mmc.c +1
-2-#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_tblk,
Quoted 3 lines
cmd/mmc.c static int do_mmc_sparse_write(cmd_tbl_t *cmdtp,
Quoted 3 lines
cmd/mmc.c +0
-0lbaint_t blkcnt, const void *buffer) {@@ -374,6 +373,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp,int flag,
Quoted 46 lines
Quoted 46 lines
cmd/mmc.c +5
-4}#endif +#if CONFIG_IS_ENABLED (MMC_WRITE )static int do_mmc_write (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {@@ -868,11 +868,11 @@ 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, "", ""), -#endifU_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,"" ,"" ), +#endifU_BOOT_CMD_MKENT (rescan,1 ,1 , do_mmc_rescan,"" ,"" ),U_BOOT_CMD_MKENT (part,1 ,1 , do_mmc_part,"" ,"" ), U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),@@ -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@@ -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.odrivers/fastboot/Kconfig +0
-1--- a/drivers/fastboot/KconfigQuoted 8 lines
drivers/fastboot/Kconfig config FASTBOOT_FLASH · line 60
Quoted 6 lines
+++ b/drivers/fastboot/Kconfig
drivers/fastboot/Kconfig +1
-0@@ -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_SPARSEIs this useful if we are NAND and not MMC? It seems no.
Quoted 2 lines
There's code in
drivers/fastboot/fb_nand.cwhich will write sparse images, so I think the select is right.
OK, then this is fine.
Quoted 2 lines
That said, there's nothings in configs/ which actually selects
FASTBOOT_FLASH_NAND
OK, I guess we can wait for a board to come along that uses it?
Quoted 6 lines
--
Alex Kiernan
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v4 13/14 mmc: Separate "mmc swrite" from fastboot
Quoted 1 line · Joe Hershberger
On Wed, May 16, 2018 at 12:00 AM, Alex Kiernan <[email protected]>
Quoted 38 lines · wrote:
Quoted 38 lines
On Wed, May 16, 2018 at 12:20 AM Joe Hershberger <[email protected]
Quoted 1 line · wrote:
On Tue, May 15, 2018 at 9:48 AM, Alex Kiernan <[email protected]>
Quoted 32 lines · wrote:
Quoted 32 lines
Introduce
CONFIG_IMAGE_SPARSEandCONFIG_CMD_MMC_SWRITEso 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.
Signed-off-by Alex Kiernan <[email protected]>---
Changes in v4:
- newChanges in v3: None
Changes in v2: Nonecmd/Kconfig | 8 ++++++++ cmd/mmc.c | 12 ++++++------ common/Makefile | 1 - drivers/fastboot/Kconfig | 1 + lib/Kconfig | 3 +++ lib/Makefile | 1 + {common => lib}/image-sparse.c | 0 7 files changed, 19 insertions(+), 7 deletions(-) rename {common => lib}/image-sparse.c (100%)cmd/Kconfig +0
-0@@ -826,6 +826,14 @@ config CMD_MMC help MMC memory mapped support.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
cmd/Kconfig config CMD_MMC
Quoted 6 lines
cmd/Kconfig +6
-0+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
Quoted 11 lines
Quoted 11 lines
sparse
Quoted 10 lines
cmd/mmc.c static int do_mmc_read(cmd_tbl_t *cmdtp, int
Quoted 10 lines
cmd/Kconfig +2
-0+ images to eMMC. + config CMD_NAND bool "nand" default y if NAND_SUNXIcmd/mmc.c +0
-0@@ -308,8 +308,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int
flag,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
cmd/mmc.c static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
Quoted 7 lines
cmd/mmc.c +1
-2return (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
Quoted 58 lines
Quoted 58 lines
blk,
Quoted 3 lines
cmd/mmc.c static int do_mmc_sparse_write(cmd_tbl_t *cmdtp,
Quoted 3 lines
cmd/mmc.c +0
-0lbaint_t blkcnt, const void *buffer) {@@ -374,6 +373,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp,int flag,
Quoted 52 lines
Quoted 52 lines
cmd/mmc.c +5
-4}#endif +#if CONFIG_IS_ENABLED (MMC_WRITE )static int do_mmc_write (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {@@ -868,11 +868,11 @@ 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, "", ""), -#endifU_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,"" ,"" ), +#endifU_BOOT_CMD_MKENT (rescan,1 ,1 , do_mmc_rescan,"" ,"" ),U_BOOT_CMD_MKENT (part,1 ,1 , do_mmc_part,"" ,"" ), U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),@@ -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@@ -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.odrivers/fastboot/Kconfig +1
-0@@ -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
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Is this useful if we are NAND and not MMC? It seems no.
There's code in
drivers/fastboot/fb_nand.cwhich will write sparse
images,
Quoted 8 lines
Quoted 1 line
so I think the select is right.
OK, then this is fine.
Quoted 2 lines
That said, there's nothings in configs/ which actually selects
FASTBOOT_FLASH_NANDOK, I guess we can wait for a board to come along that uses it?
I'm wrong; CHIP_pro_defconfig selects it by way of various defaults.
Signature · 1 line
Alex Kiernan
PATCH v4 13/14 mmc: Separate "mmc swrite" from fastboot
In reply to Alex KiernanQuoted 6 lines · Alex Kiernan
Introduce
CONFIG_IMAGE_SPARSEandCONFIG_CMD_MMC_SWRITEso 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.
Signed-off-by Alex Kiernan <[email protected]>
PATCH v4 14/14 net: fastboot: Merge AOSP UDP fastboot
In reply to Alex KiernanQuoted 221 lines · Alex Kiernan
Merge UDP fastboot support from AOSP:
https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8
Signed-off-by Alex Kiernan <[email protected]>Signed-off-by Alex Deymo <[email protected]>Signed-off-by Jocelyn Bohr <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes in v4:
- guard fb_getvar/fb_command withUDP_FUNCTION_FASTBOOTinMakefile
- add docbook comments
- remove parameter fromfastboot_boot()since we always wantfastboot_buf_addr(and if we're usingfastboot_bootcmdthen it's ignored)Changes in v3:
- use FASTBOOT as our guard inKconfignot 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
- useCMD_RET_USAGEfromdo_fastboot
- removedo_fastboot_udpfromcmd/net.cand rewrite usingnet_loop()
- renametimed_send_infotofastboot_send_info, renamefastboot_send_infotofastboot_udp_send_info
- replaceFASTBOOT_HEADER_SIZEwithsizeof(struct fastboot_header)
- move start time intotimed_send_info()rather than passing it in
- make calls tofastboot_udp_send_infoa 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
- addfastboot_buf_addr,fastboot_buf_sizeto 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)
- make global variables static and add accessors for the things which the transport layers need
- 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 toCONFIG_FASTBOOT_BUF_ADDRfor use as a marker on reboot (the AOSP code incommon/android-bootloader.cuses 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/fastboot.c | 91 +++++++++++- drivers/fastboot/Kconfig | 15 ++ drivers/fastboot/Makefile | 3 +- drivers/fastboot/fb_command.c | 327 ++++++++++++++++++++++++++++++++++++++++++ drivers/fastboot/fb_common.c | 113 +++++++++++++++ drivers/fastboot/fb_getvar.c | 229 +++++++++++++++++++++++++++++ drivers/fastboot/fb_mmc.c | 76 +++++++++- drivers/fastboot/fb_nand.c | 12 +- include/fastboot.h | 157 ++++++++++++++++++++ include/fb_mmc.h | 8 +- include/fb_nand.h | 10 +- include/net.h | 2 +- include/net/fastboot.h | 21 +++ net/Makefile | 1 + net/fastboot.c | 312 ++++++++++++++++++++++++++++++++++++++++ net/net.c | 7 + 16 files changed, 1367 insertions(+), 17 deletions(-) create mode 100644 drivers/fastboot/fb_command.c create mode 100644 drivers/fastboot/fb_getvar.c create mode 100644 include/net/fastboot.h create mode 100644 net/fastboot.ccmd/fastboot.c +86
-5@@ -10,10 +10,32 @@#include <command.h> #include <console.h> #include <g_dnl.h> +#include <fastboot.h> +#include <net.h> #include <usb.h> -static int do_fastboot (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_fastboot_udp (int argc,char *const argv[], +uintptr_t buf_addr,size_t buf_size) { +#if CONFIG_IS_ENABLED (UDP_FUNCTION_FASTBOOT ) +int err =net_loop (FASTBOOT ); + +if (err <0 ) { +printf ("fastboot udp error: %d\n" , err); +return CMD_RET_FAILURE ; + } + +return CMD_RET_SUCCESS ; +#else +pr_err ("Fastboot UDP not enabled\n" ); +return CMD_RET_FAILURE ; +#endif +} + +static int do_fastboot_usb (int argc,char *const argv[], +uintptr_t buf_addr,size_t buf_size) +{ +#if CONFIG_IS_ENABLED (USB_FUNCTION_FASTBOOT )int controller_index;char *usb_controller;int ret;@@ -58,11 +80,70 @@ exit:board_usb_cleanup (controller_index,USB_INIT_DEVICE );return ret; +#else +pr_err ("Fastboot USB not enabled\n" ); +return CMD_RET_FAILURE ; +#endif +} + +static int do_fastboot (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +uintptr_t buf_addr = (uintptr_t )NULL ; +size_t buf_size =0 ; + +if (argc <2 ) +return CMD_RET_USAGE ; + +while (argc >1 && **(argv +1 ) =='-' ) { +char *arg = *++argv; + + --argc; +while (*++arg) { +switch (*arg) { +case 'l' : +if (--argc <=0 ) +return CMD_RET_USAGE ; + buf_addr =simple_strtoul (*++argv,NULL ,16 ); + goto NXTARG; + +case 's' : +if (--argc <=0 ) +return CMD_RET_USAGE ; + buf_size =simple_strtoul (*++argv,NULL ,16 ); + goto NXTARG; + +default : +return CMD_RET_USAGE ; + } + } +NXTARG: + ; + } + +fastboot_init ((void *)buf_addr, buf_size); + +if (!strcmp (argv[1 ],"udp" )) +return do_fastboot_udp (argc, argv, buf_addr, buf_size); + +if (!strcmp (argv[1 ],"usb" )) { + argv++; + argc--; + } + +return do_fastboot_usb (argc, argv, buf_addr, buf_size); } +#ifdef CONFIG_SYS_LONGHELP +static char fastboot_help_text[] = +"[-l addr] [-s size] usb <controller> | udp\n" +"\taddr - address of buffer used during data transfers (" + __stringify(CONFIG_FASTBOOT_BUF_ADDR) ")\n" +"\tsize - size of buffer used during data transfers (" + __stringify(CONFIG_FASTBOOT_BUF_SIZE) ")" + ; +#endif +U_BOOT_CMD ( - fastboot,2 ,1 , do_fastboot, -"use USB Fastboot protocol" , -"<USB_controller>\n" -" - run as a fastboot usb device" + fastboot,CONFIG_SYS_MAXARGS ,1 , do_fastboot, +"run as a fastboot usb or udp device" , fastboot_help_text );drivers/fastboot/Kconfig +7
-0@@ -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/Kconfig config FASTBOOT_MBR_NAME · line 135
Quoted 10 lines
drivers/fastboot/Kconfig +7
-0@@ -119,6 +126,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.
I think this (feature) deserves its own patch.
Quoted 147 lines
drivers/fastboot/Kconfig +1
-0+ endif # FASTBOOT endmenudrivers/fastboot/Makefile +2
-1@@ -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.odrivers/fastboot/fb_command.c new file +124
-0@@ -0,0 +1,327 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* +* Copyright (C) 2016 The Android Open Source Project +*/ + +#include <common.h> +#include <fastboot.h> +#include <fb_mmc.h> +#include <fb_nand.h> +#include <part.h> +#include <stdlib.h> + +/** +* image_size - final fastboot image size +*/ +static u32 image_size; + +/** +* fastboot_bytes_received - number of bytes received in the current download +*/ +static u32 fastboot_bytes_received; + +/** +* fastboot_bytes_expected - number of bytes expected in the current download +*/ +static u32 fastboot_bytes_expected; + +static void fb_okay (char *,char *); +static void fb_getvar (char *,char *); +static void fb_download (char *,char *); +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH ) +static void fb_flash (char *,char *); +static void fb_erase (char *,char *); +#endif +static void fb_reboot_bootloader (char *,char *); +#if CONFIG_IS_ENABLED (FASTBOOT_CMD_OEM_FORMAT ) +static void fb_oem_format (char *,char *); +#endif + +static const struct { +const char *command; +void (*dispatch)(char *cmd_parameter,char *response); +} fb_commands[FASTBOOT_COMMAND_COUNT ] = { + [FASTBOOT_COMMAND_GETVAR ] = { + .command ="getvar" , + .dispatch = fb_getvar + }, + [FASTBOOT_COMMAND_DOWNLOAD ] = { + .command ="download" , + .dispatch = fb_download + }, +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH) + [FASTBOOT_COMMAND_FLASH] = { + .command ="flash" , + .dispatch = fb_flash + }, + [FASTBOOT_COMMAND_ERASE ] = { + .command ="erase" , + .dispatch = fb_erase + }, +#endif + [FASTBOOT_COMMAND_BOOT ] = { + .command ="boot" , + .dispatch = fb_okay + }, + [FASTBOOT_COMMAND_CONTINUE ] = { + .command ="continue" , + .dispatch = fb_okay + }, + [FASTBOOT_COMMAND_REBOOT ] = { + .command ="reboot" , + .dispatch = fb_okay + }, + [FASTBOOT_COMMAND_REBOOT_BOOTLOADER ] = { + .command ="reboot-bootloader" , + .dispatch = fb_reboot_bootloader + }, + [FASTBOOT_COMMAND_SET_ACTIVE ] = { + .command ="set_active" , + .dispatch = fb_okay + }, +#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT) + [FASTBOOT_COMMAND_OEM_FORMAT] = { + .command ="oem format" , + .dispatch = fb_oem_format, + }, +#endif +}; + +/** +* fastboot_get_bytes_remaining() - return bytes remaining in current transfer +* +* Return: Number of bytes left in the current download +*/ +u32 fastboot_get_bytes_remaining (void ) +{ +return fastboot_bytes_expected - fastboot_bytes_received; +} + +/** +* fastboot_handle_command - Handle fastboot command +* +* @cmd_string: Pointer to command string +* @response: Pointer to fastboot response buffer +* +* Return: Executed command, or -1 if not recognized +*/ +int fastboot_handle_command (char *cmd_string,char *response) +{ +int i; +char *cmd_parameter; + + cmd_parameter = cmd_string; +strsep (&cmd_parameter,":" ); + +for (i =0 ; i <FASTBOOT_COMMAND_COUNT ; i++) { +if (!strcmp (fb_commands[i].command, cmd_string)) { +if (fb_commands[i].dispatch) { + fb_commands[i].dispatch (cmd_parameter, + response); +return i; + }else { +break ; + }
drivers/fastboot/fb_command.c line 134
Quoted 10 lines
drivers/fastboot/fb_command.c new file +10
-0+ } + } + +pr_err ("command %s not recognized.\n" , cmd_string); +fastboot_fail ("unrecognized command" , response); +return -1 ; +} + +/** +* fb_okay() - Send bare OKAY response
It would be good to settle on "fastboot" or "fb" and not use both. It seems many of the "fb" are static, but some are not. Static really don't need any scoping like "fb_".
Quoted 1,345 lines
drivers/fastboot/fb_command.c new file +193
-0+* +* @cmd_parameter: Pointer to command parameter +* @response: Pointer to fastboot response buffer +* +* Send a bare OKAY fastboot response. This is used where the command is +* valid, but all the work is done after the response has been sent (e.g. +* boot, reboot etc.) +*/ +static void fb_okay (char *cmd_parameter,char *response) +{ +fastboot_okay (NULL , response); +} + +/** +* fb_getvar() - Read a config/version variable +* +* @cmd_parameter: Pointer to command parameter +* @response: Pointer to fastboot response buffer +*/ +static void fb_getvar (char *cmd_parameter,char *response) +{ +fastboot_getvar (cmd_parameter, response); +} + +/** +* fastboot_download() - Start a download transfer from the client +* +* @cmd_parameter: Pointer to command parameter +* @response: Pointer to fastboot response buffer +*/ +static void fb_download (char *cmd_parameter,char *response) +{ +char *tmp; + +if (!cmd_parameter) { +fastboot_fail ("Expected command parameter" , response); +return ; + } + fastboot_bytes_received =0 ; + fastboot_bytes_expected =simple_strtoul (cmd_parameter, &tmp,16 ); +if (fastboot_bytes_expected ==0 ) { +fastboot_fail ("Expected nonzero image size" , response); +return ; + } +/* +* Nothing to download yet. Response is of the form: +* [DATA|FAIL]$cmd_parameter +* +* where cmd_parameter is an 8 digit hexadecimal number +*/ +if (fastboot_bytes_expected >fastboot_get_buf_size ()) { +fastboot_fail (cmd_parameter, response); + }else { +printf ("Starting download of %d bytes\n" , + fastboot_bytes_expected); +fastboot_response ("DATA" , response,"%s" , cmd_parameter); + } +} + +/** +* fastboot_download_data() - Copy image data to fastboot_buf_addr. +* +* @fastboot_data: Pointer to received fastboot data +* @fastboot_data_len: Length of received fastboot data +* @response: Pointer to fastboot response buffer +* +* Copies image data from fastboot_data to fastboot_buf_addr. Writes to +* response. fastboot_bytes_received is updated to indicate the number +* of bytes that have been transferred. +* +* On completion sets image_size and ${filesize} to the total size of the +* downloaded image. +*/ +void fastboot_download_data (const void *fastboot_data, +unsigned int fastboot_data_len, +char *response) +{ +if (fastboot_data_len ==0 && + fastboot_bytes_received >= fastboot_bytes_expected) { +/* Download complete. Respond with "OKAY" */ +fastboot_okay (NULL , response); +printf ("\ndownloading of %d bytes finished\n" , + fastboot_bytes_received); + image_size = fastboot_bytes_received; +env_set_hex ("filesize" , image_size); + fastboot_bytes_expected =0 ; + fastboot_bytes_received =0 ; + }else { +#define BYTES_PER_DOT 0x20000 +u32 pre_dot_num, now_dot_num; + +if (fastboot_data_len ==0 || + (fastboot_bytes_received + fastboot_data_len) > + fastboot_bytes_expected) { +fastboot_fail ("Received invalid data length" , + response); +return ; + } +/* Download data to fastboot_buf_addr */ +memcpy (fastboot_get_buf_addr () + fastboot_bytes_received, + fastboot_data, fastboot_data_len); + + pre_dot_num = fastboot_bytes_received /BYTES_PER_DOT ; + fastboot_bytes_received += fastboot_data_len; + now_dot_num = fastboot_bytes_received /BYTES_PER_DOT ; + +if (pre_dot_num != now_dot_num) { +putc ('.' ); +if (!(now_dot_num %74 )) +putc ('\n' ); + } + } +} + +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH ) +/** +* fb_flash() - write the downloaded image to the indicated partition. +* +* @cmd_parameter: Pointer to partition name +* @response: Pointer to fastboot response buffer +* +* Writes the previously downloaded image to the partition indicated by +* cmd_parameter. Writes to response. +*/ +static void fb_flash (char *cmd_parameter,char *response) +{ +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH_MMC ) +fb_mmc_flash_write (cmd_parameter,fastboot_get_buf_addr (), image_size, + response); +#endif +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH_NAND ) +fb_nand_flash_write (cmd_parameter,fastboot_get_buf_addr (), image_size, + response); +#endif +} + +/** +* fb_erase() - erase the indicated partition. +* +* @cmd_parameter: Pointer to partition name +* @response: Pointer to fastboot response buffer +* +* Erases the partition indicated by cmd_parameter (clear to 0x00s). Writes +* to response. +*/ +static void fb_erase (char *cmd_parameter,char *response) +{ +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH_MMC ) +fb_mmc_erase (cmd_parameter, response); +#endif +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH_NAND ) +fb_nand_erase (cmd_parameter, response); +#endif +} +#endif + +/** +* fb_reboot_bootloader() - Sets reboot bootloader flag. +* +* @cmd_parameter: Pointer to command parameter +* @response: Pointer to fastboot response buffer +*/ +static void fb_reboot_bootloader (char *cmd_parameter,char *response) +{ +if (fastboot_set_reboot_flag ()) +fastboot_fail ("Cannot set reboot flag" , response); +else +fastboot_okay (NULL , response); +} + +#if CONFIG_IS_ENABLED (FASTBOOT_CMD_OEM_FORMAT ) +/** +* fb_oem_format() - Execute the OEM format command +* +* @cmd_parameter: Pointer to command parameter +* @response: Pointer to fastboot response buffer +*/ +static void fb_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 drivers/fastboot/fb_common.c +113
-0@@ -12,6 +12,22 @@#include <common.h> #include <fastboot.h> +#include <net/fastboot.h> + +/** +* fastboot_buf_addr - base address of the fastboot download buffer +*/ +static void *fastboot_buf_addr; + +/** +* fastboot_buf_size - size of the fastboot download buffer +*/ +static u32 fastboot_buf_size; + +/** +* fastboot_progress_callback - callback executed during long operations +*/ +static void (*fastboot_progress_callback)(const char *msg);/** * fastboot_response() - Writes a response of the form "$tag$reason". @@ -75,3 +91,100 @@ int __weak fastboot_set_reboot_flag(void) {return -ENOSYS ; } + +/** +* fastboot_get_buf_addr() - Return address of the fastboot transfer buffer +* +* Return: Address of the fastboot transfer buffer +*/ +void *fastboot_get_buf_addr (void ) +{ +return fastboot_buf_addr; +} + +/** +* fastboot_get_buf_size() - Return size of the fastboot transfer buffer +* +* Return: Size of the fastboot transfer buffer +*/ +u32 fastboot_get_buf_size (void ) +{ +return fastboot_buf_size; +} + +/** +* fastboot_get_progress_callback() - Return progress callback +* +* Return: Pointer to function called during long operations +*/ +void (*fastboot_get_progress_callback (void ))(const char *) +{ +return fastboot_progress_callback; +} + +/** +* fastboot_boot() - Execute fastboot boot command +* +* If ${fastboot_bootcmd} is set, run that command to execute the boot +* process, if that returns, then exit the fastboot server and return +* control to the caller. +* +* Otherwise execute "bootm <fastboot_buf_addr>", if that fails, reset +* the board. +*/ +void fastboot_boot (void ) +{ +char *s; + + s =env_get ("fastboot_bootcmd" ); +if (s) { +run_command (s,CMD_FLAG_ENV ); + }else { +static char boot_addr_start[12 ]; +static char *const bootm_args[] = { +"bootm" , boot_addr_start,NULL + }; + +snprintf (boot_addr_start,sizeof (boot_addr_start) -1 , +"0x%p" , fastboot_buf_addr); +printf ("Booting kernel at %s...\n\n\n" , boot_addr_start); + +do_bootm (NULL ,0 ,2 , bootm_args); + +/* +* This only happens if image is somehow faulty so we start +* over. We deliberately leave this policy to the invocation +* of fastbootcmd if that's what's being run +*/ +do_reset (NULL ,0 ,0 ,NULL ); + } +} + +/** +* fastboot_set_progress_callback() - set progress callback +* +* @progress: Pointer to progress callback +* +* Set a callback which is invoked periodically during long running operations +* (flash and erase). This can be used (for example) by the UDP transport to +* send INFO responses to keep the client alive whilst those commands are +* executing. +*/ +void fastboot_set_progress_callback (void (*progress)(const char *msg)) +{ + fastboot_progress_callback = progress; +} + +/* +* fastboot_init() - initialise new fastboot protocol session +* +* @buf_addr: Pointer to download buffer, or NULL for default +* @buf_size: Size of download buffer, or zero for default +*/ +void fastboot_init (void *buf_addr,u32 buf_size) +{ + fastboot_buf_addr = buf_addr ? buf_addr : + (void *)CONFIG_FASTBOOT_BUF_ADDR ; + fastboot_buf_size = buf_size ? buf_size :CONFIG_FASTBOOT_BUF_SIZE ; +fastboot_set_progress_callback (NULL ); +}drivers/fastboot/fb_getvar.c new file +229
-0@@ -0,0 +1,229 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* +* Copyright (C) 2016 The Android Open Source Project +*/ + +#include <common.h> +#include <fastboot.h> +#include <fb_mmc.h> +#include <fb_nand.h> +#include <fs.h> +#include <version.h> + +static void fb_getvar_version (char *var_parameter,char *response); +static void fb_getvar_bootloader_version (char *var_parameter,char *response); +static void fb_getvar_downloadsize (char *var_parameter,char *response); +static void fb_getvar_serialno (char *var_parameter,char *response); +static void fb_getvar_version_baseband (char *var_parameter,char *response); +static void fb_getvar_product (char *var_parameter,char *response); +static void fb_getvar_current_slot (char *var_parameter,char *response); +static void fb_getvar_slot_suffixes (char *var_parameter,char *response); +static void fb_getvar_has_slot (char *var_parameter,char *response); +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH_MMC ) +static void fb_getvar_partition_type (char *part_name,char *response); +#endif +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH ) +static void fb_getvar_partition_size (char *part_name,char *response); +#endif + +static const struct { +const char *variable; +void (*dispatch)(char *var_parameter,char *response); +} fb_getvar_dispatch[] = { + { + .variable ="version" , + .dispatch = fb_getvar_version + }, { + .variable ="bootloader-version" , + .dispatch = fb_getvar_bootloader_version + }, { + .variable ="version-bootloader" , + .dispatch = fb_getvar_bootloader_version + }, { + .variable ="downloadsize" , + .dispatch = fb_getvar_downloadsize + }, { + .variable ="max-download-size" , + .dispatch = fb_getvar_downloadsize + }, { + .variable ="serialno" , + .dispatch = fb_getvar_serialno + }, { + .variable ="version-baseband" , + .dispatch = fb_getvar_version_baseband + }, { + .variable ="product" , + .dispatch = fb_getvar_product + }, { + .variable ="current-slot" , + .dispatch = fb_getvar_current_slot + }, { + .variable ="slot-suffixes" , + .dispatch = fb_getvar_slot_suffixes + }, { + .variable ="has_slot" , + .dispatch = fb_getvar_has_slot +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC) + }, { + .variable ="partition-type" , + .dispatch = fb_getvar_partition_type +#endif +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH) + }, { + .variable ="partition-size" , + .dispatch = fb_getvar_partition_size +#endif + } +}; + +static void fb_getvar_version (char *var_parameter,char *response) +{ +fastboot_okay (FASTBOOT_VERSION , response); +} + +static void fb_getvar_bootloader_version (char *var_parameter,char *response) +{ +fastboot_okay (U_BOOT_VERSION , response); +} + +static void fb_getvar_downloadsize (char *var_parameter,char *response) +{ +fastboot_response ("OKAY" , response,"0x%08x" ,fastboot_get_buf_size ()); +} + +static void fb_getvar_serialno (char *var_parameter,char *response) +{ +const char *tmp =env_get ("serial#" ); + +if (tmp) +fastboot_okay (tmp, response); +else +fastboot_fail ("Value not set" , response); +} + +static void fb_getvar_version_baseband (char *var_parameter,char *response) +{ +fastboot_okay ("N/A" , response); +} + +static void fb_getvar_product (char *var_parameter,char *response) +{ +const char *board =env_get ("board" ); + +if (board) +fastboot_okay (board, response); +else +fastboot_fail ("Board not set" , response); +} + +static void fb_getvar_current_slot (char *var_parameter,char *response) +{ +/* A/B not implemented, for now always return _a */ +fastboot_okay ("_a" , response); +} + +static void fb_getvar_slot_suffixes (char *var_parameter,char *response) +{ +fastboot_okay ("_a,_b" , response); +} + +static void fb_getvar_has_slot (char *part_name,char *response) +{ +if (part_name && (!strcmp (part_name,"boot" ) || + !strcmp (part_name,"system" ))) +fastboot_okay ("yes" , response); +else +fastboot_okay ("no" , response); +} + +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH_MMC ) +static void fb_getvar_partition_type (char *part_name,char *response) +{ +int r; +struct blk_desc *dev_desc; +disk_partition_t part_info; + + r =fastboot_mmc_get_part_info (part_name, &dev_desc, &part_info, + response); +if (r >=0 ) { + r =fs_set_blk_dev_with_part (dev_desc, r); +if (r <0 ) +fastboot_fail ("failed to set partition" , response); +else +fastboot_okay (fs_get_type_name (), response); + } +} +#endif + +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH ) +static void fb_getvar_partition_size (char *part_name,char *response) +{ +int r; +size_t size; + +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH_MMC ) +struct blk_desc *dev_desc; +disk_partition_t part_info; + + r =fastboot_mmc_get_part_info (part_name, &dev_desc, &part_info, + response); +if (r >=0 ) + size = part_info.size; +#endif +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH_NAND ) +struct part_info *part_info; + + r =fastboot_nand_get_part_info (part_name, &part_info, response); +if (r >=0 ) + size = part_info->size; +#endif +if (r >=0 ) +fastboot_response ("OKAY" , response,"0x%016zx" , size); +} +#endif + +/** +* 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) +{ +if (!cmd_parameter) { +fastboot_fail ("missing var" , response); + }else { +#define FASTBOOT_ENV_PREFIX "fastboot." +int i; +char *var_parameter = cmd_parameter; +char envstr[FASTBOOT_RESPONSE_LEN ]; +const char *s; + +snprintf (envstr,sizeof (envstr) -1 , +FASTBOOT_ENV_PREFIX "%s" , cmd_parameter); + s =env_get (envstr); +if (s) { +fastboot_response ("OKAY" , response,"%s" , s); +return ; + } + +strsep (&var_parameter,":" ); +for (i =0 ; i <ARRAY_SIZE (fb_getvar_dispatch); ++i) { +if (!strcmp (fb_getvar_dispatch[i].variable, + cmd_parameter)) { + fb_getvar_dispatch[i].dispatch (var_parameter, + response); +return ; + } + } +pr_warn ("WARNING: unknown variable: %s\n" , cmd_parameter); +fastboot_fail ("Variable not implemented" , response); + } +}drivers/fastboot/fb_mmc.c +70
-6@@ -15,6 +15,8 @@#include <linux/compat.h> #include <android_image.h> +#define FASTBOOT_MAX_BLK_WRITE 16384 +#define BOOT_PARTITION_NAME "boot"struct fb_mmc_sparse {@@ -43,13 +45,49 @@ static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,return ret; } +/** +* fb_mmc_blk_write() - Write/erase MMC in chunks of FASTBOOT_MAX_BLK_WRITE +* +* @block_dev: Pointer to block device +* @start: First block to write/erase +* @blkcnt: Count of blocks +* @buffer: Pointer to data buffer for write or NULL for erase +*/ +static lbaint_t fb_mmc_blk_write (struct blk_desc *block_dev,lbaint_t start, +lbaint_t blkcnt,const void *buffer) +{ +lbaint_t blk = start; +lbaint_t blks_written; +lbaint_t cur_blkcnt; +lbaint_t blks =0 ; +int i; +void (*progress)(const char *) =fastboot_get_progress_callback (); + +for (i =0 ; i < blkcnt; i +=FASTBOOT_MAX_BLK_WRITE ) { + cur_blkcnt =min ((int )blkcnt - i,FASTBOOT_MAX_BLK_WRITE ); +if (buffer) { +if (progress) +progress ("writing" ); + blks_written =blk_dwrite (block_dev, blk, cur_blkcnt, + buffer + (i * block_dev->blksz)); + }else { +if (progress) +progress ("erasing" ); + blks_written =blk_derase (block_dev, blk, cur_blkcnt); + } + blk += blks_written; + blks += blks_written; + } +return blks; +} +static lbaint_t fb_mmc_sparse_write (struct sparse_storage *info,lbaint_t blk,lbaint_t blkcnt,const void *buffer) {struct fb_mmc_sparse *sparse = info->priv;struct blk_desc *dev_desc = sparse->dev_desc; -return blk_dwrite (dev_desc, blk, blkcnt, buffer); +return fb_mmc_blk_write (dev_desc, blk, blkcnt, buffer); } static lbaint_t fb_mmc_sparse_reserve(struct sparse_storage *info,@@ -60,7 +98,7 @@ static lbaint_t fb_mmc_sparse_reserve(struct sparse_storage *info,static void write_raw_image (struct blk_desc *dev_desc,disk_partition_t *info,const char *part_name,void *buffer, -unsigned int download_bytes,char *response) +u32 download_bytes,char *response) {lbaint_t blkcnt;lbaint_t blks;@@ -77,7 +115,8 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info,puts ("Flashing Raw Image\n" ); - blks =blk_dwrite (dev_desc, info->start, blkcnt, buffer); + blks =fb_mmc_blk_write (dev_desc, info->start, blkcnt, buffer); +if (blks != blkcnt) {pr_err ("failed writing to device %d\n" , dev_desc->devnum);fastboot_fail ("failed writing to device" , response);@@ -148,7 +187,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc,*/ static int fb_mmc_update_zimage (struct blk_desc *dev_desc,void *download_buffer, -unsigned int download_bytes, +u32 download_bytes,char *response) {uintptr_t hdr_addr;/* boot image header address */ @@ -251,8 +290,32 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, }#endif +int fastboot_mmc_get_part_info (char *part_name,struct blk_desc **dev_desc, +disk_partition_t *part_info,char *response) +{ +int r; + + *dev_desc =blk_get_dev ("mmc" ,CONFIG_FASTBOOT_FLASH_MMC_DEV ); +if (!*dev_desc) { +fastboot_fail ("block device not found" , response); +return -ENOENT ; + } +if (!part_name) { +fastboot_fail ("partition not found" , response); +return -ENOENT ; + } + + r =part_get_info_by_name_or_alias (*dev_desc, part_name, part_info); +if (r <0 ) { +fastboot_fail ("partition not found" , response); +return r; + } + +return r; +} +void fb_mmc_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes,char *response) +u32 download_bytes,char *response) {struct blk_desc *dev_desc;disk_partition_t info;@@ -389,7 +452,8 @@ void fb_mmc_erase(const char *cmd, char *response)printf ("Erasing blocks " LBAFU " to " LBAFU " due to alignment\n" , blks_start, blks_start + blks_size); - blks =blk_derase (dev_desc, blks_start, blks_size); + blks =fb_mmc_blk_write (dev_desc, blks_start, blks_size,NULL ); +if (blks != blks_size) {pr_err ("failed erasing from device %d\n" , dev_desc->devnum);fastboot_fail ("failed erasing from device" , response);drivers/fastboot/fb_nand.c +10
-2@@ -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,8 +145,16 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info,return blkcnt + bad_blocks; } +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); +} +void fb_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.h +157
-0@@ -15,13 +15,170 @@#define FASTBOOT_VERSION "0.4"/* The 64 defined bytes plus \0 */ +#define FASTBOOT_COMMAND_LEN (64 + 1)#define FASTBOOT_RESPONSE_LEN (64 + 1) +/** +* All known commands to fastboot +*/ +enum { +FASTBOOT_COMMAND_GETVAR =0 , +FASTBOOT_COMMAND_DOWNLOAD , +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH ) +FASTBOOT_COMMAND_FLASH , +FASTBOOT_COMMAND_ERASE , +#endif +FASTBOOT_COMMAND_BOOT , +FASTBOOT_COMMAND_CONTINUE , +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 +}; + +/** +* fastboot_response() - Writes a response of the form "$tag$reason". +* +* @param tag The first part of the response +* @param response Pointer to fastboot response buffer +* @param 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". +* +* @param reason Pointer to returned reason string +* @param 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". +* +* @param reason Pointer to returned reason string. +* Can be NULL to send a bare "OKAY" response. +* @param response Pointer to fastboot response buffer +*/ void fastboot_okay (const char *reason,char *response); + +/** +* 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 fastboot_set_reboot_flag (void ); + +/** +* fastboot_get_buf_addr() - Return address of the fastboot transfer buffer +* +* Return: Address of the fastboot transfer buffer +*/ +void *fastboot_get_buf_addr (void ); + +/** +* fastboot_get_buf_size() - Return size of the fastboot transfer buffer +* +* Return: Size of the fastboot transfer buffer +*/ +u32 fastboot_get_buf_size (void ); + +/** +* fastboot_get_bytes_remaining() - return bytes remaining in current transfer +* +* Return: Number of bytes left in the current download +*/ +u32 fastboot_get_bytes_remaining (void ); + +/** +* fastboot_get_progress_callback() - Return progress callback +* +* Return: Pointer to function called during long operations +*/ +void (*fastboot_get_progress_callback (void ))(const char *); + +/** +* 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); + +/** +* fastboot_set_progress_callback() - set progress callback +* +* @progress: Pointer to progress callback +* +* Set a callback which is invoked periodically during long running operations +* (flash and erase). This can be used (for example) by the UDP transport to +* send INFO responses to keep the client alive whilst those commands are +* executing. +*/ +void fastboot_set_progress_callback (void (*progress)(const char *msg)); + +/* +* fastboot_init() - initialise new fastboot protocol session +* +* @buf_addr: Pointer to download buffer, or NULL for default +* @buf_size: Size of download buffer, or zero for default +*/ +void fastboot_init (void *buf_addr,u32 buf_size); + +/** +* fastboot_boot() - Execute fastboot boot command +* +* If ${fastboot_bootcmd} is set, run that command to execute the boot +* process, if that returns, then exit the fastboot server and return +* control to the caller. +* +* Otherwise execute "bootm <fastboot_buf_adder>", if that fails, reset +* the board. +*/ +void fastboot_boot (void ); + +/** +* fastboot_handle_command() - Handle fastboot command +* +* @cmd_string: Pointer to command string +* @response: Pointer to fastboot response buffer +* +* Return: Executed command, or -1 if not recognized +*/ +int fastboot_handle_command (char *cmd_string,char *response); + +/** +* fastboot_download_data() - Copy image data to fastboot_buf_addr. +* +* @fastboot_data: Pointer to received fastboot data +* @fastboot_data_len: Length of received fastboot data +* @response: Pointer to fastboot response buffer +* +* Copies image data from fastboot_data to fastboot_buf_addr. Writes to +* response. fastboot_bytes_received is updated to indicate the number +* of bytes that have been transferred. +* +* On completion sets image_size and ${filesize} to the total size of the +* downloaded image. +*/ +void fastboot_download_data (const void *fastboot_data, +unsigned int fastboot_data_len,char *response);#endif /* _FASTBOOT_H_ */ include/fb_mmc.h +7
-1@@ -3,6 +3,12 @@* Copyright 2014 Broadcom Corporation. */ +#ifndef _FB_MMC_H_ +#define _FB_MMC_H_ + +int fastboot_mmc_get_part_info (char *part_name,struct blk_desc **dev_desc, +disk_partition_t *part_info,char *response);void fb_mmc_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes,char *response); +u32 download_bytes,char *response);void fb_mmc_erase (const char *cmd,char *response); +#endif include/fb_nand.h +9
-1@@ -4,6 +4,14 @@* Copyright 2015 Free Electrons. */ +#ifndef _FB_NAND_H_ +#define _FB_NAND_H_ + +#include <jffs2/load_kernel.h> + +int fastboot_nand_get_part_info (char *part_name,struct part_info **part_info, +char *response);void fb_nand_flash_write (const char *cmd,void *download_buffer, -unsigned int download_bytes,char *response); +u32 download_bytes,char *response);void fb_nand_erase (const char *cmd,char *response); +#endif include/net.h +1
-1@@ -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@@ -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@@ -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 +312
-0@@ -0,0 +1,312 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* +* Copyright (C) 2016 The Android Open Source Project +*/ + +#include <common.h> +#include <fastboot.h> +#include <net.h> +#include <net/fastboot.h> + +/* Fastboot port # defined in spec */ +#define WELL_KNOWN_PORT 5554 + +enum { +FASTBOOT_ERROR =0 , +FASTBOOT_QUERY =1 , +FASTBOOT_INIT =2 , +FASTBOOT_FASTBOOT =3 , +}; + +struct __packed fastboot_header { +uchar id; +uchar flags; +unsigned short seq; +}; + +#define PACKET_SIZE 1024 +#define DATA_SIZE (PACKET_SIZE - sizeof(struct fastboot_header)) + +/* Sequence number sent for every packet */ +static unsigned short fb_sequence_number =1 ; +static const unsigned short fb_packet_size =PACKET_SIZE ; +static const unsigned short fb_udp_version =1 ; + +/* Keep track of last packet for resubmission */ +static uchar last_packet[PACKET_SIZE ]; +static unsigned int last_packet_len; + +static struct in_addr fastboot_remote_ip; +/* The UDP port at their end */ +static int fastboot_remote_port; +/* The UDP port at our end */ +static int fastboot_our_port; + +static void boot_downloaded_image (void ); + +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH ) +/** +* fastboot_udp_send_info() - Send an INFO packet during long commands. +* +* @msg: String describing the reason for waiting +*/ +static void fastboot_udp_send_info (const char *msg) +{ +uchar *packet; +uchar *packet_base; +int len =0 ; +char response[FASTBOOT_RESPONSE_LEN ] = {0 }; + +struct fastboot_header fb_response_header = { + .id =FASTBOOT_FASTBOOT , + .flags =0 , + .seq =htons (fb_sequence_number) + }; + ++fb_sequence_number; + packet = net_tx_packet +net_eth_hdr_size () +IP_UDP_HDR_SIZE ; + packet_base = packet; + +/* Write headers */ +memcpy (packet, &fb_response_header,sizeof (fb_response_header)); + packet +=sizeof (fb_response_header); +/* Write response */ +fastboot_response ("INFO" , response,"%s" , msg); +memcpy (packet, response,strlen (response)); + packet +=strlen (response); + + len = packet - packet_base; + +/* Save packet for retransmitting */ + last_packet_len = len; +memcpy (last_packet, packet_base, last_packet_len); + +net_send_udp_packet (net_server_ethaddr, fastboot_remote_ip, + fastboot_remote_port, fastboot_our_port, len); +} + +/** +* fastboot_timed_send_info() - Send INFO packet every 30 seconds +* +* @msg: String describing the reason for waiting +* +* Send an INFO packet during long commands based on timer. An INFO packet +* is sent if the time is 30 seconds after start. Else, noop. +*/ +static void fastboot_timed_send_info (const char *msg) +{ +static ulong start; + +/* Initialize timer */ +if (start ==0 ) + start =get_timer (0 ); +ulong time =get_timer (start); +/* Send INFO packet to host every 30 seconds */ +if (time >=30000 ) { + start =get_timer (0 ); +fastboot_udp_send_info (msg); + } +} +#endif + +/** +* fastboot_send() - Sends a packet in response to received fastboot packet +* +* @fb_header: Header for response packet +* @fastboot_data: Pointer to received fastboot data +* @fastboot_data_len: Length of received fastboot data +* @retransmit: Nonzero if sending last sent packet +*/ +static void fastboot_send (struct fastboot_header fb_header,char *fastboot_data, +unsigned int fastboot_data_len,uchar retransmit) +{ +uchar *packet; +uchar *packet_base; +int len =0 ; +const char *error_msg ="An error occurred." ; +short tmp; +struct fastboot_header fb_response_header = fb_header; +static char command[FASTBOOT_COMMAND_LEN ]; +static int cmd =-1 ; +static bool pending_command; +char response[FASTBOOT_RESPONSE_LEN ] = {0 }; + +/* +* We will always be sending some sort of packet, so +* cobble together the packet headers now. +*/ + packet = net_tx_packet +net_eth_hdr_size () +IP_UDP_HDR_SIZE ; + packet_base = packet; + +/* Resend last packet */ +if (retransmit) { +memcpy (packet, last_packet, last_packet_len); +net_send_udp_packet (net_server_ethaddr, fastboot_remote_ip, + fastboot_remote_port, fastboot_our_port, + last_packet_len); +return ; + } + + fb_response_header.seq =htons (fb_response_header.seq); +memcpy (packet, &fb_response_header,sizeof (fb_response_header)); + packet +=sizeof (fb_response_header); + +switch (fb_header.id) { +case FASTBOOT_QUERY : + tmp =htons (fb_sequence_number); +memcpy (packet, &tmp,sizeof (tmp)); + packet +=sizeof (tmp); +break ; +case FASTBOOT_INIT : + tmp =htons (fb_udp_version); +memcpy (packet, &tmp,sizeof (tmp)); + packet +=sizeof (tmp); + tmp =htons (fb_packet_size); +memcpy (packet, &tmp,sizeof (tmp)); + packet +=sizeof (tmp); +break ; +case FASTBOOT_ERROR : +memcpy (packet, error_msg,strlen (error_msg)); + packet +=strlen (error_msg); +break ; +case FASTBOOT_FASTBOOT : +if (cmd ==FASTBOOT_COMMAND_DOWNLOAD ) { +fastboot_download_data (fastboot_data, fastboot_data_len, + response); + }else if (!pending_command) { +strlcpy (command, fastboot_data, +min ((size_t )fastboot_data_len +1 , +sizeof (command))); + pending_command = true; + }else { + cmd =fastboot_handle_command (command, response); + pending_command = false; + } +/* +* Sent some INFO packets, need to update sequence number in +* header +*/ +if (fb_header.seq != fb_sequence_number) { + fb_response_header.seq =htons (fb_sequence_number); +memcpy (packet_base, &fb_response_header, +sizeof (fb_response_header)); + } +/* Write response to packet */ +memcpy (packet, response,strlen (response)); + packet +=strlen (response); +break ; +default : +pr_err ("ID %d not implemented.\n" , fb_header.id); +return ; + } + + len = packet - packet_base; + +/* Save packet for retransmitting */ + last_packet_len = len; +memcpy (last_packet, packet_base, last_packet_len); + +net_send_udp_packet (net_server_ethaddr, fastboot_remote_ip, + fastboot_remote_port, fastboot_our_port, len); + +/* Continue boot process after sending response */ +if (!strncmp ("OKAY" , response,4 )) { +switch (cmd) { +case FASTBOOT_COMMAND_BOOT : +boot_downloaded_image (); +break ; + +case FASTBOOT_COMMAND_CONTINUE : +net_set_state (NETLOOP_SUCCESS ); +break ; + +case FASTBOOT_COMMAND_REBOOT : +case FASTBOOT_COMMAND_REBOOT_BOOTLOADER : +do_reset (NULL ,0 ,0 ,NULL ); +break ; + } + } + +if (!strncmp ("OKAY" , response,4 ) || !strncmp ("FAIL" , response,4 )) + cmd =-1 ; +} + +/** +* boot_downloaded_image() - Boots into downloaded image. +*/ +static void boot_downloaded_image (void ) +{ +fastboot_boot (); +net_set_state (NETLOOP_SUCCESS ); +} + +/** +* fastboot_handler() - Incoming UDP packet handler. +* +* @packet: Pointer to incoming UDP packet +* @dport: Destination UDP port +* @sip: Source IP address +* @sport: Source UDP port +* @len: Packet length +*/ +static void fastboot_handler (uchar *packet,unsigned int dport, +struct in_addr sip,unsigned int sport, +unsigned int len) +{ +struct fastboot_header fb_header; +char fastboot_data[DATA_SIZE ] = {0 }; +unsigned int fastboot_data_len =0 ; + +if (dport != fastboot_our_port) +return ; + + fastboot_remote_ip = sip; + fastboot_remote_port = sport; + +if (len <sizeof (struct fastboot_header ) || len >PACKET_SIZE ) +return ; +memcpy (&fb_header, packet,sizeof (fb_header)); + fb_header.flags =0 ; + fb_header.seq =ntohs (fb_header.seq); + packet +=sizeof (fb_header); + len -=sizeof (fb_header); + +switch (fb_header.id) { +case FASTBOOT_QUERY : +fastboot_send (fb_header, fastboot_data,0 ,0 ); +break ; +case FASTBOOT_INIT : +case FASTBOOT_FASTBOOT : + fastboot_data_len = len; +if (len >0 ) +memcpy (fastboot_data, packet, len); +if (fb_header.seq == fb_sequence_number) { +fastboot_send (fb_header, fastboot_data, + fastboot_data_len,0 ); + fb_sequence_number++; + }else if (fb_header.seq == fb_sequence_number -1 ) { +/* Retransmit last sent packet */ +fastboot_send (fb_header, fastboot_data, + fastboot_data_len,1 ); + } +break ; +default : +pr_err ("ID %d not implemented.\n" , fb_header.id); + fb_header.id =FASTBOOT_ERROR ; +fastboot_send (fb_header, fastboot_data,0 ,0 ); +break ; + } +} + +void fastboot_start_server (void ) +{ +printf ("Using %s device\n" ,eth_get_name ()); +printf ("Listening for fastboot command on %pI4\n" , &net_ip); + + fastboot_our_port =WELL_KNOWN_PORT ; + +fastboot_set_progress_callback (fastboot_timed_send_info); +net_set_udp_handler (fastboot_handler); + +/* zero out server ether in case the server ip has changed */ +memset (net_server_ethaddr,0 ,6 ); +}net/net.c +7
-1@@ -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" ); --2.7.4
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v4 14/14 net: fastboot: Merge AOSP UDP fastboot
Quoted 1 line · Joe Hershberger
On Tue, May 15, 2018 at 9:48 AM, Alex Kiernan <[email protected]>
Quoted 3 lines · wrote:
Quoted 3 lines
Merge UDP fastboot support from AOSP:
https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8
Quoted 14 lines
Quoted 14 lines
Signed-off-by Alex Kiernan <[email protected]>Signed-off-by Alex Deymo <[email protected]>Signed-off-by Jocelyn Bohr <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes in v4:
- guard fb_getvar/fb_command withUDP_FUNCTION_FASTBOOTinMakefile
- add docbook comments
- remove parameter fromfastboot_boot()since we always wantfastboot_buf_addr(and if we're usingfastboot_bootcmdthen it's ignored)
Quoted 8 lines
Quoted 8 lines
Changes in v3:
- use FASTBOOT as our guard inKconfignot 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
- useCMD_RET_USAGEfromdo_fastboot
- removedo_fastboot_udpfromcmd/net.cand rewrite usingnet_loop()
- renametimed_send_infotofastboot_send_info, rename
fastboot_send_info to
Quoted 4 lines
Quoted 4 lines
fastboot_udp_send_info
- replaceFASTBOOT_HEADER_SIZEwithsizeof(struct fastboot_header)
- move start time intotimed_send_info()rather than passing it in
- make calls tofastboot_udp_send_infoa runtime dependency, not a
compile
Quoted 5 lines
Quoted 5 lines
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
Quoted 3 lines
Quoted 3 lines
fastboot boot command
- make getvar implementation table driven
- addfastboot_buf_addr,fastboot_buf_sizeto override buffer address
and
Quoted 9 lines
Quoted 9 lines
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)
- make global variables static and add accessors for the things which the transport layers need
- squash subsequent patches which change this code into this one:
- If the fastboot flash/erase commands are disabled, remove that
support
Quoted 5 lines
Quoted 5 lines
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
Quoted 1 line
Quoted 1 line
use as a marker on reboot (the AOSP code in
common/android-bootloader.c
Quoted 3 lines
Quoted 3 lines
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
Quoted 2 lines
Quoted 2 lines
UDP no longer passes an fdt. We introduce a new environment variable '
fastboot_bootcmd' which if set overrides the hardcoded boot
command,
Quoted 1 line
Quoted 1 line
setting this then allows the UDP implementation to remain the same.
If
Quoted 1 line
Quoted 1 line
after running '
fastboot_bootcmd' the board has not booted, control
is
Quoted 2 lines
Quoted 2 lines
returned to U-Boot and the fastboot process ends.
- Separate the fastboot protocol handling from the fastboot UDP code
in
Quoted 10 lines
Quoted 10 lines
preparation for reusing it in the USB code.
Changes in v2:
- ensure fastboot syntax is backward compatible - 'fastboot 0' means 'fastboot usb 0'cmd/fastboot.c | 91 +++++++++++- drivers/fastboot/Kconfig | 15 ++ drivers/fastboot/Makefile | 3 +- drivers/fastboot/fb_command.c | 327
++++++++++++++++++++++++++++++++++++++++++
Quoted 11 lines
Quoted 11 lines
drivers/fastboot/fb_common.c | 113 +++++++++++++++ drivers/fastboot/fb_getvar.c | 229 +++++++++++++++++++++++++++++ drivers/fastboot/fb_mmc.c | 76 +++++++++- drivers/fastboot/fb_nand.c | 12 +- include/fastboot.h | 157 ++++++++++++++++++++ include/fb_mmc.h | 8 +- include/fb_nand.h | 10 +- include/net.h | 2 +- include/net/fastboot.h | 21 +++ net/Makefile | 1 + net/fastboot.c | 312
++++++++++++++++++++++++++++++++++++++++
Quoted 19 lines
Quoted 19 lines
net/net.c | 7 + 16 files changed, 1367 insertions(+), 17 deletions(-) create mode 100644 drivers/fastboot/fb_command.c create mode 100644 drivers/fastboot/fb_getvar.c create mode 100644 include/net/fastboot.h create mode 100644 net/fastboot.ccmd/fastboot.c +2
-0@@ -10,10 +10,32 @@#include <command.h> #include <console.h> #include <g_dnl.h> +#include <fastboot.h> +#include <net.h> #include <usb.h>
Quoted 1 line
cmd/fastboot.c line 15
Quoted 1 line
cmd/fastboot.c +0
-1-static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char
*const argv[])
Quoted 28 lines
Quoted 28 lines
cmd/fastboot.c +21
-0+static int do_fastboot_udp (int argc,char *const argv[], +uintptr_t buf_addr,size_t buf_size) { +#if CONFIG_IS_ENABLED (UDP_FUNCTION_FASTBOOT ) +int err =net_loop (FASTBOOT ); + +if (err <0 ) { +printf ("fastboot udp error: %d\n" , err); +return CMD_RET_FAILURE ; + } + +return CMD_RET_SUCCESS ; +#else +pr_err ("Fastboot UDP not enabled\n" ); +return CMD_RET_FAILURE ; +#endif +} + +static int do_fastboot_usb (int argc,char *const argv[], +uintptr_t buf_addr,size_t buf_size) +{ +#if CONFIG_IS_ENABLED (USB_FUNCTION_FASTBOOT )int controller_index;char *usb_controller;int ret;@@ -58,11 +80,70 @@ exit:board_usb_cleanup (controller_index,USB_INIT_DEVICE );
Quoted 8 lines
cmd/fastboot.c exit:
Quoted 8 lines
cmd/fastboot.c +7
-0return ret; +#else +pr_err ("Fastboot USB not enabled\n" ); +return CMD_RET_FAILURE ; +#endif +} + +static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char
*const argv[])
Quoted 9 lines
Quoted 9 lines
cmd/fastboot.c +9
-0+{ +uintptr_t buf_addr = (uintptr_t )NULL ; +size_t buf_size =0 ; + +if (argc <2 ) +return CMD_RET_USAGE ; + +while (argc >1 && **(argv +1 ) =='-' ) { +char *arg = *++argv;
Quoted 8 lines
cmd/fastboot.c exit:
Quoted 8 lines
cmd/fastboot.c +8
-0+ + --argc; +while (*++arg) { +switch (*arg) { +case 'l' : +if (--argc <=0 ) +return CMD_RET_USAGE ; + buf_addr = simple_strtoul(*++argv,
NULL, 16);
Quoted 6 lines
cmd/fastboot.c exit:
Quoted 6 lines
cmd/fastboot.c +6
-0+ goto NXTARG; + +case 's' : +if (--argc <=0 ) +return CMD_RET_USAGE ; + buf_size = simple_strtoul(*++argv,
NULL, 16);
Quoted 58 lines
Quoted 58 lines
cmd/fastboot.c +33
-4+ goto NXTARG; + +default : +return CMD_RET_USAGE ; + } + } +NXTARG: + ; + } + +fastboot_init ((void *)buf_addr, buf_size); + +if (!strcmp (argv[1 ],"udp" )) +return do_fastboot_udp (argc, argv, buf_addr, buf_size); + +if (!strcmp (argv[1 ],"usb" )) { + argv++; + argc--; + } + +return do_fastboot_usb (argc, argv, buf_addr, buf_size); } +#ifdef CONFIG_SYS_LONGHELP +static char fastboot_help_text[] = +"[-l addr] [-s size] usb <controller> | udp\n" +"\taddr - address of buffer used during data transfers (" + __stringify(CONFIG_FASTBOOT_BUF_ADDR) ")\n" +"\tsize - size of buffer used during data transfers (" + __stringify(CONFIG_FASTBOOT_BUF_SIZE) ")" + ; +#endif +U_BOOT_CMD ( - fastboot,2 ,1 , do_fastboot, -"use USB Fastboot protocol" , -"<USB_controller>\n" -" - run as a fastboot usb device" + fastboot,CONFIG_SYS_MAXARGS ,1 , do_fastboot, +"run as a fastboot usb or udp device" , fastboot_help_text );drivers/fastboot/Kconfig +7
-0@@ -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
Quoted 3 lines
drivers/fastboot/Kconfig config FASTBOOT_MBR_NAME · line 126
Quoted 3 lines
drivers/fastboot/Kconfig +0
-0config FASTBOOT_BUF_ADDR@@ -119,6 +126,14 @@ config FASTBOOT_MBR_NAME specified on the "fastboot flash" command line matches the
value
Quoted 1 line
drivers/fastboot/Kconfig config FASTBOOT_MBR_NAME · line 127
Quoted 1 line
drivers/fastboot/Kconfig +0
-0defined here. The default target name for updating MBR is
"mbr".
Quoted 10 lines
drivers/fastboot/Kconfig config FASTBOOT_MBR_NAME · line 135
Quoted 8 lines
drivers/fastboot/Kconfig +7
-0+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.I think this (feature) deserves its own patch.
Not sure why I squashed that as I did have have its own... I'll split it out.
Quoted 11 lines
Quoted 11 lines
drivers/fastboot/Kconfig +1
-0+ endif # FASTBOOT endmenudrivers/fastboot/Makefile +0
-0@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+
Quoted 7 lines
Review
Quoted 7 lines
drivers/fastboot/Makefile +2
-1obj-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(quoted diff) +0
-0
b/drivers/fastboot/fb_command.c
Quoted 16 lines
Quoted 16 lines
new file mode 100644
index 0000000..0ca05ecdrivers/fastboot/fb_command.c new file +11
-0@@ -0,0 +1,327 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* +* Copyright (C) 2016 The Android Open Source Project +*/ + +#include <common.h> +#include <fastboot.h> +#include <fb_mmc.h> +#include <fb_nand.h> +#include <part.h> +#include <stdlib.h>
Quoted 8 lines
drivers/fastboot/fb_command.c
Quoted 8 lines
drivers/fastboot/fb_command.c new file +8
-0+ +/** +* image_size - final fastboot image size +*/ +static u32 image_size; + +/** +* fastboot_bytes_received - number of bytes received in the current
download
Quoted 5 lines
drivers/fastboot/fb_command.c
Quoted 5 lines
drivers/fastboot/fb_command.c new file +5
-0+*/ +static u32 fastboot_bytes_received; + +/** +* fastboot_bytes_expected - number of bytes expected in the current
download
Quoted 59 lines
Quoted 59 lines
drivers/fastboot/fb_command.c new file +59
-0+*/ +static u32 fastboot_bytes_expected; + +static void fb_okay (char *,char *); +static void fb_getvar (char *,char *); +static void fb_download (char *,char *); +#if CONFIG_IS_ENABLED (FASTBOOT_FLASH ) +static void fb_flash (char *,char *); +static void fb_erase (char *,char *); +#endif +static void fb_reboot_bootloader (char *,char *); +#if CONFIG_IS_ENABLED (FASTBOOT_CMD_OEM_FORMAT ) +static void fb_oem_format (char *,char *); +#endif + +static const struct { + const char *command; + void (*dispatch)(char *cmd_parameter, char *response); +} fb_commands[FASTBOOT_COMMAND_COUNT] = { + [FASTBOOT_COMMAND_GETVAR] = { + .command = "getvar", + .dispatch = fb_getvar + }, + [FASTBOOT_COMMAND_DOWNLOAD] = { + .command = "download", + .dispatch = fb_download + }, +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH) + [FASTBOOT_COMMAND_FLASH] = { + .command = "flash", + .dispatch = fb_flash + }, + [FASTBOOT_COMMAND_ERASE] = { + .command = "erase", + .dispatch = fb_erase + }, +#endif + [FASTBOOT_COMMAND_BOOT] = { + .command = "boot", + .dispatch = fb_okay + }, + [FASTBOOT_COMMAND_CONTINUE] = { + .command = "continue", + .dispatch = fb_okay + }, + [FASTBOOT_COMMAND_REBOOT] = { + .command = "reboot", + .dispatch = fb_okay + }, + [FASTBOOT_COMMAND_REBOOT_BOOTLOADER] = { + .command = "reboot-bootloader", + .dispatch = fb_reboot_bootloader + }, + [FASTBOOT_COMMAND_SET_ACTIVE] = { + .command = "set_active", + .dispatch = fb_okay + }, +#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT) + [FASTBOOT_COMMAND_OEM_FORMAT] = {
Quoted 8 lines
drivers/fastboot/fb_command.c
Quoted 8 lines
drivers/fastboot/fb_command.c new file +8
-0+ .command = "oem format", + .dispatch = fb_oem_format, + }, +#endif +}; + +/** +* fastboot_get_bytes_remaining() - return bytes remaining in current
transfer
Quoted 39 lines
Quoted 39 lines
drivers/fastboot/fb_command.c new file +39
-0+* +* Return: Number of bytes left in the current download +*/ +u32 fastboot_get_bytes_remaining (void ) +{ +return fastboot_bytes_expected - fastboot_bytes_received; +} + +/** +* fastboot_handle_command - Handle fastboot command +* +* @cmd_string: Pointer to command string +* @response: Pointer to fastboot response buffer +* +* Return: Executed command, or -1 if not recognized +*/ +int fastboot_handle_command (char *cmd_string,char *response) +{ +int i; +char *cmd_parameter; + + cmd_parameter = cmd_string; +strsep (&cmd_parameter,":" ); + +for (i =0 ; i <FASTBOOT_COMMAND_COUNT ; i++) { +if (!strcmp (fb_commands[i].command, cmd_string)) { +if (fb_commands[i].dispatch) { + fb_commands[i].dispatch (cmd_parameter, + response); +return i; + }else { +break ; + } + } + } + +pr_err ("command %s not recognized.\n" , cmd_string); +fastboot_fail ("unrecognized command" , response); +return -1 ;
Quoted 8 lines
drivers/fastboot/fb_command.c line 134
Quoted 4 lines
drivers/fastboot/fb_command.c new file +4
-0+} + +/** +* fb_okay() - Send bare OKAY response It would be good to settle on "fastboot" or "fb" and not use both. It seems many of the "fb" are static, but some are not. Static really don't need any scoping like "
fb_".
I'm taking fb_ to be frame buffer, fastboot_ is fastboot.
I'll fix them.