From patchwork Tue May 22 09:23:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Kiernan X-Patchwork-Id: 918147 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="uQ0EKyfU"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40qsYR5hbtz9s02 for ; Tue, 22 May 2018 20:38:02 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 21A0CC21C6A; Tue, 22 May 2018 10:37:58 +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 A291BC21C6A; Tue, 22 May 2018 10:37:52 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7FB64C21C6A; Tue, 22 May 2018 09:24:47 +0000 (UTC) Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by lists.denx.de (Postfix) with ESMTPS id C57C6C21C2F for ; Tue, 22 May 2018 09:24:44 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id p3-v6so43715wrn.7 for ; Tue, 22 May 2018 02:24:44 -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:mime-version :content-transfer-encoding; bh=JTz6GiUIlOgcpr5qh5kbr2ENX1pk3EbG5OhsIqJoth8=; b=uQ0EKyfUTl+W7osg11lqGBOsXthTERiBSyPp9gCgPlZfyS7QaB0DuTQfsyx6yoT2Nu gkdIdsUkPKqbvwICZuZPdNvZOCS8ZSmSDg5bV4B+BWXUxyYeSkIlSjWOyG0RSo33/vhC qkvQs7qKVYMxpkobQhA/zlhFwCmbWKGJSF6KvU7UZrnFvl50ss3aHUA+6DsLiDFxWXvY wffQXM4p318srZI9KPZKLyHUE08vG2K8/5Dg1b/UcfVkyJ5GbM3zJ6aL2stzB49FWUha 3xs7IQksmWes0wI7Gq3elgtDZ5gcwDADJGJ0mUevVloR3XhuUxLQC/1Q78Ghbi/tw7aW W41A== 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:mime-version :content-transfer-encoding; bh=JTz6GiUIlOgcpr5qh5kbr2ENX1pk3EbG5OhsIqJoth8=; b=hqBFc6aYW+nRpmUPC2ONKLlvmAv36gHfnp5As2x66Lc50AqAZ19mKCGNbmOrKHcJp9 Li5WlXz7g2CbJrbU5XiCQFR1f4Rbwa8ip4b+qxT6GF7q2qwykgfprFovgCaWEssiO0AS PRhUy3ldY+8Dfdq5SEgAsXwuCNxgsYGI00tYLAvK7/mZrutsbmFXPSe4qgmb6vN167Us OFGaOh6NCuH8nTfVcYYXRjE90VyH+UU3aeymJuT+jx7+R0IOOB7XwJii9a3qZ1K7erZW g7N81HDmGwFiCiwF97Q76bVqRJu7nxX/jCYpUYSL5SPt1UNgMkEljxweQDEcq3DANh0T jQFQ== X-Gm-Message-State: ALKqPwfpyS1JXIiUBUtOhiz5l0/q5vlkiahAJ/IMerLlBFKbylv6Pi2F aUQN5DoqWbWFqN+UGJToScrRu+qEfO8= X-Google-Smtp-Source: AB8JxZqdptL0uhm9bScGcFtWKsaTDjT33PZiPtpL/uToWxuHNyUxI//WloPldnpnj506awMPWvXGxQ== X-Received: by 2002:adf:8e44:: with SMTP id n62-v6mr18008894wrb.159.1526981084005; Tue, 22 May 2018 02:24:44 -0700 (PDT) Received: from localhost.localdomain (193.164.125.18.ip.redstone-isp.net. [193.164.125.18]) by smtp.gmail.com with ESMTPSA id s7-v6sm1404418wrp.4.2018.05.22.02.24.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 02:24:43 -0700 (PDT) From: Alex Kiernan To: u-boot@lists.denx.de, Joe Hershberger Date: Tue, 22 May 2018 09:23:34 +0000 Message-Id: <20180522092352.19794-1-alex.kiernan@gmail.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 22 May 2018 10:37:51 +0000 Cc: Ben Young , Martyn Welch , Jocelyn Bohr , Praneeth Bajjuri , Chris Packham , Marek Vasut , Tom Rini , Daniel Thompson , Simone CIANNI , Ian Ray , Michal Simek , Heinrich Schuchardt , Jagan Teki , Benjamin Young , Otavio Salvador , Andre Przywara , Gilles Gameiro , Tien Fong Chee , Jassi Brar , Alexander Graf , Jason Kridner , Raffaele RECALCATI , Steve Rae , Jocelyn Bohr , Angelo Dureghello , Fabio Estevam , Andy Yan , Maxime Ripard Subject: [U-Boot] [PATCH v6 00/18] Add fastboot UDP support 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" This series merges the fastboot UDP support from AOSP into mainline U-Boot. Changes in UDP behaviour from the AOSP code, so it follows the existing USB behaviour: - 'boot' now follows the USB code and does 'bootm CONFIG_FASTBOOT_BUF_ADDR'. I've added 'fastboot_bootcmd' which if set overrides the boot command and allows the existing UDP behaviour to be preserved. - 'continue' in UDP now exits the fastboot server rather than executing 'run bootcmd' - 'reboot-bootloader' no longer writes 'reboot-bootloader' to CONFIG_FASTBOOT_BUF_ADDR as its marker for the subsequent boot. The code which is in AOSP common/android_bootloader.c expects this marker, but we have prior art in the USB code using the weak function fastboot_set_reboot_flag - 'getvar' in the UDP path now supports fetching 'fastboot.' prefixed variables (inherited from the USB path), these override the defaults I've pushed both USB and UDP into a single consolidated protocol layer now I've tested it on a BeagleBone Green. Green Travis build: https://travis-ci.org/akiernan/u-boot/builds/381854592 Changes in v6: - accomodate master change and switch dependency on imx6dl_mamoj from FASTBOOT to USB_FUNCTION_FASTBOOT - delete redundant FASTBOOT_FLASH_NAND_DEV symbol - add docbook comments - add docbook comments - rename fastboot_download_data() to fastboot_data_download(), rename fastboot_get_bytes_remaining() to fastboot_data_remaining() - split fastboot_data_complete() out from fastboot_data_download() so we can call it at the end of the transfer phase for USB - merged from RFC USB fastboot series - when entering the DATA phase ensure we actually install the correct handler - on completion of DATA call new fastboot_data_complete() - previous changes: - remove redundant version.h - use new fastboot_get_bytes_remaining() function - new Changes in v5: - don't depend on UDP_FUNCTION_FASTBOOT until it exists - squash in subsequent patch which updates defconfigs so we don't leave users of CONFIG_FASTBOOT without it enabled - fix build in drivers/fastboot when we have CONFIG_FASTBOOT without flash or erase and we've not yet added fb_common.c to the build - fix docbook formatting - new - new - rename CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE to CONFIG_IMAGE_SPARSE_FILLBUF_SIZE and migrate it to Kconfig. - make fastboot_bytes_received/expected static and add function fastboot_get_bytes_remaining() - move fastboot_buf_addr/fastboot_buf_size/fastboot_progress_callback into fastboot-internal.h - delete redundant fb_ prefixes from statics - new Changes in v4: - add docbook comments - leave strcmp_l1() in USB fastboot as we don't need it in UDP path - add docbook comments - new - guard fb_getvar/fb_command with UDP_FUNCTION_FASTBOOT in Makefile - add docbook comments - remove parameter from fastboot_boot() since we always want fastboot_buf_addr (and if we're using fastboot_bootcmd then it's ignored) - split oem format into new patch Changes in v3: - move imply ANDROID_BOOT_IMAGE, CMD_FASTBOOT to FASTBOOT from USB_FUNCTION_FASTBOOT - add depend on USB_FUNCTION_FASTBOOT to FASTBOOT_USB_DEV - leave images-sparse.c in common to acommodate 2f83f21 - refactor for changes in master - Merge subsequent patch for formatting response strings into this one - allow NULL to fastboot_okay() when there's no message to send - guard FASTBOOT_GPT_NAME/FASTBOOT_MBR_NAME with EFI/DOS_PARTITION - new - new - new - new - new - new - use FASTBOOT as our guard in Kconfig not a list of USB || UDP - correct mis-translation from AOSP introduced when cleaning up for checkpatch - we should write when buffer is not NULL, rather than erasing, and erase when buffer is NULL - use CMD_RET_USAGE from do_fastboot - remove do_fastboot_udp from cmd/net.c and rewrite using net_loop() - rename timed_send_info to fastboot_send_info, rename fastboot_send_info to fastboot_udp_send_info - replace FASTBOOT_HEADER_SIZE with sizeof(struct fastboot_header) - move start time into timed_send_info() rather than passing it in - make calls to fastboot_udp_send_info a runtime dependency, not a compile time one - set ${filesize} to size of downloaded image - add progress meter from USB path during download - add support for 'oem format' command from the USB path - rename 'fastbootcmd' to 'fastboot_bootcmd' to make clear that this is the fastboot boot command - make getvar implementation table driven - add fastboot_buf_addr, fastboot_buf_size to override buffer address and size - return correct filesystem type in getvar partition-type on MMC - process "fastboot." prefixed env variables in getvar first so you can override the normal values (this also lets you set a fs type for NAND devices) - squash subsequent patches which change this code into this one: - If the fastboot flash/erase commands are disabled, remove that support so we still build correctly. - Add NAND support to fastboot UDP flash/erase commands - If we don't have a partition name passed, report it as not found. - Change the behaviour of the fastboot net code such that "reboot-bootloader" is no longer written to CONFIG_FASTBOOT_BUF_ADDR for use as a marker on reboot (the AOSP code in common/android-bootloader.c uses this marker - this code could be reinstated there if that gets merged). - Merge USB and UDP boot code. The USB implementation stays the same, but UDP no longer passes an fdt. We introduce a new environment variable 'fastboot_bootcmd' which if set overrides the hardcoded boot command, setting this then allows the UDP implementation to remain the same. If after running 'fastboot_bootcmd' the board has not booted, control is returned to U-Boot and the fastboot process ends. - Separate the fastboot protocol handling from the fastboot UDP code in preparation for reusing it in the USB code. Changes in v2: - ensure fastboot syntax is backward compatible - 'fastboot 0' means 'fastboot usb 0' Alex Kiernan (18): fastboot: Move fastboot to drivers/fastboot fastboot: Refactor fastboot_okay/fail to take response fastboot: Extract fastboot_okay/fail to fb_common.c fastboot: Correct dependencies in FASTBOOT_FLASH fastboot: Add missing newlines fastboot: Remove FIXME for CONFIG_FASTBOOT_...NAME fastboot: Fix parameter types in _fb_nand_write fastboot: Rename fb_set_reboot_flag to fastboot_set_reboot_flag fastboot: Extract common definitions from USB fastboot fastboot: Rename public fb_ functions to fastboot_ ti: fastboot: Move weak overrides to board files fs: Add fs_get_type_name to return current filesystem name fastboot: Migrate FASTBOOT_FLASH_NAND_TRIMFFS to Kconfig mmc: Separate "mmc swrite" from fastboot net: fastboot: Merge AOSP UDP fastboot fastboot: Add support for 'oem format' command usb: fastboot: Convert USB f_fastboot to shared fastboot fastboot: Update fastboot documentation arch/arm/Kconfig | 2 - arch/arm/mach-omap2/boot-common.c | 10 - arch/arm/mach-omap2/utils.c | 4 +- arch/arm/mach-rockchip/rk3128-board.c | 4 +- arch/arm/mach-rockchip/rk322x-board.c | 4 +- board/amazon/kc1/kc1.c | 2 +- board/lg/sniper/sniper.c | 2 +- board/ti/am57xx/board.c | 10 + board/ti/common/Kconfig | 1 - board/ti/dra7xx/evm.c | 10 + cmd/Kconfig | 22 +- cmd/fastboot.c | 91 ++++- cmd/mmc.c | 14 +- common/Makefile | 14 - configs/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 +- doc/README.android-fastboot | 240 +++++++----- drivers/Kconfig | 2 + drivers/Makefile | 1 + {cmd => drivers}/fastboot/Kconfig | 63 ++-- drivers/fastboot/Makefile | 7 + drivers/fastboot/fb_command.c | 335 +++++++++++++++++ drivers/fastboot/fb_common.c | 169 +++++++++ drivers/fastboot/fb_getvar.c | 230 ++++++++++++ {common => drivers/fastboot}/fb_mmc.c | 216 +++++++---- {common => drivers/fastboot}/fb_nand.c | 69 +++- drivers/usb/gadget/f_fastboot.c | 347 ++---------------- fs/fs.c | 13 + include/fastboot-internal.h | 36 ++ include/fastboot.h | 137 ++++++- include/fb_mmc.h | 35 +- include/fb_nand.h | 37 +- include/fs.h | 10 + include/image-sparse.h | 4 +- include/net.h | 2 +- include/net/fastboot.h | 21 ++ lib/Kconfig | 11 + lib/Makefile | 1 + {common => lib}/image-sparse.c | 38 +- net/Makefile | 1 + net/fastboot.c | 317 ++++++++++++++++ net/net.c | 7 + scripts/config_whitelist.txt | 2 - 78 files changed, 1988 insertions(+), 627 deletions(-) rename {cmd => drivers}/fastboot/Kconfig (78%) create mode 100644 drivers/fastboot/Makefile create mode 100644 drivers/fastboot/fb_command.c create mode 100644 drivers/fastboot/fb_common.c create mode 100644 drivers/fastboot/fb_getvar.c rename {common => drivers/fastboot}/fb_mmc.c (62%) rename {common => drivers/fastboot}/fb_nand.c (71%) create mode 100644 include/fastboot-internal.h create mode 100644 include/net/fastboot.h rename {common => lib}/image-sparse.c (88%) create mode 100644 net/fastboot.c