From patchwork Tue May 29 15:30:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922202 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pKznGJuy"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wJ561X7qz9s0W for ; Wed, 30 May 2018 01:47:22 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A61BEC21F51; Tue, 29 May 2018 15:47:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, KHOP_BIG_TO_CC, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 102E9C21EA6; Tue, 29 May 2018 15:45:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4BB19C21E45; Tue, 29 May 2018 15:31:10 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by lists.denx.de (Postfix) with ESMTPS id AC778C21E31 for ; Tue, 29 May 2018 15:31:09 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id a67-v6so41664461wmf.3 for ; Tue, 29 May 2018 08:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hxEyAnLQBTdqa/+KeIyiE4avrjon0Kbi1Ujz9/46TmM=; b=pKznGJuyiCNd0uaI8vHyjYd71rnwt5Gya7MBZCFnVqkAPI3GI7d7wYpJojZ1bzq2+R I63hzJi8O5+fiEAAPE0xtbmPYG0AHi+0TfQh1SeIcv9oC5VkN7BN1VQQvciYUNtS3oig IOiRFgC1Tdt/oQRtn5Ln30EkYNnzlyOZzGXz84eLXuvzZn81ICHGDjBcWwObpGb6/iFG W/dwnkRSzceIv6FWfl3tVctsNpNMW1BOFbz13AFeLRcv+bjXpbY7arP/ObB5V2eQvEQ1 wOqUsQpAF6at0cFfRlHkWynhjKrGNKcsJBOcEYUTi/iwn55d/T4hEHtC8kcYGxfo1gyL a4Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hxEyAnLQBTdqa/+KeIyiE4avrjon0Kbi1Ujz9/46TmM=; b=Rb0A6BdNGEuVFtFfzQNW92q9rAZQYKCkjpMGnnvkYc+iyDnobDZXMb32xALwrQw3a2 hv7ul2oi8YaepD6n5D5bMFX/4w16LNRe0/o8e+1kwuSICbUib7xGOs12QUfyjr50DKZn uZ0UakoBkwQ+HC5lWtvObGVDS2XHjpOl1ryD8kSPM2Mv9zuEzkwus9czqh7njUKRbiBz Nil1A/XjC2axgB5+HHJmibAxtSayZBls63S/7CACjc/wUgxI1d24E/9zL1uFL5LVXrTD waZXPtRzseYu5bX+9305SDOl0esgawnqdxKcStXwjf29hl4ICqAx5WwEGN+MzRN3tI4X 0RNg== X-Gm-Message-State: ALKqPwfFjFuS6TV0E+c0DnP9R9gMpwpDhSvcU21IYf0Me12cUzmZYFx0 GqfDIiPsmEFCrjvPSWQ+oepqaijoTIo= X-Google-Smtp-Source: ADUXVKLRHBpExDhVxuiP+76FmGQyn5/5i6CupS6KcfOJr+YH1wOuC1iFmmVz+ywSb+QPzytDDyR8fg== X-Received: by 2002:a1c:b884:: with SMTP id i126-v6mr10748591wmf.30.1527607868699; Tue, 29 May 2018 08:31:08 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:08 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:39 +0000 Message-Id: <20180529153056.27328-2-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> X-Mailman-Approved-At: Tue, 29 May 2018 15:45:57 +0000 Cc: Jocelyn Bohr , Daniel Thompson , Michal Simek , Ian Ray , Wenbin Song , Simone CIANNI , Jocelyn Bohr , Benjamin Young , Otavio Salvador , Gilles Gameiro , Raffaele RECALCATI , Steve Rae , Fabio Estevam , Andy Yan , Maxime Ripard Subject: [U-Boot] [PATCH v8 01/18] fastboot: Move fastboot to drivers/fastboot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Separate CMD_FASTBOOT from FASTBOOT and move code and configuration to drivers/fastboot. Switch dependencies on FASTBOOT to USB_FUNCTION_FASTBOOT as anyone who wants FASTBOOT before this series wants USB_FUNCTION_FASTBOOT. Split USB_FUNCTION_FASTBOOT from FASTBOOT so they retain their existing behaviour. Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass Acked-by: Joe Hershberger --- Changes in v8: None Changes in v7: None Changes in v6: - accomodate master change and switch dependency on imx6dl_mamoj from FASTBOOT to USB_FUNCTION_FASTBOOT Changes in v5: - don't depend on UDP_FUNCTION_FASTBOOT until it exists - squash in subsequent patch which updates defconfigs so we don't leave users of CONFIG_FASTBOOT without it enabled - fix build in drivers/fastboot when we have CONFIG_FASTBOOT without flash or erase and we've not yet added fb_common.c to the build Changes in v4: None Changes in v3: - move imply ANDROID_BOOT_IMAGE, CMD_FASTBOOT to FASTBOOT from USB_FUNCTION_FASTBOOT - add depend on USB_FUNCTION_FASTBOOT to FASTBOOT_USB_DEV - leave images-sparse.c in common to acommodate 2f83f21 Changes in v2: None arch/arm/Kconfig | 2 -- board/ti/common/Kconfig | 1 - cmd/Kconfig | 14 ++++++-- common/Makefile | 15 +------- configs/am335x_boneblack_defconfig | 2 +- configs/am335x_boneblack_vboot_defconfig | 2 +- configs/am335x_evm_defconfig | 2 +- configs/am335x_evm_nor_defconfig | 2 +- configs/am335x_evm_norboot_defconfig | 2 +- configs/am335x_evm_spiboot_defconfig | 2 +- configs/am335x_evm_usbspl_defconfig | 2 +- configs/am57xx_evm_defconfig | 2 +- configs/am57xx_hs_evm_defconfig | 2 +- configs/bcm23550_w1d_defconfig | 2 +- configs/bcm28155_ap_defconfig | 2 +- configs/birdland_bav335a_defconfig | 2 +- configs/birdland_bav335b_defconfig | 2 +- configs/cgtqmx6eval_defconfig | 2 +- configs/dra7xx_evm_defconfig | 2 +- configs/dra7xx_hs_evm_defconfig | 2 +- configs/imx6dl_mamoj_defconfig | 2 +- configs/kc1_defconfig | 2 +- configs/mx6qsabrelite_defconfig | 2 +- configs/mx6sabresd_defconfig | 2 +- configs/nitrogen6dl2g_defconfig | 2 +- configs/nitrogen6dl_defconfig | 2 +- configs/nitrogen6q2g_defconfig | 2 +- configs/nitrogen6q_defconfig | 2 +- configs/nitrogen6s1g_defconfig | 2 +- configs/nitrogen6s_defconfig | 2 +- configs/omap3_beagle_defconfig | 2 +- configs/omap3_evm_defconfig | 2 +- configs/omap3_logic_defconfig | 2 +- configs/sniper_defconfig | 2 +- configs/stih410-b2260_defconfig | 2 +- .../xilinx_zynqmp_zc1751_xm015_dc1_defconfig | 2 +- .../xilinx_zynqmp_zc1751_xm016_dc2_defconfig | 2 +- configs/xilinx_zynqmp_zcu102_rev1_0_defconfig | 2 +- configs/xilinx_zynqmp_zcu102_revA_defconfig | 2 +- configs/xilinx_zynqmp_zcu102_revB_defconfig | 2 +- configs/xilinx_zynqmp_zcu106_revA_defconfig | 2 +- drivers/Kconfig | 2 ++ drivers/Makefile | 3 ++ {cmd => drivers}/fastboot/Kconfig | 35 +++++++------------ drivers/fastboot/Makefile | 8 +++++ {common => drivers/fastboot}/fb_mmc.c | 0 {common => drivers/fastboot}/fb_nand.c | 0 47 files changed, 75 insertions(+), 79 deletions(-) rename {cmd => drivers}/fastboot/Kconfig (88%) create mode 100644 drivers/fastboot/Makefile rename {common => drivers/fastboot}/fb_mmc.c (100%) rename {common => drivers/fastboot}/fb_nand.c (100%) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 582e84cf40..dde422bc5d 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1258,9 +1258,7 @@ config ARCH_ROCKCHIP select DM_REGULATOR select ENABLE_ARM_SOC_BOOT0_HOOK select SPI - imply CMD_FASTBOOT imply DISTRO_DEFAULTS - imply FASTBOOT imply FAT_WRITE imply USB_FUNCTION_FASTBOOT imply SPL_SYSRESET diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig index c21eb8c2d2..b1956b8100 100644 --- a/board/ti/common/Kconfig +++ b/board/ti/common/Kconfig @@ -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 diff --git a/cmd/Kconfig b/cmd/Kconfig index d532c9fc41..9848c067da 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -137,8 +137,6 @@ config AUTOBOOT_STOP_STR_SHA256 endmenu -source "cmd/fastboot/Kconfig" - config BUILD_BIN2C bool @@ -650,6 +648,18 @@ config CMD_DM can be useful to see the state of driver model for debugging or interest. +config CMD_FASTBOOT + bool "fastboot - Android fastboot support" + depends on FASTBOOT + help + This enables the command "fastboot" which enables the Android + fastboot mode for the platform. Fastboot is a protocol for + downloading images, flashing and device control used on + Android devices. Fastboot requires support for acting as a USB + device. + + See doc/README.android-fastboot for more information. + config CMD_FDC bool "fdcboot - Boot from floppy device" help diff --git a/common/Makefile b/common/Makefile index d0681c7dd9..9ec40b9d27 100644 --- a/common/Makefile +++ b/common/Makefile @@ -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 diff --git a/configs/am335x_boneblack_defconfig b/configs/am335x_boneblack_defconfig index 5c01b20dff..bd3a37427d 100644 --- a/configs/am335x_boneblack_defconfig +++ b/configs/am335x_boneblack_defconfig @@ -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 diff --git a/configs/am335x_boneblack_vboot_defconfig b/configs/am335x_boneblack_vboot_defconfig index abbacdc77e..baaae36d28 100644 --- a/configs/am335x_boneblack_vboot_defconfig +++ b/configs/am335x_boneblack_vboot_defconfig @@ -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 diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index 6732013b03..cc556d1c3d 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -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 diff --git a/configs/am335x_evm_nor_defconfig b/configs/am335x_evm_nor_defconfig index bbde07fb1d..41a5c79604 100644 --- a/configs/am335x_evm_nor_defconfig +++ b/configs/am335x_evm_nor_defconfig @@ -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 diff --git a/configs/am335x_evm_norboot_defconfig b/configs/am335x_evm_norboot_defconfig index 3ddcf64942..75d0793f2d 100644 --- a/configs/am335x_evm_norboot_defconfig +++ b/configs/am335x_evm_norboot_defconfig @@ -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" diff --git a/configs/am335x_evm_spiboot_defconfig b/configs/am335x_evm_spiboot_defconfig index 10eb0fe1ee..b2678875ec 100644 --- a/configs/am335x_evm_spiboot_defconfig +++ b/configs/am335x_evm_spiboot_defconfig @@ -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 diff --git a/configs/am335x_evm_usbspl_defconfig b/configs/am335x_evm_usbspl_defconfig index dc9ac216c2..44012919a3 100644 --- a/configs/am335x_evm_usbspl_defconfig +++ b/configs/am335x_evm_usbspl_defconfig @@ -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 diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index 0e99268441..3b83b69e5f 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -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 diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig index 165c2a40ba..9c2aef482f 100644 --- a/configs/am57xx_hs_evm_defconfig +++ b/configs/am57xx_hs_evm_defconfig @@ -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 diff --git a/configs/bcm23550_w1d_defconfig b/configs/bcm23550_w1d_defconfig index 9a986ca9ae..de4fa60df7 100644 --- a/configs/bcm23550_w1d_defconfig +++ b/configs/bcm23550_w1d_defconfig @@ -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 diff --git a/configs/bcm28155_ap_defconfig b/configs/bcm28155_ap_defconfig index d26cde5b0e..4f7a58e362 100644 --- a/configs/bcm28155_ap_defconfig +++ b/configs/bcm28155_ap_defconfig @@ -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 diff --git a/configs/birdland_bav335a_defconfig b/configs/birdland_bav335a_defconfig index 51b3e6b4e1..3efd5669a7 100644 --- a/configs/birdland_bav335a_defconfig +++ b/configs/birdland_bav335a_defconfig @@ -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 diff --git a/configs/birdland_bav335b_defconfig b/configs/birdland_bav335b_defconfig index 29b223a580..2f98116873 100644 --- a/configs/birdland_bav335b_defconfig +++ b/configs/birdland_bav335b_defconfig @@ -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 diff --git a/configs/cgtqmx6eval_defconfig b/configs/cgtqmx6eval_defconfig index d4204aa712..241e9582a5 100644 --- a/configs/cgtqmx6eval_defconfig +++ b/configs/cgtqmx6eval_defconfig @@ -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 diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig index 9b81b0cc71..b766ba27cd 100644 --- a/configs/dra7xx_evm_defconfig +++ b/configs/dra7xx_evm_defconfig @@ -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 diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig index 536946eb29..39a6801216 100644 --- a/configs/dra7xx_hs_evm_defconfig +++ b/configs/dra7xx_hs_evm_defconfig @@ -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 diff --git a/configs/imx6dl_mamoj_defconfig b/configs/imx6dl_mamoj_defconfig index 0001457f5d..40a128b8cb 100644 --- a/configs/imx6dl_mamoj_defconfig +++ b/configs/imx6dl_mamoj_defconfig @@ -9,7 +9,7 @@ CONFIG_DEFAULT_DEVICE_TREE="imx6dl-mamoj" CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg" CONFIG_BOOTDELAY=3 CONFIG_HUSH_PARSER=y -CONFIG_FASTBOOT=y +CONFIG_USB_FUNCTION_FASTBOOT=y CONFIG_FASTBOOT_BUF_ADDR=0x12000000 CONFIG_FASTBOOT_BUF_SIZE=0x10000000 CONFIG_FASTBOOT_FLASH=y diff --git a/configs/kc1_defconfig b/configs/kc1_defconfig index 534d60484a..ce71e37011 100644 --- a/configs/kc1_defconfig +++ b/configs/kc1_defconfig @@ -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 diff --git a/configs/mx6qsabrelite_defconfig b/configs/mx6qsabrelite_defconfig index 966e823b40..a4740d49cf 100644 --- a/configs/mx6qsabrelite_defconfig +++ b/configs/mx6qsabrelite_defconfig @@ -9,7 +9,7 @@ CONFIG_BOOTDELAY=3 # CONFIG_USE_BOOTCOMMAND is not set CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y CONFIG_BOARD_EARLY_INIT_F=y -CONFIG_FASTBOOT=y +CONFIG_USB_FUNCTION_FASTBOOT=y CONFIG_FASTBOOT_BUF_ADDR=0x12000000 CONFIG_CMD_MEMTEST=y CONFIG_SYS_ALT_MEMTEST=y diff --git a/configs/mx6sabresd_defconfig b/configs/mx6sabresd_defconfig index ca37d8bef8..5c8e9de081 100644 --- a/configs/mx6sabresd_defconfig +++ b/configs/mx6sabresd_defconfig @@ -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 diff --git a/configs/nitrogen6dl2g_defconfig b/configs/nitrogen6dl2g_defconfig index 6ef4226db9..cfb2ed8889 100644 --- a/configs/nitrogen6dl2g_defconfig +++ b/configs/nitrogen6dl2g_defconfig @@ -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 diff --git a/configs/nitrogen6dl_defconfig b/configs/nitrogen6dl_defconfig index b9784a2d23..9cb7ac22d5 100644 --- a/configs/nitrogen6dl_defconfig +++ b/configs/nitrogen6dl_defconfig @@ -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 diff --git a/configs/nitrogen6q2g_defconfig b/configs/nitrogen6q2g_defconfig index 61688ba49e..e31521a060 100644 --- a/configs/nitrogen6q2g_defconfig +++ b/configs/nitrogen6q2g_defconfig @@ -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 diff --git a/configs/nitrogen6q_defconfig b/configs/nitrogen6q_defconfig index cfee7ba889..85c352c6f0 100644 --- a/configs/nitrogen6q_defconfig +++ b/configs/nitrogen6q_defconfig @@ -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 diff --git a/configs/nitrogen6s1g_defconfig b/configs/nitrogen6s1g_defconfig index 0f29a56c46..1f3732019d 100644 --- a/configs/nitrogen6s1g_defconfig +++ b/configs/nitrogen6s1g_defconfig @@ -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 diff --git a/configs/nitrogen6s_defconfig b/configs/nitrogen6s_defconfig index 7ad1584af2..0696f09d5e 100644 --- a/configs/nitrogen6s_defconfig +++ b/configs/nitrogen6s_defconfig @@ -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 diff --git a/configs/omap3_beagle_defconfig b/configs/omap3_beagle_defconfig index 7b81b039c9..05dc73755f 100644 --- a/configs/omap3_beagle_defconfig +++ b/configs/omap3_beagle_defconfig @@ -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 diff --git a/configs/omap3_evm_defconfig b/configs/omap3_evm_defconfig index 20795c3170..52285cc165 100644 --- a/configs/omap3_evm_defconfig +++ b/configs/omap3_evm_defconfig @@ -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 diff --git a/configs/omap3_logic_defconfig b/configs/omap3_logic_defconfig index 5a31e46dba..953980c95c 100644 --- a/configs/omap3_logic_defconfig +++ b/configs/omap3_logic_defconfig @@ -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 diff --git a/configs/sniper_defconfig b/configs/sniper_defconfig index ad22a1cbe2..70e485fab2 100644 --- a/configs/sniper_defconfig +++ b/configs/sniper_defconfig @@ -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 diff --git a/configs/stih410-b2260_defconfig b/configs/stih410-b2260_defconfig index 67391bdfdf..7d990f9a34 100644 --- a/configs/stih410-b2260_defconfig +++ b/configs/stih410-b2260_defconfig @@ -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@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 diff --git a/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig b/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig index f5a33342fa..9e4886d064 100644 --- a/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig +++ b/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig @@ -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 diff --git a/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig b/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig index 7f7ee558ee..9d9216f5fe 100644 --- a/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig +++ b/configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig @@ -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 diff --git a/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig b/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig index 4cb3959f36..29743bdb1e 100644 --- a/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig +++ b/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig @@ -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 diff --git a/configs/xilinx_zynqmp_zcu102_revA_defconfig b/configs/xilinx_zynqmp_zcu102_revA_defconfig index e989d1635c..cc4118230e 100644 --- a/configs/xilinx_zynqmp_zcu102_revA_defconfig +++ b/configs/xilinx_zynqmp_zcu102_revA_defconfig @@ -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 diff --git a/configs/xilinx_zynqmp_zcu102_revB_defconfig b/configs/xilinx_zynqmp_zcu102_revB_defconfig index bd67df904a..ae791c3567 100644 --- a/configs/xilinx_zynqmp_zcu102_revB_defconfig +++ b/configs/xilinx_zynqmp_zcu102_revB_defconfig @@ -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 diff --git a/configs/xilinx_zynqmp_zcu106_revA_defconfig b/configs/xilinx_zynqmp_zcu106_revA_defconfig index a5fa33e366..34e3c857e2 100644 --- a/configs/xilinx_zynqmp_zcu106_revA_defconfig +++ b/configs/xilinx_zynqmp_zcu106_revA_defconfig @@ -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 diff --git a/drivers/Kconfig b/drivers/Kconfig index c2e813f5ad..8424898dbd 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -28,6 +28,8 @@ source "drivers/dfu/Kconfig" source "drivers/dma/Kconfig" +source "drivers/fastboot/Kconfig" + source "drivers/firmware/Kconfig" source "drivers/fpga/Kconfig" diff --git a/drivers/Makefile b/drivers/Makefile index b3f1b600a5..a79ff2e6b0 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -71,6 +71,9 @@ obj-y += block/ obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_CPU) += cpu/ obj-y += crypto/ +ifneq ($(CONFIG_FASTBOOT_FLASH_MMC_DEV)$(CONFIG_FASTBOOT_FLASH_NAND_DEV),) +obj-y += fastboot/ +endif obj-y += firmware/ obj-$(CONFIG_FPGA) += fpga/ obj-y += misc/ diff --git a/cmd/fastboot/Kconfig b/drivers/fastboot/Kconfig similarity index 88% rename from cmd/fastboot/Kconfig rename to drivers/fastboot/Kconfig index 0d2c2f131e..93a8ac64e7 100644 --- a/cmd/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -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 diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile new file mode 100644 index 0000000000..651fbf0935 --- /dev/null +++ b/drivers/fastboot/Makefile @@ -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 diff --git a/common/fb_mmc.c b/drivers/fastboot/fb_mmc.c similarity index 100% rename from common/fb_mmc.c rename to drivers/fastboot/fb_mmc.c diff --git a/common/fb_nand.c b/drivers/fastboot/fb_nand.c similarity index 100% rename from common/fb_nand.c rename to drivers/fastboot/fb_nand.c From patchwork Tue May 29 15:30:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922183 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="onQxbP+p"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHkj0YyHz9s08 for ; Wed, 30 May 2018 01:31:23 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 68F3AC21F02; Tue, 29 May 2018 15:31:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BBA8FC21E42; Tue, 29 May 2018 15:31:13 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5247DC21E31; Tue, 29 May 2018 15:31:12 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by lists.denx.de (Postfix) with ESMTPS id C2233C21E42 for ; Tue, 29 May 2018 15:31:11 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id m129-v6so41715020wmb.3 for ; Tue, 29 May 2018 08:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1FMH5n3ai8EOHMXhiaNqdONG7sk+fEAly7ICACrM79o=; b=onQxbP+pqU0WGji1AKc61jf0D1ymKB6r2d/oZcu2TeAXZftEjjgDioy1PD3RGpHb7q Hfp+RcXiW4gLgVMBHmOdX0fJ4N2aNufkzjJ8p90PRsPCBhrqhaPL1q8q2YMuNJLFTjqB 0GrGKijfLB6nFhvyCbCBDstlFtx+Z5T5wTQH9yDB22DVr/xfh6LwySIZYWJWGp5Sb2Y0 LiL2jyhERqO4Vl8RufC/k+fz7XDuhx9doW3GWbnrlmGGEqxTcP+vchDPu2mrxyEYOky6 CJBfa2yPzjDuxSqvP9N4aHkpx0ap0rD466XCV+Zpmuy2U0r4vH1ul3OEWd8vF0l01xC6 LtnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1FMH5n3ai8EOHMXhiaNqdONG7sk+fEAly7ICACrM79o=; b=nCoB6+Wye7LEUw+gjoe/jJ8MDsZGnkoB/+oJusCBJMo0N+YNTroAZOa7qW/8FhMHvV 8nHSh2mNJGEtBLFvjTzci6SXLp/AhIzJlqk9tXslBjQO5/BCqXWJCdcY8ARkofIvMrR7 pIi88698Unk4cbz10OPa1IDXGEMVvUMNPivh1J2eTlLBWwMyp1PLAfayH3In59RtXB+/ L/2L7hcFY5Pe8o8873n3qYKArInexldrX9ZudCfQlw3NiEaqa59BOObJ74Zix4zRJunT GGd8cJ4ApPXeP9AcToyC8nwQUg77G5LcXDIv9sro0yQsY3Fg9ZSgw2uFx4Mo3mCiYqGI 8X4Q== X-Gm-Message-State: ALKqPweZ74LY943nkmA8GRP+YB0YtaI6W5q7H4MzwdQaqckcxN5MDLmr sDnTVVni8Kxm8IdHyBgPXa247p5u1Ow= X-Google-Smtp-Source: ADUXVKLmJeI4mvDLufWu8nVyMXYNbaz7sVhlksde3flaTjYYc2YGo1b69ap/w6OlgUJ9rVPneW8H+w== X-Received: by 2002:a1c:aa0c:: with SMTP id t12-v6mr1677515wme.56.1527607870901; Tue, 29 May 2018 08:31:10 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:10 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:40 +0000 Message-Id: <20180529153056.27328-3-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Marek Vasut , Jocelyn Bohr , Angelo Dureghello , Jassi Brar , Jocelyn Bohr Subject: [U-Boot] [PATCH v8 02/18] fastboot: Refactor fastboot_okay/fail to take response X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add the response string as a parameter to fastboot_okay/fail, instead of modifying a global, to match the contract expected by the AOSP U-Boot code. Signed-off-by: Alex Kiernan Reviewed-by: Joe Hershberger --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - refactor for changes in master Changes in v2: None cmd/mmc.c | 2 +- common/image-sparse.c | 32 +++++++------ drivers/fastboot/fb_mmc.c | 83 ++++++++++++++++++--------------- drivers/fastboot/fb_nand.c | 34 +++++++------- drivers/usb/gadget/f_fastboot.c | 35 ++++++-------- include/fastboot.h | 4 +- include/fb_mmc.h | 4 +- include/fb_nand.h | 4 +- include/image-sparse.h | 4 +- 9 files changed, 105 insertions(+), 97 deletions(-) diff --git a/cmd/mmc.c b/cmd/mmc.c index a3357eff8f..a5719b81eb 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -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; diff --git a/common/image-sparse.c b/common/image-sparse.c index 9223b9a1b8..1ae7a4d0e8 100644 --- a/common/image-sparse.c +++ b/common/image-sparse.c @@ -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; } diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index 46f0073dbc..1bcb2e52d4 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -73,7 +73,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) + unsigned int download_bytes, char *response) { lbaint_t blkcnt; lbaint_t blks; @@ -84,7 +84,7 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info, if (blkcnt > info->size) { pr_err("too large for partition: '%s'\n", part_name); - fastboot_fail("too large for partition"); + fastboot_fail("too large for partition", response); return; } @@ -93,13 +93,13 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info, blks = blk_dwrite(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"); + fastboot_fail("failed writing to device", response); return; } printf("........ wrote " LBAFU " bytes to '%s'\n", blkcnt * info->blksz, part_name); - fastboot_okay(""); + fastboot_okay(NULL, response); } #ifdef CONFIG_ANDROID_BOOT_IMAGE @@ -114,7 +114,8 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info, */ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc, disk_partition_t *info, - struct andr_img_hdr *hdr) + struct andr_img_hdr *hdr, + char *response) { ulong sector_size; /* boot partition sector size */ lbaint_t hdr_sectors; /* boot image header sectors count */ @@ -125,7 +126,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc, hdr_sectors = DIV_ROUND_UP(sizeof(struct andr_img_hdr), sector_size); if (hdr_sectors == 0) { pr_err("invalid number of boot sectors: 0"); - fastboot_fail("invalid number of boot sectors: 0"); + fastboot_fail("invalid number of boot sectors: 0", response); return 0; } @@ -133,7 +134,8 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc, res = blk_dread(dev_desc, info->start, hdr_sectors, (void *)hdr); if (res != hdr_sectors) { pr_err("cannot read header from boot partition"); - fastboot_fail("cannot read header from boot partition"); + fastboot_fail("cannot read header from boot partition", + response); return 0; } @@ -141,7 +143,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc, res = android_image_check_header(hdr); if (res != 0) { pr_err("bad boot image magic"); - fastboot_fail("boot partition not initialized"); + fastboot_fail("boot partition not initialized", response); return 0; } @@ -159,7 +161,8 @@ 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) + unsigned int download_bytes, + char *response) { uintptr_t hdr_addr; /* boot image header address */ struct andr_img_hdr *hdr; /* boot image header */ @@ -179,7 +182,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, res = part_get_info_by_name(dev_desc, BOOT_PARTITION_NAME, &info); if (res < 0) { pr_err("cannot find boot partition"); - fastboot_fail("cannot find boot partition"); + fastboot_fail("cannot find boot partition", response); return -1; } @@ -188,17 +191,18 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, hdr = (struct andr_img_hdr *)hdr_addr; /* Read boot image header */ - hdr_sectors = fb_mmc_get_boot_header(dev_desc, &info, hdr); + hdr_sectors = fb_mmc_get_boot_header(dev_desc, &info, hdr, response); if (hdr_sectors == 0) { pr_err("unable to read boot image header"); - fastboot_fail("unable to read boot image header"); + 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"); - fastboot_fail("moving second stage is not supported yet"); + fastboot_fail("moving second stage is not supported yet", + response); return -1; } @@ -216,7 +220,8 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, ramdisk_buffer); if (res != ramdisk_sectors) { pr_err("cannot read ramdisk from boot partition"); - fastboot_fail("cannot read ramdisk from boot partition"); + fastboot_fail("cannot read ramdisk from boot partition", + response); return -1; } @@ -225,7 +230,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, res = blk_dwrite(dev_desc, info.start, hdr_sectors, (void *)hdr); if (res == 0) { pr_err("cannot writeback boot image header"); - fastboot_fail("cannot write back boot image header"); + fastboot_fail("cannot write back boot image header", response); return -1; } @@ -237,7 +242,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, download_buffer); if (res == 0) { pr_err("cannot write new kernel"); - fastboot_fail("cannot write new kernel"); + fastboot_fail("cannot write new kernel", response); return -1; } @@ -249,18 +254,18 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, ramdisk_buffer); if (res == 0) { pr_err("cannot write back original ramdisk"); - fastboot_fail("cannot write back original ramdisk"); + fastboot_fail("cannot write back original ramdisk", response); return -1; } puts("........ zImage was updated in boot partition\n"); - fastboot_okay(""); + fastboot_okay(NULL, response); return 0; } #endif void fb_mmc_flash_write(const char *cmd, void *download_buffer, - unsigned int download_bytes) + unsigned int download_bytes, char *response) { struct blk_desc *dev_desc; disk_partition_t info; @@ -268,7 +273,7 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, 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\n"); - fastboot_fail("invalid mmc device"); + fastboot_fail("invalid mmc device", response); return; } @@ -279,16 +284,17 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, if (is_valid_gpt_buf(dev_desc, download_buffer)) { printf("%s: invalid GPT - refusing to write to flash\n", __func__); - fastboot_fail("invalid GPT partition"); + fastboot_fail("invalid GPT partition", response); return; } if (write_mbr_and_gpt_partitions(dev_desc, download_buffer)) { printf("%s: writing GPT partitions failed\n", __func__); - fastboot_fail("writing GPT partitions failed"); + fastboot_fail("writing GPT partitions failed", + response); return; } printf("........ success\n"); - fastboot_okay(""); + fastboot_okay(NULL, response); return; } #endif @@ -299,30 +305,32 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, if (is_valid_dos_buf(download_buffer)) { printf("%s: invalid MBR - refusing to write to flash\n", __func__); - fastboot_fail("invalid MBR partition"); + fastboot_fail("invalid MBR partition", response); return; } if (write_mbr_partition(dev_desc, download_buffer)) { printf("%s: writing MBR partition failed\n", __func__); - fastboot_fail("writing MBR partition failed"); + fastboot_fail("writing MBR partition failed", + response); return; } printf("........ success\n"); - fastboot_okay(""); + fastboot_okay(NULL, response); return; } #endif #ifdef CONFIG_ANDROID_BOOT_IMAGE if (strncasecmp(cmd, "zimage", 6) == 0) { - fb_mmc_update_zimage(dev_desc, download_buffer, download_bytes); + fb_mmc_update_zimage(dev_desc, download_buffer, + download_bytes, response); return; } #endif if (part_get_info_by_name_or_alias(dev_desc, cmd, &info) < 0) { pr_err("cannot find partition: '%s'\n", cmd); - fastboot_fail("cannot find partition"); + fastboot_fail("cannot find partition", response); return; } @@ -344,16 +352,17 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, sparse.start); sparse.priv = &sparse_priv; - err = write_sparse_image(&sparse, cmd, download_buffer); + err = write_sparse_image(&sparse, cmd, download_buffer, + response); if (!err) - fastboot_okay(""); + fastboot_okay(NULL, response); } else { write_raw_image(dev_desc, &info, cmd, download_buffer, - download_bytes); + download_bytes, response); } } -void fb_mmc_erase(const char *cmd) +void fb_mmc_erase(const char *cmd, char *response) { int ret; struct blk_desc *dev_desc; @@ -363,21 +372,21 @@ void fb_mmc_erase(const char *cmd) if (mmc == NULL) { pr_err("invalid mmc device"); - fastboot_fail("invalid mmc device"); + 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"); - fastboot_fail("invalid mmc device"); + 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); - fastboot_fail("cannot find partition"); + fastboot_fail("cannot find partition", response); return; } @@ -396,11 +405,11 @@ void fb_mmc_erase(const char *cmd) blks = blk_derase(dev_desc, blks_start, blks_size); if (blks != blks_size) { pr_err("failed erasing from device %d", dev_desc->devnum); - fastboot_fail("failed erasing from device"); + fastboot_fail("failed erasing from device", response); return; } printf("........ erased " LBAFU " bytes from '%s'\n", blks_size * info.blksz, cmd); - fastboot_okay(""); + fastboot_okay(NULL, response); } diff --git a/drivers/fastboot/fb_nand.c b/drivers/fastboot/fb_nand.c index c07655e49e..2ee0d644e0 100644 --- a/drivers/fastboot/fb_nand.c +++ b/drivers/fastboot/fb_nand.c @@ -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); } diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 3acadae8b1..bb60612647 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -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); } diff --git a/include/fastboot.h b/include/fastboot.h index 009f1a72e1..ed52daeb1b 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -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_ */ diff --git a/include/fb_mmc.h b/include/fb_mmc.h index a2d7c4895f..39a960cc9d 100644 --- a/include/fb_mmc.h +++ b/include/fb_mmc.h @@ -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); diff --git a/include/fb_nand.h b/include/fb_nand.h index 3daae8c4ca..2c92a4eb50 100644 --- a/include/fb_nand.h +++ b/include/fb_nand.h @@ -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); diff --git a/include/image-sparse.h b/include/image-sparse.h index f39dc16617..234c237b84 100644 --- a/include/image-sparse.h +++ b/include/image-sparse.h @@ -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); From patchwork Tue May 29 15:30:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922184 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CTXrDHr/"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHlk1mc7z9s08 for ; Wed, 30 May 2018 01:32:18 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EAD3DC21F64; Tue, 29 May 2018 15:32:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7DC7EC21ED5; Tue, 29 May 2018 15:31:15 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 852FCC21E42; Tue, 29 May 2018 15:31:13 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by lists.denx.de (Postfix) with ESMTPS id E2D72C21E31 for ; Tue, 29 May 2018 15:31:12 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id a67-v6so41664957wmf.3 for ; Tue, 29 May 2018 08:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LnDY6MxDQgo8kFVcTwCgsesa2g5kUK05wCkD9JIdZic=; b=CTXrDHr/rmFoadIph3oiRJxd1CpkiJL5mD8zZl2mV1tQBxF8YbKiz+ONml0IaJiRGj XOGPNvEPDZbKhtymUjW52UrH0fQzwuuZvvrbkdq909UKZ3etI9SclktWzz7jjOzmBBc3 A1FQwlqc0jn0gCogvtQQjG/CZg2pvNymiF9nbkhcmGTV0Uq5E1+yQlcN180Vs42tvaOZ LfqgDlPqe6QloDd9Td0sOhpDcpCq1N4kvNuryUNtR5oGHtxNUBAYAPeM5Egr+jot2nB4 4F41sDvIcrpuekPRGYMCgbvDuwl5srGvOvJa8Fvr6htxsMxMmv34MbEs2gtYQF40O6zt D2zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LnDY6MxDQgo8kFVcTwCgsesa2g5kUK05wCkD9JIdZic=; b=ilv0QXMxuAguxeaDFzD/usgiyW2fY/JXlMJoTDtFQcZA05RqQt9+VMiOukNEDP7JF0 hB52OZ6njvnrqxrUoYtf+fJ1d6UrVfgyXhU2j+KuoD27kZI04vytw+qi71ocDQMZdrhZ T22NjNt1USxF8q3D2HwdptThgxtZbLzsqBOzxQdjfn98eQOayOu66w+YTyE7tFg5AaAf Yo/GAeYGh3ZqnZ17Y1Spx/5RgqZt2pmosT8cukk4SuRyfGpOvZVYA9l+ULelXXluGu5n Pw015p3Wzveq2cOqQEQYsGgC/rgTQgErCZrkaDR4YkPWCoGrsPIlakNFQRrTEbP/d6Wc UzeQ== X-Gm-Message-State: ALKqPwdidyRmGA/ZXHPQJmxamPx9TRGH5E4cjtPqK8ETz/PuBVYQgfGE wwZRRAvX3UAaIwC26+Ps8NpUbwFp5co= X-Google-Smtp-Source: ADUXVKIDSzhyXafqLa4UaWePoiSW39SfibZUQSwzQg0pdDmSjpjxLgbHwqHTg01GimJPDEK47KO+zQ== X-Received: by 2002:a1c:ee0d:: with SMTP id m13-v6mr11937539wmh.136.1527607872273; Tue, 29 May 2018 08:31:12 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:11 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:41 +0000 Message-Id: <20180529153056.27328-4-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Marek Vasut , Jocelyn Bohr , Jocelyn Bohr Subject: [U-Boot] [PATCH v8 03/18] fastboot: Extract fastboot_okay/fail to fb_common.c X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add drivers/fastboot/fb_common.c, where fastboot_okay/fail are implemented so we can call them from a non-USB implementation. Introduce fastboot_response which takes varargs parameters so we can use it to generate formatted response strings. Refactor fastboot_okay/fail to use it. Signed-off-by: Alex Kiernan Reviewed-by: Joe Hershberger --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: - fix docbook formatting Changes in v4: - add docbook comments Changes in v3: - Merge subsequent patch for formatting response strings into this one - allow NULL to fastboot_okay() when there's no message to send Changes in v2: None drivers/Makefile | 4 +-- drivers/fastboot/Makefile | 2 ++ drivers/fastboot/fb_common.c | 61 +++++++++++++++++++++++++++++++++ drivers/usb/gadget/f_fastboot.c | 13 ------- include/fastboot.h | 24 +++++++++++++ 5 files changed, 88 insertions(+), 16 deletions(-) create mode 100644 drivers/fastboot/fb_common.c diff --git a/drivers/Makefile b/drivers/Makefile index a79ff2e6b0..d29a6e467b 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -71,9 +71,7 @@ obj-y += block/ obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_CPU) += cpu/ obj-y += crypto/ -ifneq ($(CONFIG_FASTBOOT_FLASH_MMC_DEV)$(CONFIG_FASTBOOT_FLASH_NAND_DEV),) -obj-y += fastboot/ -endif +obj-$(CONFIG_FASTBOOT) += fastboot/ obj-y += firmware/ obj-$(CONFIG_FPGA) += fpga/ obj-y += misc/ diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile index 651fbf0935..b38dcff202 100644 --- a/drivers/fastboot/Makefile +++ b/drivers/fastboot/Makefile @@ -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 diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c new file mode 100644 index 0000000000..c4a7702bb3 --- /dev/null +++ b/drivers/fastboot/fb_common.c @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2008 - 2009 + * Windriver, + * Tom Rix + * + * Copyright 2011 Sebastian Andrzej Siewior + * + * Copyright 2014 Linaro, Ltd. + * Rob Herring + */ + +#include +#include + +/** + * fastboot_response() - Writes a response of the form "$tag$reason". + * + * @tag: The first part of the response + * @response: Pointer to fastboot response buffer + * @format: printf style format string + */ +void fastboot_response(const char *tag, char *response, + const char *format, ...) +{ + va_list args; + + strlcpy(response, tag, FASTBOOT_RESPONSE_LEN); + if (format) { + va_start(args, format); + vsnprintf(response + strlen(response), + FASTBOOT_RESPONSE_LEN - strlen(response) - 1, + format, args); + va_end(args); + } +} + +/** + * fastboot_fail() - Write a FAIL response of the form "FAIL$reason". + * + * @reason: Pointer to returned reason string + * @response: Pointer to fastboot response buffer + */ +void fastboot_fail(const char *reason, char *response) +{ + fastboot_response("FAIL", response, "%s", reason); +} + +/** + * fastboot_okay() - Write an OKAY response of the form "OKAY$reason". + * + * @reason: Pointer to returned reason string, or NULL to send a bare "OKAY" + * @response: Pointer to fastboot response buffer + */ +void fastboot_okay(const char *reason, char *response) +{ + if (reason) + fastboot_response("OKAY", response, "%s", reason); + else + fastboot_response("OKAY", response, NULL); +} diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index bb60612647..2e6e1615bf 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -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; diff --git a/include/fastboot.h b/include/fastboot.h index ed52daeb1b..6cd44d2ab9 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -15,7 +15,31 @@ /* The 64 defined bytes plus \0 */ #define FASTBOOT_RESPONSE_LEN (64 + 1) +/** + * fastboot_response() - Writes a response of the form "$tag$reason". + * + * @tag: The first part of the response + * @response: Pointer to fastboot response buffer + * @format: printf style format string + */ +void fastboot_response(const char *tag, char *response, + const char *format, ...) + __attribute__ ((format (__printf__, 3, 4))); + +/** + * fastboot_fail() - Write a FAIL response of the form "FAIL$reason". + * + * @reason: Pointer to returned reason string + * @response: Pointer to fastboot response buffer + */ void fastboot_fail(const char *reason, char *response); + +/** + * fastboot_okay() - Write an OKAY response of the form "OKAY$reason". + * + * @reason: Pointer to returned reason string, or NULL to send a bare "OKAY" + * @response: Pointer to fastboot response buffer + */ void fastboot_okay(const char *reason, char *response); #endif /* _FASTBOOT_H_ */ From patchwork Tue May 29 15:30:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922185 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="r1rnxmBj"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHmW5S9Pz9s08 for ; Wed, 30 May 2018 01:32:59 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5C9B9C21F0B; Tue, 29 May 2018 15:32:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5A444C21F02; Tue, 29 May 2018 15:31:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AC20CC21EA1; Tue, 29 May 2018 15:31:24 +0000 (UTC) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by lists.denx.de (Postfix) with ESMTPS id 76ECCC21E79 for ; Tue, 29 May 2018 15:31:14 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id m129-v6so41715450wmb.3 for ; Tue, 29 May 2018 08:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dAnQM0Us6XZK9sPOOFEwBnClFillhoYv4vTBkRvuO1o=; b=r1rnxmBjxDCmRhGlL2JwGBAiLRkuVYfp54HX5p/e2X18ruSxSmmqpIaJ0aZhijP7sR MFg/HIM6SR8oIV1epoRJ2XiYCF9OGmH5nYnVZN04+uHxL8+v8dPWucuRVd/7m95bCyv7 rhWjlmsyJGtxzxf0MFF8HNRH4YWfjRk8+nwX3d+30plwBVtGWL80WzML4wXKvSp8ZPKh Q3xiFGxpHWaeLPgNiQz+INT88/Si9k7jlmQVhdQBPgBVfIJ4gVqg8NXBgbwAzngnuTr+ eefFfpf1Xw7t7XoIU50rQ0T/P7T4CQHkyVSB3VDqqLFN9yZy9nHQ9eIxE4H+0tN4Nzg1 tsrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dAnQM0Us6XZK9sPOOFEwBnClFillhoYv4vTBkRvuO1o=; b=iU1nobCOZrwjFU+cF2eJ6RaIBlnqDNYZHy9eSal7xZMdKE6Ps3T6cU2iX7Xp+OTvFh 0fJ4KcsvdrhIdWCKC+bPrKCmI3jR8xXw7yXPWG8/1QOdOrkQHfCLYnHXdafd6OvtbD9r qfivQKaOF0W2yqlcF1Bn5aGywh5XBuiSaRo6zWnYOOhRrdUxJL+Wo7gtdAmDsemLYcD8 10VqZIfaE8WBBmqU3BGahBMg8eiVltwVclDWIlEjjNHqEUP8oi+273i955FX7C6/iWEh AedNdJozAp2vDZvFzSfCHwoe4N1JX1MOy7SEBuJ+KrDMsk8FUocuEI96ejOG1r+qwfIv TkQw== X-Gm-Message-State: ALKqPwehUheqYh8yp+AP1tOrI63Ffv/IaaLo/MYEQ+wKavVBu2JUk9Vo 8G98R7/ihvSN/6PeVqhZPgmnRxVEPVw= X-Google-Smtp-Source: ADUXVKJ9kCuhtq3WuC25dS8j9exPDV7avcwN7O6sqtpgz0T3HIHR84K3/0qUG/C5EIRFQIm2Lh4KVg== X-Received: by 2002:a1c:911:: with SMTP id 17-v6mr10639291wmj.5.1527607873831; Tue, 29 May 2018 08:31:13 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:13 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:42 +0000 Message-Id: <20180529153056.27328-5-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Marek Vasut , Benjamin Young , Jocelyn Bohr , Praneeth Bajjuri , Andre Przywara , Jocelyn Bohr , Maxime Ripard Subject: [U-Boot] [PATCH v8 04/18] fastboot: Correct dependencies in FASTBOOT_FLASH X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Ensure that when selecting FASTBOOT_FLASH you end up with a buildable configuration. Prior to this you could select NAND without MTDPARTS and end up with an image which (surprisingly) excluded NAND. Also fix dependencies on FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME which require you have EFI_PARTITION/DOS_PARTITION enabled. Delete redundant FASTBOOT_FLASH_NAND_DEV from Kconfig - it was only ever used as a guard and the value was ignored in all cases, we're using FASTBOOT_FLASH_NAND as the guard now. Signed-off-by: Alex Kiernan Reviewed-by: Joe Hershberger --- Changes in v8: None Changes in v7: None Changes in v6: - delete redundant FASTBOOT_FLASH_NAND_DEV symbol Changes in v5: None Changes in v4: None Changes in v3: - guard FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME with EFI/DOS_PARTITION Changes in v2: None arch/arm/mach-omap2/utils.c | 4 ++-- drivers/fastboot/Kconfig | 17 ++++------------- drivers/fastboot/Makefile | 8 ++------ drivers/usb/gadget/f_fastboot.c | 14 +++++++------- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c index dc7b37f164..edf5edcb68 100644 --- a/arch/arm/mach-omap2/utils.c +++ b/arch/arm/mach-omap2/utils.c @@ -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(); diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 93a8ac64e7..9bbc5c661d 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -56,6 +56,7 @@ config FASTBOOT_USB_DEV config FASTBOOT_FLASH bool "Enable FASTBOOT FLASH command" default y if ARCH_SUNXI + depends on MMC || (NAND && CMD_MTDPARTS) help The fastboot protocol includes a "flash" command for writing the downloaded image to a non-volatile storage device. Define @@ -71,7 +72,7 @@ config FASTBOOT_FLASH_MMC config FASTBOOT_FLASH_NAND bool "FASTBOOT on NAND" - depends on NAND + depends on NAND && CMD_MTDPARTS endchoice @@ -85,19 +86,9 @@ config FASTBOOT_FLASH_MMC_DEV regarding the non-volatile storage device. Define this to the eMMC device that fastboot should use to store the image. -config FASTBOOT_FLASH_NAND_DEV - int "Define FASTBOOT NAND FLASH default device" - depends on FASTBOOT_FLASH_NAND - depends on CMD_MTDPARTS - default 0 if ARCH_SUNXI && NAND_SUNXI - help - The fastboot "flash" command requires additional information - regarding the non-volatile storage device. Define this to - the NAND device that fastboot should use to store the image. - config FASTBOOT_GPT_NAME string "Target name for updating GPT" - depends on FASTBOOT_FLASH + depends on FASTBOOT_FLASH_MMC && EFI_PARTITION default "gpt" help The fastboot "flash" command supports writing the downloaded @@ -110,7 +101,7 @@ config FASTBOOT_GPT_NAME config FASTBOOT_MBR_NAME string "Target name for updating MBR" - depends on FASTBOOT_FLASH + depends on FASTBOOT_FLASH_MMC && DOS_PARTITION default "mbr" help The fastboot "flash" command allows to write the downloaded image diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile index b38dcff202..e4bd389adf 100644 --- a/drivers/fastboot/Makefile +++ b/drivers/fastboot/Makefile @@ -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 diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 2e6e1615bf..323ac89417 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -20,10 +20,10 @@ #include #include #include -#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#ifdef CONFIG_FASTBOOT_FLASH_MMC #include #endif -#ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV +#ifdef CONFIG_FASTBOOT_FLASH_NAND #include #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); From patchwork Tue May 29 15:30:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922187 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iYm73L0b"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHp73XnNz9s01 for ; Wed, 30 May 2018 01:34:23 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 0D273C21F1B; Tue, 29 May 2018 15:33:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3C106C21F1B; Tue, 29 May 2018 15:31:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F23FCC21EE5; Tue, 29 May 2018 15:31:29 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by lists.denx.de (Postfix) with ESMTPS id 13D6BC21EEF for ; Tue, 29 May 2018 15:31:16 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id r15-v6so14225366wmc.1 for ; Tue, 29 May 2018 08:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iVVyqJiB713vL3IdywsSBrus8YFRtF1g2c0DXn4Ztbc=; b=iYm73L0b7yQfjkbY/dcdNOCITiVY8rYcEY/yGHqj6Defa0iu5pZuouGZoTcP/AbMg6 pYRjndGPa7Y1Za5e6M+sNwl9GUNQeLaskmql/cdTHvexLW3l8/6enUMPKgAj119wLAAP PxZSA9wUvevinnm+m/+Qflhe7UcmOqg8Z4wjTpM9LSoHlyQVH4K07t5YNKhyMhSEmhc0 ZvK7HOMCmKVUqTdF0EOGR5Bi0BFP3azuLojkX1eWJVZSte94uUAymkYI4P8ukqJGsq4e vviq7ti5EfVXnrM3Kh98mBvfiMREO6CN7BSnI+qNw/dT+O/aOqwLu4NIiYw4CgSxbQ7Z WFeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iVVyqJiB713vL3IdywsSBrus8YFRtF1g2c0DXn4Ztbc=; b=LjAI6g84dKrFqy0hR5OO3/XyKIwyStJCeUgUbEaUTP5aZNsmAPBNDs/feYY61mzBbM +J2vP6aTqrVVybXUGONgIA+XHMwKCI84r3Z8UZQIc7uAUuaz9syMvkwN2UDzU5r+2kQw cNbyFi4OxgL6UOJcIJ9hp3VeD1Sr/KCO6rjdizLx/cCkBCWl7e0+INE8w72eTUc8r1X6 lWrDnLA7mbySumw+dN29Kw7yBQvzjHlAhaR3pfHxe0Tx1O8GXST+5kvI7a7rO7clqx9u NDmIJyu/Y3OSQ2wh57K+X7us2ejnHjrpkCFPP8ZH1EgdTLRFhKBpTEg3l11Ts5/j9Ewc qltg== X-Gm-Message-State: ALKqPwfv5pj6kLVnIQrnZ8aEy5yqXt9FIrwBQgwUZA0ZnWsJ99U8Rt3i bawaxaYtR2nJuGs8sC8oKA3VdR4PToc= X-Google-Smtp-Source: ADUXVKKtaW6RhtHUOhps7eXTF6gzWJ1pPGUfQPWtX2vTkFYN50jq2hqwP+fjgiIovEHCMH5LNbCMvQ== X-Received: by 2002:a1c:1f13:: with SMTP id f19-v6mr10514979wmf.73.1527607875482; Tue, 29 May 2018 08:31:15 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:14 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:43 +0000 Message-Id: <20180529153056.27328-6-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Jocelyn Bohr , Jassi Brar , Jocelyn Bohr Subject: [U-Boot] [PATCH v8 05/18] fastboot: Add missing newlines X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add newlines so we format our output correctly. Signed-off-by: Alex Kiernan Acked-by: Joe Hershberger Reviewed-by: Jocelyn Bohr --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None drivers/fastboot/fb_mmc.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index 1bcb2e52d4..b1db29684d 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -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; } From patchwork Tue May 29 15:30:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922186 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DNi8knii"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHnz3pN1z9s01 for ; Wed, 30 May 2018 01:34:15 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 2580CC21F16; Tue, 29 May 2018 15:33:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 03557C21E79; Tue, 29 May 2018 15:31:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 66FE6C21E79; Tue, 29 May 2018 15:31:30 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by lists.denx.de (Postfix) with ESMTPS id 6A0B3C21E96 for ; Tue, 29 May 2018 15:31:17 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id l1-v6so41891686wmb.2 for ; Tue, 29 May 2018 08:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZLe77r8M6EXWaxD333XWUOmkLRM6peCB91WuvXpT73A=; b=DNi8kniiamLRbPPOdYR5qAuUJ0rDiYXQhbXMiNNTbpmIFyaJ+K+0nXj0Rz1/m/UjqW yu1EOdZQxhxcX6J5GpNERW2XsclwXw4HzzTdFSk8hXwydXR2iCCyWymQEhkLqpTLTikY 7crWjOn26BtUQ2ATl1hCqAi3OwzZDAxkCi0qcVtn5aTfTYCiL2BWDXDgKn6bpkH4b4iu 9HHYdrGDAI9ozSvYLNHAxPluyGnvxlBI6cxixLDd8uGxl2gjultl4cfOCIZhZnmVBiEw 61Mtii6RNoiV8Bff7seYPwy0R4Fkr+uYsFXDTYN3d4Yu6kST92pnXEvYxje45DBqaDYs kq5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZLe77r8M6EXWaxD333XWUOmkLRM6peCB91WuvXpT73A=; b=R/pVzw+F064W/zxHRu4i5TRDp8P60UjZvEMjMYQzN5Ugo1oXxNkwq8f8xd6JWzEAxN g1oLbcy3VsfEk695JnbkaXJgPOj4iRmnEPKmtiwGurAwRtGxZm7ubxZv151PnqtRQvrX jEkhjHx7NKdOuV0QRgSNUy1z5zpOPc+uxqykwaeZXksoSKHHIZlLswcsxmnXYllW0rED dF+2d6omIeWP0PIFSM8DYbzcJ6/CWgwWcY4B40aUpccZGuBZDqvXWjauRqYCw9HYYZgw 7u34cujuYhdRDpK72OwANXvVJ5IbTm/ky0nEVV5n+WEeYo3BJ9UxmOGePPwjAb1JKQNs A3Rw== X-Gm-Message-State: ALKqPwchBqiQU7PvTc6QFahzUIloYLMcYTMEWha1MzZQHSQlTT16lwcP 2BgKqie7+ykx9y7U1TgyuQJutBSH374= X-Google-Smtp-Source: ADUXVKIq9nNX/L6CB7C45oSGwGi17KiyFHsnlucDHSK6+mMZvCQUrX4niql4J6tSNDniDyA+0sgsiA== X-Received: by 2002:a1c:20c7:: with SMTP id g190-v6mr7181317wmg.2.1527607876796; Tue, 29 May 2018 08:31:16 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:16 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:44 +0000 Message-Id: <20180529153056.27328-7-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Jocelyn Bohr , Jassi Brar , Jocelyn Bohr Subject: [U-Boot] [PATCH v8 06/18] fastboot: Remove FIXME for CONFIG_FASTBOOT_...NAME X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" CONFIG_FASTBOOT_GPT_NAME and CONFIG_FASTBOOT_MBR_NAME are always defined by Kconfig if you're compiling this code, so remove these redundant defaults. Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass Acked-by: Joe Hershberger --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - new Changes in v2: None drivers/fastboot/fb_mmc.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index b1db29684d..038905face 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -15,19 +15,6 @@ #include #include -/* - * 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 { From patchwork Tue May 29 15:30:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922189 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Lw4wDONO"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHtB0mQhz9s08 for ; Wed, 30 May 2018 01:37:53 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id CA389C21F0B; Tue, 29 May 2018 15:33:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BBEBBC21E57; Tue, 29 May 2018 15:31:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 048FAC21E79; Tue, 29 May 2018 15:31:30 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by lists.denx.de (Postfix) with ESMTPS id A10F3C21EFF for ; Tue, 29 May 2018 15:31:18 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id 18-v6so36278290wml.2 for ; Tue, 29 May 2018 08:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8osmquoriwoVtyoAjiwfE+O3Zso7ZDwLLgqK4bBPbQ4=; b=Lw4wDONOLiaMrVqnr+4cdtGtwd8zXbuhWVfmNNH627vdwJtTkMDeJQSVcdik6Xu2DH SSIyNG36e6unypA3HAa97q53Ra+8C0u5iXCpYVQmw51rQNwDs5ZJ3A3RRCtmisoADe4l SNw3/bjWZ75X1iHIo3nWWhPCjA7pw15BfzpOpbZBJwJqsINQAqC4riF+za0LBvTnk2aC DpYXwJ8sgCLfv1N6uQYOSs4dR9NqeVM8TxhQy0g3w4c5VqCivO+8KnfcrhReeBYKRS8C jQSZz0MY9lirU14H75mBc6zOFpdpNVd/NCxjx+X9D92eqdxzhR/5nDw9c5ayqNpOqrHr 6rFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8osmquoriwoVtyoAjiwfE+O3Zso7ZDwLLgqK4bBPbQ4=; b=QsKP9f6f7iaWuGrRm2/rvps8Lnjg88hhYKikIO6lE5fQJH6dh925T8fLrOr+EwhTja Sg0i8Cadb7GHmnLwavjzaJvK6U3VWHWQZNFkLBtjIxdlaHmo2zrn2zrdMZ9zhRoPS3+6 tercL2w2NoxLIQhcpZ/LzCm/XRAi/97BcThpTp4ZEuCBXHR/5uZ3nQVWTx/vuTDmYo+m lqqydk1GryUYg3L7ZWueQxQCQsODHVLvu89Sp0xoXk/FOXjU/6q62Z94RiGwbwIWiamp ZuSnHhNLzRTqC5R0Q4TraMP2TZNoo3NFk8uOYMFVf94YZ1wcFEFLqZHz9FlHRIZDSTSy 1pxA== X-Gm-Message-State: ALKqPwcy18EE5KpxWhLYfs7h1+dNb6/v2IbA7RgYnbWOTXDKFJ8q4C51 KiMT2nrEVDgFbE3nMkV1WYkZUksfJ6I= X-Google-Smtp-Source: ADUXVKJIH2tA/FOyw2ATWKmGmY8VGNZfF0XmjXcRp0z9n2JqDTyT3o3n4AJRWa1YhBSRmKg+0Juqqw== X-Received: by 2002:a1c:6dd3:: with SMTP id b80-v6mr10671507wmi.32.1527607878031; Tue, 29 May 2018 08:31:18 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:17 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:45 +0000 Message-Id: <20180529153056.27328-8-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> MIME-Version: 1.0 Cc: Jocelyn Bohr , Jassi Brar Subject: [U-Boot] [PATCH v8 07/18] fastboot: Fix parameter types in _fb_nand_write X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Compiling on a 64 bit target the arguments to _fb_nand_write are incompatible: drivers/fastboot/fb_nand.c: In function ‘_fb_nand_write’: drivers/fastboot/fb_nand.c:101:42: warning: passing argument 3 of ‘nand_write_skip_bad’ from incompatible pointer type [-Wincompatible-pointer-types] return nand_write_skip_bad(mtd, offset, &length, written, ^ In file included from drivers/fastboot/fb_nand.c:16:0: include/nand.h:107:5: note: expected ‘size_t * {aka long unsigned int *}’ but argument is of type ‘unsigned int *’ int nand_write_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length, ^~~~~~~~~~~~~~~~~~~ Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass Acked-by: Joe Hershberger --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - new Changes in v2: None drivers/fastboot/fb_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/fastboot/fb_nand.c b/drivers/fastboot/fb_nand.c index 2ee0d644e0..849a6f16a5 100644 --- a/drivers/fastboot/fb_nand.c +++ b/drivers/fastboot/fb_nand.c @@ -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; From patchwork Tue May 29 15:30:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922192 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Iw885dKI"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHth6Kjlz9s08 for ; Wed, 30 May 2018 01:38:20 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 8D82EC21E42; Tue, 29 May 2018 15:33:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7558EC21F24; Tue, 29 May 2018 15:31:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6FB32C21F22; Tue, 29 May 2018 15:31:31 +0000 (UTC) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by lists.denx.de (Postfix) with ESMTPS id 7C457C21F07 for ; Tue, 29 May 2018 15:31:20 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id 18-v6so36278630wml.2 for ; Tue, 29 May 2018 08:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=op8lAGm68Y5uuNEYN2BruF8I32ZQCuKk/Ircb6xN+1c=; b=Iw885dKIAZl99YMn9BOuyqrY0tmO+t3e8cTiV9ONjyk8E/1xpU8BiVWskGcLsISq9l xbFkUzCGwvwAUMVBhvDzZIqebDde0Kft67WbzEfsb/1Zpt0aIHSbcDFeRcIiRR8Xdwor a/YFiGXwhKsNinFPJ5GpoTjehJwCQfEL+ZyDrR1gnvH878C7UlUrD+yWW5XuTcf3IFq7 EpOCJPqrSgnwMNMuvMHBV87gUz4NPZqsJu+PQh7g7IM6f7QUtj2ynns4VwKvzPk5O8ku jk/upJ0Q4J2V3q2r8BZvtgp5R0CH3r+W0WN5BNhd3wPpPN/4+fVXGa84YlvjEARLRRt/ R/pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=op8lAGm68Y5uuNEYN2BruF8I32ZQCuKk/Ircb6xN+1c=; b=qXtWXtl0E04DbqbUb5uGm8iOrvlnZNqXBiyP+2BDk+hbib0cjUH3+BKDU5NLtr5TrO ahytp/k9+B7sanxHOlEnst1tzidDuEEXg0GaeYQXfLncXxXwG0NCzNr5901WE8nSsK0E JwGnIfYnk5aGruUBaY/ubS5tkhrcREpNftc2EugXEu6B/Ymw8vvJ7SSD022Obw1Bd8OX h1ljHkl/RbQ/Tn4byVhhWsqt2Ci2DAUZ+aOmw7s8++RdDUJuvEE1kuK82QkQJre+4N4D xIn4g2oFLaWOy5EULejYXd4GoKA77n596a8GMhIbwfF55zBAbNb/+ngiOPF70r3fbGL7 UuYA== X-Gm-Message-State: ALKqPwcib6rOcAqSKcGZ57gBeTapR/C8bkaye6ceiW6A4RDtd0B4xmjC jxOn1RFvmenziZkjmQXs2QtZGmtXE64= X-Google-Smtp-Source: ADUXVKLhaBY7tzvg8/X8ffi+u///1PotNmsI8IZsqVAopx6cC8EGmPYRMNMKhJT1bLdAKkw3B0iqYQ== X-Received: by 2002:a1c:ea1a:: with SMTP id i26-v6mr12995781wmh.11.1527607879823; Tue, 29 May 2018 08:31:19 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:19 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:46 +0000 Message-Id: <20180529153056.27328-9-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Marek Vasut , Jocelyn Bohr , Jocelyn Bohr Subject: [U-Boot] [PATCH v8 08/18] fastboot: Rename fb_set_reboot_flag to fastboot_set_reboot_flag X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Rename fb_set_reboot_flag to fastboot_set_reboot_flag so it matches all other fastboot code in the global name space. Fix the guards around them so that they're dependent on FASTBOOT, not just USB_FUNCTION_FASTBOOT. Move the weak implementation of fastboot_set_reboot_flag to fb_common.c so we can call it from non-USB fastboot code. Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass Acked-by: Joe Hershberger --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - new Changes in v2: None arch/arm/mach-omap2/boot-common.c | 4 ++-- arch/arm/mach-rockchip/rk3128-board.c | 4 ++-- arch/arm/mach-rockchip/rk322x-board.c | 4 ++-- board/amazon/kc1/kc1.c | 2 +- board/lg/sniper/sniper.c | 2 +- drivers/fastboot/fb_common.c | 15 +++++++++++++++ drivers/usb/gadget/f_fastboot.c | 7 +------ include/fastboot.h | 2 +- 8 files changed, 25 insertions(+), 15 deletions(-) diff --git a/arch/arm/mach-omap2/boot-common.c b/arch/arm/mach-omap2/boot-common.c index 0e9fd03fef..b22b6713e5 100644 --- a/arch/arm/mach-omap2/boot-common.c +++ b/arch/arm/mach-omap2/boot-common.c @@ -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"); diff --git a/arch/arm/mach-rockchip/rk3128-board.c b/arch/arm/mach-rockchip/rk3128-board.c index 48cd8ba81e..7fd667a0b8 100644 --- a/arch/arm/mach-rockchip/rk3128-board.c +++ b/arch/arm/mach-rockchip/rk3128-board.c @@ -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; diff --git a/arch/arm/mach-rockchip/rk322x-board.c b/arch/arm/mach-rockchip/rk322x-board.c index 99a60c4e2e..7366d45ab6 100644 --- a/arch/arm/mach-rockchip/rk322x-board.c +++ b/arch/arm/mach-rockchip/rk322x-board.c @@ -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; diff --git a/board/amazon/kc1/kc1.c b/board/amazon/kc1/kc1.c index d9ca18363c..031fd11092 100644 --- a/board/amazon/kc1/kc1.c +++ b/board/amazon/kc1/kc1.c @@ -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"); } diff --git a/board/lg/sniper/sniper.c b/board/lg/sniper/sniper.c index 34a7a11f05..a7de4c2167 100644 --- a/board/lg/sniper/sniper.c +++ b/board/lg/sniper/sniper.c @@ -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"); } diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c index c4a7702bb3..79e080ac87 100644 --- a/drivers/fastboot/fb_common.c +++ b/drivers/fastboot/fb_common.c @@ -59,3 +59,18 @@ void fastboot_okay(const char *reason, char *response) else fastboot_response("OKAY", response, NULL); } + +/** + * fastboot_set_reboot_flag() - Set flag to indicate reboot-bootloader + * + * Set flag which indicates that we should reboot into the bootloader + * following the reboot that fastboot executes after this function. + * + * This function should be overridden in your board file with one + * which sets whatever flag your board specific Android bootloader flow + * requires in order to re-enter the bootloader. + */ +int __weak fastboot_set_reboot_flag(void) +{ + return -ENOSYS; +} diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 323ac89417..697eee57d0 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -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; } diff --git a/include/fastboot.h b/include/fastboot.h index 6cd44d2ab9..816e71b4d0 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -41,5 +41,5 @@ void fastboot_fail(const char *reason, char *response); * @response: Pointer to fastboot response buffer */ void fastboot_okay(const char *reason, char *response); - +int fastboot_set_reboot_flag(void); #endif /* _FASTBOOT_H_ */ From patchwork Tue May 29 15:30:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922198 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="D60V/QJ7"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHwt5Qryz9s08 for ; Wed, 30 May 2018 01:40:14 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 773B1C21F3E; Tue, 29 May 2018 15:34:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C1C38C21F00; Tue, 29 May 2018 15:31:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EC343C21F3D; Tue, 29 May 2018 15:31:33 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by lists.denx.de (Postfix) with ESMTPS id B749EC21ECA for ; Tue, 29 May 2018 15:31:21 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id x12-v6so48544797wmc.0 for ; Tue, 29 May 2018 08:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=S48THtoR7kNaO4TlpWVjIvLFQUDsU0dSoHUUl6xPSqg=; b=D60V/QJ7O5fLdIwu3dptlO5911R8sZahnaZ+e5KMNJzFzTrrDMrE23GMgn+AKxk6pw bmeIi9kWZWTuoMNtrPdTEryY3CPrUxgWDVS1fCh5v/m/4lv40iMZ9VR5z0wJP/D4nh41 Lay0n1xCS+PqM9bl7ZWNmGiBKCliFqgBDkxwaP8dzx1KDu8q4hwpMysswdSseKY52IWR v6x2oQWq8V991/fpb4WGDHGvpZQLZ1GeWeKQFb2/RT6PIHul/0DRQfjE6Nh4ueNaUxV1 z2s0j+kWIR2fljNzGNE2ylGI0WkZolzqovOj2vLuGN3kzmF/XlpwGC6L4VMDPYofAL9X 2oTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=S48THtoR7kNaO4TlpWVjIvLFQUDsU0dSoHUUl6xPSqg=; b=fuGfsV2E+IZER6de+JF29IGL6IrZaoMRtYWw8nRcV5c7CvyYjy5fVLqbWMyTeNGqBK age9VfnQlacQCHEx0NKUJ/IPI1lDnQDp+4oBrmGeXabTNEHm+M6h91DhXEKmG+qc5BNV pbH5m7yTtqVy73WAqRy7x4QyKklWwHsJ2zyzqAZ/AE2ESzR1rPJnPEZ7hkqegZHvbzO3 c9dX2IYyg8fDD5I4h+9WpmlXF48va5hQIRpgXLDrmP4+tfy7ZLffCCIT0c5prUrlumSA l7Ll0po1+nI6dAIrfUhSY+oGGt8NaarJlWSzVTcY1K4yGxonvn7FmRvZLqxQv5nEQpJ3 0bNw== X-Gm-Message-State: ALKqPwflA4MUeXdoyRlCAouqcFTi/Kycf6IeVl2k8WIfJxHU045jjXEZ nuI23yn1QNsa2psU2grxVNHzcS811SI= X-Google-Smtp-Source: ADUXVKKrCl5SHLfFyM2G0P3rIPY2gD2j5H847K6r3ZDewHJWttzz1rL5dKx6SR31Rd5qx/EwYmQkBQ== X-Received: by 2002:a1c:ee0d:: with SMTP id m13-v6mr11937979wmh.136.1527607881238; Tue, 29 May 2018 08:31:21 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:20 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:47 +0000 Message-Id: <20180529153056.27328-10-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Marek Vasut , Jocelyn Bohr , Jocelyn Bohr Subject: [U-Boot] [PATCH v8 09/18] fastboot: Extract common definitions from USB fastboot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Move FASTBOOT_VERSION to include/fastboot.h so when we merge the UDP code we only have one definition. Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass Acked-by: Joe Hershberger --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: - leave strcmp_l1() in USB fastboot as we don't need it in UDP path Changes in v3: - new Changes in v2: None drivers/usb/gadget/f_fastboot.c | 2 -- include/fastboot.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 697eee57d0..25784a193e 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -27,8 +27,6 @@ #include #endif -#define FASTBOOT_VERSION "0.4" - #define FASTBOOT_INTERFACE_CLASS 0xff #define FASTBOOT_INTERFACE_SUB_CLASS 0x42 #define FASTBOOT_INTERFACE_PROTOCOL 0x03 diff --git a/include/fastboot.h b/include/fastboot.h index 816e71b4d0..bf3d9e2f67 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -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) From patchwork Tue May 29 15:30:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922191 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="smeUYygf"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHtT0Yvdz9s08 for ; Wed, 30 May 2018 01:38:08 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BA113C21F21; Tue, 29 May 2018 15:34:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 850BAC21F3B; Tue, 29 May 2018 15:31:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A3F44C21EDC; Tue, 29 May 2018 15:31:34 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by lists.denx.de (Postfix) with ESMTPS id 47DADC21F06 for ; Tue, 29 May 2018 15:31:23 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id t11-v6so41874825wmt.0 for ; Tue, 29 May 2018 08:31:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aDe7n7AZMEqeBi+P+ePM1YwUirxp+Sz+q7KCWjzOiUc=; b=smeUYygf5gqzEd7toHSMIL8rtvBgQGny/K6c1aFJw+N7otDaUceQKvSBJx4S3V8I+t XNHePUKJ6Tu/Xl2aBKYDNrjDxJYkfnEH2yXE63UITULkbWQTWBVFZr708raBPxmqoSTK A9/ZStDnfIoViZzcT7fttJF8WzCE55SiKF9Y7P+i0Q/1gAVMeqLdAVYQFbJ6DauM7U1Q bqQfl4JfHDZPh3NYC3E4WoWvav2S+7XxG/jvAhDVajrCW34RVvsMcc+lh5XU8HqYo/1c bGm5kSCvGd0IO4BZXnC/WG2ovyRvewhnPwHGBZiHJuPsL8fHgKZyPcSoSJPW114g7lUF dxSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aDe7n7AZMEqeBi+P+ePM1YwUirxp+Sz+q7KCWjzOiUc=; b=Z4h9kczf4M7RLyFcj6wqhOFLTGK2QiuZGniYnNa9uX6AftRF1eOvyTRyVNsTHLUFmS rq9vMUO4FSEbspAQHdPXch9IbYz1IkeU1NrvNdM6Lp3ATf8wLUnXluWSGzRXyJXjugrs 3R/nZjArXAkngPme9VTBRwSf9N1JLxY7Fe+YD3Z8Hn8Dnv+LZzLJlDjg/vfjm78nMpXx 39bfWGsAl6Tgvt58hdhfOcWuLESAy/Bkrn3z42gDSMuPrDUVRsmp55dyyCh1rO8vXjdE DhkXE0RJay+fQHivrT1IMXU6nwx+hYCa0jErYrqKB9awxek+Q9t+BM+6N5alhB2FZSmp aVRw== X-Gm-Message-State: ALKqPwcjjUniSQ99LNUl4q/1jBkLtp7AFr69tQKOslQeVrCfPGyV/LlD ZSwvvwxq1XagPq7fLZNgPCggih/zxXo= X-Google-Smtp-Source: ADUXVKKugfA7t9I9lIw4PzGQAWMZbWtrcuMoPcvt2IK5f6CQD1uMxn7I4g26WLLT4BMiowH7D5fgCA== X-Received: by 2002:a1c:911:: with SMTP id 17-v6mr10639696wmj.5.1527607882657; Tue, 29 May 2018 08:31:22 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:22 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:48 +0000 Message-Id: <20180529153056.27328-11-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Marek Vasut , Jocelyn Bohr , Jassi Brar , Jocelyn Bohr Subject: [U-Boot] [PATCH v8 10/18] fastboot: Rename public fb_ functions to fastboot_ X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Rename fb_mmc_flash_write/fb_mmc_erase/fb_nand_flash_write/fb_nand_erase to fastboot_... as they form a public interface Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: - add docbook comments Changes in v5: - new Changes in v4: None Changes in v3: None Changes in v2: None drivers/fastboot/fb_mmc.c | 20 +++++++++++++++++--- drivers/fastboot/fb_nand.c | 20 +++++++++++++++++--- drivers/usb/gadget/f_fastboot.c | 12 ++++++------ include/fb_mmc.h | 21 ++++++++++++++++++--- include/fb_nand.h | 20 +++++++++++++++++--- 5 files changed, 75 insertions(+), 18 deletions(-) diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index 038905face..47fcf74b69 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -251,8 +251,16 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, } #endif -void fb_mmc_flash_write(const char *cmd, void *download_buffer, - unsigned int download_bytes, char *response) +/** + * fastboot_mmc_flash_write() - Write image to eMMC for fastboot + * + * @cmd: Named partition to write image to + * @download_buffer: Pointer to image data + * @download_bytes: Size of image data + * @response: Pointer to fastboot response buffer + */ +void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, + unsigned int download_bytes, char *response) { struct blk_desc *dev_desc; disk_partition_t info; @@ -349,7 +357,13 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, } } -void fb_mmc_erase(const char *cmd, char *response) +/** + * fastboot_mmc_flash_erase() - Erase eMMC for fastboot + * + * @cmd: Named partition to erase + * @response: Pointer to fastboot response buffer + */ +void fastboot_mmc_erase(const char *cmd, char *response) { int ret; struct blk_desc *dev_desc; diff --git a/drivers/fastboot/fb_nand.c b/drivers/fastboot/fb_nand.c index 849a6f16a5..535f541eb8 100644 --- a/drivers/fastboot/fb_nand.c +++ b/drivers/fastboot/fb_nand.c @@ -145,8 +145,16 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info, return blkcnt + bad_blocks; } -void fb_nand_flash_write(const char *cmd, void *download_buffer, - unsigned int download_bytes, char *response) +/** + * fastboot_nand_flash_write() - Write image to NAND for fastboot + * + * @cmd: Named device to write image to + * @download_buffer: Pointer to image data + * @download_bytes: Size of image data + * @response: Pointer to fastboot response buffer + */ +void fastboot_nand_flash_write(const char *cmd, void *download_buffer, + unsigned int download_bytes, char *response) { struct part_info *part; struct mtd_info *mtd = NULL; @@ -204,7 +212,13 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer, fastboot_okay(NULL, response); } -void fb_nand_erase(const char *cmd, char *response) +/** + * fastboot_nand_flash_erase() - Erase NAND for fastboot + * + * @cmd: Named device to erase + * @response: Pointer to fastboot response buffer + */ +void fastboot_nand_erase(const char *cmd, char *response) { struct part_info *part; struct mtd_info *mtd = NULL; diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 25784a193e..07d6a62155 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -577,12 +577,12 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) fastboot_fail("no flash device defined", response); #ifdef CONFIG_FASTBOOT_FLASH_MMC - fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, - download_bytes, response); + fastboot_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, + download_bytes, response); #endif #ifdef CONFIG_FASTBOOT_FLASH_NAND - fb_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, - download_bytes, response); + fastboot_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, + download_bytes, response); #endif fastboot_tx_write_str(response); } @@ -625,10 +625,10 @@ static void cb_erase(struct usb_ep *ep, struct usb_request *req) fastboot_fail("no flash device defined", response); #ifdef CONFIG_FASTBOOT_FLASH_MMC - fb_mmc_erase(cmd, response); + fastboot_mmc_erase(cmd, response); #endif #ifdef CONFIG_FASTBOOT_FLASH_NAND - fb_nand_erase(cmd, response); + fastboot_nand_erase(cmd, response); #endif fastboot_tx_write_str(response); } diff --git a/include/fb_mmc.h b/include/fb_mmc.h index 39a960cc9d..daca81a201 100644 --- a/include/fb_mmc.h +++ b/include/fb_mmc.h @@ -3,6 +3,21 @@ * Copyright 2014 Broadcom Corporation. */ -void fb_mmc_flash_write(const char *cmd, void *download_buffer, - unsigned int download_bytes, char *response); -void fb_mmc_erase(const char *cmd, char *response); +/** + * fastboot_mmc_flash_write() - Write image to eMMC for fastboot + * + * @cmd: Named partition to write image to + * @download_buffer: Pointer to image data + * @download_bytes: Size of image data + * @response: Pointer to fastboot response buffer + */ +void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, + unsigned int download_bytes, char *response); + +/** + * fastboot_mmc_flash_erase() - Erase eMMC for fastboot + * + * @cmd: Named partition to erase + * @response: Pointer to fastboot response buffer + */ +void fastboot_mmc_erase(const char *cmd, char *response); diff --git a/include/fb_nand.h b/include/fb_nand.h index 2c92a4eb50..b5d4c0cc5f 100644 --- a/include/fb_nand.h +++ b/include/fb_nand.h @@ -4,6 +4,20 @@ * Copyright 2015 Free Electrons. */ -void fb_nand_flash_write(const char *cmd, void *download_buffer, - unsigned int download_bytes, char *response); -void fb_nand_erase(const char *cmd, char *response); +/** + * fastboot_nand_flash_write() - Write image to NAND for fastboot + * + * @cmd: Named device to write image to + * @download_buffer: Pointer to image data + * @download_bytes: Size of image data + * @response: Pointer to fastboot response buffer + */ +void fastboot_nand_flash_write(const char *cmd, void *download_buffer, + unsigned int download_bytes, char *response); +/** + * fastboot_nand_flash_erase() - Erase NAND for fastboot + * + * @cmd: Named device to erase + * @response: Pointer to fastboot response buffer + */ +void fastboot_nand_erase(const char *cmd, char *response); From patchwork Tue May 29 15:30:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922193 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NGjYtJB8"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHv217rdz9s0W for ; Wed, 30 May 2018 01:38:38 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id D684AC21F47; Tue, 29 May 2018 15:34:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4F4B7C21ECA; Tue, 29 May 2018 15:31:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C7B0AC21F0C; Tue, 29 May 2018 15:31:39 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by lists.denx.de (Postfix) with ESMTPS id 5F323C21F0C for ; Tue, 29 May 2018 15:31:24 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id q4-v6so29527115wmq.1 for ; Tue, 29 May 2018 08:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=11uYGZ+R14lY2JEHHu5nFpXzbES09u4qafFKrGyXI5E=; b=NGjYtJB8WBG3qvuurpvk0MMAm1DrHs9HdwM8yyAN8iyYLs1I8I0wkJpViEdiyYMD9m I80bqx1xQTu3wCrePWIBR6UPmG3o+B0/Lhc+3BNp2+pSFH3eqh/Vysmv/cNxzmSLX3/c kA2ICNqeBp/j7wswij7RG9h2APhItdJR0g+/7fZoGE3GduaIiKA2IzejNu1cwSwf4Cuz oMTTRNatz4eWFX4v7DkZmotTgVZqqwKmat8vZzf+2DD/4Wo8KAHiXdPoavHJzkBjvCFl blgGfe1H1+jHmaZ6L80yGv6yMQhonQDL5IUohedwmbbSuLbKH1IGlERi0bGKmqQ6ypgi goZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=11uYGZ+R14lY2JEHHu5nFpXzbES09u4qafFKrGyXI5E=; b=lY4DMlu5S9m7LG6ROquauH3xMR5eBQ6gPwnMVfnS++QYFX9h0mFDXn1VcBaFJyagso IAQu++J6Zkw7lNPnTbSNdR0tv2jzM62YWVXz/ki0zTQOPRxaXs7ro5rFh/Msq2VsmqzC NhaKZRnb7oFmSRCQ9a5nTMdB8BRMMMLtXYYzM6xCori/OFBntUJqiqcrC3G72ka9qrtT RCkkHbjVYBvdbX/AWxFG2WZpQW73o7RCPlsu3xF54CY76s1CA+0WD80w1/M8fYjsa/Pj 5El87iO4cWcOlaSzc6M2EpPw7NWvrJwi0Uy5K1xQuPsxTRQOwytqGRucGc/k9Zi+etb+ +B+w== X-Gm-Message-State: ALKqPwezXioj27+k2T0dXTpoYVH35Cx3kV7l/+SyJM0CjmtgeTM14orA yxlEArFf7yvQQe6/JEhXkgAJn3u4awc= X-Google-Smtp-Source: ADUXVKIEtp7PA5XjNSqQA6vjsbDc4XufvWm4cAr8RGWJy8mS8riP/hKw2IWINDOlmg1QXQWGEbqtZQ== X-Received: by 2002:a1c:1f13:: with SMTP id f19-v6mr10515361wmf.73.1527607883885; Tue, 29 May 2018 08:31:23 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:23 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:49 +0000 Message-Id: <20180529153056.27328-12-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Tom Rini , Jocelyn Bohr Subject: [U-Boot] [PATCH v8 11/18] ti: fastboot: Move weak overrides to board files X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Overriding fastboot_set_reboot_flag() in arch/arm/mach-omap2/boot-common.c leaves it applying all boards that derive from this, not just the ones which have support for Android bootloader flow. Move the weak function override to the relevant board files. Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - new Changes in v2: None arch/arm/mach-omap2/boot-common.c | 10 ---------- board/ti/am57xx/board.c | 10 ++++++++++ board/ti/dra7xx/evm.c | 10 ++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/arch/arm/mach-omap2/boot-common.c b/arch/arm/mach-omap2/boot-common.c index b22b6713e5..d4a1e2e42c 100644 --- a/arch/arm/mach-omap2/boot-common.c +++ b/arch/arm/mach-omap2/boot-common.c @@ -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 diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c index fd9d20779b..177a3246c3 100644 --- a/board/ti/am57xx/board.c +++ b/board/ti/am57xx/board.c @@ -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 diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c index 6918f4de01..bbe54450ae 100644 --- a/board/ti/dra7xx/evm.c +++ b/board/ti/dra7xx/evm.c @@ -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 From patchwork Tue May 29 15:30:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922196 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="l4PFiMnK"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHwG372sz9s08 for ; Wed, 30 May 2018 01:39:42 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 242BFC21E96; Tue, 29 May 2018 15:35:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id EA194C21F4E; Tue, 29 May 2018 15:31:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E9576C21F2A; Tue, 29 May 2018 15:31:39 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by lists.denx.de (Postfix) with ESMTPS id 8E22EC21F00 for ; Tue, 29 May 2018 15:31:25 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id a8-v6so41798682wmg.5 for ; Tue, 29 May 2018 08:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nQ+Wrf+ffB080mb+unCsK24lu1WUjP8lmq48V0nKKC4=; b=l4PFiMnK0epWeKiWyAvZkTWAhggzMYHIjb63Np/cdg78gXBJU1hWnKKc8V63ppAMmR EA+7GOxUVW5qwnbLIHdd9efcAIr1zSewlFrKbzOMQocsStQWrcz3qAqoaBTKORQNW7eq Ge8uZc0QSju0YEbTwOLGZC6spqDChuzFF+PqtZQLAlJGmOAnRo9DMaituS9XKbJEAKMt /gPXO1HP/LTMrzUotcGOkKMFsjo2Us+y6O0MRVMshFHxCfjoOLHeYP2NbpHvD+ZBMDLS r5oyzFapds6qS8ESpi5Sf0sezpWRKEAny2FNT4YZD4tcclKVT2i04eTAh1ovoBUTdont MnBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nQ+Wrf+ffB080mb+unCsK24lu1WUjP8lmq48V0nKKC4=; b=iUa5g30z1QstLaN4ybACwdzZBq9CcdF29sddLFmS4rkIg7aqQMpZ8MlIe6WMi3M0wX Iu/IQMcuJiWsYLuzsbazy0SEXwtnS/ltBggnj/QkcWS2iGKFZyjMp2+kOGzwdxQxxdqd OmkpEYX7Hl5HzI00U0DUbobOFQquH8iPQ31ttcqID9MdJKc4biW1loCVTWfAxKDOkI+D N/0zHGupJEmzwglZtJf2R7rVJ5/KVpQALGPNlaW3JvO0GPgXNCMPTEMZO4XdyXQHtdfB SuogAQWaxzzj9KDf2aUOZeiJwTLayySIaIi0D0AMab2oHd2oIThvJTzSqRHJqnNzCiuk WySg== X-Gm-Message-State: ALKqPwdwkcElM7zIsGaVSkNgoYe/Lt3ltHBYKb8P8ZaJ1k4QgiiN50yk MEVJ9NiQnaB0J5aUefCtDnMjtI84oM8= X-Google-Smtp-Source: ADUXVKLKJaL56KwUMayMAQAqwokg/pHUm+ViLqHCr9gW+TcHJyTZQlUzcGS1g9l17RqszX0ZqtqILg== X-Received: by 2002:a1c:e6d4:: with SMTP id e81-v6mr10353903wmi.152.1527607885079; Tue, 29 May 2018 08:31:25 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:24 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:50 +0000 Message-Id: <20180529153056.27328-13-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Jocelyn Bohr , Heinrich Schuchardt Subject: [U-Boot] [PATCH v8 12/18] fs: Add fs_get_type_name to return current filesystem name X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add fs_get_type_name so we can get the current filesystem type. Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass Reviewed-by: Joe Hershberger --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: - add docbook comments Changes in v3: - new Changes in v2: None fs/fs.c | 13 +++++++++++++ include/fs.h | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/fs/fs.c b/fs/fs.c index 94cdc37deb..33808d549e 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -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; diff --git a/include/fs.h b/include/fs.h index d703ed5027..163da103b4 100644 --- a/include/fs.h +++ b/include/fs.h @@ -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". From patchwork Tue May 29 15:30:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922197 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uNb4H9rk"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHwg0fn5z9s08 for ; Wed, 30 May 2018 01:40:03 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id CB01BC21F2B; Tue, 29 May 2018 15:35:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C8B22C21F2F; Tue, 29 May 2018 15:31:46 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A76B9C21F3E; Tue, 29 May 2018 15:31:39 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by lists.denx.de (Postfix) with ESMTPS id 11948C21F0F for ; Tue, 29 May 2018 15:31:27 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id 18-v6so36279736wml.2 for ; Tue, 29 May 2018 08:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ivYE6zW219kSGdbZFDUBDufJX+T1NjTdkYVPAtqjpBM=; b=uNb4H9rkiBgBoi0HQTqfnNHWYmML8FNmxQ9Q1s+HfD6SZ6QD78XIZQvM+eo4fVB00+ lsj4qF7c4MzVCCIslo5aEYkl9Z+IQ00sDxU+xCSLJCB7anvuwg6JpUNhdmHXBwlrfaN7 Bz+rSOD3HC7r/4PnHvQ9sdQCsZpJttuKXjUAZIPv31QcS/W98e7roqZOd8WqZSRKsmQ0 gKSxZbaswblK+qlQmtp+TQdwJY+2ZcWIqlIJyeKS7FcIuSSJo7HmzxWeGv3GK48NqZzv 6t5G/QRNNJPV078fMTKNoGd8BiCbJYBuBdpzjH+FPr81ucUDrumSVntr1yBKLkaivlIE K3pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ivYE6zW219kSGdbZFDUBDufJX+T1NjTdkYVPAtqjpBM=; b=icXxwijvaCSip51PWF+33KUBGbw5l6nrkNTYarGn9LW2lRAIPmtVBloa3q9YCc2ZoH 0DB2kdz7Xqbu7R6Mvwa2YTMDg7Z0EM83v+3htliOmjLSCYLvGt6C9uS7cHz9bxevZnV4 V7FpCrd682tOq+f5VmzXutOpPue8mkEI3NSPgoylLtPCuIUIMlVbjwBvCIw48RXWEHsn 1VjnWVUrKhdWe6jY/AWfFLfzQsWNLl8/KDtufExNWfIzwThfy88HCzIjHB9py5jNHoJZ BFoescbRTDuTDbSRvU4vzb01Ti5R3gGqD12Bw1Ln1b9nuhjH1NuLvl82BrFvjI2UZFpR bRjw== X-Gm-Message-State: ALKqPwcE3+U9bw1FlIQo+o5Y0ZnTp44+5FiuPd6xK6+eNDimAxWodUZC w9g5cYVLhcnz9VhCNdMsUMWHDaRlgd8= X-Google-Smtp-Source: AB8JxZr428tO3iwQPuVV1U9sSzXQRrGr7H/TnxjX2mchVxPvl0Kd+Lw+4C5RwBq4Pss10qop2OGRlA== X-Received: by 2002:a1c:ca:: with SMTP id 193-v6mr10522419wma.99.1527607886534; Tue, 29 May 2018 08:31:26 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:25 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:51 +0000 Message-Id: <20180529153056.27328-14-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Benjamin Young , Jocelyn Bohr , Andre Przywara , Maxime Ripard , Chris Packham Subject: [U-Boot] [PATCH v8 13/18] fastboot: Migrate FASTBOOT_FLASH_NAND_TRIMFFS to Kconfig X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add FASTBOOT_FLASH_NAND_TRIMFFS to Kconfig; note there are no in-tree users of it. Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: - new Changes in v4: None Changes in v3: None Changes in v2: None drivers/fastboot/Kconfig | 7 +++++++ scripts/config_whitelist.txt | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 9bbc5c661d..1d7caaff99 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -86,6 +86,13 @@ config FASTBOOT_FLASH_MMC_DEV regarding the non-volatile storage device. Define this to the eMMC device that fastboot should use to store the image. +config FASTBOOT_FLASH_NAND_TRIMFFS + bool "Skip empty pages when flashing NAND" + depends on FASTBOOT_FLASH_NAND + help + When flashing NAND enable the DROP_FFS flag to drop trailing all-0xff + pages. + config FASTBOOT_GPT_NAME string "Target name for updating GPT" depends on FASTBOOT_FLASH_MMC && EFI_PARTITION diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 705ed89a65..117ed2e152 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -590,7 +590,6 @@ CONFIG_EXYNOS_SPL CONFIG_EXYNOS_TMU CONFIG_FACTORYSET CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE -CONFIG_FASTBOOT_FLASH_NAND_TRIMFFS CONFIG_FAST_FLASH_BIT CONFIG_FB_ADDR CONFIG_FB_BACKLIGHT From patchwork Tue May 29 15:30:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922203 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DXiQO2Tp"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wJ6D42bkz9s0W for ; Wed, 30 May 2018 01:48:20 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EA63EC21F1C; Tue, 29 May 2018 15:48:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, KHOP_BIG_TO_CC, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id DA365C21F3B; Tue, 29 May 2018 15:45:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BB9B1C21F19; Tue, 29 May 2018 15:31:41 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by lists.denx.de (Postfix) with ESMTPS id 16042C21F19 for ; Tue, 29 May 2018 15:31:29 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id a8-v6so41799190wmg.5 for ; Tue, 29 May 2018 08:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=D0m7tiM8HKBZOzxLRIXiHwIEj489ywI5QDKPSeA7fFo=; b=DXiQO2TplUaAoANkDaq3LykHDo1ilAOzGaH7zd+f0Oi3rvfB+UWn9LcWgoQTW2SG/X cWxIrdi+cDjdWgJkRTfT49FDt+0KzPlQpfxDz49K9RGSubGTyeQDB2lEG2apber9caDg wopuD50TeLmIpA/BRJ74qu5zYCpwvxw8kTU8h0Nos0boNaHsQV2bit744Q++wHHC3cr0 wxbm2YRZLawP6Xn7XtUESJgkrsyapzxaeVg+f+iJenEUoM+T904vLgpazKgHh/rloR2C 4m4bQXkeLI2ZOCRYmsi7bYivdWrI33aylOlICh+5f7FFd2DvE12Xd5wHEb45sL8q9rlY UKDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=D0m7tiM8HKBZOzxLRIXiHwIEj489ywI5QDKPSeA7fFo=; b=DzcTpQvjJ30VuQBcdagPLPgzBXqTEBl9tmJQLw8nHZRrCeavOBUiDnU8+b3ELUq7bn QjrrAJZ1eLlbKDuwQzJ8KS2G8wmRuEMP7+Ar1Gum5eKo8FtugSVazXAwlsklI17ErmAa 7HCYFTFmw0vHxWSQapXvCbDKKMH+2UfjSNlFoJwsB5ZrkKF7Bpom0zsLKXJZEDA8ZjOc iAwaOz7sWH7tgeZ2eS0EJmrFGPLlWJEW9PanHdL1PdXnsgr8vVC8gHjFxuFvBHLQW6VS 41N2A7noUBDwp+tPeCctyAMIDAJGOSKjFQy2VZku3fvtH69lYMF2Rwgw75ElQRJGpQf/ mTVQ== X-Gm-Message-State: ALKqPwfjHN8IQod76pSytoRWIkDHBsAgvVRqPJ4mISslHRnnRCH2Zx18 NNfU70mATKWx0D5vjZhR1H4TTk9qL2E= X-Google-Smtp-Source: ADUXVKIrF9N5gyUh8ujWqkrAayH8cHdpIB4CnQCNfICoxkbZU/lY/GK4pC+eo3/qYgzO9xGuOAa8yw== X-Received: by 2002:a1c:6506:: with SMTP id z6-v6mr10486447wmb.86.1527607888451; Tue, 29 May 2018 08:31:28 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:27 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:52 +0000 Message-Id: <20180529153056.27328-15-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> X-Mailman-Approved-At: Tue, 29 May 2018 15:45:57 +0000 Cc: Jocelyn Bohr , Chris Packham , Angelo Dureghello , Jagan Teki , Alexander Graf , Ben Young , Andre Przywara , Jassi Brar , Heinrich Schuchardt , Andy Yan , Maxime Ripard Subject: [U-Boot] [PATCH v8 14/18] mmc: Separate "mmc swrite" from fastboot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Introduce CONFIG_IMAGE_SPARSE and CONFIG_CMD_MMC_SWRITE so the "mmc swrite" command is separated from the fastboot code. Move image-sparse from common to lib so it's clear it's library code. Rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE and migrate it to Kconfig. Signed-off-by: Alex Kiernan Acked-by: Jassi Brar Reviewed-by: Simon Glass --- Changes in v8: - add Reviewed-by: tag Changes in v7: None Changes in v6: None Changes in v5: - rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE and migrate it to Kconfig. Changes in v4: - new Changes in v3: None Changes in v2: None cmd/Kconfig | 8 ++++++++ cmd/mmc.c | 12 ++++++------ common/Makefile | 1 - drivers/fastboot/Kconfig | 1 + lib/Kconfig | 11 +++++++++++ lib/Makefile | 1 + {common => lib}/image-sparse.c | 6 +----- scripts/config_whitelist.txt | 1 - 8 files changed, 28 insertions(+), 13 deletions(-) rename {common => lib}/image-sparse.c (97%) diff --git a/cmd/Kconfig b/cmd/Kconfig index 9848c067da..30cf63f172 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -833,6 +833,14 @@ config CMD_MMC_RPMB Enable the commands for reading, writing and programming the key for the Replay Protection Memory Block partition in eMMC. +config CMD_MMC_SWRITE + bool "mmc swrite" + depends on CMD_MMC && MMC_WRITE + select IMAGE_SPARSE + help + Enable support for the "mmc swrite" command to write Android sparse + images to eMMC. + config CMD_NAND bool "nand" default y if NAND_SUNXI diff --git a/cmd/mmc.c b/cmd/mmc.c index a5719b81eb..c2ee2d9c0a 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -308,8 +308,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag, return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; } -#if CONFIG_IS_ENABLED(MMC_WRITE) -#if defined(CONFIG_FASTBOOT_FLASH) +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) static lbaint_t mmc_sparse_write(struct sparse_storage *info, lbaint_t blk, lbaint_t blkcnt, const void *buffer) { @@ -374,6 +373,7 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp, int flag, } #endif +#if CONFIG_IS_ENABLED(MMC_WRITE) static int do_mmc_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -868,10 +868,10 @@ static cmd_tbl_t cmd_mmc[] = { U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""), #if CONFIG_IS_ENABLED(MMC_WRITE) U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""), -#if defined(CONFIG_FASTBOOT_FLASH) - U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""), -#endif U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""), +#endif +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) + U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""), #endif U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""), U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""), @@ -927,7 +927,7 @@ U_BOOT_CMD( "info - display info of the current MMC device\n" "mmc read addr blk# cnt\n" "mmc write addr blk# cnt\n" -#if defined(CONFIG_FASTBOOT_FLASH) +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) "mmc swrite addr blk#\n" #endif "mmc erase blk# cnt\n" diff --git a/common/Makefile b/common/Makefile index 9ec40b9d27..b3da72ebb2 100644 --- a/common/Makefile +++ b/common/Makefile @@ -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 diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 1d7caaff99..0c9ced53de 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -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 diff --git a/lib/Kconfig b/lib/Kconfig index 1590f7afa4..15c6a52d4a 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -61,6 +61,17 @@ config SPL_STRTO config TPL_STRTO bool +config IMAGE_SPARSE + bool + +config IMAGE_SPARSE_FILLBUF_SIZE + hex "Android sparse image CHUNK_TYPE_FILL buffer size" + default 0x80000 + depends on IMAGE_SPARSE + help + Set the size of the fill buffer used when processing CHUNK_TYPE_FILL + chunks. + config USE_PRIVATE_LIBGCC bool "Use private libgcc" depends on HAVE_PRIVATE_LIBGCC diff --git a/lib/Makefile b/lib/Makefile index e6cb4afc23..c0511cbff8 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -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 diff --git a/common/image-sparse.c b/lib/image-sparse.c similarity index 97% rename from common/image-sparse.c rename to lib/image-sparse.c index 1ae7a4d0e8..036062139b 100644 --- a/common/image-sparse.c +++ b/lib/image-sparse.c @@ -44,10 +44,6 @@ #include -#ifndef CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE -#define CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE (1024 * 512) -#endif - static void default_log(const char *ignored, char *response) {} int write_sparse_image(struct sparse_storage *info, @@ -69,7 +65,7 @@ int write_sparse_image(struct sparse_storage *info, int i; int j; - fill_buf_num_blks = CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE / info->blksz; + fill_buf_num_blks = CONFIG_IMAGE_SPARSE_FILLBUF_SIZE / info->blksz; /* Read and skip over sparse image header */ sparse_header = (sparse_header_t *)data; diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 117ed2e152..5304f9577d 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -589,7 +589,6 @@ CONFIG_EXYNOS_RELOCATE_CODE_BASE CONFIG_EXYNOS_SPL CONFIG_EXYNOS_TMU CONFIG_FACTORYSET -CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE CONFIG_FAST_FLASH_BIT CONFIG_FB_ADDR CONFIG_FB_BACKLIGHT From patchwork Tue May 29 15:30:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922195 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FuDEkNhB"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHw91q6dz9s0W for ; Wed, 30 May 2018 01:39:37 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id E7EB4C21F58; Tue, 29 May 2018 15:36:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 825D1C21EA7; Tue, 29 May 2018 15:31:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F1D43C21EEB; Tue, 29 May 2018 15:31:46 +0000 (UTC) Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by lists.denx.de (Postfix) with ESMTPS id E0ED4C21EEB for ; Tue, 29 May 2018 15:31:33 +0000 (UTC) Received: by mail-wm0-f54.google.com with SMTP id v131-v6so22590660wma.1 for ; Tue, 29 May 2018 08:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rzZ4OKuzRY4FCGwnnbazQZd2MOwN7IC17aPlwkg5swo=; b=FuDEkNhB6zBmyLnr+z0P0oqGee3yzmk8z1ohdko1P2ksdGiXie0AZydPfbu6pAlcqv gmF/e311kaviNENcb7sdsNQfa6xdi0WAUPU+paqv3W+m0TrYJqqO2dGp8gtwJLyeWMB6 dqN3jDyK5MUdMHUSAUBsHFTkEUacX8xJ0iEvswjLz2s+8X78y+HZtyow8W9OJcRjHI5Z dhBt7bDoJ/JJ86Axixnylt5ssuC0GJpL1fimf2GZ1RS+0tQGRU9cTmyJL5A1N2hoWkho hlVDJ1EoFiWXdyOXk98tiozChEeUltERVjlrW1eLL3bG7dUzJTDM84whhybH/uFJK5Pq ynyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rzZ4OKuzRY4FCGwnnbazQZd2MOwN7IC17aPlwkg5swo=; b=m2jOpWPNM+ryF/KCPZrdpJ7Zy8u75NRIVHTnFsfspkayMcb/nmES2SEh2yniwy8Lsg XRMBv+aG5QyALw5NzqX8PnvE8Hfj7O0XzQUwJN/9/C/qfWIEOnev+dW0ThhynuAx4+KK dc52TjnowrWz+iHUpcYUK+xvmu702driM3KGDyrsJ+NOKo5jGUJ771E/XPnzKNnrT3u0 TUCUUO1HZyp4tJUa+fU1qvh5b/WN1bB4TTDfbD2bs+N62ZfHlmnSYDE85eYB12RmK61o PK7+LQ5liRn90snH5KxDpu4KGH/pJUhJoyPqkPLVED5yZVgfVa0djf9obbV811ETLLjY kIxA== X-Gm-Message-State: ALKqPwf95gfX8oPT+ZoKEqccmSOVJMpBaBsmW2expaYm3/5oeEKbjlIj 5bqczEyJyM9DXgz5wCp1VueMgQtRgMk= X-Google-Smtp-Source: ADUXVKJcH9sGQKoD94n4AGZZNmoqeUlUk8c+LXbXBii3CERy+KNEmR9iThhFogWI/cqXEb3XaJ4GJw== X-Received: by 2002:a1c:b443:: with SMTP id d64-v6mr8740974wmf.44.1527607892249; Tue, 29 May 2018 08:31:32 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:31 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:53 +0000 Message-Id: <20180529153056.27328-16-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Benjamin Young , Jocelyn Bohr , Maxime Ripard , Jagan Teki , Jassi Brar , Jason Kridner , Jocelyn Bohr Subject: [U-Boot] [PATCH v8 15/18] net: fastboot: Merge AOSP UDP fastboot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Signed-off-by: Alex Deymo Signed-off-by: Jocelyn Bohr Reviewed-by: Simon Glass Acked-by: Joe Hershberger --- Changes in v8: None Changes in v7: None Changes in v6: - add docbook comments - rename fastboot_download_data() to fastboot_data_download(), rename fastboot_get_bytes_remaining() to fastboot_data_remaining() - split fastboot_data_complete() out from fastboot_data_download() so we can call it at the end of the transfer phase for USB Changes in v5: - make fastboot_bytes_received/expected static and add function fastboot_get_bytes_remaining() - move fastboot_buf_addr/fastboot_buf_size/fastboot_progress_callback into fastboot-internal.h - delete redundant fb_ prefixes from statics Changes in v4: - guard fb_getvar/fb_command with UDP_FUNCTION_FASTBOOT in Makefile - add docbook comments - remove parameter from fastboot_boot() since we always want fastboot_buf_addr (and if we're using fastboot_bootcmd then it's ignored) - split oem format into new patch Changes in v3: - use FASTBOOT as our guard in Kconfig not a list of USB || UDP - correct mis-translation from AOSP introduced when cleaning up for checkpatch - we should write when buffer is not NULL, rather than erasing, and erase when buffer is NULL - use CMD_RET_USAGE from do_fastboot - remove do_fastboot_udp from cmd/net.c and rewrite using net_loop() - rename timed_send_info to fastboot_send_info, rename fastboot_send_info to fastboot_udp_send_info - replace FASTBOOT_HEADER_SIZE with sizeof(struct fastboot_header) - move start time into timed_send_info() rather than passing it in - make calls to fastboot_udp_send_info a runtime dependency, not a compile time one - set ${filesize} to size of downloaded image - add progress meter from USB path during download - add support for 'oem format' command from the USB path - rename 'fastbootcmd' to 'fastboot_bootcmd' to make clear that this is the fastboot boot command - make getvar implementation table driven - add fastboot_buf_addr, fastboot_buf_size to override buffer address and size - return correct filesystem type in getvar partition-type on MMC - process "fastboot." prefixed env variables in getvar first so you can override the normal values (this also lets you set a fs type for NAND devices) - squash subsequent patches which change this code into this one: - If the fastboot flash/erase commands are disabled, remove that support so we still build correctly. - Add NAND support to fastboot UDP flash/erase commands - If we don't have a partition name passed, report it as not found. - Change the behaviour of the fastboot net code such that "reboot-bootloader" is no longer written to CONFIG_FASTBOOT_BUF_ADDR for use as a marker on reboot (the AOSP code in common/android-bootloader.c uses this marker - this code could be reinstated there if that gets merged). - Merge USB and UDP boot code. The USB implementation stays the same, but UDP no longer passes an fdt. We introduce a new environment variable 'fastboot_bootcmd' which if set overrides the hardcoded boot command, setting this then allows the UDP implementation to remain the same. If after running 'fastboot_bootcmd' the board has not booted, control is returned to U-Boot and the fastboot process ends. - Separate the fastboot protocol handling from the fastboot UDP code in preparation for reusing it in the USB code. Changes in v2: - ensure fastboot syntax is backward compatible - 'fastboot 0' means 'fastboot usb 0' cmd/Kconfig | 4 +- cmd/fastboot.c | 91 +++++++++- drivers/fastboot/Kconfig | 7 + drivers/fastboot/Makefile | 3 +- drivers/fastboot/fb_command.c | 302 ++++++++++++++++++++++++++++++++ drivers/fastboot/fb_common.c | 93 ++++++++++ drivers/fastboot/fb_getvar.c | 230 ++++++++++++++++++++++++ drivers/fastboot/fb_mmc.c | 84 ++++++++- drivers/fastboot/fb_nand.c | 19 +- include/fastboot-internal.h | 36 ++++ include/fastboot.h | 104 +++++++++++ include/fb_mmc.h | 18 +- include/fb_nand.h | 19 +- include/net.h | 2 +- include/net/fastboot.h | 21 +++ net/Makefile | 1 + net/fastboot.c | 317 ++++++++++++++++++++++++++++++++++ net/net.c | 7 + 18 files changed, 1338 insertions(+), 20 deletions(-) create mode 100644 drivers/fastboot/fb_command.c create mode 100644 drivers/fastboot/fb_getvar.c create mode 100644 include/fastboot-internal.h create mode 100644 include/net/fastboot.h create mode 100644 net/fastboot.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 30cf63f172..17ca0bb267 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -655,8 +655,8 @@ config CMD_FASTBOOT This enables the command "fastboot" which enables the Android fastboot mode for the platform. Fastboot is a protocol for downloading images, flashing and device control used on - Android devices. Fastboot requires support for acting as a USB - device. + Android devices. Fastboot requires either the network stack + enabled or support for acting as a USB device. See doc/README.android-fastboot for more information. diff --git a/cmd/fastboot.c b/cmd/fastboot.c index a5ec5f46f6..557257aef8 100644 --- a/cmd/fastboot.c +++ b/cmd/fastboot.c @@ -10,10 +10,32 @@ #include #include #include +#include +#include #include -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 | 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", - "\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 ); diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 0c9ced53de..625f016600 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -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 diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile index e4bd389adf..8831096181 100644 --- a/drivers/fastboot/Makefile +++ b/drivers/fastboot/Makefile @@ -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 diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c new file mode 100644 index 0000000000..af4f500694 --- /dev/null +++ b/drivers/fastboot/fb_command.c @@ -0,0 +1,302 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (C) 2016 The Android Open Source Project + */ + +#include +#include +#include +#include +#include +#include +#include + +/** + * 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 okay(char *, char *); +static void getvar(char *, char *); +static void download(char *, char *); +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH) +static void flash(char *, char *); +static void erase(char *, char *); +#endif +static void reboot_bootloader(char *, char *); + +static const struct { + const char *command; + void (*dispatch)(char *cmd_parameter, char *response); +} commands[FASTBOOT_COMMAND_COUNT] = { + [FASTBOOT_COMMAND_GETVAR] = { + .command = "getvar", + .dispatch = getvar + }, + [FASTBOOT_COMMAND_DOWNLOAD] = { + .command = "download", + .dispatch = download + }, +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH) + [FASTBOOT_COMMAND_FLASH] = { + .command = "flash", + .dispatch = flash + }, + [FASTBOOT_COMMAND_ERASE] = { + .command = "erase", + .dispatch = erase + }, +#endif + [FASTBOOT_COMMAND_BOOT] = { + .command = "boot", + .dispatch = okay + }, + [FASTBOOT_COMMAND_CONTINUE] = { + .command = "continue", + .dispatch = okay + }, + [FASTBOOT_COMMAND_REBOOT] = { + .command = "reboot", + .dispatch = okay + }, + [FASTBOOT_COMMAND_REBOOT_BOOTLOADER] = { + .command = "reboot-bootloader", + .dispatch = reboot_bootloader + }, + [FASTBOOT_COMMAND_SET_ACTIVE] = { + .command = "set_active", + .dispatch = okay + }, +}; + +/** + * 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(commands[i].command, cmd_string)) { + if (commands[i].dispatch) { + 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; +} + +/** + * okay() - Send bare OKAY response + * + * @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 okay(char *cmd_parameter, char *response) +{ + fastboot_okay(NULL, response); +} + +/** + * getvar() - Read a config/version variable + * + * @cmd_parameter: Pointer to command parameter + * @response: Pointer to fastboot response buffer + */ +static void 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 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_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_data_remaining() - return bytes remaining in current transfer + * + * Return: Number of bytes left in the current download + */ +u32 fastboot_data_remaining(void) +{ + return fastboot_bytes_expected - fastboot_bytes_received; +} + +/** + * fastboot_data_download() - 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_data_download(const void *fastboot_data, + unsigned int fastboot_data_len, + char *response) +{ +#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_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'); + } + *response = '\0'; +} + +/** + * fastboot_data_complete() - Mark current transfer complete + * + * @response: Pointer to fastboot response buffer + * + * Set image_size and ${filesize} to the total size of the downloaded image. + */ +void fastboot_data_complete(char *response) +{ + /* 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; +} + +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH) +/** + * 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 flash(char *cmd_parameter, char *response) +{ +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC) + fastboot_mmc_flash_write(cmd_parameter, fastboot_buf_addr, image_size, + response); +#endif +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND) + fastboot_nand_flash_write(cmd_parameter, fastboot_buf_addr, image_size, + response); +#endif +} + +/** + * 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 erase(char *cmd_parameter, char *response) +{ +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC) + fastboot_mmc_erase(cmd_parameter, response); +#endif +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND) + fastboot_nand_erase(cmd_parameter, response); +#endif +} +#endif + +/** + * reboot_bootloader() - Sets reboot bootloader flag. + * + * @cmd_parameter: Pointer to command parameter + * @response: Pointer to fastboot response buffer + */ +static void reboot_bootloader(char *cmd_parameter, char *response) +{ + if (fastboot_set_reboot_flag()) + fastboot_fail("Cannot set reboot flag", response); + else + fastboot_okay(NULL, response); +} diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c index 79e080ac87..c6e06aab7a 100644 --- a/drivers/fastboot/fb_common.c +++ b/drivers/fastboot/fb_common.c @@ -12,6 +12,22 @@ #include #include +#include + +/** + * fastboot_buf_addr - base address of the fastboot download buffer + */ +void *fastboot_buf_addr; + +/** + * fastboot_buf_size - size of the fastboot download buffer + */ +u32 fastboot_buf_size; + +/** + * fastboot_progress_callback - callback executed during long operations + */ +void (*fastboot_progress_callback)(const char *msg); /** * fastboot_response() - Writes a response of the form "$tag$reason". @@ -74,3 +90,80 @@ int __weak fastboot_set_reboot_flag(void) { return -ENOSYS; } + +/** + * 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 ", 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); +} diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c new file mode 100644 index 0000000000..4d264c985d --- /dev/null +++ b/drivers/fastboot/fb_getvar.c @@ -0,0 +1,230 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (C) 2016 The Android Open Source Project + */ + +#include +#include +#include +#include +#include +#include +#include + +static void getvar_version(char *var_parameter, char *response); +static void getvar_bootloader_version(char *var_parameter, char *response); +static void getvar_downloadsize(char *var_parameter, char *response); +static void getvar_serialno(char *var_parameter, char *response); +static void getvar_version_baseband(char *var_parameter, char *response); +static void getvar_product(char *var_parameter, char *response); +static void getvar_current_slot(char *var_parameter, char *response); +static void getvar_slot_suffixes(char *var_parameter, char *response); +static void getvar_has_slot(char *var_parameter, char *response); +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC) +static void getvar_partition_type(char *part_name, char *response); +#endif +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH) +static void getvar_partition_size(char *part_name, char *response); +#endif + +static const struct { + const char *variable; + void (*dispatch)(char *var_parameter, char *response); +} getvar_dispatch[] = { + { + .variable = "version", + .dispatch = getvar_version + }, { + .variable = "bootloader-version", + .dispatch = getvar_bootloader_version + }, { + .variable = "version-bootloader", + .dispatch = getvar_bootloader_version + }, { + .variable = "downloadsize", + .dispatch = getvar_downloadsize + }, { + .variable = "max-download-size", + .dispatch = getvar_downloadsize + }, { + .variable = "serialno", + .dispatch = getvar_serialno + }, { + .variable = "version-baseband", + .dispatch = getvar_version_baseband + }, { + .variable = "product", + .dispatch = getvar_product + }, { + .variable = "current-slot", + .dispatch = getvar_current_slot + }, { + .variable = "slot-suffixes", + .dispatch = getvar_slot_suffixes + }, { + .variable = "has_slot", + .dispatch = getvar_has_slot +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC) + }, { + .variable = "partition-type", + .dispatch = getvar_partition_type +#endif +#if CONFIG_IS_ENABLED(FASTBOOT_FLASH) + }, { + .variable = "partition-size", + .dispatch = getvar_partition_size +#endif + } +}; + +static void getvar_version(char *var_parameter, char *response) +{ + fastboot_okay(FASTBOOT_VERSION, response); +} + +static void getvar_bootloader_version(char *var_parameter, char *response) +{ + fastboot_okay(U_BOOT_VERSION, response); +} + +static void getvar_downloadsize(char *var_parameter, char *response) +{ + fastboot_response("OKAY", response, "0x%08x", fastboot_buf_size); +} + +static void 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 getvar_version_baseband(char *var_parameter, char *response) +{ + fastboot_okay("N/A", response); +} + +static void 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 getvar_current_slot(char *var_parameter, char *response) +{ + /* A/B not implemented, for now always return _a */ + fastboot_okay("_a", response); +} + +static void getvar_slot_suffixes(char *var_parameter, char *response) +{ + fastboot_okay("_a,_b", response); +} + +static void 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 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 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., 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(getvar_dispatch); ++i) { + if (!strcmp(getvar_dispatch[i].variable, + cmd_parameter)) { + getvar_dispatch[i].dispatch(var_parameter, + response); + return; + } + } + pr_warn("WARNING: unknown variable: %s\n", cmd_parameter); + fastboot_fail("Variable not implemented", response); + } +} diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index 47fcf74b69..4c1c7fd2cd 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -15,6 +16,8 @@ #include #include +#define FASTBOOT_MAX_BLK_WRITE 16384 + #define BOOT_PARTITION_NAME "boot" struct fb_mmc_sparse { @@ -43,13 +46,48 @@ 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; + + for (i = 0; i < blkcnt; i += FASTBOOT_MAX_BLK_WRITE) { + cur_blkcnt = min((int)blkcnt - i, FASTBOOT_MAX_BLK_WRITE); + if (buffer) { + if (fastboot_progress_callback) + fastboot_progress_callback("writing"); + blks_written = blk_dwrite(block_dev, blk, cur_blkcnt, + buffer + (i * block_dev->blksz)); + } else { + if (fastboot_progress_callback) + fastboot_progress_callback("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,6 +290,38 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, } #endif +/** + * fastboot_mmc_get_part_info() - Lookup eMMC partion by name + * + * @part_name: Named partition to lookup + * @dev_desc: Pointer to returned blk_desc pointer + * @part_info: Pointer to returned disk_partition_t + * @response: Pointer to fastboot response buffer + */ +int fastboot_mmc_get_part_info(char *part_name, struct blk_desc **dev_desc, + disk_partition_t *part_info, char *response) +{ + 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; +} + /** * fastboot_mmc_flash_write() - Write image to eMMC for fastboot * @@ -260,7 +331,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc, * @response: Pointer to fastboot response buffer */ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, - unsigned int download_bytes, char *response) + u32 download_bytes, char *response) { struct blk_desc *dev_desc; disk_partition_t info; @@ -403,7 +474,8 @@ void fastboot_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); diff --git a/drivers/fastboot/fb_nand.c b/drivers/fastboot/fb_nand.c index 535f541eb8..526bc12307 100644 --- a/drivers/fastboot/fb_nand.c +++ b/drivers/fastboot/fb_nand.c @@ -88,7 +88,7 @@ static int _fb_nand_erase(struct mtd_info *mtd, struct part_info *part) } static int _fb_nand_write(struct mtd_info *mtd, struct part_info *part, - void *buffer, unsigned int offset, + void *buffer, u32 offset, size_t length, size_t *written) { int flags = WITH_WR_VERIFY; @@ -145,6 +145,21 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info, return blkcnt + bad_blocks; } +/** + * fastboot_nand_get_part_info() - Lookup NAND partion by name + * + * @part_name: Named device to lookup + * @part_info: Pointer to returned part_info pointer + * @response: Pointer to fastboot response buffer + */ +int fastboot_nand_get_part_info(char *part_name, struct part_info **part_info, + char *response) +{ + struct mtd_info *mtd = NULL; + + return fb_nand_lookup(part_name, &mtd, part_info, response); +} + /** * fastboot_nand_flash_write() - Write image to NAND for fastboot * @@ -154,7 +169,7 @@ static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info, * @response: Pointer to fastboot response buffer */ void fastboot_nand_flash_write(const char *cmd, void *download_buffer, - unsigned int download_bytes, char *response) + u32 download_bytes, char *response) { struct part_info *part; struct mtd_info *mtd = NULL; diff --git a/include/fastboot-internal.h b/include/fastboot-internal.h new file mode 100644 index 0000000000..bf2f2b3c89 --- /dev/null +++ b/include/fastboot-internal.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _FASTBOOT_INTERNAL_H_ +#define _FASTBOOT_INTERNAL_H_ + +/** + * fastboot_buf_addr - base address of the fastboot download buffer + */ +extern void *fastboot_buf_addr; + +/** + * fastboot_buf_size - size of the fastboot download buffer + */ +extern u32 fastboot_buf_size; + +/** + * fastboot_progress_callback - callback executed during long operations + */ +extern void (*fastboot_progress_callback)(const char *msg); + +/** + * fastboot_getvar() - Writes variable indicated by cmd_parameter to response. + * + * @cmd_parameter: Pointer to command parameter + * @response: Pointer to fastboot response buffer + * + * Look up cmd_parameter first as an environment variable of the form + * fastboot., if that exists return use its value to set + * response. + * + * Otherwise lookup the name of variable and execute the appropriate + * function to return the requested value. + */ +void fastboot_getvar(char *cmd_parameter, char *response); + +#endif diff --git a/include/fastboot.h b/include/fastboot.h index bf3d9e2f67..9a3d5ba693 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -15,8 +15,28 @@ #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, + + FASTBOOT_COMMAND_COUNT +}; + /** * fastboot_response() - Writes a response of the form "$tag$reason". * @@ -43,5 +63,89 @@ void fastboot_fail(const char *reason, char *response); * @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_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 ", 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_data_remaining() - return bytes remaining in current transfer + * + * Return: Number of bytes left in the current download + */ +u32 fastboot_data_remaining(void); + +/** + * fastboot_data_download() - 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. + */ +void fastboot_data_download(const void *fastboot_data, + unsigned int fastboot_data_len, char *response); + +/** + * fastboot_data_complete() - Mark current transfer complete + * + * @response: Pointer to fastboot response buffer + * + * Set image_size and ${filesize} to the total size of the downloaded image. + */ +void fastboot_data_complete(char *response); + #endif /* _FASTBOOT_H_ */ diff --git a/include/fb_mmc.h b/include/fb_mmc.h index daca81a201..fd5db9eac8 100644 --- a/include/fb_mmc.h +++ b/include/fb_mmc.h @@ -3,6 +3,20 @@ * Copyright 2014 Broadcom Corporation. */ +#ifndef _FB_MMC_H_ +#define _FB_MMC_H_ + +/** + * fastboot_mmc_get_part_info() - Lookup eMMC partion by name + * + * @part_name: Named partition to lookup + * @dev_desc: Pointer to returned blk_desc pointer + * @part_info: Pointer to returned disk_partition_t + * @response: Pointer to fastboot response buffer + */ +int fastboot_mmc_get_part_info(char *part_name, struct blk_desc **dev_desc, + disk_partition_t *part_info, char *response); + /** * fastboot_mmc_flash_write() - Write image to eMMC for fastboot * @@ -12,8 +26,7 @@ * @response: Pointer to fastboot response buffer */ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, - unsigned int download_bytes, char *response); - + u32 download_bytes, char *response); /** * fastboot_mmc_flash_erase() - Erase eMMC for fastboot * @@ -21,3 +34,4 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, * @response: Pointer to fastboot response buffer */ void fastboot_mmc_erase(const char *cmd, char *response); +#endif diff --git a/include/fb_nand.h b/include/fb_nand.h index b5d4c0cc5f..08ab0e28a6 100644 --- a/include/fb_nand.h +++ b/include/fb_nand.h @@ -4,6 +4,21 @@ * Copyright 2015 Free Electrons. */ +#ifndef _FB_NAND_H_ +#define _FB_NAND_H_ + +#include + +/** + * fastboot_nand_get_part_info() - Lookup NAND partion by name + * + * @part_name: Named device to lookup + * @part_info: Pointer to returned part_info pointer + * @response: Pointer to fastboot response buffer + */ +int fastboot_nand_get_part_info(char *part_name, struct part_info **part_info, + char *response); + /** * fastboot_nand_flash_write() - Write image to NAND for fastboot * @@ -13,7 +28,8 @@ * @response: Pointer to fastboot response buffer */ void fastboot_nand_flash_write(const char *cmd, void *download_buffer, - unsigned int download_bytes, char *response); + u32 download_bytes, char *response); + /** * fastboot_nand_flash_erase() - Erase NAND for fastboot * @@ -21,3 +37,4 @@ void fastboot_nand_flash_write(const char *cmd, void *download_buffer, * @response: Pointer to fastboot response buffer */ void fastboot_nand_erase(const char *cmd, char *response); +#endif diff --git a/include/net.h b/include/net.h index 65f51d77a5..5760685556 100644 --- a/include/net.h +++ b/include/net.h @@ -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 */ diff --git a/include/net/fastboot.h b/include/net/fastboot.h new file mode 100644 index 0000000000..68602095d2 --- /dev/null +++ b/include/net/fastboot.h @@ -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__ */ diff --git a/net/Makefile b/net/Makefile index d1e8e01f62..07466879f5 100644 --- a/net/Makefile +++ b/net/Makefile @@ -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) diff --git a/net/fastboot.c b/net/fastboot.c new file mode 100644 index 0000000000..a9f7c0743d --- /dev/null +++ b/net/fastboot.c @@ -0,0 +1,317 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (C) 2016 The Android Open Source Project + */ + +#include +#include +#include +#include + +/* 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 sequence_number = 1; +static const unsigned short packet_size = PACKET_SIZE; +static const unsigned short 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 response_header = { + .id = FASTBOOT_FASTBOOT, + .flags = 0, + .seq = htons(sequence_number) + }; + ++sequence_number; + packet = net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE; + packet_base = packet; + + /* Write headers */ + memcpy(packet, &response_header, sizeof(response_header)); + packet += sizeof(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 + * + * @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 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 response_header = 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; + } + + response_header.seq = htons(response_header.seq); + memcpy(packet, &response_header, sizeof(response_header)); + packet += sizeof(response_header); + + switch (header.id) { + case FASTBOOT_QUERY: + tmp = htons(sequence_number); + memcpy(packet, &tmp, sizeof(tmp)); + packet += sizeof(tmp); + break; + case FASTBOOT_INIT: + tmp = htons(udp_version); + memcpy(packet, &tmp, sizeof(tmp)); + packet += sizeof(tmp); + tmp = htons(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) { + if (!fastboot_data_len && !fastboot_data_remaining()) { + fastboot_data_complete(response); + } else { + fastboot_data_download(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 (header.seq != sequence_number) { + response_header.seq = htons(sequence_number); + memcpy(packet_base, &response_header, + sizeof(response_header)); + } + /* Write response to packet */ + memcpy(packet, response, strlen(response)); + packet += strlen(response); + break; + default: + pr_err("ID %d not implemented.\n", 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 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(&header, packet, sizeof(header)); + header.flags = 0; + header.seq = ntohs(header.seq); + packet += sizeof(header); + len -= sizeof(header); + + switch (header.id) { + case FASTBOOT_QUERY: + fastboot_send(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 (header.seq == sequence_number) { + fastboot_send(header, fastboot_data, + fastboot_data_len, 0); + sequence_number++; + } else if (header.seq == sequence_number - 1) { + /* Retransmit last sent packet */ + fastboot_send(header, fastboot_data, + fastboot_data_len, 1); + } + break; + default: + pr_err("ID %d not implemented.\n", header.id); + header.id = FASTBOOT_ERROR; + fastboot_send(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); +} diff --git a/net/net.c b/net/net.c index 7f85211442..a4932f46d9 100644 --- a/net/net.c +++ b/net/net.c @@ -87,6 +87,7 @@ #include #include #include +#include #include #if defined(CONFIG_LED_STATUS) #include @@ -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"); From patchwork Tue May 29 15:30:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922194 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ANGksj0T"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHvz2f08z9s08 for ; Wed, 30 May 2018 01:39:27 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 0C972C21F1D; Tue, 29 May 2018 15:35:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B3FCDC21EB1; Tue, 29 May 2018 15:31:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DD1F1C21F60; Tue, 29 May 2018 15:31:46 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by lists.denx.de (Postfix) with ESMTPS id CD78AC21F2F for ; Tue, 29 May 2018 15:31:34 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id o78-v6so41930969wmg.0 for ; Tue, 29 May 2018 08:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gL0w1qmB/xNEtYPLEb82oejBmgO/Eg6z+K2+EKN4GAA=; b=ANGksj0TgwvLiqHeQ8D2BcfTKMXK82FsGj5chnHAMCmBp8RUfTwrzSzGSSY66BVPNH KmSog/SrYaezuxm5LatQP0ooLYkcTwUJZ+BZwA0GVeRthvBvSY008pkvx3PfDv4y/t7P 1pbU7JqzDCA1alzgJfr9mM2fo9Gh7nm+sK0uqebgfgQ7EqOgJuDANnZ4IfVGAYIhjCjK kXXQZ5cayQkZPTorfgPfquUmkh54rXMLWovb0i+or9lGKkoZor15XuvG8fJKkJyziMDo 713nYhMTWC0Y2lPnIIeGX3pkUwQexrlL0Q7WZlchGFL9+8lHBikZXdw/nvgk2np8SrEf DDFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gL0w1qmB/xNEtYPLEb82oejBmgO/Eg6z+K2+EKN4GAA=; b=MEhK3ojU7d3oHWZW5k1Nmy8ww5qRB1twCuW6Dui7AStN4hBUZK7krqbEWGtYEZmmZO kangvca9I9lsISheD6JMmqNEOht2l6hyQTjUEMc8cVydki+mC8iieGlFAGfR4SYpFX1c Dc/6I6zLgw7HH8cM9VOnERG7QCDflRVTVsVQC9QvQ+70obHKr9YnSsZi6lTw9jKTj4Tn +Tclv0ma5Plxz4bd//AWYLTgUxwBbUvgmKluecWMJIEGd0Db1Sp6T3tGDqfkw9pQkxRk yHqedFjPXwY0Cs3+UkpijaFSiOtltlIIfIfRLm/hS/ajZtMBA+SH9V1i+fpIVNUN7h9j U7TA== X-Gm-Message-State: ALKqPwcroZFDXYM7UrvrkgtXD61UGdInjDoW6kjIYykythdOnoYnFqUM MJQjMEG4OpA3CkuqZKC3HU/2+1YhsPI= X-Google-Smtp-Source: ADUXVKLGye9HfgMsXBbiNnaQ6b9J+zcjFF3If1au4c4o5T/yYPm2NaF7xhfQ5qLsDPe4xaNIm99gtA== X-Received: by 2002:a1c:1f13:: with SMTP id f19-v6mr10515837wmf.73.1527607894280; Tue, 29 May 2018 08:31:34 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:32 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:54 +0000 Message-Id: <20180529153056.27328-17-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Benjamin Young , Jocelyn Bohr , Jocelyn Bohr , Maxime Ripard Subject: [U-Boot] [PATCH v8 16/18] fastboot: Add support for 'oem format' command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Introduce 'oem format' which matches the USB implementation, guard this with CONFIG_FASTBOOT_CMD_OEM_FORMAT so that you can configure it out. Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: - new Changes in v4: None Changes in v3: None Changes in v2: None drivers/fastboot/Kconfig | 8 ++++++++ drivers/fastboot/fb_command.c | 33 +++++++++++++++++++++++++++++++++ include/fastboot.h | 3 +++ 3 files changed, 44 insertions(+) diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 625f016600..bc25ea1d9c 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -124,6 +124,14 @@ config FASTBOOT_MBR_NAME specified on the "fastboot flash" command line matches the value defined here. The default target name for updating MBR is "mbr". +config FASTBOOT_CMD_OEM_FORMAT + bool "Enable the 'oem format' command" + depends on FASTBOOT_FLASH_MMC && CMD_GPT + help + Add support for the "oem format" command from a client. This + relies on the env variable partitions to contain the list of + partitions as required by the gpt command. + endif # FASTBOOT endmenu diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index af4f500694..200f9910c5 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -34,6 +34,9 @@ static void flash(char *, char *); static void erase(char *, char *); #endif static void reboot_bootloader(char *, char *); +#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT) +static void oem_format(char *, char *); +#endif static const struct { const char *command; @@ -77,6 +80,12 @@ static const struct { .command = "set_active", .dispatch = okay }, +#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT) + [FASTBOOT_COMMAND_OEM_FORMAT] = { + .command = "oem format", + .dispatch = oem_format, + }, +#endif }; /** @@ -300,3 +309,27 @@ static void reboot_bootloader(char *cmd_parameter, char *response) else fastboot_okay(NULL, response); } + +#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT) +/** + * oem_format() - Execute the OEM format command + * + * @cmd_parameter: Pointer to command parameter + * @response: Pointer to fastboot response buffer + */ +static void oem_format(char *cmd_parameter, char *response) +{ + char cmdbuf[32]; + + if (!env_get("partitions")) { + fastboot_fail("partitions not set", response); + } else { + sprintf(cmdbuf, "gpt write mmc %x $partitions", + CONFIG_FASTBOOT_FLASH_MMC_DEV); + if (run_command(cmdbuf, 0)) + fastboot_fail("", response); + else + fastboot_okay(NULL, response); + } +} +#endif diff --git a/include/fastboot.h b/include/fastboot.h index 9a3d5ba693..1933b1d98e 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -33,6 +33,9 @@ enum { FASTBOOT_COMMAND_REBOOT, FASTBOOT_COMMAND_REBOOT_BOOTLOADER, FASTBOOT_COMMAND_SET_ACTIVE, +#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT) + FASTBOOT_COMMAND_OEM_FORMAT, +#endif FASTBOOT_COMMAND_COUNT }; From patchwork Tue May 29 15:30:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922204 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kKPmqMl4"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wJ7264GHz9s08 for ; Wed, 30 May 2018 01:49:02 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 68769C21F60; Tue, 29 May 2018 15:48:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, KHOP_BIG_TO_CC, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id F082BC21F4F; Tue, 29 May 2018 15:46:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 08BBBC21F3D; Tue, 29 May 2018 15:31:48 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by lists.denx.de (Postfix) with ESMTPS id EE11AC21F06 for ; Tue, 29 May 2018 15:31:38 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id v13-v6so14571718wrp.13 for ; Tue, 29 May 2018 08:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SmvgrSqqZR9Z7QOvwfYbk27PbJiBdtVi1Iwkvttf9Co=; b=kKPmqMl4CJ0JMfA/o8jP/Qazsu4qwdQY+JGBcolbyNuQN1NuVsvVbaKhDgXE4cvivx QYcInxONor+fxPrrEQ3/tK4O6X1VXgoiLbY+CfKIRRsfdY3kzk8+C+WqcPyha6XKfTuG wrpiHyIRSKyMgsABY6+8As6BOxuYMjBeqaX33AUvDKr9fu8aa5ZYHAu3YiF3EQLJ1kko i0GiYLfWMyOW12yc0f4lJEvV7amBb+GiZCZU5JFmmijrJS6TyoCtUOCwW6XiZcaaDuei s6+f3Jqdwy1ChcIgbxzUhJ1a2zkBpjdHxqRnoBG3la+jlPw5jACYcnKtvMhS/jJgXli+ BpIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SmvgrSqqZR9Z7QOvwfYbk27PbJiBdtVi1Iwkvttf9Co=; b=SsgL4CMylnjYMAvEglgWmEZfHxmgyXSX8zU8NTmYfFHwgnrZ0GrjkesN7HnYEO3iuf 3icvv3I7GioNMeZoiKevG7pdIt4rJZ+3I7vqjAJM0cjnCK0BDKgkGd8Ydza6amKiqwIW PHOSNMtF9jmgOEt/4QevtjEk8R+pWeO3JEB12EgiE/xf0F5MA+CeojJJH+BVinenKs+E Xc1+qwhfSEN/AIBCOsow3VCkFpw+AIdcYLKaj6AJ6tuCT3AsPeDPZ8yiRI+vYnlzJJbY XeeY4dw0P6nhzMifyklSZtc/+82uYbdOXNyeX52bpQ09bNSZ3EpT1g47AoeGhVUunCSO boXA== X-Gm-Message-State: ALKqPwd1MSrn76s0HSpk7Y0sI1b4EAz7GeAdgCA1SmSVdn0peLYwQULt DJuKo3UP6EA89h81U3gYQpaSyRPU7/M= X-Google-Smtp-Source: AB8JxZo6t4AERywuoGGc06eUaWcziKwcig2thBL1UNQ1t4pBDQsCzynqpCHkURmtHzbbMPuVGppq1w== X-Received: by 2002:adf:ae59:: with SMTP id u25-v6mr13713875wrd.157.1527607897771; Tue, 29 May 2018 08:31:37 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:36 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:55 +0000 Message-Id: <20180529153056.27328-18-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> X-Mailman-Approved-At: Tue, 29 May 2018 15:45:57 +0000 Cc: Jocelyn Bohr , Maxime Ripard , Marek Vasut , Stefan Mavrodiev , Michal Simek , Ian Campbell , Jocelyn Bohr , Hans de Goede , Jernej Skrabec , huang lin , Olliver Schinagl , Quentin Schulz Subject: [U-Boot] [PATCH v8 17/18] usb: fastboot: Convert USB f_fastboot to shared fastboot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Convert USB fastboot code to use shared fastboot protocol. Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass --- Changes in v8: - add Reviewed-by: tag Changes in v7: - set FASTBOOT_CMD_OEM_FORMAT for all existing users of FASTBOOT_FLASH_MMC_DEV that also have CMD_GPT Changes in v6: - merged from RFC USB fastboot series - when entering the DATA phase ensure we actually install the correct handler - on completion of DATA call new fastboot_data_complete() - previous changes: - remove redundant version.h - use new fastboot_get_bytes_remaining() function Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None configs/A13-OLinuXino_defconfig | 1 + configs/A20-OLinuXino-Lime2-eMMC_defconfig | 1 + configs/A20-OLinuXino-Lime2_defconfig | 1 + configs/A20-Olimex-SOM204-EVB-eMMC_defconfig | 1 + configs/A20-Olimex-SOM204-EVB_defconfig | 1 + configs/Bananapi_m2m_defconfig | 1 + configs/Cubietruck_defconfig | 1 + configs/Sinlinx_SinA33_defconfig | 1 + configs/am335x_boneblack_defconfig | 7 +- configs/am57xx_evm_defconfig | 13 +- configs/am57xx_hs_evm_defconfig | 13 +- configs/chromebit_mickey_defconfig | 5 +- configs/chromebook_jerry_defconfig | 5 +- configs/chromebook_minnie_defconfig | 5 +- configs/dra7xx_evm_defconfig | 11 +- configs/dra7xx_hs_evm_defconfig | 11 +- configs/evb-rk3036_defconfig | 5 +- configs/evb-rk3128_defconfig | 9 +- configs/evb-rk3229_defconfig | 5 +- configs/evb-rk3288_defconfig | 5 +- configs/evb-rk3328_defconfig | 7 +- configs/fennec-rk3288_defconfig | 5 +- configs/firefly-rk3288_defconfig | 5 +- configs/kylin-rk3036_defconfig | 5 +- configs/miqi-rk3288_defconfig | 5 +- configs/parrot_r16_defconfig | 1 + configs/phycore-rk3288_defconfig | 5 +- configs/popmetal-rk3288_defconfig | 5 +- configs/rock2_defconfig | 5 +- configs/stih410-b2260_defconfig | 11 +- configs/tbs_a711_defconfig | 1 + configs/tinker-rk3288_defconfig | 5 +- .../xilinx_zynqmp_zc1751_xm015_dc1_defconfig | 7 +- configs/xilinx_zynqmp_zcu102_rev1_0_defconfig | 7 +- configs/xilinx_zynqmp_zcu102_revA_defconfig | 7 +- configs/xilinx_zynqmp_zcu102_revB_defconfig | 7 +- configs/xilinx_zynqmp_zcu106_revA_defconfig | 7 +- drivers/fastboot/Makefile | 4 +- drivers/usb/gadget/f_fastboot.c | 318 ++---------------- 39 files changed, 156 insertions(+), 363 deletions(-) diff --git a/configs/A13-OLinuXino_defconfig b/configs/A13-OLinuXino_defconfig index 8e160d7cc4..b8ec1e54db 100644 --- a/configs/A13-OLinuXino_defconfig +++ b/configs/A13-OLinuXino_defconfig @@ -22,6 +22,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_DFU_RAM=y +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_AXP_ALDO3_VOLT=3300 CONFIG_CONS_INDEX=2 CONFIG_USB_EHCI_HCD=y diff --git a/configs/A20-OLinuXino-Lime2-eMMC_defconfig b/configs/A20-OLinuXino-Lime2-eMMC_defconfig index 9d043e856a..5657fc2594 100644 --- a/configs/A20-OLinuXino-Lime2-eMMC_defconfig +++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig @@ -20,6 +20,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_SCSI_AHCI=y CONFIG_DFU_RAM=y +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ETH_DESIGNWARE=y CONFIG_RGMII=y CONFIG_SUN7I_GMAC=y diff --git a/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig index f2997c6fe5..134d1d3fef 100644 --- a/configs/A20-OLinuXino-Lime2_defconfig +++ b/configs/A20-OLinuXino-Lime2_defconfig @@ -19,6 +19,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_SCSI_AHCI=y CONFIG_DFU_RAM=y +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ETH_DESIGNWARE=y CONFIG_RGMII=y CONFIG_SUN7I_GMAC=y diff --git a/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig b/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig index 847945b649..3bb8c4c7e6 100644 --- a/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig +++ b/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig @@ -18,6 +18,7 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_SCSI_AHCI=y +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_PHY_ADDR=3 CONFIG_PHY_MICREL=y CONFIG_PHY_MICREL_KSZ90X1=y diff --git a/configs/A20-Olimex-SOM204-EVB_defconfig b/configs/A20-Olimex-SOM204-EVB_defconfig index e56f2c7110..cfb7ffa556 100644 --- a/configs/A20-Olimex-SOM204-EVB_defconfig +++ b/configs/A20-Olimex-SOM204-EVB_defconfig @@ -17,6 +17,7 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_SCSI_AHCI=y +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_PHY_ADDR=3 CONFIG_PHY_MICREL=y CONFIG_PHY_MICREL_KSZ90X1=y diff --git a/configs/Bananapi_m2m_defconfig b/configs/Bananapi_m2m_defconfig index 2032a4aef8..2316437c94 100644 --- a/configs/Bananapi_m2m_defconfig +++ b/configs/Bananapi_m2m_defconfig @@ -13,6 +13,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-r16-bananapi-m2m" # CONFIG_CMD_FLASH is not set # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_PARTITION_UUIDS is not set +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_MUSB_GADGET=y CONFIG_USB_FUNCTION_MASS_STORAGE=y diff --git a/configs/Cubietruck_defconfig b/configs/Cubietruck_defconfig index f0bb4c9d5c..601eb3ca0c 100644 --- a/configs/Cubietruck_defconfig +++ b/configs/Cubietruck_defconfig @@ -21,6 +21,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_SCSI_AHCI=y CONFIG_DFU_RAM=y +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ETH_DESIGNWARE=y CONFIG_RGMII=y CONFIG_SUN7I_GMAC=y diff --git a/configs/Sinlinx_SinA33_defconfig b/configs/Sinlinx_SinA33_defconfig index 9e6267200b..394534b8b5 100644 --- a/configs/Sinlinx_SinA33_defconfig +++ b/configs/Sinlinx_SinA33_defconfig @@ -18,6 +18,7 @@ CONFIG_CMD_DFU=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_DFU_RAM=y +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_MUSB_GADGET=y CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y diff --git a/configs/am335x_boneblack_defconfig b/configs/am335x_boneblack_defconfig index bd3a37427d..31d2fe9cbf 100644 --- a/configs/am335x_boneblack_defconfig +++ b/configs/am335x_boneblack_defconfig @@ -16,9 +16,6 @@ CONFIG_AUTOBOOT_KEYED=y CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n" CONFIG_AUTOBOOT_DELAY_STR="d" CONFIG_AUTOBOOT_STOP_STR=" " -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=1 CONFIG_CMD_SPL=y # CONFIG_CMD_FLASH is not set # CONFIG_CMD_SETEXPR is not set @@ -28,6 +25,10 @@ CONFIG_BOOTCOUNT_LIMIT=y CONFIG_DFU_TFTP=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=1 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_MMC_OMAP_HS=y CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index 3b83b69e5f..2d8e64e613 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -24,12 +24,6 @@ CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_DMA_SUPPORT=y CONFIG_SPL_OS_BOOT=y CONFIG_SPL_SPI_LOAD=y -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_BUF_ADDR=0x82000000 -CONFIG_FASTBOOT_BUF_SIZE=0x2F000000 -CONFIG_FASTBOOT_USB_DEV=1 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=1 CONFIG_CMD_SPL=y # CONFIG_CMD_FLASH is not set # CONFIG_CMD_SETEXPR is not set @@ -45,6 +39,13 @@ CONFIG_SCSI_AHCI=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_BUF_ADDR=0x82000000 +CONFIG_FASTBOOT_BUF_SIZE=0x2F000000 +CONFIG_FASTBOOT_USB_DEV=1 +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=1 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_DM_GPIO=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig index 9c2aef482f..3a73fdb2ca 100644 --- a/configs/am57xx_hs_evm_defconfig +++ b/configs/am57xx_hs_evm_defconfig @@ -29,12 +29,6 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_DMA_SUPPORT=y CONFIG_SPL_SPI_LOAD=y -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_BUF_ADDR=0x82000000 -CONFIG_FASTBOOT_BUF_SIZE=0x2F000000 -CONFIG_FASTBOOT_USB_DEV=1 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=1 # CONFIG_CMD_FLASH is not set # CONFIG_CMD_SETEXPR is not set CONFIG_OF_CONTROL=y @@ -48,6 +42,13 @@ CONFIG_SCSI_AHCI=y # CONFIG_BLK is not set CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_BUF_ADDR=0x82000000 +CONFIG_FASTBOOT_BUF_SIZE=0x2F000000 +CONFIG_FASTBOOT_USB_DEV=1 +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=1 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_DM_GPIO=y CONFIG_DM_I2C=y CONFIG_DM_MMC=y diff --git a/configs/chromebit_mickey_defconfig b/configs/chromebit_mickey_defconfig index d1728ef639..72ecdc69f6 100644 --- a/configs/chromebit_mickey_defconfig +++ b/configs/chromebit_mickey_defconfig @@ -16,8 +16,6 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 CONFIG_SPL_SPI_LOAD=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -44,6 +42,9 @@ CONFIG_SPL_SYSCON=y # CONFIG_SPL_SIMPLE_BUS is not set CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_I2C_CROS_EC_TUNNEL=y CONFIG_SYS_I2C_ROCKCHIP=y diff --git a/configs/chromebook_jerry_defconfig b/configs/chromebook_jerry_defconfig index 43d93f4637..fb8400d06e 100644 --- a/configs/chromebook_jerry_defconfig +++ b/configs/chromebook_jerry_defconfig @@ -18,8 +18,6 @@ CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 CONFIG_SPL_SPI_LOAD=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -46,6 +44,9 @@ CONFIG_SPL_SYSCON=y # CONFIG_SPL_SIMPLE_BUS is not set CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_I2C_CROS_EC_TUNNEL=y CONFIG_SYS_I2C_ROCKCHIP=y diff --git a/configs/chromebook_minnie_defconfig b/configs/chromebook_minnie_defconfig index 706809ca53..a8776c9adf 100644 --- a/configs/chromebook_minnie_defconfig +++ b/configs/chromebook_minnie_defconfig @@ -17,8 +17,6 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 CONFIG_SPL_SPI_LOAD=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -45,6 +43,9 @@ CONFIG_SPL_SYSCON=y # CONFIG_SPL_SIMPLE_BUS is not set CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_I2C_CROS_EC_TUNNEL=y CONFIG_SYS_I2C_ROCKCHIP=y diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig index b766ba27cd..182f9a9ebf 100644 --- a/configs/dra7xx_evm_defconfig +++ b/configs/dra7xx_evm_defconfig @@ -25,11 +25,6 @@ CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_DMA_SUPPORT=y CONFIG_SPL_OS_BOOT=y CONFIG_SPL_SPI_LOAD=y -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_BUF_ADDR=0x82000000 -CONFIG_FASTBOOT_BUF_SIZE=0x2F000000 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=1 CONFIG_CMD_SPL=y # CONFIG_CMD_FLASH is not set # CONFIG_CMD_SETEXPR is not set @@ -50,6 +45,12 @@ CONFIG_DWC_AHCI=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_BUF_ADDR=0x82000000 +CONFIG_FASTBOOT_BUF_SIZE=0x2F000000 +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=1 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_DM_GPIO=y CONFIG_PCF8575_GPIO=y CONFIG_DM_I2C=y diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig index 39a6801216..8584d41f1a 100644 --- a/configs/dra7xx_hs_evm_defconfig +++ b/configs/dra7xx_hs_evm_defconfig @@ -30,11 +30,6 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_DMA_SUPPORT=y CONFIG_SPL_SPI_LOAD=y -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_BUF_ADDR=0x82000000 -CONFIG_FASTBOOT_BUF_SIZE=0x2F000000 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=1 # CONFIG_CMD_FLASH is not set # CONFIG_CMD_SETEXPR is not set CONFIG_OF_CONTROL=y @@ -50,6 +45,12 @@ CONFIG_DWC_AHCI=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_BUF_ADDR=0x82000000 +CONFIG_FASTBOOT_BUF_SIZE=0x2F000000 +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=1 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_DM_GPIO=y CONFIG_PCF8575_GPIO=y CONFIG_DM_I2C=y diff --git a/configs/evb-rk3036_defconfig b/configs/evb-rk3036_defconfig index 33775e8cdd..b9242e83e0 100644 --- a/configs/evb-rk3036_defconfig +++ b/configs/evb-rk3036_defconfig @@ -15,8 +15,6 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x0 CONFIG_DISPLAY_BOARDINFO_LATE=y # CONFIG_SPL_FRAMEWORK is not set CONFIG_SPL_STACK_R=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y @@ -31,6 +29,9 @@ CONFIG_SPL_PARTITION_UUIDS=y CONFIG_REGMAP=y CONFIG_SYSCON=y CONFIG_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_LED=y diff --git a/configs/evb-rk3128_defconfig b/configs/evb-rk3128_defconfig index 796d0ec92e..9c8252e95f 100644 --- a/configs/evb-rk3128_defconfig +++ b/configs/evb-rk3128_defconfig @@ -7,10 +7,6 @@ CONFIG_DEBUG_UART=y CONFIG_FIT=y # CONFIG_DISPLAY_CPUINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_FASTBOOT_BUF_ADDR=0x60800800 -CONFIG_FASTBOOT_BUF_SIZE=0x04000000 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y @@ -20,6 +16,11 @@ CONFIG_CMD_TIME=y CONFIG_REGMAP=y CONFIG_SYSCON=y CONFIG_CLK=y +CONFIG_FASTBOOT_BUF_ADDR=0x60800800 +CONFIG_FASTBOOT_BUF_SIZE=0x04000000 +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y diff --git a/configs/evb-rk3229_defconfig b/configs/evb-rk3229_defconfig index 710b0b4e1a..7298bf1963 100644 --- a/configs/evb-rk3229_defconfig +++ b/configs/evb-rk3229_defconfig @@ -14,8 +14,6 @@ CONFIG_DEBUG_UART=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x200 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y # CONFIG_CMD_SETEXPR is not set @@ -30,6 +28,9 @@ CONFIG_SYSCON=y CONFIG_SPL_SYSCON=y CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y diff --git a/configs/evb-rk3288_defconfig b/configs/evb-rk3288_defconfig index 7695277daf..a7beaa6728 100644 --- a/configs/evb-rk3288_defconfig +++ b/configs/evb-rk3288_defconfig @@ -14,8 +14,6 @@ CONFIG_SILENT_CONSOLE=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -41,6 +39,9 @@ CONFIG_SYSCON=y CONFIG_SPL_SYSCON=y CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_LED=y diff --git a/configs/evb-rk3328_defconfig b/configs/evb-rk3328_defconfig index 78ae24b56b..59bf9e5197 100644 --- a/configs/evb-rk3328_defconfig +++ b/configs/evb-rk3328_defconfig @@ -8,9 +8,6 @@ CONFIG_DEBUG_UART=y CONFIG_FIT=y # CONFIG_DISPLAY_CPUINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_FASTBOOT_BUF_ADDR=0x800800 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=1 CONFIG_CMD_BOOTZ=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y @@ -23,6 +20,10 @@ CONFIG_NET_RANDOM_ETHADDR=y CONFIG_REGMAP=y CONFIG_SYSCON=y CONFIG_CLK=y +CONFIG_FASTBOOT_BUF_ADDR=0x800800 +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=1 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y diff --git a/configs/fennec-rk3288_defconfig b/configs/fennec-rk3288_defconfig index efdd583cf6..dbd6be55e2 100644 --- a/configs/fennec-rk3288_defconfig +++ b/configs/fennec-rk3288_defconfig @@ -15,8 +15,6 @@ CONFIG_CONSOLE_MUX=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -42,6 +40,9 @@ CONFIG_SPL_SYSCON=y # CONFIG_SPL_SIMPLE_BUS is not set CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y diff --git a/configs/firefly-rk3288_defconfig b/configs/firefly-rk3288_defconfig index b252d27464..83b4968c4a 100644 --- a/configs/firefly-rk3288_defconfig +++ b/configs/firefly-rk3288_defconfig @@ -14,8 +14,6 @@ CONFIG_SILENT_CONSOLE=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -42,6 +40,9 @@ CONFIG_SPL_SYSCON=y # CONFIG_SPL_SIMPLE_BUS is not set CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_DM_KEYBOARD=y diff --git a/configs/kylin-rk3036_defconfig b/configs/kylin-rk3036_defconfig index ca53005ecb..373764aaf1 100644 --- a/configs/kylin-rk3036_defconfig +++ b/configs/kylin-rk3036_defconfig @@ -14,8 +14,6 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x0 CONFIG_DISPLAY_BOARDINFO_LATE=y # CONFIG_SPL_FRAMEWORK is not set CONFIG_SPL_STACK_R=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y @@ -31,6 +29,9 @@ CONFIG_ENV_IS_IN_MMC=y CONFIG_REGMAP=y CONFIG_SYSCON=y CONFIG_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_LED=y diff --git a/configs/miqi-rk3288_defconfig b/configs/miqi-rk3288_defconfig index f44537c88f..5bfcb0c90b 100644 --- a/configs/miqi-rk3288_defconfig +++ b/configs/miqi-rk3288_defconfig @@ -14,8 +14,6 @@ CONFIG_SILENT_CONSOLE=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -42,6 +40,9 @@ CONFIG_SPL_SYSCON=y # CONFIG_SPL_SIMPLE_BUS is not set CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y diff --git a/configs/parrot_r16_defconfig b/configs/parrot_r16_defconfig index 991e9b99aa..553a8d6572 100644 --- a/configs/parrot_r16_defconfig +++ b/configs/parrot_r16_defconfig @@ -15,6 +15,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-r16-parrot" # CONFIG_CMD_FLASH is not set # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_PARTITION_UUIDS is not set +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_CONS_INDEX=5 CONFIG_USB_EHCI_HCD=y CONFIG_USB_MUSB_GADGET=y diff --git a/configs/phycore-rk3288_defconfig b/configs/phycore-rk3288_defconfig index d78b6d57b6..fc3b81c43c 100644 --- a/configs/phycore-rk3288_defconfig +++ b/configs/phycore-rk3288_defconfig @@ -17,8 +17,6 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_POWER_SUPPORT=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -44,6 +42,9 @@ CONFIG_SPL_SYSCON=y # CONFIG_SPL_SIMPLE_BUS is not set CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MISC=y diff --git a/configs/popmetal-rk3288_defconfig b/configs/popmetal-rk3288_defconfig index 2670b4b75a..84c099560f 100644 --- a/configs/popmetal-rk3288_defconfig +++ b/configs/popmetal-rk3288_defconfig @@ -15,8 +15,6 @@ CONFIG_CONSOLE_MUX=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -42,6 +40,9 @@ CONFIG_SPL_SYSCON=y # CONFIG_SPL_SIMPLE_BUS is not set CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y diff --git a/configs/rock2_defconfig b/configs/rock2_defconfig index cd9a821974..01d53ac1c3 100644 --- a/configs/rock2_defconfig +++ b/configs/rock2_defconfig @@ -14,8 +14,6 @@ CONFIG_SILENT_CONSOLE=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -42,6 +40,9 @@ CONFIG_SPL_SYSCON=y # CONFIG_SPL_SIMPLE_BUS is not set CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MMC_DW=y diff --git a/configs/stih410-b2260_defconfig b/configs/stih410-b2260_defconfig index 7d990f9a34..ba1ff25d35 100644 --- a/configs/stih410-b2260_defconfig +++ b/configs/stih410-b2260_defconfig @@ -10,11 +10,6 @@ CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="console=ttyAS1,115200 CONSOLE=/dev/ttyAS1 consoleblank=0 root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait mem=992M@0x40000000 vmalloc=256m" # CONFIG_DISPLAY_CPUINFO is not set CONFIG_SYS_PROMPT="stih410-b2260 => " -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_BUF_ADDR=0x40000000 -CONFIG_FASTBOOT_BUF_SIZE=0x3DF00000 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y @@ -26,6 +21,12 @@ CONFIG_OF_CONTROL=y CONFIG_REGMAP=y CONFIG_SYSCON=y CONFIG_CLK=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_BUF_ADDR=0x40000000 +CONFIG_FASTBOOT_BUF_SIZE=0x3DF00000 +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_MISC=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_STI=y diff --git a/configs/tbs_a711_defconfig b/configs/tbs_a711_defconfig index 3e3de4fbb3..5d58f5ceb4 100644 --- a/configs/tbs_a711_defconfig +++ b/configs/tbs_a711_defconfig @@ -16,6 +16,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-a83t-tbs-a711" # CONFIG_CMD_FLASH is not set # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_AXP_DCDC5_VOLT=1200 CONFIG_USB_EHCI_HCD=y CONFIG_USB_MUSB_GADGET=y diff --git a/configs/tinker-rk3288_defconfig b/configs/tinker-rk3288_defconfig index fb6bfa57ad..e1c99c3828 100644 --- a/configs/tinker-rk3288_defconfig +++ b/configs/tinker-rk3288_defconfig @@ -16,8 +16,6 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000 CONFIG_SPL_I2C_SUPPORT=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y @@ -43,6 +41,9 @@ CONFIG_SPL_SYSCON=y # CONFIG_SPL_SIMPLE_BUS is not set CONFIG_CLK=y CONFIG_SPL_CLK=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MISC=y diff --git a/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig b/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig index 9e4886d064..b4521aab43 100644 --- a/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig +++ b/configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig @@ -19,9 +19,6 @@ CONFIG_SPL_RAM_SUPPORT=y CONFIG_SPL_RAM_DEVICE=y CONFIG_SPL_ATF=y CONFIG_SYS_PROMPT="ZynqMP> " -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_THOR_DOWNLOAD=y CONFIG_CMD_MEMTEST=y CONFIG_SYS_ALT_MEMTEST=y @@ -47,6 +44,10 @@ CONFIG_SPL_DM=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_CLK_ZYNQMP=y CONFIG_DFU_RAM=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_FPGA_XILINX=y CONFIG_FPGA_ZYNQMPPL=y CONFIG_DM_GPIO=y diff --git a/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig b/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig index 29743bdb1e..976640cae0 100644 --- a/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig +++ b/configs/xilinx_zynqmp_zcu102_rev1_0_defconfig @@ -19,9 +19,6 @@ CONFIG_SPL_RAM_SUPPORT=y CONFIG_SPL_RAM_DEVICE=y CONFIG_SPL_ATF=y CONFIG_SYS_PROMPT="ZynqMP> " -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_THOR_DOWNLOAD=y CONFIG_CMD_EEPROM=y CONFIG_CMD_MEMTEST=y @@ -50,6 +47,10 @@ CONFIG_SCSI_AHCI=y CONFIG_SATA_CEVA=y CONFIG_CLK_ZYNQMP=y CONFIG_DFU_RAM=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_FPGA_XILINX=y CONFIG_FPGA_ZYNQMPPL=y CONFIG_DM_GPIO=y diff --git a/configs/xilinx_zynqmp_zcu102_revA_defconfig b/configs/xilinx_zynqmp_zcu102_revA_defconfig index cc4118230e..3420ce5dc3 100644 --- a/configs/xilinx_zynqmp_zcu102_revA_defconfig +++ b/configs/xilinx_zynqmp_zcu102_revA_defconfig @@ -19,9 +19,6 @@ CONFIG_SPL_RAM_SUPPORT=y CONFIG_SPL_RAM_DEVICE=y CONFIG_SPL_ATF=y CONFIG_SYS_PROMPT="ZynqMP> " -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_THOR_DOWNLOAD=y CONFIG_CMD_EEPROM=y CONFIG_CMD_MEMTEST=y @@ -50,6 +47,10 @@ CONFIG_SCSI_AHCI=y CONFIG_SATA_CEVA=y CONFIG_CLK_ZYNQMP=y CONFIG_DFU_RAM=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_FPGA_XILINX=y CONFIG_FPGA_ZYNQMPPL=y CONFIG_DM_GPIO=y diff --git a/configs/xilinx_zynqmp_zcu102_revB_defconfig b/configs/xilinx_zynqmp_zcu102_revB_defconfig index ae791c3567..a9ba4a17e9 100644 --- a/configs/xilinx_zynqmp_zcu102_revB_defconfig +++ b/configs/xilinx_zynqmp_zcu102_revB_defconfig @@ -19,9 +19,6 @@ CONFIG_SPL_RAM_SUPPORT=y CONFIG_SPL_RAM_DEVICE=y CONFIG_SPL_ATF=y CONFIG_SYS_PROMPT="ZynqMP> " -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_THOR_DOWNLOAD=y CONFIG_CMD_EEPROM=y CONFIG_CMD_MEMTEST=y @@ -50,6 +47,10 @@ CONFIG_SCSI_AHCI=y CONFIG_SATA_CEVA=y CONFIG_CLK_ZYNQMP=y CONFIG_DFU_RAM=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_FPGA_XILINX=y CONFIG_FPGA_ZYNQMPPL=y CONFIG_DM_GPIO=y diff --git a/configs/xilinx_zynqmp_zcu106_revA_defconfig b/configs/xilinx_zynqmp_zcu106_revA_defconfig index 34e3c857e2..32c6f23210 100644 --- a/configs/xilinx_zynqmp_zcu106_revA_defconfig +++ b/configs/xilinx_zynqmp_zcu106_revA_defconfig @@ -18,9 +18,6 @@ CONFIG_SPL_RAM_SUPPORT=y CONFIG_SPL_RAM_DEVICE=y CONFIG_SPL_ATF=y CONFIG_SYS_PROMPT="ZynqMP> " -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_CMD_THOR_DOWNLOAD=y CONFIG_CMD_EEPROM=y CONFIG_CMD_MEMTEST=y @@ -48,6 +45,10 @@ CONFIG_SCSI_AHCI=y CONFIG_SATA_CEVA=y CONFIG_CLK_ZYNQMP=y CONFIG_DFU_RAM=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_CMD_OEM_FORMAT=y CONFIG_FPGA_XILINX=y CONFIG_FPGA_ZYNQMPPL=y CONFIG_DM_GPIO=y diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile index 8831096181..a2421565e2 100644 --- a/drivers/fastboot/Makefile +++ b/drivers/fastboot/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ obj-y += fb_common.o -obj-$(CONFIG_UDP_FUNCTION_FASTBOOT) += fb_getvar.o -obj-$(CONFIG_UDP_FUNCTION_FASTBOOT) += fb_command.o +obj-y += fb_getvar.o +obj-y += fb_command.o obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 07d6a62155..3ad4346f2d 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -18,14 +18,7 @@ #include #include #include -#include #include -#ifdef CONFIG_FASTBOOT_FLASH_MMC -#include -#endif -#ifdef CONFIG_FASTBOOT_FLASH_NAND -#include -#endif #define FASTBOOT_INTERFACE_CLASS 0xff #define FASTBOOT_INTERFACE_SUB_CLASS 0x42 @@ -56,8 +49,6 @@ static inline struct f_fastboot *func_to_fastboot(struct usb_function *f) } static struct f_fastboot *fastboot_func; -static unsigned int download_size; -static unsigned int download_bytes; static struct usb_endpoint_descriptor fs_ep_in = { .bLength = USB_DT_ENDPOINT_SIZE, @@ -145,7 +136,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); static void fastboot_complete(struct usb_ep *ep, struct usb_request *req) { @@ -355,85 +345,9 @@ static void compl_do_reset(struct usb_ep *ep, struct usb_request *req) do_reset(NULL, 0, 0, NULL); } -static void cb_reboot(struct usb_ep *ep, struct usb_request *req) -{ - char *cmd = req->buf; - if (!strcmp_l1("reboot-bootloader", cmd)) { - if (fastboot_set_reboot_flag()) { - fastboot_tx_write_str("FAILCannot set reboot flag"); - return; - } - } - fastboot_func->in_req->complete = compl_do_reset; - fastboot_tx_write_str("OKAY"); -} - -static int strcmp_l1(const char *s1, const char *s2) -{ - if (!s1 || !s2) - return -1; - return strncmp(s1, s2, strlen(s1)); -} - -static void cb_getvar(struct usb_ep *ep, struct usb_request *req) -{ - char *cmd = req->buf; - char response[FASTBOOT_RESPONSE_LEN]; - const char *s; - size_t chars_left; - - strcpy(response, "OKAY"); - chars_left = sizeof(response) - strlen(response) - 1; - - strsep(&cmd, ":"); - if (!cmd) { - pr_err("missing variable"); - fastboot_tx_write_str("FAILmissing var"); - return; - } - - if (!strcmp_l1("version", cmd)) { - strncat(response, FASTBOOT_VERSION, chars_left); - } else if (!strcmp_l1("bootloader-version", cmd)) { - strncat(response, U_BOOT_VERSION, chars_left); - } else if (!strcmp_l1("downloadsize", cmd) || - !strcmp_l1("max-download-size", cmd)) { - char str_num[12]; - - sprintf(str_num, "0x%08x", CONFIG_FASTBOOT_BUF_SIZE); - strncat(response, str_num, chars_left); - } else if (!strcmp_l1("serialno", cmd)) { - s = env_get("serial#"); - if (s) - strncat(response, s, chars_left); - else - strcpy(response, "FAILValue not set"); - } else { - char *envstr; - - envstr = malloc(strlen("fastboot.") + strlen(cmd) + 1); - if (!envstr) { - fastboot_tx_write_str("FAILmalloc error"); - return; - } - - sprintf(envstr, "fastboot.%s", cmd); - s = env_get(envstr); - if (s) { - strncat(response, s, chars_left); - } else { - printf("WARNING: unknown variable: %s\n", cmd); - strcpy(response, "FAILVariable not implemented"); - } - - free(envstr); - } - fastboot_tx_write_str(response); -} - static unsigned int rx_bytes_expected(struct usb_ep *ep) { - int rx_remain = download_size - download_bytes; + int rx_remain = fastboot_data_remaining(); unsigned int rem; unsigned int maxpacket = ep->maxpacket; @@ -455,14 +369,12 @@ static unsigned int rx_bytes_expected(struct usb_ep *ep) return rx_remain; } -#define BYTES_PER_DOT 0x20000 static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req) { - char response[FASTBOOT_RESPONSE_LEN]; - unsigned int transfer_size = download_size - download_bytes; + char response[FASTBOOT_RESPONSE_LEN] = {0}; + unsigned int transfer_size = fastboot_data_remaining(); const unsigned char *buffer = req->buf; unsigned int buffer_size = req->actual; - unsigned int pre_dot_num, now_dot_num; if (req->status != 0) { printf("Bad status: %d\n", req->status); @@ -472,33 +384,19 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req) if (buffer_size < transfer_size) transfer_size = buffer_size; - memcpy((void *)CONFIG_FASTBOOT_BUF_ADDR + download_bytes, - buffer, transfer_size); - - pre_dot_num = download_bytes / BYTES_PER_DOT; - download_bytes += transfer_size; - now_dot_num = download_bytes / BYTES_PER_DOT; - - if (pre_dot_num != now_dot_num) { - putc('.'); - if (!(now_dot_num % 74)) - putc('\n'); - } + fastboot_data_download(buffer, transfer_size, response); + if (response[0]) { + fastboot_tx_write_str(response); + } else if (!fastboot_data_remaining()) { + fastboot_data_complete(response); - /* Check if transfer is done */ - if (download_bytes >= download_size) { /* - * Reset global transfer variable, keep download_bytes because - * it will be used in the next possible flashing command + * Reset global transfer variable */ - download_size = 0; req->complete = rx_handler_command; req->length = EP_BUFFER_SIZE; - strcpy(response, "OKAY"); fastboot_tx_write_str(response); - - printf("\ndownloading of %d bytes finished\n", download_bytes); } else { req->length = rx_bytes_expected(ep); } @@ -507,197 +405,55 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req) usb_ep_queue(ep, req, 0); } -static void cb_download(struct usb_ep *ep, struct usb_request *req) -{ - char *cmd = req->buf; - char response[FASTBOOT_RESPONSE_LEN]; - - strsep(&cmd, ":"); - download_size = simple_strtoul(cmd, NULL, 16); - download_bytes = 0; - - printf("Starting download of %d bytes\n", download_size); - - if (0 == download_size) { - strcpy(response, "FAILdata invalid size"); - } else if (download_size > CONFIG_FASTBOOT_BUF_SIZE) { - download_size = 0; - strcpy(response, "FAILdata too large"); - } else { - sprintf(response, "DATA%08x", download_size); - req->complete = rx_handler_dl_image; - req->length = rx_bytes_expected(ep); - } - fastboot_tx_write_str(response); -} - -static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req) -{ - char boot_addr_start[12]; - char *bootm_args[] = { "bootm", boot_addr_start, NULL }; - - puts("Booting kernel..\n"); - - sprintf(boot_addr_start, "0x%lx", (long)CONFIG_FASTBOOT_BUF_ADDR); - do_bootm(NULL, 0, 2, bootm_args); - - /* This only happens if image is somehow faulty so we start over */ - do_reset(NULL, 0, 0, NULL); -} - -static void cb_boot(struct usb_ep *ep, struct usb_request *req) -{ - fastboot_func->in_req->complete = do_bootm_on_complete; - fastboot_tx_write_str("OKAY"); -} - static void do_exit_on_complete(struct usb_ep *ep, struct usb_request *req) { g_dnl_trigger_detach(); } -static void cb_continue(struct usb_ep *ep, struct usb_request *req) +static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req) { - fastboot_func->in_req->complete = do_exit_on_complete; - fastboot_tx_write_str("OKAY"); + fastboot_boot(); + do_exit_on_complete(ep, req); } -#ifdef CONFIG_FASTBOOT_FLASH -static void cb_flash(struct usb_ep *ep, struct usb_request *req) +static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) { - char *cmd = req->buf; - char response[FASTBOOT_RESPONSE_LEN]; + char *cmdbuf = req->buf; + char response[FASTBOOT_RESPONSE_LEN] = {0}; + int cmd = -1; - strsep(&cmd, ":"); - if (!cmd) { - pr_err("missing partition name"); - fastboot_tx_write_str("FAILmissing partition name"); + if (req->status != 0 || req->length == 0) return; - } - - fastboot_fail("no flash device defined", response); -#ifdef CONFIG_FASTBOOT_FLASH_MMC - fastboot_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, - download_bytes, response); -#endif -#ifdef CONFIG_FASTBOOT_FLASH_NAND - fastboot_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, - download_bytes, response); -#endif - fastboot_tx_write_str(response); -} -#endif -static void cb_oem(struct usb_ep *ep, struct usb_request *req) -{ - char *cmd = req->buf; -#ifdef CONFIG_FASTBOOT_FLASH_MMC - if (strncmp("format", cmd + 4, 6) == 0) { - char cmdbuf[32]; - sprintf(cmdbuf, "gpt write mmc %x $partitions", - CONFIG_FASTBOOT_FLASH_MMC_DEV); - if (run_command(cmdbuf, 0)) - fastboot_tx_write_str("FAIL"); - else - fastboot_tx_write_str("OKAY"); - } else -#endif - if (strncmp("unlock", cmd + 4, 8) == 0) { - fastboot_tx_write_str("FAILnot implemented"); - } - else { - fastboot_tx_write_str("FAILunknown oem command"); + if (req->actual < req->length) { + cmdbuf[req->actual] = '\0'; + cmd = fastboot_handle_command(cmdbuf, response); + } else { + pr_err("buffer overflow"); + fastboot_fail("buffer overflow", response); } -} -#ifdef CONFIG_FASTBOOT_FLASH -static void cb_erase(struct usb_ep *ep, struct usb_request *req) -{ - char *cmd = req->buf; - char response[FASTBOOT_RESPONSE_LEN]; - - strsep(&cmd, ":"); - if (!cmd) { - pr_err("missing partition name"); - fastboot_tx_write_str("FAILmissing partition name"); - return; + if (!strncmp("DATA", response, 4)) { + req->complete = rx_handler_dl_image; + req->length = rx_bytes_expected(ep); } - fastboot_fail("no flash device defined", response); -#ifdef CONFIG_FASTBOOT_FLASH_MMC - fastboot_mmc_erase(cmd, response); -#endif -#ifdef CONFIG_FASTBOOT_FLASH_NAND - fastboot_nand_erase(cmd, response); -#endif fastboot_tx_write_str(response); -} -#endif -struct cmd_dispatch_info { - char *cmd; - void (*cb)(struct usb_ep *ep, struct usb_request *req); -}; - -static const struct cmd_dispatch_info cmd_dispatch_info[] = { - { - .cmd = "reboot", - .cb = cb_reboot, - }, { - .cmd = "getvar:", - .cb = cb_getvar, - }, { - .cmd = "download:", - .cb = cb_download, - }, { - .cmd = "boot", - .cb = cb_boot, - }, { - .cmd = "continue", - .cb = cb_continue, - }, -#ifdef CONFIG_FASTBOOT_FLASH - { - .cmd = "flash", - .cb = cb_flash, - }, { - .cmd = "erase", - .cb = cb_erase, - }, -#endif - { - .cmd = "oem", - .cb = cb_oem, - }, -}; - -static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) -{ - char *cmdbuf = req->buf; - void (*func_cb)(struct usb_ep *ep, struct usb_request *req) = NULL; - int i; - - if (req->status != 0 || req->length == 0) - return; + if (!strncmp("OKAY", response, 4)) { + switch (cmd) { + case FASTBOOT_COMMAND_BOOT: + fastboot_func->in_req->complete = do_bootm_on_complete; + break; - for (i = 0; i < ARRAY_SIZE(cmd_dispatch_info); i++) { - if (!strcmp_l1(cmd_dispatch_info[i].cmd, cmdbuf)) { - func_cb = cmd_dispatch_info[i].cb; + case FASTBOOT_COMMAND_CONTINUE: + fastboot_func->in_req->complete = do_exit_on_complete; break; - } - } - if (!func_cb) { - pr_err("unknown command: %.*s", req->actual, cmdbuf); - fastboot_tx_write_str("FAILunknown command"); - } else { - if (req->actual < req->length) { - u8 *buf = (u8 *)req->buf; - buf[req->actual] = 0; - func_cb(ep, req); - } else { - pr_err("buffer overflow"); - fastboot_tx_write_str("FAILbuffer overflow"); + case FASTBOOT_COMMAND_REBOOT: + case FASTBOOT_COMMAND_REBOOT_BOOTLOADER: + fastboot_func->in_req->complete = compl_do_reset; + break; } } From patchwork Tue May 29 15:30:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 922190 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TAoF2un7"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wHtH5jjzz9s08 for ; Wed, 30 May 2018 01:37:59 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 6E54AC21ED5; Tue, 29 May 2018 15:37:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 6BD98C21F6D; Tue, 29 May 2018 15:31:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A8766C21F52; Tue, 29 May 2018 15:31:49 +0000 (UTC) Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by lists.denx.de (Postfix) with ESMTPS id E7CD8C21EB1 for ; Tue, 29 May 2018 15:31:39 +0000 (UTC) Received: by mail-wm0-f49.google.com with SMTP id l1-v6so41895193wmb.2 for ; Tue, 29 May 2018 08:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DZCZdUyFzWQkGSv2wox+MqjGcYP/dKo2qQ7v5QaocLc=; b=TAoF2un73t9jjZdKqHxJ1rdxrM56Gh2s4VahBP6DmOEGQAqm8/F5v3yqY4p5CJgH7j WgPsNuGXKvOumIbzz85uSYvY5KT7HPR4us5USy9szLGH1qoJEw+WFEay2U1W57eUG6lz iQoouvku6v/YJYGDqOglCdi0pISqLqTQfJX/q/De+exFDzXdpX1S5YheOUy9MYWtnnsq T5tta77WQ0YYM81SGVZJjjlAbrgrv9oXmZ5qsELpVZiIKawEJHl0GDiK+WJ9Ek0K/ELe mq3vHujqFcvOTY66ucJe4LDmsA1v2tQK4qdQLn+DhYnxTMdNqSl4mocRcIV+KudLyGc6 u0vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DZCZdUyFzWQkGSv2wox+MqjGcYP/dKo2qQ7v5QaocLc=; b=jTgTK/XAxPxin505Yw5tgYxO9Ex0W/Rxd2jT47sn/ticCljlOQiD8SeCcZF2uLXZt5 5t44egmEaeRT/+c0ZpglDcl79jb8sb7HPZJs5DEUYfQu8oSAH/VM7PeE3V460Ygpmsyr yznUTi2FLC9WAgEwNiDnWpD1p5yo1shBN8+v2Z3mSRxkBvh49WwhnA1wsA5Mw5LsDne/ cx/QFmpRsHe85yxLmTp7kt/KRLU4Q3cVtLn7YinvGiAnE3gFkrQd1mSCaUwJNknsqg0h WcmB3R8etSciSKJXljsHogis1oS4xx/46paC8pW1pkR7mc33XBgEMD6OjnG5MuobRVIu U5SQ== X-Gm-Message-State: ALKqPwcbqKm6sfGGu2kzAiLm2grF9k/HhHdI24YveBsljkZCR7Kaoy6j eTe6sIqFFrIbQgAeMX2fVZ3hvattJlA= X-Google-Smtp-Source: ADUXVKJfu9AAJOli5rOK4YAUjsFy+blepBuYkIzqzHwK7DuglNsMLhkac3tY/LShSBZdIWegJSvvuQ== X-Received: by 2002:a1c:ea1a:: with SMTP id i26-v6mr12996807wmh.11.1527607899302; Tue, 29 May 2018 08:31:39 -0700 (PDT) Received: from localhost.localdomain (host109-150-118-55.range109-150.btcentralplus.com. [109.150.118.55]) by smtp.gmail.com with ESMTPSA id v15-v6sm14229010wmf.47.2018.05.29.08.31.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 08:31:38 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger , Lukasz Majewski Date: Tue, 29 May 2018 15:30:56 +0000 Message-Id: <20180529153056.27328-19-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529153056.27328-1-alex.kiernan@gmail.com> References: <20180529153056.27328-1-alex.kiernan@gmail.com> Cc: Maxime Ripard , Jocelyn Bohr Subject: [U-Boot] [PATCH v8 18/18] fastboot: Update fastboot documentation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Update fastboot documentation to reflect merged USB/UDP implementation. Signed-off-by: Alex Kiernan Reviewed-by: Simon Glass --- Changes in v8: - add Reviewed-by: tag Changes in v7: None Changes in v6: - new Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None doc/README.android-fastboot | 240 +++++++++++++++++++++++------------- 1 file changed, 156 insertions(+), 84 deletions(-) diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot index 2c3ee7810a..431191c473 100644 --- a/doc/README.android-fastboot +++ b/doc/README.android-fastboot @@ -1,142 +1,214 @@ +================ Android Fastboot -~~~~~~~~~~~~~~~~ +================ Overview ======== -The protocol that is used over USB is described in -README.android-fastboot-protocol in same directory. -The current implementation is a minimal support of the erase command,the -"oem format" command and flash command;it only supports eMMC devices. +The protocol that is used over USB and UDP is described in the +``README.android-fastboot-protocol`` file in the same directory. + +The current implementation supports the following standard commands: + +- ``boot`` +- ``continue`` +- ``download`` +- ``erase`` (if enabled) +- ``flash`` (if enabled) +- ``getvar`` +- ``reboot`` +- ``reboot-bootloader`` +- ``set_active`` (only a stub implementation which always succeeds) + +The following OEM commands are supported (if enabled): + +- oem format - this executes ``gpt write mmc %x $partitions`` + +Support for both eMMC and NAND devices is included. Client installation =================== -The counterpart to this gadget is the fastboot client which can -be found in Android's platform/system/core repository in the fastboot -folder. It runs on Windows, Linux and even OSX. Linux user are lucky since -they only need libusb. -Windows users need to bring some time until they have Android SDK (currently -http://dl.google.com/android/installer_r12-windows.exe) installed. You -need to install ADB package which contains the required glue libraries for -accessing USB. Also you need "Google USB driver package" and "SDK platform -tools". Once installed the usb driver is placed in your SDK folder under -extras\google\usb_driver. The android_winusb.inf needs a line like - - %SingleBootLoaderInterface% = USB_Install, USB\VID_0451&PID_D022 - -either in the [Google.NTx86] section for 32bit Windows or [Google.NTamd64] -for 64bit Windows. VID and PID should match whatever the fastboot is -advertising. + +The counterpart to this is the fastboot client which can be found in +Android's ``platform/system/core`` repository in the fastboot +folder. It runs on Windows, Linux and OSX. The fastboot client is +part of the Android SDK Platform-Tools and can be downloaded from: + +https://developer.android.com/studio/releases/platform-tools Board specific ============== + +USB configuration +----------------- + The fastboot gadget relies on the USB download gadget, so the following options must be configured: -CONFIG_USB_GADGET_DOWNLOAD -CONFIG_USB_GADGET_VENDOR_NUM -CONFIG_USB_GADGET_PRODUCT_NUM -CONFIG_USB_GADGET_MANUFACTURER +:: + + CONFIG_USB_GADGET_DOWNLOAD + CONFIG_USB_GADGET_VENDOR_NUM + CONFIG_USB_GADGET_PRODUCT_NUM + CONFIG_USB_GADGET_MANUFACTURER -NOTE: The CONFIG_USB_GADGET_VENDOR_NUM must be one of the numbers supported by -the fastboot client. The list of vendor IDs supported can be found in the -fastboot client source code (fastboot.c) mentioned above. +NOTE: The ``CONFIG_USB_GADGET_VENDOR_NUM`` must be one of the numbers +supported by the fastboot client. The list of vendor IDs supported can +be found in the fastboot client source code. -The fastboot function is enabled by defining CONFIG_USB_FUNCTION_FASTBOOT, -CONFIG_CMD_FASTBOOT and CONFIG_ANDROID_BOOT_IMAGE. +General configuration +--------------------- -The fastboot protocol requires a large memory buffer for downloads. This -buffer should be as large as possible for a platform. The location of the -buffer and size are set with CONFIG_FASTBOOT_BUF_ADDR and -CONFIG_FASTBOOT_BUF_SIZE. +The fastboot protocol requires a large memory buffer for +downloads. This buffer should be as large as possible for a +platform. The location of the buffer and size are set with +``CONFIG_FASTBOOT_BUF_ADDR`` and ``CONFIG_FASTBOOT_BUF_SIZE``. These +may be overridden on the fastboot command line using ``-l`` and +``-s``. + +Fastboot environment variables +============================== + +Partition aliases +----------------- Fastboot partition aliases can also be defined for devices where GPT limitations prevent user-friendly partition names such as "boot", "system" and "cache". Or, where the actual partition name doesn't match a standard -partition name used commonly with fastboot. Current implentation checks -aliases when accessing partitions by name (flash_write and erase functions). -To define a partition alias add an environment variable similar to: -fastboot_partition_alias_= -Example: fastboot_partition_alias_boot=LNX +partition name used commonly with fastboot. + +The current implementation checks aliases when accessing partitions by +name (flash_write and erase functions). To define a partition alias +add an environment variable similar to: + +``fastboot_partition_alias_=`` + +for example: + +``fastboot_partition_alias_boot=LNX`` + +Variable overrides +------------------ + +Variables retrived through ``getvar`` can be overridden by defining +environment variables of the form ``fastboot.``. These are +looked up first so can be used to override values which would +otherwise be returned. Using this mechanism you can also return types +for NAND filesystems, as the fully parameterised variable is looked +up, e.g. + +``fastboot.partition-type:boot=jffs2`` + +Boot command +------------ + +When executing the fastboot ``boot`` command, if ``fastboot_bootcmd`` is set then +that will be executed in place of ``bootm ``. Partition Names =============== -The Fastboot implementation in U-boot allows to write images into disk -partitions (currently on eMMC). Target partitions are referred on the host -computer by their names. + +The Fastboot implementation in U-Boot allows to write images into disk +partitions. Target partitions are referred on the host computer by +their names. For GPT/EFI the respective partition name is used. For MBR the partitions are referred by generic names according to the following schema: - + -Example: hda3, sdb1, usbda1 +Example: ``hda3``, ``sdb1``, ``usbda1`` The device type is as follows: - * IDE, ATAPI and SATA disks: hd - * SCSI disks: sd - * USB media: usbd - * MMC and SD cards: mmcsd - * Disk on chip: docd - * other: xx + * IDE, ATAPI and SATA disks: ``hd`` + * SCSI disks: ``sd`` + * USB media: ``usbd`` + * MMC and SD cards: ``mmcsd`` + * Disk on chip: ``docd`` + * other: ``xx`` -The device index starts from 'a' and refers to the interface (e.g. USB +The device index starts from ``a`` and refers to the interface (e.g. USB controller, SD/MMC controller) or disk index. The partition index starts -from 1 and describes the partition number on the particular device. +from ``1`` and describes the partition number on the particular device. Writing Partition Table ======================= + Fastboot also allows to write the partition table to the media. This can be done by writing the respective partition table image to a special target "gpt" or "mbr". These names can be customized by defining the following configuration options: -CONFIG_FASTBOOT_GPT_NAME -CONFIG_FASTBOOT_MBR_NAME +:: + + CONFIG_FASTBOOT_GPT_NAME + CONFIG_FASTBOOT_MBR_NAME In Action ========= -Enter into fastboot by executing the fastboot command in u-boot and you -should see: -|GADGET DRIVER: usb_dnl_fastboot + +Enter into fastboot by executing the fastboot command in U-Boot for either USB: + +:: + + => fastboot usb 0 + +or UDP: + +:: + + => fastboot udp + link up on port 0, speed 100, full duplex + Using ethernet@4a100000 device + Listening for fastboot command on 192.168.0.102 On the client side you can fetch the bootloader version for instance: -|>fastboot getvar bootloader-version -|bootloader-version: U-Boot 2014.04-00005-gd24cabc -|finished. total time: 0.000s + +:: + + $ fastboot getvar bootloader-version + bootloader-version: U-Boot 2014.04-00005-gd24cabc + finished. total time: 0.000s or initiate a reboot: -|>fastboot reboot + +:: + + $ fastboot reboot and once the client comes back, the board should reset. You can also specify a kernel image to boot. You have to either specify -the an image in Android format _or_ pass a binary kernel and let the +the an image in Android format *or* pass a binary kernel and let the fastboot client wrap the Android suite around it. On OMAP for instance you take zImage kernel and pass it to the fastboot client: -|>fastboot -b 0x80000000 -c "console=ttyO2 earlyprintk root=/dev/ram0 -| mem=128M" boot zImage -|creating boot image... -|creating boot image - 1847296 bytes -|downloading 'boot.img'... -|OKAY [ 2.766s] -|booting... -|OKAY [ -0.000s] -|finished. total time: 2.766s - -and on the gadget side you should see: -|Starting download of 1847296 bytes -|........................................................ -|downloading of 1847296 bytes finished -|Booting kernel.. -|## Booting Android Image at 0x81000000 ... -|Kernel load addr 0x80008000 size 1801 KiB -|Kernel command line: console=ttyO2 earlyprintk root=/dev/ram0 mem=128M -| Loading Kernel Image ... OK -|OK -| -|Starting kernel ... +:: + + $ fastboot -b 0x80000000 -c "console=ttyO2 earlyprintk root=/dev/ram0 mem=128M" boot zImage + creating boot image... + creating boot image - 1847296 bytes + downloading 'boot.img'... + OKAY [ 2.766s] + booting... + OKAY [ -0.000s] + finished. total time: 2.766s + +and on the U-Boot side you should see: + +:: + + Starting download of 1847296 bytes + ........................................................ + downloading of 1847296 bytes finished + Booting kernel.. + ## Booting Android Image at 0x81000000 ... + Kernel load addr 0x80008000 size 1801 KiB + Kernel command line: console=ttyO2 earlyprintk root=/dev/ram0 mem=128M + Loading Kernel Image ... OK + OK + + Starting kernel ...