Commit 64ece84854ae49f40e9b9d4d88502247774f9d2f

Authored by Steve Rae
Committed by Tom Rini
1 parent ac6e5fed31

fastboot: sparse: remove session-id logic

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>

Showing 7 changed files with 16 additions and 45 deletions Side-by-side Diff

... ... @@ -97,9 +97,8 @@
97 97 fastboot_okay(response_str, "");
98 98 }
99 99  
100   -void fb_mmc_flash_write(const char *cmd, unsigned int session_id,
101   - void *download_buffer, unsigned int download_bytes,
102   - char *response)
  100 +void fb_mmc_flash_write(const char *cmd, void *download_buffer,
  101 + unsigned int download_bytes, char *response)
103 102 {
104 103 struct blk_desc *dev_desc;
105 104 disk_partition_t info;
... ... @@ -153,8 +152,7 @@
153 152 printf("Flashing sparse image at offset " LBAFU "\n",
154 153 info.start);
155 154  
156   - store_sparse_image(&sparse, &sparse_priv, session_id,
157   - download_buffer);
  155 + store_sparse_image(&sparse, &sparse_priv, download_buffer);
158 156 } else {
159 157 write_raw_image(dev_desc, &info, cmd, download_buffer,
160 158 download_bytes);
... ... @@ -126,7 +126,7 @@
126 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 130 void *download_buffer, unsigned int download_bytes,
131 131 char *response)
132 132 {
... ... @@ -161,7 +161,7 @@
161 161 sparse.name = part->name;
162 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 165 download_buffer);
166 166 } else {
167 167 printf("Flashing raw image at offset 0x%llx\n",
common/image-sparse.c
... ... @@ -52,8 +52,6 @@
52 52 u16 type;
53 53 } sparse_buffer_t;
54 54  
55   -static uint32_t last_offset;
56   -
57 55 static unsigned int sparse_get_chunk_data_size(sparse_header_t *sparse,
58 56 chunk_header_t *chunk)
59 57 {
... ... @@ -267,8 +265,8 @@
267 265 free(buffer);
268 266 }
269 267  
270   -int store_sparse_image(sparse_storage_t *storage, void *storage_priv,
271   - unsigned int session_id, void *data)
  268 +int store_sparse_image(sparse_storage_t *storage,
  269 + void *storage_priv, void *data)
272 270 {
273 271 unsigned int chunk, offset;
274 272 sparse_header_t *sparse_header;
275 273  
276 274  
... ... @@ -303,19 +301,10 @@
303 301 return -EINVAL;
304 302 }
305 303  
306   - /*
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;
  304 + puts("Flashing Sparse Image\n");
314 305  
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   -
318 306 /* Start processing chunks */
  307 + start = storage->start;
319 308 for (chunk = 0; chunk < sparse_header->total_chunks; chunk++) {
320 309 uint32_t blkcnt;
321 310  
... ... @@ -389,8 +378,6 @@
389 378 printf("sparse image write failure\n");
390 379 return -EIO;
391 380 }
392   -
393   - last_offset = start + total_blocks;
394 381  
395 382 return 0;
396 383 }
drivers/usb/gadget/f_fastboot.c
... ... @@ -59,7 +59,6 @@
59 59 }
60 60  
61 61 static struct f_fastboot *fastboot_func;
62   -static unsigned int fastboot_flash_session_id;
63 62 static unsigned int download_size;
64 63 static unsigned int download_bytes;
65 64  
... ... @@ -424,15 +423,6 @@
424 423  
425 424 sprintf(str_num, "0x%08x", CONFIG_FASTBOOT_BUF_SIZE);
426 425 strncat(response, str_num, chars_left);
427   -
428   - /*
429   - * This also indicates the start of a new flashing
430   - * "session", in which we could have 1-N buffers to
431   - * write to a partition.
432   - *
433   - * Reset our session counter.
434   - */
435   - fastboot_flash_session_id = 0;
436 426 } else if (!strcmp_l1("serialno", cmd)) {
437 427 s = getenv("serial#");
438 428 if (s)
439 429  
440 430  
... ... @@ -600,16 +590,14 @@
600 590  
601 591 strcpy(response, "FAILno flash device defined");
602 592 #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
603   - fb_mmc_flash_write(cmd, fastboot_flash_session_id,
604   - (void *)CONFIG_FASTBOOT_BUF_ADDR,
  593 + fb_mmc_flash_write(cmd, (void *)CONFIG_FASTBOOT_BUF_ADDR,
605 594 download_bytes, response);
606 595 #endif
607 596 #ifdef CONFIG_FASTBOOT_FLASH_NAND_DEV
608   - fb_nand_flash_write(cmd, fastboot_flash_session_id,
  597 + fb_nand_flash_write(cmd,
609 598 (void *)CONFIG_FASTBOOT_BUF_ADDR,
610 599 download_bytes, response);
611 600 #endif
612   - fastboot_flash_session_id++;
613 601 fastboot_tx_write_str(response);
614 602 }
615 603 #endif
... ... @@ -4,8 +4,7 @@
4 4 * SPDX-License-Identifier: GPL-2.0+
5 5 */
6 6  
7   -void fb_mmc_flash_write(const char *cmd, unsigned int session_id,
8   - void *download_buffer, unsigned int download_bytes,
9   - char *response);
  7 +void fb_mmc_flash_write(const char *cmd, void *download_buffer,
  8 + unsigned int download_bytes, char *response);
10 9 void fb_mmc_erase(const char *cmd, char *response);
... ... @@ -5,8 +5,7 @@
5 5 * SPDX-License-Identifier: GPL-2.0+
6 6 */
7 7  
8   -void fb_nand_flash_write(const char *cmd, unsigned int session_id,
9   - void *download_buffer, unsigned int download_bytes,
10   - char *response);
  8 +void fb_nand_flash_write(const char *cmd, void *download_buffer,
  9 + unsigned int download_bytes, char *response);
11 10 void fb_nand_erase(const char *cmd, char *response);
include/image-sparse.h
... ... @@ -32,5 +32,5 @@
32 32 }
33 33  
34 34 int store_sparse_image(sparse_storage_t *storage, void *storage_priv,
35   - unsigned int session_id, void *data);
  35 + void *data);