From patchwork Sat May 21 01:05:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 624708 X-Patchwork-Delegate: p.marczak@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3rBRkc0PbHz9t6g for ; Sat, 21 May 2016 11:18:00 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EFF53A75CE; Sat, 21 May 2016 03:17:54 +0200 (CEST) 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 BMuDB8aQrYKN; Sat, 21 May 2016 03:17:54 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 97DCBA7535; Sat, 21 May 2016 03:17:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C382F4BB1A for ; Sat, 21 May 2016 03:17:42 +0200 (CEST) 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 dclcdd435yqD for ; Sat, 21 May 2016 03:17:42 +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 151A94BA38 for ; Sat, 21 May 2016 03:17:40 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.26,341,1459839600"; d="scan'208";a="95491976" Received: from mail-irv-18.broadcom.com ([10.15.198.37]) by mail-gw1-out.broadcom.com with ESMTP; 20 May 2016 19:04:32 -0700 Received: from mail-irva-12.broadcom.com (mail-irva-12.broadcom.com [10.11.16.101]) by mail-irv-18.broadcom.com (Postfix) with ESMTP id D018A82022; Fri, 20 May 2016 18:06:36 -0700 (PDT) Received: from VM-host64-64-A1.ric.broadcom.com (lbrmn-vmlnx03.ric.broadcom.com [10.136.4.105]) by mail-irva-12.broadcom.com (Postfix) with ESMTP id 13191127621; Fri, 20 May 2016 18:06:35 -0700 (PDT) From: Steve Rae To: u-boot@lists.denx.de Date: Fri, 20 May 2016 18:05:54 -0700 Message-Id: <1463792758-24338-2-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1463792758-24338-1-git-send-email-srae@broadcom.com> References: <1463792758-24338-1-git-send-email-srae@broadcom.com> Cc: Steve Rae , Tom Rini , Stephen Warren Subject: [U-Boot] [PATCH 1/5] fastboot: sparse: remove session-id logic X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This "session-id" alogrithm is not required, and currently corrupts the stored image whenever more the one "session" is required. Signed-off-by: Steve Rae --- for more information, see the thread starting at [1] [1] http://lists.denx.de/pipermail/u-boot/2016-April/251889.html common/fb_mmc.c | 8 +++----- common/fb_nand.c | 4 ++-- common/image-sparse.c | 21 ++++----------------- drivers/usb/gadget/f_fastboot.c | 16 ++-------------- include/fb_mmc.h | 5 ++--- include/fb_nand.h | 5 ++--- include/image-sparse.h | 2 +- 7 files changed, 16 insertions(+), 45 deletions(-) diff --git a/common/fb_mmc.c b/common/fb_mmc.c index e3abcc8..9e53adb 100644 --- a/common/fb_mmc.c +++ b/common/fb_mmc.c @@ -97,9 +97,8 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info, fastboot_okay(response_str, ""); } -void fb_mmc_flash_write(const char *cmd, unsigned int session_id, - void *download_buffer, unsigned int download_bytes, - char *response) +void fb_mmc_flash_write(const char *cmd, void *download_buffer, + unsigned int download_bytes, char *response) { struct blk_desc *dev_desc; disk_partition_t info; @@ -153,8 +152,7 @@ void fb_mmc_flash_write(const char *cmd, unsigned int session_id, printf("Flashing sparse image at offset " LBAFU "\n", info.start); - store_sparse_image(&sparse, &sparse_priv, session_id, - download_buffer); + store_sparse_image(&sparse, &sparse_priv, download_buffer); } else { write_raw_image(dev_desc, &info, cmd, download_buffer, download_bytes); diff --git a/common/fb_nand.c b/common/fb_nand.c index 9ca8602..896ed6d 100644 --- a/common/fb_nand.c +++ b/common/fb_nand.c @@ -126,7 +126,7 @@ static int fb_nand_sparse_write(struct sparse_storage *storage, return written / storage->block_sz; } -void fb_nand_flash_write(const char *partname, unsigned int session_id, +void fb_nand_flash_write(const char *partname, void *download_buffer, unsigned int download_bytes, char *response) { @@ -161,7 +161,7 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id, sparse.name = part->name; sparse.write = fb_nand_sparse_write; - ret = store_sparse_image(&sparse, &sparse_priv, session_id, + ret = store_sparse_image(&sparse, &sparse_priv, download_buffer); } else { printf("Flashing raw image at offset 0x%llx\n", diff --git a/common/image-sparse.c b/common/image-sparse.c index 2bf737b..893c68b 100644 --- a/common/image-sparse.c +++ b/common/image-sparse.c @@ -52,8 +52,6 @@ typedef struct sparse_buffer { u16 type; } sparse_buffer_t; -static uint32_t last_offset; - static unsigned int sparse_get_chunk_data_size(sparse_header_t *sparse, chunk_header_t *chunk) { @@ -267,8 +265,8 @@ static void sparse_put_data_buffer(sparse_buffer_t *buffer) free(buffer); } -int store_sparse_image(sparse_storage_t *storage, void *storage_priv, - unsigned int session_id, void *data) +int store_sparse_image(sparse_storage_t *storage, + void *storage_priv, void *data) { unsigned int chunk, offset; sparse_header_t *sparse_header; @@ -303,19 +301,10 @@ int store_sparse_image(sparse_storage_t *storage, void *storage_priv, return -EINVAL; } - /* - * If it's a new flashing session, start at the beginning of - * the partition. If not, then simply resume where we were. - */ - if (session_id > 0) - start = last_offset; - else - start = storage->start; - - printf("Flashing sparse image on partition %s at offset 0x%x (ID: %d)\n", - storage->name, start * storage->block_sz, session_id); + puts("Flashing Sparse Image\n"); /* Start processing chunks */ + start = storage->start; for (chunk = 0; chunk < sparse_header->total_chunks; chunk++) { uint32_t blkcnt; @@ -390,7 +379,5 @@ int store_sparse_image(sparse_storage_t *storage, void *storage_priv, return -EIO; } - last_offset = start + total_blocks; - return 0; } diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 28b244a..ddf989c 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -59,7 +59,6 @@ static inline struct f_fastboot *func_to_fastboot(struct usb_function *f) } static struct f_fastboot *fastboot_func; -static unsigned int fastboot_flash_session_id; static unsigned int download_size; static unsigned int download_bytes; @@ -424,15 +423,6 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) sprintf(str_num, "0x%08x", CONFIG_FASTBOOT_BUF_SIZE); strncat(response, str_num, chars_left); - - /* - * This also indicates the start of a new flashing - * "session", in which we could have 1-N buffers to - * write to a partition. - * - * Reset our session counter. - */ - fastboot_flash_session_id = 0; } else if (!strcmp_l1("serialno", cmd)) { s = getenv("serial#"); if (s) @@ -600,16 +590,14 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) strcpy(response, "FAILno flash device defined"); #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV - fb_mmc_flash_write(cmd, fastboot_flash_session_id, - (void *)CONFIG_FASTBOOT_BUF_ADDR, + fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, download_bytes, response); #endif #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV - fb_nand_flash_write(cmd, fastboot_flash_session_id, + fb_nand_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, download_bytes, response); #endif - fastboot_flash_session_id++; fastboot_tx_write_str(response); } #endif diff --git a/include/fb_mmc.h b/include/fb_mmc.h index 978a139..402ba9b 100644 --- a/include/fb_mmc.h +++ b/include/fb_mmc.h @@ -4,7 +4,6 @@ * SPDX-License-Identifier: GPL-2.0+ */ -void fb_mmc_flash_write(const char *cmd, unsigned int session_id, - void *download_buffer, unsigned int download_bytes, - char *response); +void fb_mmc_flash_write(const char *cmd, void *download_buffer, + unsigned int download_bytes, char *response); void fb_mmc_erase(const char *cmd, char *response); diff --git a/include/fb_nand.h b/include/fb_nand.h index 80ddef5..88bdf36 100644 --- a/include/fb_nand.h +++ b/include/fb_nand.h @@ -5,7 +5,6 @@ * SPDX-License-Identifier: GPL-2.0+ */ -void fb_nand_flash_write(const char *cmd, unsigned int session_id, - void *download_buffer, unsigned int download_bytes, - char *response); +void fb_nand_flash_write(const char *cmd, void *download_buffer, + unsigned int download_bytes, char *response); void fb_nand_erase(const char *cmd, char *response); diff --git a/include/image-sparse.h b/include/image-sparse.h index 0382f5b..a2b0694 100644 --- a/include/image-sparse.h +++ b/include/image-sparse.h @@ -32,4 +32,4 @@ static inline int is_sparse_image(void *buf) } int store_sparse_image(sparse_storage_t *storage, void *storage_priv, - unsigned int session_id, void *data); + void *data);