summaryrefslogtreecommitdiffstats
path: root/common/fb_mmc.c
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2015-10-15 14:34:15 +0200
committerTom Rini <trini@konsulko.com>2015-11-12 13:17:32 -0500
commit6c9e00eebfd7244d74068832a1bb7f8679d1861a (patch)
tree0bd9d87445bddbcd877d34f6672c5d0825fc2c52 /common/fb_mmc.c
parenta5d1e04a532b1fccd9c4f0a1d4ed6410664a9424 (diff)
downloadblackbird-obmc-uboot-6c9e00eebfd7244d74068832a1bb7f8679d1861a.tar.gz
blackbird-obmc-uboot-6c9e00eebfd7244d74068832a1bb7f8679d1861a.zip
fastboot: Implement flashing session counter
The fastboot flash command that writes an image to a partition works in several steps: 1 - Retrieve the maximum size the device can download through the "max-download-size" variable 2 - Retrieve the partition type through the "partition-type:%s" variable, that indicates whether or not the partition needs to be erased (even though the fastboot client has minimal support for that) 3a - If the image is smaller than what the device can handle, send the image and flash it. 3b - If the image is larger than what the device can handle, create a sparse image, and split it in several chunks that would fit. Send the chunk, flash it, repeat until we have no more data to send. However, in the 3b case, the subsequent transfers have no particular identifiers, the protocol just assumes that you would resume the writes where you left it. While doing so works well, it also means that flashing two subsequent images on the same partition (for example because the user made a mistake) would not work withouth flashing another partition or rebooting the board, which is not really intuitive. Since we have always the same pattern, we can however maintain a counter that will be reset every time the client will retrieve max-download-size, and incremented after each buffer will be flashed, that will allow us to tell whether we should simply resume the flashing where we were, or start back at the beginning of the partition. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'common/fb_mmc.c')
-rw-r--r--common/fb_mmc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index c9f2ed6b58..c6989668ae 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -96,8 +96,9 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,
fastboot_okay(response_str, "");
}
-void fb_mmc_flash_write(const char *cmd, void *download_buffer,
- unsigned int download_bytes, char *response)
+void fb_mmc_flash_write(const char *cmd, unsigned int session_id,
+ void *download_buffer, unsigned int download_bytes,
+ char *response)
{
block_dev_desc_t *dev_desc;
disk_partition_t info;
@@ -151,7 +152,8 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
printf("Flashing sparse image at offset " LBAFU "\n",
info.start);
- store_sparse_image(&sparse, &sparse_priv, download_buffer);
+ store_sparse_image(&sparse, &sparse_priv, session_id,
+ download_buffer);
} else {
write_raw_image(dev_desc, &info, cmd, download_buffer,
download_bytes);
OpenPOWER on IntegriCloud