]> git.sur5r.net Git - u-boot/commitdiff
fastboot: Add support for 'oem format' command
authorAlex Kiernan <alex.kiernan@gmail.com>
Tue, 29 May 2018 15:30:54 +0000 (15:30 +0000)
committerMarek Vasut <marex@denx.de>
Wed, 30 May 2018 09:59:21 +0000 (11:59 +0200)
Introduce 'oem format' which matches the USB implementation, guard this
with CONFIG_FASTBOOT_CMD_OEM_FORMAT so that you can configure it out.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/fastboot/Kconfig
drivers/fastboot/fb_command.c
include/fastboot.h

index 625f01660030c8d4ac7cea2ba638df9db1df886a..bc25ea1d9c7ac8452c2a2b894d91e90dff23be13 100644 (file)
@@ -124,6 +124,14 @@ config FASTBOOT_MBR_NAME
          specified on the "fastboot flash" command line matches the value
          defined here. The default target name for updating MBR is "mbr".
 
+config FASTBOOT_CMD_OEM_FORMAT
+       bool "Enable the 'oem format' command"
+       depends on FASTBOOT_FLASH_MMC && CMD_GPT
+       help
+         Add support for the "oem format" command from a client. This
+         relies on the env variable partitions to contain the list of
+         partitions as required by the gpt command.
+
 endif # FASTBOOT
 
 endmenu
index af4f50069433713a251bc4dc17f8063681480b28..200f9910c5666af794c3a3156ac97aaae15df417 100644 (file)
@@ -34,6 +34,9 @@ static void flash(char *, char *);
 static void erase(char *, char *);
 #endif
 static void reboot_bootloader(char *, char *);
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+static void oem_format(char *, char *);
+#endif
 
 static const struct {
        const char *command;
@@ -77,6 +80,12 @@ static const struct {
                .command = "set_active",
                .dispatch = okay
        },
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+       [FASTBOOT_COMMAND_OEM_FORMAT] = {
+               .command = "oem format",
+               .dispatch = oem_format,
+       },
+#endif
 };
 
 /**
@@ -300,3 +309,27 @@ static void reboot_bootloader(char *cmd_parameter, char *response)
        else
                fastboot_okay(NULL, response);
 }
+
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+/**
+ * oem_format() - Execute the OEM format command
+ *
+ * @cmd_parameter: Pointer to command parameter
+ * @response: Pointer to fastboot response buffer
+ */
+static void oem_format(char *cmd_parameter, char *response)
+{
+       char cmdbuf[32];
+
+       if (!env_get("partitions")) {
+               fastboot_fail("partitions not set", response);
+       } else {
+               sprintf(cmdbuf, "gpt write mmc %x $partitions",
+                       CONFIG_FASTBOOT_FLASH_MMC_DEV);
+               if (run_command(cmdbuf, 0))
+                       fastboot_fail("", response);
+               else
+                       fastboot_okay(NULL, response);
+       }
+}
+#endif
index 9a3d5ba693b936964df93195982e965fbd6e9e78..1933b1d98e3bb9a03832f37b5efb616cb6ec952b 100644 (file)
@@ -33,6 +33,9 @@ enum {
        FASTBOOT_COMMAND_REBOOT,
        FASTBOOT_COMMAND_REBOOT_BOOTLOADER,
        FASTBOOT_COMMAND_SET_ACTIVE,
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
+       FASTBOOT_COMMAND_OEM_FORMAT,
+#endif
 
        FASTBOOT_COMMAND_COUNT
 };