From patchwork Sat Aug 23 19:53:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 35876 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2D3062057E for ; Sat, 23 Aug 2014 19:54:37 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id m1sf71716697oag.3 for ; Sat, 23 Aug 2014 12:54:36 -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=ROt23LpFsDgGRRoPhwLtawu1+NmPlMJ9g6MU3VlDR3w=; b=ahVW3KuB9cgtHxAIKoPgBW0a111YV8L4KQGKiAbcs5YHCInU7+4i9YTOB+iOsOjljc T1LL48xFgnMxRS02NKMIErb2YkWSzwmrl8hTy8Dgy6EylwbovEYQs59Q7H7tjBc0SHY1 c4BvoleDAtNznn26ajwQlKA0OZhfB+jqay8MLyVjT66nk8GkX8pFgkG+yNYuoVGs7PjN pB+cl5aEtFel1OZ4Fz5gGP+f8HTs18QmleThYs9/9GTOGQLBlbDnQISW9ewvfGol094k Pubvry/Vpy4Laxi5gQserFyClS9+rjmwXxaIuqQ9f9ShP0YkZkBmkDki/T9e3LnyHs+U fiNg== X-Gm-Message-State: ALoCoQn9m4+zpNMQ4zWvPGy3ggqUHklgubA4vWlOnAuUNpTd9L0C18OVdC/OPMli58HlsS90FLUS X-Received: by 10.182.191.36 with SMTP id gv4mr1249472obc.50.1408823676806; Sat, 23 Aug 2014 12:54:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.235 with SMTP id q98ls1631404qga.91.gmail; Sat, 23 Aug 2014 12:54:36 -0700 (PDT) X-Received: by 10.221.5.137 with SMTP id og9mr9707236vcb.18.1408823676668; Sat, 23 Aug 2014 12:54:36 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id x7si14383803vcm.78.2014.08.23.12.54.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 23 Aug 2014 12:54:36 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id hy10so13572652vcb.4 for ; Sat, 23 Aug 2014 12:54:36 -0700 (PDT) X-Received: by 10.220.163.69 with SMTP id z5mr9749269vcx.10.1408823676530; Sat, 23 Aug 2014 12:54:36 -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 uj3csp8618vcb; Sat, 23 Aug 2014 12:54:36 -0700 (PDT) X-Received: by 10.180.91.70 with SMTP id cc6mr5586830wib.66.1408823675160; Sat, 23 Aug 2014 12:54:35 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id n17si3444776wij.84.2014.08.23.12.54.34 for ; Sat, 23 Aug 2014 12:54:35 -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 AEC094B5B9; Sat, 23 Aug 2014 21:54:27 +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 wUMhBUDB5K65; Sat, 23 Aug 2014 21:54:27 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 67B564B5D3; Sat, 23 Aug 2014 21:54:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3B57F4A056 for ; Sat, 23 Aug 2014 21:54:16 +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 MYZxoZcrj45h for ; Sat, 23 Aug 2014 21:54:15 +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 9586D4A027 for ; Sat, 23 Aug 2014 21:54:12 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.04,387,1406617200"; d="scan'208";a="43221739" Received: from irvexchcas06.broadcom.com (HELO IRVEXCHCAS06.corp.ad.broadcom.com) ([10.9.208.53]) by mail-gw3-out.broadcom.com with ESMTP; 23 Aug 2014 13:08:57 -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; Sat, 23 Aug 2014 12:54:11 -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; Sat, 23 Aug 2014 12:54:11 -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 A0BAC9F9F7; Sat, 23 Aug 2014 12:54:09 -0700 (PDT) From: Steve Rae To: , Tom Rini , Marek Vasut Date: Sat, 23 Aug 2014 12:53:05 -0700 Message-ID: <1408823626-12744-5-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 Cc: Steve Rae , Rob Herring , Pantelis Antoniou , Vadim Bendebury Subject: [U-Boot] [PATCH v5 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.220.173 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 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 | 33 +++++++++++++++++++++++---------- 2 files changed, 24 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 e559e2a..c2e896f 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, @@ -33,7 +41,7 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, if (blkcnt > info->size) { printf("%s: too large for partition: '%s'\n", __func__, part_name); - fastboot_resp("FAILtoo large for partition"); + fastboot_fail("too large for partition"); return; } @@ -44,13 +52,13 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info, if (blks != blkcnt) { printf("%s: failed writing to device %d\n", __func__, 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, @@ -66,17 +74,22 @@ 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) { printf("%s: invalid mmc device\n", __func__); - fastboot_resp("FAILinvalid mmc device"); + fastboot_fail("invalid mmc device"); return; } ret = get_partition_info_efi_by_name(dev_desc, cmd, &info); if (ret) { printf("%s: cannot find partition: '%s'\n", __func__, 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); + } }