Skip to contentSkip to conversation

fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT

PATCH New Patrick Delaunay 2 participants 7 messages Jan 27, 2021 – Feb 1, 2021 Arm MediaTek

lore
Share & tools
lore
#0 lore raw

v2 cover fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT

Hi,

It is a rebased V2 version of the serie [1].

This serie adds a lot of new #if and doesn't respect the last U-Boot coding rules with 14 warnings detected by checkpatch:

warning: Use 'if (IS_ENABLED(CONFIG...))'
instead of '#if or #ifdef' where possible

But I chose to copy the existing code of the fastboot files fb_command.c to a have an easier review.

So I prefer sent a patch (if it is required) to remove all the #ifdef in this file when the serie will be accepted.

I check compilation of the added features on stm32mp1 platform with the serie [2].

The compilation for modified boards (with already activated config CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT) is verified with buildman:

tools/buildman/buildman mt8512_bm1_emmc mt8518_ap1_emmc pumpkin Building current source for 3 boards (3 threads, 4 jobs per thread)
aarch64: w+ pumpkin
+===================== WARNING ====================== +This board does not use CONFIG_DM_ETH (Driver Model +for Ethernet drivers). Please update the board to use +CONFIG_DM_ETH before the v2020.07 release. Failure to +update by the deadline may result in board removal. +See doc/driver-model/migration.rst for more info.

+====================================================
   aarch64:  w+   mt8518_ap1_emmc
+===================== WARNING ======================

+This board does not use CONFIG_DM_ETH (Driver Model +for Ethernet drivers). Please update the board to use +CONFIG_DM_ETH before the v2020.07 release. Failure to +update by the deadline may result in board removal. +See doc/driver-model/migration.rst for more info.

+====================================================
   aarch64:  w+   mt8512_bm1_emmc
+===================== WARNING ======================

+This board does not use CONFIG_DM_ETH (Driver Model +for Ethernet drivers). Please update the board to use +CONFIG_DM_ETH before the v2020.07 release. Failure to +update by the deadline may result in board removal. +See doc/driver-model/migration.rst for more info.

+====================================================
    0    3    0 /3              0:00:07  : mt8512_bm1_emmc

Completed: 3 total built, duration 0:00:23, rate 0.13

[1] "fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT"

    http://patchwork.ozlabs.org/project/uboot/list/?series=200509&state=*

[2] "configs: stm32mp1: enable fastboot support of eMMC boot partition"

    http://patchwork.ozlabs.org/project/uboot/list/?series=200510

Regards

Patrick

Changes in v2:
- rebase on master branch
- new impact on pumpkin_defconfig and mt8512_bm1_emmc_defconfig
- new impact on pumpkin_defconfig and mt8512_bm1_emmc_defconfig

Patrick Delaunay (4):
fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT
fastboot: mmc: extend flash/erase for both emmc hwpart 1 and 2
fastboot: add command to select the default emmc hwpart for boot
fastboot: add command to select the eMMC boot configuration

 configs/mt8512_bm1_emmc_defconfig |  3 +-
 configs/mt8518_ap1_emmc_defconfig |  3 +-
 configs/pumpkin_defconfig         |  3 +-
 doc/android/fastboot.rst          |  3 ++
 drivers/fastboot/Kconfig          | 62 ++++++++++++++++++++------
 drivers/fastboot/fb_command.c     | 72 +++++++++++++++++++++++++++++++
 drivers/fastboot/fb_mmc.c         | 52 ++++++++++++++--------
 include/fastboot.h                |  6 +++
 8 files changed, 171 insertions(+), 33 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/4 fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT

Split userdata and boot partition support for eMMC update and correct the description (update is supported).

The new configuration CONFIG_FASTBOOT_MMC_USER_SUPPORT allows to activate support of userdata partition update, based on target name=CONFIG_FASTBOOT_MMC_USER_NAME

This patch also removes the unnecessary dependency with ARCH_MEDIATEK and EFI_PARTITION.

---

Changes in v2:
- rebase on master branch
- new impact on pumpkin_defconfig and mt8512_bm1_emmc_defconfig

 configs/mt8512_bm1_emmc_defconfig |  1 +
 configs/mt8518_ap1_emmc_defconfig |  1 +
 configs/pumpkin_defconfig         |  1 +
 drivers/fastboot/Kconfig          | 22 +++++++++++++++++-----
 drivers/fastboot/fb_mmc.c         |  9 ++++++---
 5 files changed, 26 insertions(+), 8 deletions(-)
configs/mt8512_bm1_emmc_defconfig +1 -0
index c6b3ee484b..1bda45c5d2 100644
@@ -29,6 +29,7 @@ CONFIG_FASTBOOT_BUF_SIZE=0x1e00000
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
+CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_HS200_SUPPORT=y
 CONFIG_MMC_MTK=y
configs/mt8518_ap1_emmc_defconfig +1 -0
index b95d2c683a..d5fb0ccd48 100644
@@ -25,6 +25,7 @@ CONFIG_FASTBOOT_BUF_SIZE=0x1E00000
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
+CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_HS200_SUPPORT=y
 CONFIG_MMC_MTK=y
configs/pumpkin_defconfig +1 -0
index cd77889eea..a9655f5abb 100644
@@ -53,6 +53,7 @@ CONFIG_FASTBOOT_BUF_SIZE=0x4000000
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
+CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
 # CONFIG_INPUT is not set
 CONFIG_DM_MMC=y
 # CONFIG_MMC_QUIRKS is not set
drivers/fastboot/Kconfig +17 -5
index 4352ba67a7..cb8425685f 100644
@@ -124,14 +124,26 @@ config FASTBOOT_MMC_BOOT1_NAME
 	  defined here.
 	  The default target name for updating EMMC_BOOT1 is "mmc0boot0".
 
+config FASTBOOT_MMC_USER_SUPPORT
+	bool "Enable eMMC userdata partition flash/erase"
+	depends on FASTBOOT_FLASH_MMC
+	help
+	  Define this to enable the support "flash" and "erase" command on
+	  eMMC userdata. The "flash" command only update the MBR and GPT
+	  header when CONFIG_EFI_PARTITION is supported.
+	  The "erase" command erase all the userdata.
+	  This occurs when the specified "partition name" on the
+	  fastboot command line matches the value CONFIG_FASTBOOT_MMC_USER_NAME.
+
 config FASTBOOT_MMC_USER_NAME
-	string "Target name for erasing EMMC_USER"
-	depends on FASTBOOT_FLASH_MMC && EFI_PARTITION && ARCH_MEDIATEK
+	string "Target name for updating EMMC_USER"
+	depends on FASTBOOT_MMC_USER_SUPPORT
 	default "mmc0"
 	help
-	  The fastboot "erase" command supports erasing EMMC_USER. This occurs
-	  when the specified "EMMC_USER name" on the "fastboot erase" commands
-	  match the value defined here.
+	  The fastboot "flash" and "erase" command supports EMMC_USER.
+	  This occurs when the specified "EMMC_USER name" on the
+	  "fastboot flash" and the "fastboot erase" commands match the value
+	  defined here.
 	  The default target name for erasing EMMC_USER is "mmc0".
 
 config FASTBOOT_GPT_NAME
drivers/fastboot/fb_mmc.c +6 -3
index 4e26cef941..b5d4c90bfc 100644
@@ -174,7 +174,8 @@ static void write_raw_image(struct blk_desc *dev_desc,
 	fastboot_okay(NULL, response);
 }
 
-#ifdef CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT
+#if defined(CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT) || \
+	defined(CONFIG_FASTBOOT_MMC_USER_SUPPORT)
 static int fb_mmc_erase_mmc_hwpart(struct blk_desc *dev_desc)
 {
 	lbaint_t blks;
@@ -193,7 +194,9 @@ static int fb_mmc_erase_mmc_hwpart(struct blk_desc *dev_desc)
 
 	return 0;
 }
+#endif
 
+#ifdef CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT
 static void fb_mmc_boot1_ops(struct blk_desc *dev_desc, void *buffer,
 			     u32 buff_sz, char *response)
 {
@@ -473,7 +476,7 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
 #endif
 
 #if CONFIG_IS_ENABLED(EFI_PARTITION)
-#ifndef CONFIG_FASTBOOT_MMC_USER_NAME
+#ifndef CONFIG_FASTBOOT_MMC_USER_SUPPORT
 	if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0) {
 #else
 	if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0 ||
@@ -603,7 +606,7 @@ void fastboot_mmc_erase(const char *cmd, char *response)
 	}
 #endif
 
-#ifdef CONFIG_FASTBOOT_MMC_USER_NAME
+#ifdef CONFIG_FASTBOOT_MMC_USER_SUPPORT
 	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) {
 		/* erase EMMC userdata */
 		if (fb_mmc_erase_mmc_hwpart(dev_desc))
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/4 fastboot: mmc: extend flash/erase for both emmc hwpart 1 and 2

In reply to Patrick Delaunay

Update the code and the configs for eMMC boot and userdata partitions acces
- FASTBOOT_MMC_BOOT_SUPPORT: boot partition 1 and 2 (erase/write)
- FASTBOOT_MMC_BOOT1_NAME: boot partition 1, default name="mmc0boot0"
- FASTBOOT_MMC_BOOT2_NAME: boot partition 2, default name="mmc0boot1"

This patch also removes the unnecessary dependency with ARCH_MEDIATEK and EFI_PARTITION.

---

Changes in v2:
- new impact on pumpkin_defconfig and mt8512_bm1_emmc_defconfig

 configs/mt8512_bm1_emmc_defconfig |  2 +-
 configs/mt8518_ap1_emmc_defconfig |  2 +-
 configs/pumpkin_defconfig         |  2 +-
 drivers/fastboot/Kconfig          | 26 ++++++++++++-----
 drivers/fastboot/fb_mmc.c         | 47 ++++++++++++++++++++-----------
 5 files changed, 52 insertions(+), 27 deletions(-)
configs/mt8512_bm1_emmc_defconfig +1 -1
index 1bda45c5d2..d8e0e86c10 100644
@@ -28,7 +28,7 @@ CONFIG_FASTBOOT_BUF_ADDR=0x56000000
 CONFIG_FASTBOOT_BUF_SIZE=0x1e00000
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
-CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
+CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y
 CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_HS200_SUPPORT=y
configs/mt8518_ap1_emmc_defconfig +1 -1
index d5fb0ccd48..2c760c1591 100644
@@ -24,7 +24,7 @@ CONFIG_FASTBOOT_BUF_ADDR=0x56000000
 CONFIG_FASTBOOT_BUF_SIZE=0x1E00000
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
-CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
+CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y
 CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_HS200_SUPPORT=y
configs/pumpkin_defconfig +1 -1
index a9655f5abb..5270ec28cb 100644
@@ -52,7 +52,7 @@ CONFIG_FASTBOOT_BUF_ADDR=0x4d000000
 CONFIG_FASTBOOT_BUF_SIZE=0x4000000
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
-CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
+CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y
 CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
 # CONFIG_INPUT is not set
 CONFIG_DM_MMC=y
drivers/fastboot/Kconfig +19 -7
index cb8425685f..ef57290876 100644
@@ -104,18 +104,19 @@ config FASTBOOT_FLASH_NAND_TRIMFFS
 	  When flashing NAND enable the DROP_FFS flag to drop trailing all-0xff
 	  pages.
 
-config FASTBOOT_MMC_BOOT1_SUPPORT
-	bool "Enable EMMC_BOOT1 flash/erase"
-	depends on FASTBOOT_FLASH_MMC && EFI_PARTITION && ARCH_MEDIATEK
+config FASTBOOT_MMC_BOOT_SUPPORT
+	bool "Enable EMMC_BOOT flash/erase"
+	depends on FASTBOOT_FLASH_MMC
 	help
 	  The fastboot "flash" and "erase" commands normally does operations
-	  on EMMC userdata. Define this to enable the special commands to
-	  flash/erase EMMC_BOOT1.
-	  The default target name for updating EMMC_BOOT1 is "mmc0boot0".
+	  on eMMC userdata. Define this to enable the special commands to
+	  flash/erase eMMC boot partition.
+	  The default target name for updating eMMC boot partition 1/2 is
+	  CONFIG_FASTBOOT_MMC_BOOT1_NAME/CONFIG_FASTBOOT_MMC_BOOT2_NAME.
 
 config FASTBOOT_MMC_BOOT1_NAME
 	string "Target name for updating EMMC_BOOT1"
-	depends on FASTBOOT_MMC_BOOT1_SUPPORT
+	depends on FASTBOOT_MMC_BOOT_SUPPORT
 	default "mmc0boot0"
 	help
 	  The fastboot "flash" and "erase" commands support operations on
@@ -124,6 +125,17 @@ config FASTBOOT_MMC_BOOT1_NAME
 	  defined here.
 	  The default target name for updating EMMC_BOOT1 is "mmc0boot0".
 
+config FASTBOOT_MMC_BOOT2_NAME
+	string "Target name for updating EMMC_BOOT2"
+	depends on FASTBOOT_MMC_BOOT_SUPPORT
+	default "mmc0boot1"
+	help
+	  The fastboot "flash" and "erase" commands support operations on
+	  EMMC_BOOT2. This occurs when the specified "EMMC_BOOT2 name" on
+	  the "fastboot flash" and "fastboot erase" commands match the value
+	  defined here.
+	  The default target name for updating EMMC_BOOT2 is "mmc0boot1".
+
 config FASTBOOT_MMC_USER_SUPPORT
 	bool "Enable eMMC userdata partition flash/erase"
 	depends on FASTBOOT_FLASH_MMC
drivers/fastboot/fb_mmc.c +30 -17

94 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

PATCH v2 3/4 fastboot: add command to select the default emmc hwpart for boot

In reply to Patrick Delaunay

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)

---

(no changes since v1)

 doc/android/fastboot.rst      |  2 ++
 drivers/fastboot/Kconfig      |  7 +++++++
 drivers/fastboot/fb_command.c | 36 +++++++++++++++++++++++++++++++++++
 include/fastboot.h            |  3 +++
 4 files changed, 48 insertions(+)
doc/android/fastboot.rst +2 -0
index 2877c3cbaa..d8cb64261c 100644
@@ -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.
 
drivers/fastboot/Kconfig +7 -0
index ef57290876..9bd5597253 100644
@@ -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.
+
 config FASTBOOT_USE_BCB_SET_REBOOT_FLAG
 	bool "Use BCB by fastboot to set boot reason"
 	depends on CMD_BCB && !ARCH_MESON && !ARCH_ROCKCHIP && !TARGET_KC1 && \
drivers/fastboot/fb_command.c +36 -0
index d3c578672d..ae4a7dc7fb 100644
@@ -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
include/fastboot.h +3 -0
index 8e9ee80907..86559d1595 100644
@@ -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
 };
Signature · 1 line
2.17.1
#4 lore raw

PATCH v2 4/4 fastboot: add command to select the eMMC boot configuration

In reply to Patrick Delaunay

Add command oem bootbus which executes the command ``mmc bootbus <id> <arg>`` on the current fastboot mmc device (<i> = CONFIG_FASTBOOT_FLASH_MMC_DEV) to set the eMMC boot configuration on first update, with
<arg> = boot_bus_width reset_boot_bus_width boot_mode

$> fastboot oem bootbus:<boot_bus_width> <reset_boot_bus_width> <boot_mode>

---

(no changes since v1)

 doc/android/fastboot.rst      |  1 +
 drivers/fastboot/Kconfig      |  7 +++++++
 drivers/fastboot/fb_command.c | 36 +++++++++++++++++++++++++++++++++++
 include/fastboot.h            |  3 +++
 4 files changed, 47 insertions(+)
doc/android/fastboot.rst +1 -0
index d8cb64261c..16b11399b3 100644
@@ -25,6 +25,7 @@ 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
+- ``oem bootbus``  - this executes ``mmc bootbus %x %s`` to configure eMMC
 
 Support for both eMMC and NAND devices is included.
 
drivers/fastboot/Kconfig +7 -0
index 9bd5597253..5f2e109759 100644
@@ -196,6 +196,13 @@ config FASTBOOT_CMD_OEM_PARTCONF
 	  Add support for the "oem partconf" command from a client. This set
 	  the mmc boot-partition for the selecting eMMC device.
 
+config FASTBOOT_CMD_OEM_BOOTBUS
+	bool "Enable the 'oem bootbus' command"
+	depends on FASTBOOT_FLASH_MMC && SUPPORT_EMMC_BOOT
+	help
+	  Add support for the "oem bootbus" command from a client. This set
+	  the mmc boot configuration for the selecting eMMC device.
+
 config FASTBOOT_USE_BCB_SET_REBOOT_FLAG
 	bool "Use BCB by fastboot to set boot reason"
 	depends on CMD_BCB && !ARCH_MESON && !ARCH_ROCKCHIP && !TARGET_KC1 && \
drivers/fastboot/fb_command.c +36 -0
index ae4a7dc7fb..41fc8d7904 100644
@@ -45,6 +45,9 @@ static void oem_format(char *, char *);
 #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF)
 static void oem_partconf(char *, char *);
 #endif
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
+static void oem_bootbus(char *, char *);
+#endif
 
 static const struct {
 	const char *command;
@@ -108,6 +111,12 @@ static const struct {
 		.dispatch = oem_partconf,
 	},
 #endif
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
+	[FASTBOOT_COMMAND_OEM_BOOTBUS] = {
+		.command = "oem bootbus",
+		.dispatch = oem_bootbus,
+	},
+#endif
 };
 
 /**
@@ -410,3 +419,30 @@ static void oem_partconf(char *cmd_parameter, char *response)
 		fastboot_okay(NULL, response);
 }
 #endif
+
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
+/**
+ * oem_bootbus() - Execute the OEM bootbus command
+ *
+ * @cmd_parameter: Pointer to command parameter
+ * @response: Pointer to fastboot response buffer
+ */
+static void oem_bootbus(char *cmd_parameter, char *response)
+{
+	char cmdbuf[32];
+
+	if (!cmd_parameter) {
+		fastboot_fail("Expected command parameter", response);
+		return;
+	}
+
+	/* execute 'mmc bootbus' command with cmd_parameter arguments*/
+	snprintf(cmdbuf, sizeof(cmdbuf), "mmc bootbus %x %s",
+		 CONFIG_FASTBOOT_FLASH_MMC_DEV, cmd_parameter);
+	printf("Execute: %s\n", cmdbuf);
+	if (run_command(cmdbuf, 0))
+		fastboot_fail("Cannot set oem bootbus", response);
+	else
+		fastboot_okay(NULL, response);
+}
+#endif
include/fastboot.h +3 -0
index 86559d1595..3df7e6b81f 100644
@@ -41,6 +41,9 @@ enum {
 #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF)
 	FASTBOOT_COMMAND_OEM_PARTCONF,
 #endif
+#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
+	FASTBOOT_COMMAND_OEM_BOOTBUS,
+#endif
 
 	FASTBOOT_COMMAND_COUNT
 };
Signature · 1 line
2.17.1
#5 lore raw

v2 cover fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT

In reply to Patrick Delaunay

Hi Patrick,

I believe that the first two patches in this series can be replicated with [1]. For example, if you currently use FASTBOOT_MMC_BOOT_SUPPORT with FASTBOOT_MMC_BOOT1_NAME set to "mmc0boot1", leading to commands like

$ fastboot erase mmc0boot1

You could instead do

$ fastboot erase 0.1:0

And the first behavior could be emulated by setting the environmental variable "fastboot_partition_alias_mmc0boot1" to "0.1:0".

I would like to work towards deprecating Kconfigs for achieving this particular use case. This is because everything is set at compile-time, but we have existing tools which make this easy to do at run-time. Favoring run-time configuration makes it easier to use one U-Boot for different boards, and also makes it easier for users to modify U-Boot.

For the latter two patches, I think there are two existing solutions. First, there is the patch to add "ucmd" support to fastboot. This allows running arbitrary commands on the U-Boot side. However, this may be unsuitable for systems which need to maintain a chain of trust (since allowing arbitrary commands would allow arbitrary software to run).

With this in mind, FIT images allow for script sections. For example, one could create an image tree source file like

/dts-v1/;

/ {
	description = "Configuration script";
	#address-cells = <1>;

	images {
		default = "script-1";
		script-1 {
			data = /incbin/("mmc.scr");
			type = "script";
			compression = "none";
			signature {
				algo = "sha1,rsa2048";
				key-name-hint = "dev";
			};
		};
	};
};

(or something similar; I haven't tested this). This would create a fit with containing "mmc.scr". On the U-Boot side, running

fastboot 0
source

Would source any script contained within the FIT image (if it was downloaded e.g. with "fastboot boot mmc.itb". I think this process would work well for "run once" scripts like setting the mmc boot partitions.

Please let me know if any of the above suggestions would achieve the functionality you need.

--Sean

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=223198
[2] https://patchwork.ozlabs.org/project/uboot/patch/20210111101919.228555-1-hs at denx.de/

Quoted 84 lines · Patrick Delaunay

Hi,

It is a rebased V2 version of the serie [1].

This serie adds a lot of new #if and doesn't respect the last U-Boot coding rules with 14 warnings detected by checkpatch:

warning: Use 'if (IS_ENABLED(CONFIG...))'
instead of '#if or #ifdef' where possible

But I chose to copy the existing code of the fastboot files fb_command.c to a have an easier review.

So I prefer sent a patch (if it is required) to remove all the #ifdef in this file when the serie will be accepted.

I check compilation of the added features on stm32mp1 platform with the serie [2].

The compilation for modified boards (with already activated config CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT) is verified with buildman:

tools/buildman/buildman mt8512_bm1_emmc mt8518_ap1_emmc pumpkin Building current source for 3 boards (3 threads, 4 jobs per thread)
aarch64: w+ pumpkin
+===================== WARNING ======================

(quoted diff) +20 -0
+This board does not use CONFIG_DM_ETH (Driver Model
+for Ethernet drivers). Please update the board to use
+CONFIG_DM_ETH before the v2020.07 release. Failure to
+update by the deadline may result in board removal.
+See doc/driver-model/migration.rst for more info.
+====================================================
    aarch64:  w+   mt8518_ap1_emmc
+===================== WARNING ======================
+This board does not use CONFIG_DM_ETH (Driver Model
+for Ethernet drivers). Please update the board to use
+CONFIG_DM_ETH before the v2020.07 release. Failure to
+update by the deadline may result in board removal.
+See doc/driver-model/migration.rst for more info.
+====================================================
    aarch64:  w+   mt8512_bm1_emmc
+===================== WARNING ======================
+This board does not use CONFIG_DM_ETH (Driver Model
+for Ethernet drivers). Please update the board to use
+CONFIG_DM_ETH before the v2020.07 release. Failure to
+update by the deadline may result in board removal.
+See doc/driver-model/migration.rst for more info.
+====================================================
     0    3    0 /3              0:00:07  : mt8512_bm1_emmc

Completed: 3 total built, duration 0:00:23, rate 0.13

[1] "fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT"

     http://patchwork.ozlabs.org/project/uboot/list/?series=200509&state=*

[2] "configs: stm32mp1: enable fastboot support of eMMC boot partition"

     http://patchwork.ozlabs.org/project/uboot/list/?series=200510

Regards

Patrick

Changes in v2:
- rebase on master branch
- new impact on pumpkin_defconfig and mt8512_bm1_emmc_defconfig
- new impact on pumpkin_defconfig and mt8512_bm1_emmc_defconfig

Patrick Delaunay (4):
fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT
fastboot: mmc: extend flash/erase for both emmc hwpart 1 and 2
fastboot: add command to select the default emmc hwpart for boot
fastboot: add command to select the eMMC boot configuration

  configs/mt8512_bm1_emmc_defconfig |  3 +-
  configs/mt8518_ap1_emmc_defconfig |  3 +-
  configs/pumpkin_defconfig         |  3 +-
  doc/android/fastboot.rst          |  3 ++
  drivers/fastboot/Kconfig          | 62 ++++++++++++++++++++------
  drivers/fastboot/fb_command.c     | 72 +++++++++++++++++++++++++++++++
  drivers/fastboot/fb_mmc.c         | 52 ++++++++++++++--------
  include/fastboot.h                |  6 +++
  8 files changed, 171 insertions(+), 33 deletions(-)
#6 lore raw

v2 cover fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT

Looks like I didn't CC people properly...

Quoted 155 lines · Sean Anderson

Hi Patrick,

I believe that the first two patches in this series can be replicated with [1]. For example, if you currently use FASTBOOT_MMC_BOOT_SUPPORT with FASTBOOT_MMC_BOOT1_NAME set to "mmc0boot1", leading to commands like

$ fastboot erase mmc0boot1

You could instead do

$ fastboot erase 0.1:0

And the first behavior could be emulated by setting the environmental variable "fastboot_partition_alias_mmc0boot1" to "0.1:0".

I would like to work towards deprecating Kconfigs for achieving this particular use case. This is because everything is set at compile-time, but we have existing tools which make this easy to do at run-time. Favoring run-time configuration makes it easier to use one U-Boot for different boards, and also makes it easier for users to modify U-Boot.

For the latter two patches, I think there are two existing solutions. First, there is the patch to add "ucmd" support to fastboot. This allows running arbitrary commands on the U-Boot side. However, this may be unsuitable for systems which need to maintain a chain of trust (since allowing arbitrary commands would allow arbitrary software to run).

With this in mind, FIT images allow for script sections. For example, one could create an image tree source file like

/dts-v1/;

/ {
????description = "Configuration script";
????#address-cells = <1>;

????images {
??????? default = "script-1";
??????? script-1 {
??????????? data = /incbin/("mmc.scr");
??????????? type = "script";
??????????? compression = "none";
??????????? signature {
??????????????? algo = "sha1,rsa2048";
??????????????? key-name-hint = "dev";
??????????? };
??????? };
????};
};

(or something similar; I haven't tested this). This would create a fit with containing "mmc.scr". On the U-Boot side, running

fastboot 0
source

Would source any script contained within the FIT image (if it was downloaded e.g. with "fastboot boot mmc.itb". I think this process would work well for "run once" scripts like setting the mmc boot partitions.

Please let me know if any of the above suggestions would achieve the functionality you need.

--Sean

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=223198
[2] https://patchwork.ozlabs.org/project/uboot/patch/20210111101919.228555-1-hs at denx.de/

Quoted 84 lines · Patrick Delaunay

Hi,

It is a rebased V2 version of the serie [1].

This serie adds a lot of new #if and doesn't respect the last U-Boot coding rules with 14 warnings detected by checkpatch:

?? warning: Use 'if (IS_ENABLED(CONFIG...))' ??????????? instead of '#if or #ifdef' where possible

But I chose to copy the existing code of the fastboot files fb_command.c to a have an easier review.

So I prefer sent a patch (if it is required) to remove all the #ifdef in this file when the serie will be accepted.

I check compilation of the added features on stm32mp1 platform with the serie [2].

The compilation for modified boards (with already activated config CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT) is verified with buildman:

tools/buildman/buildman mt8512_bm1_emmc mt8518_ap1_emmc pumpkin Building current source for 3 boards (3 threads, 4 jobs per thread) ??? aarch64:? w+?? pumpkin
+===================== WARNING ======================

(quoted diff) +6 -0
+This board does not use CONFIG_DM_ETH (Driver Model
+for Ethernet drivers). Please update the board to use
+CONFIG_DM_ETH before the v2020.07 release. Failure to
+update by the deadline may result in board removal.
+See doc/driver-model/migration.rst for more info.
+====================================================

??? aarch64:? w+?? mt8518_ap1_emmc +===================== WARNING ======================

(quoted diff) +6 -0
+This board does not use CONFIG_DM_ETH (Driver Model
+for Ethernet drivers). Please update the board to use
+CONFIG_DM_ETH before the v2020.07 release. Failure to
+update by the deadline may result in board removal.
+See doc/driver-model/migration.rst for more info.
+====================================================

??? aarch64:? w+?? mt8512_bm1_emmc +===================== WARNING ======================

(quoted diff) +6 -0
+This board does not use CONFIG_DM_ETH (Driver Model
+for Ethernet drivers). Please update the board to use
+CONFIG_DM_ETH before the v2020.07 release. Failure to
+update by the deadline may result in board removal.
+See doc/driver-model/migration.rst for more info.
+====================================================

???? 0??? 3??? 0 /3????????????? 0:00:07? : mt8512_bm1_emmc
Completed: 3 total built, duration 0:00:23, rate 0.13

[1] "fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT"
???? http://patchwork.ozlabs.org/project/uboot/list/?series=200509&state=*

[2] "configs: stm32mp1: enable fastboot support of eMMC boot partition" ???? http://patchwork.ozlabs.org/project/uboot/list/?series=200510

Regards

Patrick

Changes in v2:
- rebase on master branch
- new impact on pumpkin_defconfig and mt8512_bm1_emmc_defconfig
- new impact on pumpkin_defconfig and mt8512_bm1_emmc_defconfig

Patrick Delaunay (4):
?? fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT ?? fastboot: mmc: extend flash/erase for both emmc hwpart 1 and 2 ?? fastboot: add command to select the default emmc hwpart for boot ?? fastboot: add command to select the eMMC boot configuration

? configs/mt8512_bm1_emmc_defconfig |? 3 +-
? configs/mt8518_ap1_emmc_defconfig |? 3 +-
? configs/pumpkin_defconfig???????? |? 3 +-
? doc/android/fastboot.rst????????? |? 3 ++
? drivers/fastboot/Kconfig????????? | 62 ++++++++++++++++++++------
? drivers/fastboot/fb_command.c???? | 72 +++++++++++++++++++++++++++++++
? drivers/fastboot/fb_mmc.c???????? | 52 ++++++++++++++--------
? include/fastboot.h??????????????? |? 6 +++

? 8 files changed, 171 insertions(+), 33 deletions(-)