]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fastboot: add command to select the default emmc hwpart for boot
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Wed, 27 Jan 2021 13:46:48 +0000 (14:46 +0100)
committerMarek Vasut <marex@denx.de>
Sun, 7 Feb 2021 18:22:55 +0000 (19:22 +0100)
Add fastboot command oem partconf which executes the command
``mmc partconf <id> <arg> 0`` on the current <id> mmc device
to configure the eMMC boot partition with
<arg>: boot_ack boot_partition, so the command is:

$> fastboot oem partconf:<boot_ack> <boot_partition>

The partition_access argument is forced to 0 (userdata)

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
[lukma - Kconfig adjustments after merging this patch]

doc/android/fastboot.rst
drivers/fastboot/Kconfig
drivers/fastboot/fb_command.c
include/fastboot.h

index 2877c3cbaaae175fdcf266bd8d051f9670618340..d8cb64261cdcd7082ab6d2437118c939a6c28675 100644 (file)
@@ -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 <arg> 0`` to configure eMMC
+  with <arg> = boot_ack boot_partition
 
 Support for both eMMC and NAND devices is included.
 
index 8a92e750078fa1a979219a24fed041abca584b48..1bcc8d4ab9924e4c42c18493153153c12d60c12b 100644 (file)
@@ -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
index d3c578672dc6f60226255c7c040c1b9096637995..ae4a7dc7fb823eb3f86e7a6efb6e9417c8019851 100644 (file)
@@ -42,6 +42,9 @@ static void reboot_recovery(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;
@@ -99,6 +102,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
 };
 
 /**
@@ -374,3 +383,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
index b86b508e69fd95288067936642dd28e7b3a5449c..80dd8255aa2dd64b82c17030d4fc467d76d754d0 100644 (file)
@@ -38,6 +38,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
 };