From mboxrd@z Thu Jan 1 00:00:00 1970 From: Patrick Delaunay Date: Wed, 9 Sep 2020 15:22:38 +0200 Subject: [PATCH 3/4] fastboot: add command to select the default emmc hwpart for boot In-Reply-To: <20200909152228.1.I4ae7c1ab59fed4861cde9322a8d12167c9d0187a@changeid> References: <20200909152228.1.I4ae7c1ab59fed4861cde9322a8d12167c9d0187a@changeid> Message-ID: <20200909152228.3.I54be34962a84794d7c1af363107e5194e81f21bf@changeid> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Add fastboot command oem partconf which executes the command ``mmc partconf 0`` on the current mmc device to configure the eMMC boot partition with : boot_ack boot_partition, so the command is: $> fastboot oem partconf: The partition_access argument is forced to 0 (userdata) Signed-off-by: Patrick Delaunay --- doc/android/fastboot.rst | 2 ++ drivers/fastboot/Kconfig | 7 +++++++ drivers/fastboot/fb_command.c | 36 +++++++++++++++++++++++++++++++++++ include/fastboot.h | 3 +++ 4 files changed, 48 insertions(+) diff --git a/doc/android/fastboot.rst b/doc/android/fastboot.rst index de3f6c37d7..7d69372753 100644 --- a/doc/android/fastboot.rst +++ b/doc/android/fastboot.rst @@ -23,6 +23,8 @@ The current implementation supports the following standard commands: The following OEM commands are supported (if enabled): - ``oem format`` - this executes ``gpt write mmc %x $partitions`` +- ``oem partconf`` - this executes ``mmc partconf %x 0`` to configure eMMC + with = boot_ack boot_partition Support for both eMMC and NAND devices is included. diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 8a92e75007..1bcc8d4ab9 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -189,6 +189,13 @@ config FASTBOOT_CMD_OEM_FORMAT relies on the env variable partitions to contain the list of partitions as required by the gpt command. +config FASTBOOT_CMD_OEM_PARTCONF + bool "Enable the 'oem partconf' command" + depends on FASTBOOT_FLASH_MMC && SUPPORT_EMMC_BOOT + help + Add support for the "oem partconf" command from a client. This set + the mmc boot-partition for the selecting eMMC device. + endif # FASTBOOT endmenu diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index 49f6a61c37..e42c018348 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -40,6 +40,9 @@ static void reboot_bootloader(char *, char *); #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT) static void oem_format(char *, char *); #endif +#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF) +static void oem_partconf(char *, char *); +#endif static const struct { const char *command; @@ -89,6 +92,12 @@ static const struct { .dispatch = oem_format, }, #endif +#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF) + [FASTBOOT_COMMAND_OEM_PARTCONF] = { + .command = "oem partconf", + .dispatch = oem_partconf, + }, +#endif }; /** @@ -336,3 +345,30 @@ static void oem_format(char *cmd_parameter, char *response) } } #endif + +#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF) +/** + * oem_partconf() - Execute the OEM partconf command + * + * @cmd_parameter: Pointer to command parameter + * @response: Pointer to fastboot response buffer + */ +static void oem_partconf(char *cmd_parameter, char *response) +{ + char cmdbuf[32]; + + if (!cmd_parameter) { + fastboot_fail("Expected command parameter", response); + return; + } + + /* execute 'mmc partconfg' command with cmd_parameter arguments*/ + snprintf(cmdbuf, sizeof(cmdbuf), "mmc partconf %x %s 0", + CONFIG_FASTBOOT_FLASH_MMC_DEV, cmd_parameter); + printf("Execute: %s\n", cmdbuf); + if (run_command(cmdbuf, 0)) + fastboot_fail("Cannot set oem partconf", response); + else + fastboot_okay(NULL, response); +} +#endif diff --git a/include/fastboot.h b/include/fastboot.h index 1933b1d98e..3e68852e9a 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -36,6 +36,9 @@ enum { #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT) FASTBOOT_COMMAND_OEM_FORMAT, #endif +#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF) + FASTBOOT_COMMAND_OEM_PARTCONF, +#endif FASTBOOT_COMMAND_COUNT }; -- 2.17.1