From patchwork Sat Aug 23 19:53:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 35888 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ACF14203C0 for ; Mon, 25 Aug 2014 08:39:42 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hq11sf40732564vcb.7 for ; Mon, 25 Aug 2014 01:39:42 -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=CYYFjtJZOykswVOy9KZRl3D0LVSbkiGemA5N5jIp+VY=; b=SJKqJA3f4j+Z3v+5C4+Fwk2LujKBqCEQHe3zF8QU46hjZ/yIy9eJQLwT+O0uLwBuEG v/NeLHz5GwNb1x3Ai9hh0b/NwwEmLccdEF48gs4TW/CYy4yKZflpDWo8j/uhksov77g2 QYpeC6tWOTL1mHkK5DEYoO5Nrkt7897sZJiOq7g42ZiwGi+gefueT6R0EnIY/yJ79ZrU 8yCJmTDrPU56w+x1Gf2SZqPxDWfSWdbkTIAhV46oOor1h9jVqfEJtc2ynx03mtWm5G9y fMd441/P9NKLe58vV++DsocPSt0xZJdBv7NlEz/WlWd+OdbTsgA6dunyu7z0fzm2pYFq Kl8Q== X-Gm-Message-State: ALoCoQlrFRYkckY4TX9MpI3sDqsBSclnFGnZEvwQQtF9uTlm7rF2eDojH1N8HSaQZplepYpmWSAL X-Received: by 10.236.87.46 with SMTP id x34mr498259yhe.49.1408955982434; Mon, 25 Aug 2014 01:39:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.112 with SMTP id 103ls1966957qga.9.gmail; Mon, 25 Aug 2014 01:39:42 -0700 (PDT) X-Received: by 10.52.26.173 with SMTP id m13mr3510512vdg.69.1408954781508; Mon, 25 Aug 2014 01:19:41 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id xk3si12977696vdb.7.2014.08.25.01.19.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 01:19:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hy4so14485861vcb.22 for ; Mon, 25 Aug 2014 01:19:41 -0700 (PDT) X-Received: by 10.221.5.137 with SMTP id og9mr17337776vcb.18.1408954781433; Mon, 25 Aug 2014 01:19:41 -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.45.67 with SMTP id uj3csp98694vcb; Mon, 25 Aug 2014 01:19:40 -0700 (PDT) X-Received: by 10.180.87.231 with SMTP id bb7mr14075938wib.63.1408954780199; Mon, 25 Aug 2014 01:19:40 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id a1si54766204wje.8.2014.08.25.01.19.39 for ; Mon, 25 Aug 2014 01:19:40 -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 011AE4B62A; Mon, 25 Aug 2014 10:19:26 +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 qYAld66MgWUa; Mon, 25 Aug 2014 10:19:25 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6C7BCA73E5; Mon, 25 Aug 2014 10:18:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B29D04A051 for ; Sat, 23 Aug 2014 21:53:54 +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 Wh5huxla5XUu for ; Sat, 23 Aug 2014 21:53:53 +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-gw3-out.broadcom.com (mail-gw3-out.broadcom.com [216.31.210.64]) by theia.denx.de (Postfix) with ESMTP id 391A24A027 for ; Sat, 23 Aug 2014 21:53:51 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.04,387,1406617200"; d="scan'208";a="43221736" Received: from irvexchcas07.broadcom.com (HELO IRVEXCHCAS07.corp.ad.broadcom.com) ([10.9.208.55]) by mail-gw3-out.broadcom.com with ESMTP; 23 Aug 2014 13:08:37 -0700 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.3.174.1; Sat, 23 Aug 2014 12:53:50 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.174.1; Sat, 23 Aug 2014 12:53:50 -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 870C89F9F7; Sat, 23 Aug 2014 12:53:49 -0700 (PDT) From: Steve Rae To: , Tom Rini , Marek Vasut Date: Sat, 23 Aug 2014 12:53:03 -0700 Message-ID: <1408823626-12744-3-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1408823626-12744-1-git-send-email-srae@broadcom.com> References: <1408823626-12744-1-git-send-email-srae@broadcom.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 25 Aug 2014 10:18:21 +0200 Cc: Steve Rae , Rob Herring , Pantelis Antoniou , Jeroen Hofstee , "Josh\"" , Mateusz Zalega , "Clifton A\"" , Nobuhiro Iwamatsu , York Sun , Holger Freyther Subject: [U-Boot] [PATCH v5 2/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.220.177 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 Reviewed-by: Marek Vasut Acked-by: Lukasz Majewski --- Changes in v5: None Changes in v4: None Changes in v3: None 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 1d71359..ed26884 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 4045727..1677609 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 7a1acb9..e2659fa 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" @@ -469,6 +472,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); @@ -488,6 +513,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)