diff options
author | Alex Kiernan <alex.kiernan@gmail.com> | 2018-05-29 18:30:54 +0300 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2018-05-30 12:59:21 +0300 |
commit | 3845b9065fea9859bf2cd6413168e3cb4ba38f06 (patch) | |
tree | 74a36e23ceb23a2ca1a46d4c57b84ef4028f7faf /drivers/fastboot/fb_command.c | |
parent | f73a7df984a9820d9beb829b32ccb5c3d55dc152 (diff) | |
download | u-boot-3845b9065fea9859bf2cd6413168e3cb4ba38f06.tar.xz |
fastboot: Add support for 'oem format' command
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>
Diffstat (limited to 'drivers/fastboot/fb_command.c')
-rw-r--r-- | drivers/fastboot/fb_command.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index af4f500694..200f9910c5 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -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 |