summaryrefslogtreecommitdiff
path: root/drivers
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 /drivers
parenta5d1e04a532b1fccd9c4f0a1d4ed6410664a9424 (diff)
downloadu-boot-imx-6c9e00eebfd7244d74068832a1bb7f8679d1861a.zip
u-boot-imx-6c9e00eebfd7244d74068832a1bb7f8679d1861a.tar.gz
u-boot-imx-6c9e00eebfd7244d74068832a1bb7f8679d1861a.tar.bz2
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 'drivers')
-rw-r--r--drivers/usb/gadget/f_fastboot.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 05fb773..a70463d 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -51,6 +51,7 @@ 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;
static bool is_high_speed;
@@ -393,6 +394,15 @@ 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)
@@ -555,9 +565,11 @@ 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, (void *)CONFIG_FASTBOOT_BUF_ADDR,
+ fb_mmc_flash_write(cmd, fastboot_flash_session_id,
+ (void *)CONFIG_FASTBOOT_BUF_ADDR,
download_bytes, response);
#endif
+ fastboot_flash_session_id++;
fastboot_tx_write_str(response);
}
#endif