]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
usb/gadget: fastboot: add support for flash command
authorSteve Rae <srae@broadcom.com>
Tue, 26 Aug 2014 18:47:28 +0000 (11:47 -0700)
committerTom Rini <trini@ti.com>
Wed, 24 Sep 2014 22:30:27 +0000 (18:30 -0400)
- implement 'fastboot flash' for eMMC devices

Signed-off-by: Steve Rae <srae@broadcom.com>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Reviewed-by: Marek Vasut <marex@denx.de>
README
doc/README.android-fastboot
drivers/usb/gadget/f_fastboot.c

diff --git a/README b/README
index 70dd97d64d8ef1bb253c5dac7525b2b892f6ada2..766e9e0ebd88f05741ea6cf34657ace277dd75d6 100644 (file)
--- a/README
+++ b/README
@@ -1629,6 +1629,16 @@ The following options need to be configured:
                downloads. This buffer should be as large as possible for a
                platform. Define this to the size available RAM for fastboot.
 
+               CONFIG_FASTBOOT_FLASH
+               The fastboot protocol includes a "flash" command for writing
+               the downloaded image to a non-volatile storage device. Define
+               this to enable the "fastboot flash" command.
+
+               CONFIG_FASTBOOT_FLASH_MMC_DEV
+               The fastboot "flash" command requires additional information
+               regarding the non-volatile storage device. Define this to
+               the eMMC device that fastboot should use to store the image.
+
 - Journaling Flash filesystem support:
                CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE,
                CONFIG_JFFS2_NAND_DEV
index 404572729a722346795b65f62627a168c4e3f0aa..167760968ff56e5ede39c7395cc4cffbc9f01d7e 100644 (file)
@@ -6,8 +6,9 @@ Overview
 The protocol that is used over USB is described in
 README.android-fastboot-protocol in same directory.
 
-The current implementation does not yet support the flash and erase
-commands.
+The current implementation does not yet support the erase command or the
+"oem format" command, and there is minimal support for the flash command;
+it only supports eMMC devices.
 
 Client installation
 ===================
index 7a1acb9df02be0d47a7fd492eaa1004d9c45232a..e2659faf627c463ad3bc77001ed7eb12135b70a8 100644 (file)
@@ -19,6 +19,9 @@
 #include <linux/compiler.h>
 #include <version.h>
 #include <g_dnl.h>
+#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+#include <fb_mmc.h>
+#endif
 
 #define FASTBOOT_VERSION               "0.4"
 
@@ -469,6 +472,28 @@ static void cb_boot(struct usb_ep *ep, struct usb_request *req)
        fastboot_tx_write_str("OKAY");
 }
 
+#ifdef CONFIG_FASTBOOT_FLASH
+static void cb_flash(struct usb_ep *ep, struct usb_request *req)
+{
+       char *cmd = req->buf;
+       char response[RESPONSE_LEN];
+
+       strsep(&cmd, ":");
+       if (!cmd) {
+               printf("%s: missing partition name\n", __func__);
+               fastboot_tx_write_str("FAILmissing partition name");
+               return;
+       }
+
+       strcpy(response, "FAILno flash device defined");
+#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+       fb_mmc_flash_write(cmd, (void *)CONFIG_USB_FASTBOOT_BUF_ADDR,
+                          download_bytes, response);
+#endif
+       fastboot_tx_write_str(response);
+}
+#endif
+
 struct cmd_dispatch_info {
        char *cmd;
        void (*cb)(struct usb_ep *ep, struct usb_request *req);
@@ -488,6 +513,12 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = {
                .cmd = "boot",
                .cb = cb_boot,
        },
+#ifdef CONFIG_FASTBOOT_FLASH
+       {
+               .cmd = "flash",
+               .cb = cb_flash,
+       },
+#endif
 };
 
 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)