]> git.sur5r.net Git - u-boot/commitdiff
fastboot: sparse: remove session-id logic
authorSteve Rae <srae@broadcom.com>
Tue, 7 Jun 2016 18:19:35 +0000 (11:19 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 27 Jun 2016 20:36:33 +0000 (16:36 -0400)
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 <srae@broadcom.com>
common/fb_mmc.c
common/fb_nand.c
common/image-sparse.c
drivers/usb/gadget/f_fastboot.c
include/fb_mmc.h
include/fb_nand.h
include/image-sparse.h

index e3abcc85beea94dd26d5ee0a2cb51fd8616e7542..9e53adba5ed973c528674a2bfc42ed538ba6c5e0 100644 (file)
@@ -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);
index ae34f4891b6e9fc55d78e42d8687af7586be780b..a0a9839db51812f8aa122ce6b2972e8b3d359940 100644 (file)
@@ -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",
index 2bf737b46c27b4d3c53bfb83468eecf6e0cd1d30..893c68b35f7bd4fd0ba63c5572540308b68f8309 100644 (file)
@@ -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;
 }
index 28b244a8d002c1c6d15c8372477dd755e0e35abe..ddf989c21584cac91b6a91705beb2d69bc3ba74a 100644 (file)
@@ -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
index 978a1395a185a31b5be5646f6d3042b8ac3d22fa..402ba9b1b47079864a6d97d1863435380b84ae52 100644 (file)
@@ -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);
index 80ddef5656a86a10ab1819c3c1527065a7ff6f99..88bdf3690de9820d6a31f58001c55e0f4df73aaf 100644 (file)
@@ -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);
index 0382f5bd2639fecd498b7a2635ed5035381ee58d..a2b0694190d99ed8235f98c622a581e589f347e3 100644 (file)
@@ -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);