From patchwork Thu Jun 26 18:45:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 32591 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 628A7201EF for ; Thu, 26 Jun 2014 18:46:23 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id v10sf13487274pde.7 for ; Thu, 26 Jun 2014 11:46:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=MApSY7PsqAcEIOMc1DV40JS+IhXvNYkJWSI3+h1qfvA=; b=hXEdZt2MoFEjkiHaDQJIMsAPg1bznBuLxSzhOcFMC5CqZ8CRx48lRzeHznIveCAlsY nmggRpDxKq/ArLHsT4eeSLY/8V0wiRxpRn4FxkHjJQj5702Z3mfBeUQT6c74KOnVdQv9 tC954efDYBNCo7HWGLeXNXyPqkQxU/gnCUhqql2WVrUYf2V055F3T//pC5IJIieJetc8 aGUJajabql5O0bqRyFqKyJtPVZq6L96b0+eLCLSYA5McKIFThudF8lkTgijCcSMjZ+tr EKSf6+osN3m0McSCYuNGI3x757ATuxaTHLy4nJWHGh3A6jTvcz/LO9zakMN3+2iEs1td j0uA== X-Gm-Message-State: ALoCoQng+1lxnULn6xTr3fGN74OyVbWcIQhIPo1GG8HQbXioybKe/Lad+SHW5h5z0IDCyjx6zodV X-Received: by 10.66.220.34 with SMTP id pt2mr8980847pac.8.1403808382691; Thu, 26 Jun 2014 11:46:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.27.131 with SMTP id 3ls330133qgx.9.gmail; Thu, 26 Jun 2014 11:46:22 -0700 (PDT) X-Received: by 10.58.182.234 with SMTP id eh10mr4407860vec.41.1403808382543; Thu, 26 Jun 2014 11:46:22 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id dc1si5154878vdc.4.2014.06.26.11.46.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Jun 2014 11:46:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id pa12so4186767veb.14 for ; Thu, 26 Jun 2014 11:46:22 -0700 (PDT) X-Received: by 10.58.119.75 with SMTP id ks11mr15796231veb.20.1403808382435; Thu, 26 Jun 2014 11:46:22 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp51219vcb; Thu, 26 Jun 2014 11:46:22 -0700 (PDT) X-Received: by 10.140.31.131 with SMTP id f3mr22508576qgf.59.1403808381982; Thu, 26 Jun 2014 11:46:21 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id l7si13977620wiz.53.2014.06.26.11.46.20 for ; Thu, 26 Jun 2014 11:46:21 -0700 (PDT) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4A5C7A7761; Thu, 26 Jun 2014 20:46:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9xIcrC5gK4NP; Thu, 26 Jun 2014 20:46:14 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 13BEBA775C; Thu, 26 Jun 2014 20:46:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BD782A774B for ; Thu, 26 Jun 2014 20:46:04 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tiIN24QNpkKY for ; Thu, 26 Jun 2014 20:46:04 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-gw1-out.broadcom.com (mail-gw1-out.broadcom.com [216.31.210.62]) by theia.denx.de (Postfix) with ESMTP id 6D50FA7749 for ; Thu, 26 Jun 2014 20:45:50 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.01,554,1400050800"; d="scan'208";a="36704194" Received: from irvexchcas06.broadcom.com (HELO IRVEXCHCAS06.corp.ad.broadcom.com) ([10.9.208.53]) by mail-gw1-out.broadcom.com with ESMTP; 26 Jun 2014 12:07:32 -0700 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS06.corp.ad.broadcom.com (10.9.208.53) with Microsoft SMTP Server (TLS) id 14.3.174.1; Thu, 26 Jun 2014 11:45:49 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.3.174.1; Thu, 26 Jun 2014 11:45:49 -0700 Received: from mail.broadcom.com (lbrmn-vmlnx03.ric.broadcom.com [10.136.4.105]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 14E6A9FB97; Thu, 26 Jun 2014 11:45:30 -0700 (PDT) From: Steve Rae To: Rob Herring , Sebastian Siewior Date: Thu, 26 Jun 2014 11:45:17 -0700 Message-ID: <1403808318-16215-4-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1403808318-16215-1-git-send-email-srae@broadcom.com> References: <1403808318-16215-1-git-send-email-srae@broadcom.com> MIME-Version: 1.0 Cc: Marek Vasut , Steve Rae , Pantelis Antoniou , u-boot@lists.denx.de, Tom Rini Subject: [U-Boot] [PATCH v2 3/4] usb/gadget: fastboot: add support for flash command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srae@broadcom.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 - implement 'fastboot flash' for eMMC devices Signed-off-by: Steve Rae --- Changes in v2: - update README.android-fastboot file README | 10 ++++++++++ doc/README.android-fastboot | 5 +++-- drivers/usb/gadget/f_fastboot.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/README b/README index fe5cacb..984db6d 100644 --- a/README +++ b/README @@ -1623,6 +1623,16 @@ The following options need to be configured: downloads. This buffer should be as large as possible for a platform. Define this to the size available RAM for fastboot. + CONFIG_FASTBOOT_FLASH + The fastboot protocol includes a "flash" command for writing + the downloaded image to a non-volatile storage device. Define + this to enable the "fastboot flash" command. + + CONFIG_FASTBOOT_FLASH_MMC_DEV + The fastboot "flash" command requires addition information + regarding the non-volatile storage device. Define this to + the eMMC device that fastboot should use to store the image. + - Journaling Flash filesystem support: CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE, CONFIG_JFFS2_NAND_DEV diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot index f1d128c..430e29c 100644 --- a/doc/README.android-fastboot +++ b/doc/README.android-fastboot @@ -6,8 +6,9 @@ Overview The protocol that is used over USB is described in README.android-fastboot-protocol in same directory. -The current implementation does not yet support the flash and erase -commands. +The current implementation does not yet support the erase command or the +"oem format" command, and there is minimal support for the flash command; +it only supports eMMC devices. Client installation =================== diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 9dd85b6..89c2d3e 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -19,6 +19,9 @@ #include #include #include +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +#include +#endif #define FASTBOOT_VERSION "0.4" @@ -466,6 +469,28 @@ static void cb_boot(struct usb_ep *ep, struct usb_request *req) fastboot_tx_write_str("OKAY"); } +#ifdef CONFIG_FASTBOOT_FLASH +static void cb_flash(struct usb_ep *ep, struct usb_request *req) +{ + char *cmd = req->buf; + char response[RESPONSE_LEN]; + + strsep(&cmd, ":"); + if (!cmd) { + printf("%s: missing partition name\n", __func__); + fastboot_tx_write_str("FAILmissing partition name"); + return; + } + + strcpy(response, "FAILno flash device defined"); +#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV + fb_mmc_flash_write(cmd, (void *)CONFIG_USB_FASTBOOT_BUF_ADDR, + download_bytes, response); +#endif + fastboot_tx_write_str(response); +} +#endif + struct cmd_dispatch_info { char *cmd; void (*cb)(struct usb_ep *ep, struct usb_request *req); @@ -485,6 +510,12 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = { .cmd = "boot", .cb = cb_boot, }, +#ifdef CONFIG_FASTBOOT_FLASH + { + .cmd = "flash", + .cb = cb_flash, + }, +#endif }; static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)