diff options
author | Steve Rae | 2016-06-07 13:19:35 -0500 |
---|---|---|
committer | Praneeth Bajjuri | 2017-08-09 15:22:19 -0500 |
commit | bc5c71b22f13419206edfe67754b90a1ca388081 (patch) | |
tree | 610d557143328ac2d7126733b9d0e19d904a4604 | |
parent | 0b457c33bd99c22c0d0f0f0b84e9b6c320e42e68 (diff) | |
download | u-boot-bc5c71b22f13419206edfe67754b90a1ca388081.tar.gz u-boot-bc5c71b22f13419206edfe67754b90a1ca388081.tar.xz u-boot-bc5c71b22f13419206edfe67754b90a1ca388081.zip |
fastboot: sparse: remove session-id logic
commit 64ece84854ae49f40e9b9d4d88502247774f9d2f upstream.
This "session-id" alogrithm is not required, and currently corrupts
the stored image whenever more the one "session" is required.
Conflicts:
common/fb_mmc.c
Change-Id: Icd660c17515e885a00a4cf1d48acab1d84e688f7
Signed-off-by: Steve Rae <srae@broadcom.com>
Signed-off-by: Vishal Mahaveer <vishalm@ti.com>
-rw-r--r-- | common/fb_mmc.c | 16 | ||||
-rw-r--r-- | common/fb_nand.c | 4 | ||||
-rw-r--r-- | common/image-sparse.c | 21 | ||||
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 16 | ||||
-rw-r--r-- | include/fb_mmc.h | 5 | ||||
-rw-r--r-- | include/fb_nand.h | 5 | ||||
-rw-r--r-- | include/image-sparse.h | 2 |
7 files changed, 16 insertions, 53 deletions
diff --git a/common/fb_mmc.c b/common/fb_mmc.c index 8e2b92ce96..9e53adba5e 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, | |||
97 | fastboot_okay(response_str, ""); | 97 | fastboot_okay(response_str, ""); |
98 | } | 98 | } |
99 | 99 | ||
100 | void fb_mmc_flash_write(const char *cmd, unsigned int session_id, | 100 | void fb_mmc_flash_write(const char *cmd, void *download_buffer, |
101 | void *download_buffer, unsigned int download_bytes, | 101 | unsigned int download_bytes, char *response) |
102 | char *response) | ||
103 | { | 102 | { |
104 | struct blk_desc *dev_desc; | 103 | struct blk_desc *dev_desc; |
105 | disk_partition_t info; | 104 | disk_partition_t info; |
@@ -141,7 +140,6 @@ void fb_mmc_flash_write(const char *cmd, unsigned int session_id, | |||
141 | if (is_sparse_image(download_buffer)) { | 140 | if (is_sparse_image(download_buffer)) { |
142 | struct fb_mmc_sparse sparse_priv; | 141 | struct fb_mmc_sparse sparse_priv; |
143 | sparse_storage_t sparse; | 142 | sparse_storage_t sparse; |
144 | int ret; | ||
145 | 143 | ||
146 | sparse_priv.dev_desc = dev_desc; | 144 | sparse_priv.dev_desc = dev_desc; |
147 | 145 | ||
@@ -154,15 +152,7 @@ void fb_mmc_flash_write(const char *cmd, unsigned int session_id, | |||
154 | printf("Flashing sparse image at offset " LBAFU "\n", | 152 | printf("Flashing sparse image at offset " LBAFU "\n", |
155 | info.start); | 153 | info.start); |
156 | 154 | ||
157 | ret = store_sparse_image(&sparse, &sparse_priv, session_id, | 155 | store_sparse_image(&sparse, &sparse_priv, download_buffer); |
158 | download_buffer); | ||
159 | if (ret) { | ||
160 | printf("%s: writing sparse image failed: %d\n", | ||
161 | __func__, ret); | ||
162 | fastboot_fail(response_str, | ||
163 | "writing sparse image failed"); | ||
164 | return; | ||
165 | } | ||
166 | } else { | 156 | } else { |
167 | write_raw_image(dev_desc, &info, cmd, download_buffer, | 157 | write_raw_image(dev_desc, &info, cmd, download_buffer, |
168 | download_bytes); | 158 | download_bytes); |
diff --git a/common/fb_nand.c b/common/fb_nand.c index 9ca8602a73..896ed6df6c 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, | |||
126 | return written / storage->block_sz; | 126 | return written / storage->block_sz; |
127 | } | 127 | } |
128 | 128 | ||
129 | void fb_nand_flash_write(const char *partname, unsigned int session_id, | 129 | void fb_nand_flash_write(const char *partname, |
130 | void *download_buffer, unsigned int download_bytes, | 130 | void *download_buffer, unsigned int download_bytes, |
131 | char *response) | 131 | char *response) |
132 | { | 132 | { |
@@ -161,7 +161,7 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id, | |||
161 | sparse.name = part->name; | 161 | sparse.name = part->name; |
162 | sparse.write = fb_nand_sparse_write; | 162 | sparse.write = fb_nand_sparse_write; |
163 | 163 | ||
164 | ret = store_sparse_image(&sparse, &sparse_priv, session_id, | 164 | ret = store_sparse_image(&sparse, &sparse_priv, |
165 | download_buffer); | 165 | download_buffer); |
166 | } else { | 166 | } else { |
167 | printf("Flashing raw image at offset 0x%llx\n", | 167 | printf("Flashing raw image at offset 0x%llx\n", |
diff --git a/common/image-sparse.c b/common/image-sparse.c index 2bf737b46c..893c68b35f 100644 --- a/common/image-sparse.c +++ b/common/image-sparse.c | |||
@@ -52,8 +52,6 @@ typedef struct sparse_buffer { | |||
52 | u16 type; | 52 | u16 type; |
53 | } sparse_buffer_t; | 53 | } sparse_buffer_t; |
54 | 54 | ||
55 | static uint32_t last_offset; | ||
56 | |||
57 | static unsigned int sparse_get_chunk_data_size(sparse_header_t *sparse, | 55 | static unsigned int sparse_get_chunk_data_size(sparse_header_t *sparse, |
58 | chunk_header_t *chunk) | 56 | chunk_header_t *chunk) |
59 | { | 57 | { |
@@ -267,8 +265,8 @@ static void sparse_put_data_buffer(sparse_buffer_t *buffer) | |||
267 | free(buffer); | 265 | free(buffer); |
268 | } | 266 | } |
269 | 267 | ||
270 | int store_sparse_image(sparse_storage_t *storage, void *storage_priv, | 268 | int store_sparse_image(sparse_storage_t *storage, |
271 | unsigned int session_id, void *data) | 269 | void *storage_priv, void *data) |
272 | { | 270 | { |
273 | unsigned int chunk, offset; | 271 | unsigned int chunk, offset; |
274 | sparse_header_t *sparse_header; | 272 | sparse_header_t *sparse_header; |
@@ -303,19 +301,10 @@ int store_sparse_image(sparse_storage_t *storage, void *storage_priv, | |||
303 | return -EINVAL; | 301 | return -EINVAL; |
304 | } | 302 | } |
305 | 303 | ||
306 | /* | 304 | puts("Flashing Sparse Image\n"); |
307 | * If it's a new flashing session, start at the beginning of | ||
308 | * the partition. If not, then simply resume where we were. | ||
309 | */ | ||
310 | if (session_id > 0) | ||
311 | start = last_offset; | ||
312 | else | ||
313 | start = storage->start; | ||
314 | |||
315 | printf("Flashing sparse image on partition %s at offset 0x%x (ID: %d)\n", | ||
316 | storage->name, start * storage->block_sz, session_id); | ||
317 | 305 | ||
318 | /* Start processing chunks */ | 306 | /* Start processing chunks */ |
307 | start = storage->start; | ||
319 | for (chunk = 0; chunk < sparse_header->total_chunks; chunk++) { | 308 | for (chunk = 0; chunk < sparse_header->total_chunks; chunk++) { |
320 | uint32_t blkcnt; | 309 | uint32_t blkcnt; |
321 | 310 | ||
@@ -390,7 +379,5 @@ int store_sparse_image(sparse_storage_t *storage, void *storage_priv, | |||
390 | return -EIO; | 379 | return -EIO; |
391 | } | 380 | } |
392 | 381 | ||
393 | last_offset = start + total_blocks; | ||
394 | |||
395 | return 0; | 382 | return 0; |
396 | } | 383 | } |
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 1c9ecb7ecd..f6f3c3b326 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c | |||
@@ -61,7 +61,6 @@ static inline struct f_fastboot *func_to_fastboot(struct usb_function *f) | |||
61 | } | 61 | } |
62 | 62 | ||
63 | static struct f_fastboot *fastboot_func; | 63 | static struct f_fastboot *fastboot_func; |
64 | static unsigned int fastboot_flash_session_id; | ||
65 | static unsigned int download_size; | 64 | static unsigned int download_size; |
66 | static unsigned int download_bytes; | 65 | static unsigned int download_bytes; |
67 | static char f_cmdbuf[MAX_CMDS][32]; | 66 | static char f_cmdbuf[MAX_CMDS][32]; |
@@ -452,15 +451,6 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) | |||
452 | 451 | ||
453 | sprintf(str_num, "0x%08x", CONFIG_FASTBOOT_BUF_SIZE); | 452 | sprintf(str_num, "0x%08x", CONFIG_FASTBOOT_BUF_SIZE); |
454 | strncat(response, str_num, chars_left); | 453 | strncat(response, str_num, chars_left); |
455 | |||
456 | /* | ||
457 | * This also indicates the start of a new flashing | ||
458 | * "session", in which we could have 1-N buffers to | ||
459 | * write to a partition. | ||
460 | * | ||
461 | * Reset our session counter. | ||
462 | */ | ||
463 | fastboot_flash_session_id = 0; | ||
464 | } else if (!strcmp_l1("serialno", cmd)) { | 454 | } else if (!strcmp_l1("serialno", cmd)) { |
465 | s = getenv("serial#"); | 455 | s = getenv("serial#"); |
466 | if (s) | 456 | if (s) |
@@ -804,16 +794,14 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) | |||
804 | } | 794 | } |
805 | 795 | ||
806 | #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV | 796 | #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV |
807 | fb_mmc_flash_write(cmd, fastboot_flash_session_id, | 797 | fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR, |
808 | (void *)CONFIG_FASTBOOT_BUF_ADDR, | ||
809 | download_bytes, response); | 798 | download_bytes, response); |
810 | #endif | 799 | #endif |
811 | #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV | 800 | #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV |
812 | fb_nand_flash_write(cmd, fastboot_flash_session_id, | 801 | fb_nand_flash_write(cmd, |
813 | (void *)CONFIG_FASTBOOT_BUF_ADDR, | 802 | (void *)CONFIG_FASTBOOT_BUF_ADDR, |
814 | download_bytes, response); | 803 | download_bytes, response); |
815 | #endif | 804 | #endif |
816 | fastboot_flash_session_id++; | ||
817 | fastboot_tx_write_str(response); | 805 | fastboot_tx_write_str(response); |
818 | } | 806 | } |
819 | #endif | 807 | #endif |
diff --git a/include/fb_mmc.h b/include/fb_mmc.h index 978a1395a1..402ba9b1b4 100644 --- a/include/fb_mmc.h +++ b/include/fb_mmc.h | |||
@@ -4,7 +4,6 @@ | |||
4 | * SPDX-License-Identifier: GPL-2.0+ | 4 | * SPDX-License-Identifier: GPL-2.0+ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | void fb_mmc_flash_write(const char *cmd, unsigned int session_id, | 7 | void fb_mmc_flash_write(const char *cmd, void *download_buffer, |
8 | void *download_buffer, unsigned int download_bytes, | 8 | unsigned int download_bytes, char *response); |
9 | char *response); | ||
10 | void fb_mmc_erase(const char *cmd, char *response); | 9 | void fb_mmc_erase(const char *cmd, char *response); |
diff --git a/include/fb_nand.h b/include/fb_nand.h index 80ddef5656..88bdf3690d 100644 --- a/include/fb_nand.h +++ b/include/fb_nand.h | |||
@@ -5,7 +5,6 @@ | |||
5 | * SPDX-License-Identifier: GPL-2.0+ | 5 | * SPDX-License-Identifier: GPL-2.0+ |
6 | */ | 6 | */ |
7 | 7 | ||
8 | void fb_nand_flash_write(const char *cmd, unsigned int session_id, | 8 | void fb_nand_flash_write(const char *cmd, void *download_buffer, |
9 | void *download_buffer, unsigned int download_bytes, | 9 | unsigned int download_bytes, char *response); |
10 | char *response); | ||
11 | void fb_nand_erase(const char *cmd, char *response); | 10 | void fb_nand_erase(const char *cmd, char *response); |
diff --git a/include/image-sparse.h b/include/image-sparse.h index 0382f5bd26..a2b0694190 100644 --- a/include/image-sparse.h +++ b/include/image-sparse.h | |||
@@ -32,4 +32,4 @@ static inline int is_sparse_image(void *buf) | |||
32 | } | 32 | } |
33 | 33 | ||
34 | int store_sparse_image(sparse_storage_t *storage, void *storage_priv, | 34 | int store_sparse_image(sparse_storage_t *storage, void *storage_priv, |
35 | unsigned int session_id, void *data); | 35 | void *data); |