From patchwork Tue Aug 26 18:47:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 36047 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ED6A420551 for ; Tue, 26 Aug 2014 18:46:51 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id v1sf51836387yhn.8 for ; Tue, 26 Aug 2014 11:46:51 -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=BNZDallfmmUEmALNTF9wFWYvlPaoNkNtcmL79EsWdrk=; b=ReiDOiXMlEiDhdWSAeyB+3XK6ffzf/IGfg1fbDuvA8+8ozR018sHv/7cR53pCUR9Op c5Xg1JcvAOQpWA+31/6iFccrJ6h1joqhOfNG6GGcmQ/y6wBQiU3AuVP2jsLUGKqYbImt AaL5q2ifT/QjlUifoQnhgKPn+yePbeM3NeCYZRdZ9IU33gSVrknEYO6Cr6W6NcxpJ1Fp AgWfRpRH/F5CSMN5PPJkCzSHewyDzShj1cOP+FzUch4Q5cW3xJqPhhk3zASj/KpV1O0H d5OuF3u6+ICVZtrdLajYlTeT20bmR9Dj1dcfaaDKLjShcwZ4kf7SNJSKvKX+EuzID58+ Jyxw== X-Gm-Message-State: ALoCoQmKT8XH0XMDbCUuKQYnUd6nmwxr/Izk65ltUleJ1yV25MuHNG9008WOMYlaAEBk2lcJCGQc X-Received: by 10.236.207.101 with SMTP id m65mr6013233yho.41.1409078811801; Tue, 26 Aug 2014 11:46:51 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.34 with SMTP id d31ls1852598qgf.93.gmail; Tue, 26 Aug 2014 11:46:51 -0700 (PDT) X-Received: by 10.236.162.7 with SMTP id x7mr42970138yhk.6.1409078811617; Tue, 26 Aug 2014 11:46:51 -0700 (PDT) Received: from mail-yh0-f42.google.com (mail-yh0-f42.google.com [209.85.213.42]) by mx.google.com with ESMTPS id i62si3055516yhq.187.2014.08.26.11.46.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Aug 2014 11:46:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.213.42 as permitted sender) client-ip=209.85.213.42; Received: by mail-yh0-f42.google.com with SMTP id a41so12271157yho.15 for ; Tue, 26 Aug 2014 11:46:51 -0700 (PDT) X-Received: by 10.52.52.136 with SMTP id t8mr2637407vdo.21.1409078811349; Tue, 26 Aug 2014 11:46:51 -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 uj3csp221710vcb; Tue, 26 Aug 2014 11:46:50 -0700 (PDT) X-Received: by 10.180.100.230 with SMTP id fb6mr23812605wib.0.1409078809974; Tue, 26 Aug 2014 11:46:49 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id hj19si5698162wib.36.2014.08.26.11.46.49 for ; Tue, 26 Aug 2014 11:46:49 -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 6873DA74CA; Tue, 26 Aug 2014 20:46:44 +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 7BPfAP2bSipf; Tue, 26 Aug 2014 20:46:44 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A2E07A74D1; Tue, 26 Aug 2014 20:46:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 93906A74C5 for ; Tue, 26 Aug 2014 20:46:35 +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 45x8Thu9J5I4 for ; Tue, 26 Aug 2014 20:46:33 +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 0EB9AA74C2 for ; Tue, 26 Aug 2014 20:46:23 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.04,405,1406617200"; d="scan'208";a="43957259" Received: from irvexchcas06.broadcom.com (HELO IRVEXCHCAS06.corp.ad.broadcom.com) ([10.9.208.53]) by mail-gw1-out.broadcom.com with ESMTP; 26 Aug 2014 12:40:13 -0700 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS06.corp.ad.broadcom.com (10.9.208.53) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 26 Aug 2014 11:46:21 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.3.174.1; Tue, 26 Aug 2014 11:46:21 -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 D2AEC9F9FC; Tue, 26 Aug 2014 11:46:19 -0700 (PDT) From: Steve Rae To: Lukasz Majewski Date: Tue, 26 Aug 2014 11:47:30 -0700 Message-ID: <1409078850-7873-5-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1409078850-7873-1-git-send-email-srae@broadcom.com> References: <1409078850-7873-1-git-send-email-srae@broadcom.com> MIME-Version: 1.0 Cc: Steve Rae , Marek Vasut , Pantelis Antoniou , u-boot@lists.denx.de, Tom Rini Subject: [U-Boot] [PATCH v6 4/4] usb/gadget: fastboot: implement sparse format 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.213.42 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 - add capability to "fastboot flash" with sparse format images Signed-off-by: Steve Rae Acked-by: Lukasz Majewski --- Changes in v6: - remove excess braces Changes in v5: - use the common/aboot.c for the "sparse format" handling Changes in v4: - rearranged "sparse format" support in this patchset, in order to isolate... Changes in v3: None Changes in v2: None common/Makefile | 1 + common/fb_mmc.c | 32 ++++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/common/Makefile b/common/Makefile index daebe39..bc53078 100644 --- a/common/Makefile +++ b/common/Makefile @@ -268,6 +268,7 @@ obj-y += stdio.o # This option is not just y/n - it can have a numeric value ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV +obj-y += aboot.o obj-y += fb_mmc.o endif diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 14d3982..fb06d8a 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -7,16 +7,24 @@ #include #include #include +#include +#include /* The 64 defined bytes plus the '\0' */ #define RESPONSE_LEN (64 + 1) static char *response_str; -static void fastboot_resp(const char *s) +void fastboot_fail(const char *s) { - strncpy(response_str, s, RESPONSE_LEN); - response_str[RESPONSE_LEN - 1] = '\0'; + strncpy(response_str, "FAIL", 4); + strncat(response_str, s, RESPONSE_LEN - 4 - 1); +} + +void fastboot_okay(const char *s) +{ + strncpy(response_str, "OKAY", 4); + strncat(response_str, s, RESPONSE_LEN - 4 - 1); } static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, @@ -32,7 +40,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, if (blkcnt > info->size) { error("too large for partition: '%s'\n", part_name); - fastboot_resp("FAILtoo large for partition"); + fastboot_fail("too large for partition"); return; } @@ -42,13 +50,13 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, buffer); if (blks != blkcnt) { error("failed writing to device %d\n", dev_desc->dev); - fastboot_resp("FAILfailed writing to device"); + fastboot_fail("failed writing to device"); return; } printf("........ wrote " LBAFU " bytes to '%s'\n", blkcnt * info->blksz, part_name); - fastboot_resp("OKAY"); + fastboot_okay(""); } void fb_mmc_flash_write(const char *cmd, void *download_buffer, @@ -64,17 +72,21 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer, dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV); if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) { error("invalid mmc device\n"); - fastboot_resp("FAILinvalid mmc device"); + fastboot_fail("invalid mmc device"); return; } ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); if (ret) { error("cannot find partition: '%s'\n", cmd); - fastboot_resp("FAILcannot find partition"); + fastboot_fail("cannot find partition"); return; } - write_raw_image(dev_desc, &info, cmd, download_buffer, - download_bytes); + if (is_sparse_image(download_buffer)) + write_sparse_image(dev_desc, &info, cmd, download_buffer, + download_bytes); + else + write_raw_image(dev_desc, &info, cmd, download_buffer, + download_bytes); }