Skip to contentSkip to conversation

fastboot: Add better support for specifying partitions

PATCH Superseded Sean Anderson 3 participants 15 messages Feb 2, 2021 – Feb 8, 2021 MMC, SD and SDIO

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover fastboot: Add better support for specifying partitions

This series adds support for flashing eMMC boot partitions, and for flashing whole partitions. Specifically, it does this by using the existing U-Boot naming scheme to specify partitions, and not by adding new KConfig options.

I have added tests for partition naming, but not for the whole flash process (though that could be a future project). I have tested this on one board, but I have *not* tested the mt85-specific KConfigs. Hopefully this series can be a way to phase out those options.

Changes in v4:
- xxx_auto_alloc_size -> xxx_auto
- Fix missing closing brace
- Expand documentation, making it more man-page-like

Changes in v3:
- Rebase onto dfu/master

Changes in v2:
- Update documentation for part_get_info_by_dev_and_name
- Move partition documentation under doc/usage

Sean Anderson (9):
mmc: sandbox: Add support for writing
test: dm: Add test for fastboot mmc partition naming
part: Give several functions more useful return values
part: Support getting whole disk from
part_get_info_by_dev_and_name_or_num
part: Support string block devices in part_get_info_by_dev_and_name
fastboot: Remove mmcpart argument from raw_part_get_info_by_name
fastboot: Move part_get_info_by_name_or_alias after
raw_part_get_info_by_name
fastboot: Allow u-boot-style partitions
fastboot: Partition specification

 cmd/ab_select.c             |   3 +-
 configs/sandbox64_defconfig |   2 +
 configs/sandbox_defconfig   |   2 +
 disk/part.c                 |  90 +++++++++-------
 doc/android/fastboot.rst    |   4 +
 doc/usage/index.rst         |   1 +
 doc/usage/partitions.rst    |  80 ++++++++++++++
 drivers/fastboot/fb_mmc.c   | 210 +++++++++++++++++++++---------------
 drivers/mmc/sandbox_mmc.c   |  43 ++++++--
 include/part.h              |   6 +-
 test/dm/Makefile            |   3 +
 test/dm/fastboot.c          |  95 ++++++++++++++++
 test/dm/mmc.c               |  19 +++-
 13 files changed, 417 insertions(+), 141 deletions(-)
 create mode 100644 doc/usage/partitions.rst
 create mode 100644 test/dm/fastboot.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v4 1/9 mmc: sandbox: Add support for writing

This adds support writing to the sandbox mmc backed by an in-memory buffer. The unit test has been updated to test reading, writing, and erasing. I'm not sure what MMCs erase to; I picked 0, but if it's 0xFF then that can be easily changed.

---

Changes in v4:
- xxx_auto_alloc_size -> xxx_auto

 drivers/mmc/sandbox_mmc.c | 43 +++++++++++++++++++++++++++++++++------
 test/dm/mmc.c             | 19 ++++++++++++-----
 2 files changed, 51 insertions(+), 11 deletions(-)
drivers/mmc/sandbox_mmc.c +37 -6
index 8a2391d651..18ba020aac 100644
@@ -17,6 +17,17 @@ struct sandbox_mmc_plat {
 	struct mmc mmc;
 };
 
+#define MMC_CSIZE 0
+#define MMC_CMULT 8 /* 8 because the card is high-capacity */
+#define MMC_BL_LEN_SHIFT 10
+#define MMC_BL_LEN BIT(MMC_BL_LEN_SHIFT)
+#define MMC_CAPACITY (((MMC_CSIZE + 1) << (MMC_CMULT + 2)) \
+		      * MMC_BL_LEN) /* 1 MiB */
+
+struct sandbox_mmc_priv {
+	u8 buf[MMC_CAPACITY];
+};
+
 /**
  * sandbox_mmc_send_cmd() - Emulate SD commands
  *
@@ -26,6 +37,10 @@ struct sandbox_mmc_plat {
 static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
 				struct mmc_data *data)
 {
+	struct sandbox_mmc_priv *priv = dev_get_priv(dev);
+	struct mmc *mmc = mmc_get_mmc_dev(dev);
+	static ulong erase_start, erase_end;
+
 	switch (cmd->cmdidx) {
 	case MMC_CMD_ALL_SEND_CID:
 		memset(cmd->response, '\0', sizeof(cmd->response));
@@ -44,8 +59,9 @@ static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
 		break;
 	case MMC_CMD_SEND_CSD:
 		cmd->response[0] = 0;
-		cmd->response[1] = 10 << 16;	/* 1 << block_len */
-		cmd->response[2] = 0;
+		cmd->response[1] = (MMC_BL_LEN_SHIFT << 16) |
+				   ((MMC_CSIZE >> 16) & 0x3f);
+		cmd->response[2] = (MMC_CSIZE & 0xffff) << 16;
 		cmd->response[3] = 0;
 		break;
 	case SD_CMD_SWITCH_FUNC: {
@@ -59,13 +75,27 @@ static int sandbox_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
 		break;
 	}
 	case MMC_CMD_READ_SINGLE_BLOCK:
-		memset(data->dest, '\0', data->blocksize);
-		break;
 	case MMC_CMD_READ_MULTIPLE_BLOCK:
-		strcpy(data->dest, "this is a test");
+		memcpy(data->dest, &priv->buf[cmd->cmdarg * data->blocksize],
+		       data->blocks * data->blocksize);
+		break;
+	case MMC_CMD_WRITE_SINGLE_BLOCK:
+	case MMC_CMD_WRITE_MULTIPLE_BLOCK:
+		memcpy(&priv->buf[cmd->cmdarg * data->blocksize], data->src,
+		       data->blocks * data->blocksize);
 		break;
 	case MMC_CMD_STOP_TRANSMISSION:
 		break;
+	case SD_CMD_ERASE_WR_BLK_START:
+		erase_start = cmd->cmdarg;
+		break;
+	case SD_CMD_ERASE_WR_BLK_END:
+		erase_end = cmd->cmdarg;
+		break;
+	case MMC_CMD_ERASE:
+		memset(&priv->buf[erase_start * mmc->write_bl_len], '\0',
+		       (erase_end - erase_start + 1) * mmc->write_bl_len);
+		break;
 	case SD_CMD_APP_SEND_OP_COND:
 		cmd->response[0] = OCR_BUSY | OCR_HCS;
 		cmd->response[1] = 0;
@@ -148,5 +178,6 @@ U_BOOT_DRIVER(mmc_sandbox) = {
 	.bind		= sandbox_mmc_bind,
 	.unbind		= sandbox_mmc_unbind,
 	.probe		= sandbox_mmc_probe,
-	.plat_auto	= sizeof(struct sandbox_mmc_plat),
+	.priv_auto = sizeof(struct sandbox_mmc_priv),
+	.plat_auto = sizeof(struct sandbox_mmc_plat),
 };
test/dm/mmc.c +14 -5
index 4e5136c850..f744452ff2 100644
@@ -29,16 +29,25 @@ static int dm_test_mmc_blk(struct unit_test_state *uts)
 {
 	struct udevice *dev;
 	struct blk_desc *dev_desc;
-	char cmp[1024];
+	int i;
+	char write[1024], read[1024];
 
 	ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
 	ut_assertok(blk_get_device_by_str("mmc", "0", &dev_desc));
 
-	/* Read a few blocks and look for the string we expect */
+	/* Write a few blocks and verify that we get the same data back */
 	ut_asserteq(512, dev_desc->blksz);
-	memset(cmp, '\0', sizeof(cmp));
-	ut_asserteq(2, blk_dread(dev_desc, 0, 2, cmp));
-	ut_assertok(strcmp(cmp, "this is a test"));
+	for (i = 0; i < sizeof(write); i++)
+		write[i] = i;
+	ut_asserteq(2, blk_dwrite(dev_desc, 0, 2, write));
+	ut_asserteq(2, blk_dread(dev_desc, 0, 2, read));
+	ut_asserteq_mem(write, read, sizeof(write));
+
+	/* Now erase them */
+	memset(write, '\0', sizeof(write));
+	ut_asserteq(2, blk_derase(dev_desc, 0, 2));
+	ut_asserteq(2, blk_dread(dev_desc, 0, 2, read));
+	ut_asserteq_mem(write, read, sizeof(write));
 
 	return 0;
 }
Signature · 1 line
2.25.1
#2 lore raw

PATCH v4 2/9 test: dm: Add test for fastboot mmc partition naming

In reply to Sean Anderson

This test verifies the mapping between fastboot partitions and partitions as understood by U-Boot. It also tests the creation of GPT partitions, though that is not the primary goal.

---

(no changes since v1)

 configs/sandbox64_defconfig |  2 ++
 configs/sandbox_defconfig   |  2 ++
 test/dm/Makefile            |  3 ++
 test/dm/fastboot.c          | 64 +++++++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+)
 create mode 100644 test/dm/fastboot.c
configs/sandbox64_defconfig +2 -0
index 4e67819559..9fe07f0c38 100644
@@ -110,6 +110,8 @@ CONFIG_DM_DEMO=y
 CONFIG_DM_DEMO_SIMPLE=y
 CONFIG_DM_DEMO_SHAPE=y
 CONFIG_DFU_SF=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_GPIO_HOG=y
 CONFIG_DM_GPIO_LOOKUP_LABEL=y
 CONFIG_PM8916_GPIO=y
configs/sandbox_defconfig +2 -0
index 0c7674efc9..269288783f 100644
@@ -135,6 +135,8 @@ CONFIG_DFU_SF=y
 CONFIG_DMA=y
 CONFIG_DMA_CHANNELS=y
 CONFIG_SANDBOX_DMA=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_GPIO_HOG=y
 CONFIG_DM_GPIO_LOOKUP_LABEL=y
 CONFIG_PM8916_GPIO=y
test/dm/Makefile +3 -0
index 46e076ed09..be4385c709 100644
@@ -91,5 +91,8 @@ obj-$(CONFIG_SCMI_FIRMWARE) += scmi.o
 ifneq ($(CONFIG_PINMUX),)
 obj-$(CONFIG_PINCONF) += pinmux.o
 endif
+ifneq ($(CONFIG_EFI_PARTITION)$(CONFIG_FASTBOOT_FLASH_MMC),)
+obj-y += fastboot.o
+endif
 endif
 endif # !SPL
test/dm/fastboot.c new file +64 -0

64 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw

PATCH v4 3/9 part: Give several functions more useful return values

In reply to Sean Anderson

Several functions in disk/part.c just return -1 on error. This makes them return different errnos for different failures. This helps callers differentiate between failures, even if they cannot read stdout.

---

(no changes since v1)

 disk/part.c | 50 ++++++++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 22 deletions(-)
disk/part.c +28 -22
index b69fd345f3..5e354e256f 100644
@@ -354,7 +354,7 @@ int part_get_info(struct blk_desc *dev_desc, int part,
 	}
 #endif /* CONFIG_HAVE_BLOCK_DEVICE */
 
-	return -1;
+	return -ENOENT;
 }
 
 int part_get_info_whole_disk(struct blk_desc *dev_desc,
@@ -416,7 +416,7 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,
 	*dev_desc = get_dev_hwpart(ifname, dev, hwpart);
 	if (!(*dev_desc) || ((*dev_desc)->type == DEV_TYPE_UNKNOWN)) {
 		debug("** Bad device %s %s **\n", ifname, dev_hwpart_str);
-		dev = -ENOENT;
+		dev = -ENODEV;
 		goto cleanup;
 	}
 
@@ -440,7 +440,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 			     struct blk_desc **dev_desc,
 			     struct disk_partition *info, int allow_whole_dev)
 {
-	int ret = -1;
+	int ret;
 	const char *part_str;
 	char *dup_str = NULL;
 	const char *dev_str;
@@ -482,7 +482,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 	if (0 == strcmp(ifname, "ubi")) {
 		if (!ubifs_is_mounted()) {
 			printf("UBIFS not mounted, use ubifsmount to mount volume first!\n");
-			return -1;
+			return -EINVAL;
 		}
 
 		*dev_desc = NULL;
@@ -504,6 +504,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 	/* If still no dev_part_str, it's an error */
 	if (!dev_part_str) {
 		printf("** No device specified **\n");
+		ret = -ENODEV;
 		goto cleanup;
 	}
 
@@ -520,8 +521,10 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 
 	/* Look up the device */
 	dev = blk_get_device_by_str(ifname, dev_str, dev_desc);
-	if (dev < 0)
+	if (dev < 0) {
+		ret = dev;
 		goto cleanup;
+	}
 
 	/* Convert partition ID string to number */
 	if (!part_str || !*part_str) {
@@ -538,6 +541,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 		if (*ep || (part == 0 && !allow_whole_dev)) {
 			printf("** Bad partition specification %s %s **\n",
 			    ifname, dev_part_str);
+			ret = -ENOENT;
 			goto cleanup;
 		}
 	}
@@ -551,6 +555,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 		if (!(*dev_desc)->lba) {
 			printf("** Bad device size - %s %s **\n", ifname,
 			       dev_str);
+			ret = -EINVAL;
 			goto cleanup;
 		}
 
@@ -562,6 +567,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 		if ((part > 0) || (!allow_whole_dev)) {
 			printf("** No partition table - %s %s **\n", ifname,
 			       dev_str);
+			ret = -EPROTONOSUPPORT;
 			goto cleanup;
 		}
 
@@ -630,7 +636,6 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 				*info = tmpinfo;
 		} else {
 			printf("** No valid partitions found **\n");
-			ret = -1;
 			goto cleanup;
 		}
 	}
@@ -638,7 +643,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 		printf("** Invalid partition type \"%.32s\""
 			" (expect \"" BOOT_PART_TYPE "\")\n",
 			info->type);
-		ret  = -1;
+		ret  = -EINVAL;
 		goto cleanup;
 	}
 
@@ -674,7 +679,7 @@ int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
 		}
 	}
 
-	return -1;
+	return -ENOENT;
 }
 
 int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
@@ -704,7 +709,7 @@ static int part_get_info_by_dev_and_name(const char *dev_iface,
 {
 	char *ep;
 	const char *part_str;
-	int dev_num;
+	int dev_num, ret;
 
 	part_str = strchr(dev_part_str, '#');
 	if (!part_str || part_str == dev_part_str)
@@ -720,13 +725,12 @@ static int part_get_info_by_dev_and_name(const char *dev_iface,
 	*dev_desc = blk_get_dev(dev_iface, dev_num);
 	if (!*dev_desc) {
 		printf("Could not find %s %d\n", dev_iface, dev_num);
-		return -EINVAL;
+		return -ENODEV;
 	}
-	if (part_get_info_by_name(*dev_desc, part_str, part_info) < 0) {
+	ret = part_get_info_by_name(*dev_desc, part_str, part_info);
+	if (ret < 0)
 		printf("Could not find \"%s\" partition\n", part_str);
-		return -EINVAL;
-	}
-	return 0;
+	return ret;
 }
 
 int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
@@ -734,21 +738,23 @@ int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
 					 struct blk_desc **dev_desc,
 					 struct disk_partition *part_info)
 {
+	int ret;
+
 	/* Split the part_name if passed as "$dev_num#part_name". */
-	if (!part_get_info_by_dev_and_name(dev_iface, dev_part_str,
-					   dev_desc, part_info))
-		return 0;
+	ret = part_get_info_by_dev_and_name(dev_iface, dev_part_str,
+					    dev_desc, part_info);
+	if (ret >= 0)
+		return ret;
 	/*
 	 * Couldn't lookup by name, try looking up the partition description
 	 * directly.
 	 */
-	if (blk_get_device_part_str(dev_iface, dev_part_str,
-				    dev_desc, part_info, 1) < 0) {
+	ret = blk_get_device_part_str(dev_iface, dev_part_str,
+				      dev_desc, part_info, 1);
+	if (ret < 0)
 		printf("Couldn't find partition %s %s\n",
 		       dev_iface, dev_part_str);
-		return -EINVAL;
-	}
-	return 0;
+	return ret;
 }
 
 void part_set_generic_name(const struct blk_desc *dev_desc,
Signature · 1 line
2.25.1
#4 lore raw

PATCH v4 4/9 part: Support getting whole disk from part_get_info_by_dev_and_name_or_num

In reply to Sean Anderson

This adds an option to part_get_info_by_dev_and_name_or_num to allow callers to specify whether whole-disk partitions are fine.

---

(no changes since v1)

 cmd/ab_select.c | 3 ++-
 disk/part.c     | 5 +++--
 include/part.h  | 6 +++++-
 3 files changed, 10 insertions(+), 4 deletions(-)
cmd/ab_select.c +2 -1
index 6298fcfb60..3e46663d6e 100644
@@ -22,7 +22,8 @@ static int do_ab_select(struct cmd_tbl *cmdtp, int flag, int argc,
 
 	/* Lookup the "misc" partition from argv[2] and argv[3] */
 	if (part_get_info_by_dev_and_name_or_num(argv[2], argv[3],
-						 &dev_desc, &part_info) < 0) {
+						 &dev_desc, &part_info,
+						 false) < 0) {
 		return CMD_RET_FAILURE;
 	}
 
disk/part.c +3 -2
index 5e354e256f..39c6b00a59 100644
@@ -736,7 +736,8 @@ static int part_get_info_by_dev_and_name(const char *dev_iface,
 int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
 					 const char *dev_part_str,
 					 struct blk_desc **dev_desc,
-					 struct disk_partition *part_info)
+					 struct disk_partition *part_info,
+					 int allow_whole_dev)
 {
 	int ret;
 
@@ -750,7 +751,7 @@ int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
 	 * directly.
 	 */
 	ret = blk_get_device_part_str(dev_iface, dev_part_str,
-				      dev_desc, part_info, 1);
+				      dev_desc, part_info, allow_whole_dev);
 	if (ret < 0)
 		printf("Couldn't find partition %s %s\n",
 		       dev_iface, dev_part_str);
include/part.h +5 -1
index 815515aa80..7f78271a98 100644
@@ -227,12 +227,16 @@ int part_get_info_by_name(struct blk_desc *dev_desc,
  * @param[in] dev_part_str Input partition description, like "0#misc" or "0:1"
  * @param[out] dev_desc	Place to store the device description pointer
  * @param[out] part_info Place to store the partition information
+ * @param[in] allow_whole_dev true to allow the user to select partition 0
+ *		(which means the whole device), false to require a valid
+ *		partition number >= 1
  * @return 0 on success, or a negative on error
  */
 int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
 					 const char *dev_part_str,
 					 struct blk_desc **dev_desc,
-					 struct disk_partition *part_info);
+					 struct disk_partition *part_info,
+					 int allow_whole_dev);
 
 /**
  * part_set_generic_name() - create generic partition like hda1 or sdb2
Signature · 1 line
2.25.1
#5 lore raw

PATCH v4 5/9 part: Support string block devices in part_get_info_by_dev_and_name

In reply to Sean Anderson

This adds support for things like "#partname" and "0.1#partname". The block device parsing is done like in blk_get_device_part_str.

---

(no changes since v2)

Changes in v2:
- Update Documentation

 disk/part.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)
disk/part.c +22 -19
index 39c6b00a59..aaeafbb0b2 100644
@@ -692,12 +692,13 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
  * Get partition info from device number and partition name.
  *
  * Parse a device number and partition name string in the form of
- * "device_num#partition_name", for example "0#misc". If the partition
- * is found, sets dev_desc and part_info accordingly with the information
- * of the partition with the given partition_name.
+ * "devicenum.hwpartnum#partition_name", for example "0.1#misc". devicenum and
+ * hwpartnum are both optional, defaulting to 0. If the partition is found,
+ * sets dev_desc and part_info accordingly with the information of the
+ * partition with the given partition_name.
  *
  * @param[in] dev_iface Device interface
- * @param[in] dev_part_str Input string argument, like "0#misc"
+ * @param[in] dev_part_str Input string argument, like "0.1#misc"
  * @param[out] dev_desc Place to store the device description pointer
  * @param[out] part_info Place to store the partition information
  * @return 0 on success, or a negative on error
@@ -707,29 +708,31 @@ static int part_get_info_by_dev_and_name(const char *dev_iface,
 					 struct blk_desc **dev_desc,
 					 struct disk_partition *part_info)
 {
-	char *ep;
-	const char *part_str;
-	int dev_num, ret;
+	char *dup_str = NULL;
+	const char *dev_str, *part_str;
+	int ret;
 
+	/* Separate device and partition name specification */
 	part_str = strchr(dev_part_str, '#');
-	if (!part_str || part_str == dev_part_str)
-		return -EINVAL;
-
-	dev_num = simple_strtoul(dev_part_str, &ep, 16);
-	if (ep != part_str) {
-		/* Not all the first part before the # was parsed. */
+	if (part_str) {
+		dup_str = strdup(dev_part_str);
+		dup_str[part_str - dev_part_str] = 0;
+		dev_str = dup_str;
+		part_str++;
+	} else {
 		return -EINVAL;
 	}
-	part_str++;
 
-	*dev_desc = blk_get_dev(dev_iface, dev_num);
-	if (!*dev_desc) {
-		printf("Could not find %s %d\n", dev_iface, dev_num);
-		return -ENODEV;
-	}
+	ret = blk_get_device_by_str(dev_iface, dev_str, dev_desc);
+	if (ret)
+		goto cleanup;
+
 	ret = part_get_info_by_name(*dev_desc, part_str, part_info);
 	if (ret < 0)
 		printf("Could not find \"%s\" partition\n", part_str);
+
+cleanup:
+	free(dup_str);
 	return ret;
 }
 
Signature · 1 line
2.25.1
#6 lore raw

PATCH v4 6/9 fastboot: Remove mmcpart argument from raw_part_get_info_by_name

In reply to Sean Anderson

The only thing mmcpart was used for was to pass to blk_dselect_hwpart. This calls blk_dselect_hwpart directly from raw_part_get_info_by_name. The error handling is dropped, but it is reintroduced in the next commit (albeit less specificly).

---

(no changes since v1)

 drivers/fastboot/fb_mmc.c | 41 +++++++++++++++++----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)
drivers/fastboot/fb_mmc.c +18 -23
index 50532acb84..75347bb99b 100644
@@ -51,7 +51,8 @@ static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
 }
 
 static int raw_part_get_info_by_name(struct blk_desc *dev_desc,
-		const char *name, struct disk_partition *info, int *mmcpart)
+				     const char *name,
+				     struct disk_partition *info)
 {
 	/* strlen("fastboot_raw_partition_") + PART_NAME_LEN + 1 */
 	char env_desc_name[23 + PART_NAME_LEN + 1];
@@ -85,8 +86,13 @@ static int raw_part_get_info_by_name(struct blk_desc *dev_desc,
 	strncpy((char *)info->name, name, PART_NAME_LEN);
 
 	if (raw_part_desc) {
-		if (strcmp(strsep(&raw_part_desc, " "), "mmcpart") == 0)
-			*mmcpart = simple_strtoul(raw_part_desc, NULL, 0);
+		if (strcmp(strsep(&raw_part_desc, " "), "mmcpart") == 0) {
+			ulong mmcpart = simple_strtoul(raw_part_desc, NULL, 0);
+			int ret = blk_dselect_hwpart(dev_desc, mmcpart);
+
+			if (ret)
+				return ret;
+		}
 	}
 
 	return 0;
@@ -425,7 +431,6 @@ int fastboot_mmc_get_part_info(const char *part_name,
 			       struct disk_partition *part_info, char *response)
 {
 	int r = 0;
-	int mmcpart;
 
 	*dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
 	if (!*dev_desc) {
@@ -437,7 +442,7 @@ int fastboot_mmc_get_part_info(const char *part_name,
 		return -ENOENT;
 	}
 
-	if (raw_part_get_info_by_name(*dev_desc, part_name, part_info, &mmcpart) < 0) {
+	if (raw_part_get_info_by_name(*dev_desc, part_name, part_info) < 0) {
 		r = part_get_info_by_name_or_alias(*dev_desc, part_name, part_info);
 		if (r < 0) {
 			fastboot_fail("partition not found", response);
@@ -461,7 +466,6 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
 {
 	struct blk_desc *dev_desc;
 	struct disk_partition info;
-	int mmcpart = 0;
 
 	dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
 	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
@@ -541,16 +545,12 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
 	}
 #endif
 
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info, &mmcpart) == 0) {
-		if (blk_dselect_hwpart(dev_desc, mmcpart)) {
-			pr_err("Failed to select hwpart\n");
-			fastboot_fail("Failed to select hwpart", response);
+	if (raw_part_get_info_by_name(dev_desc, cmd, &info) != 0) {
+		if (part_get_info_by_name_or_alias(dev_desc, cmd, &info) < 0) {
+			pr_err("cannot find partition: '%s'\n", cmd);
+			fastboot_fail("cannot find partition", response);
 			return;
 		}
-	} else if (part_get_info_by_name_or_alias(dev_desc, cmd, &info) < 0) {
-		pr_err("cannot find partition: '%s'\n", cmd);
-		fastboot_fail("cannot find partition", response);
-		return;
 	}
 
 	if (is_sparse_image(download_buffer)) {
@@ -593,7 +593,6 @@ void fastboot_mmc_erase(const char *cmd, char *response)
 	struct disk_partition info;
 	lbaint_t blks, blks_start, blks_size, grp_size;
 	struct mmc *mmc = find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	int mmcpart = 0;
 
 	if (mmc == NULL) {
 		pr_err("invalid mmc device\n");
@@ -632,16 +631,12 @@ void fastboot_mmc_erase(const char *cmd, char *response)
 	}
 #endif
 
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info, &mmcpart) == 0) {
-		if (blk_dselect_hwpart(dev_desc, mmcpart)) {
-			pr_err("Failed to select hwpart\n");
-			fastboot_fail("Failed to select hwpart", response);
+	if (raw_part_get_info_by_name(dev_desc, cmd, &info) != 0) {
+		if (part_get_info_by_name_or_alias(dev_desc, cmd, &info) < 0) {
+			pr_err("cannot find partition: '%s'\n", cmd);
+			fastboot_fail("cannot find partition", response);
 			return;
 		}
-	} else if (part_get_info_by_name_or_alias(dev_desc, cmd, &info) < 0) {
-		pr_err("cannot find partition: '%s'\n", cmd);
-		fastboot_fail("cannot find partition", response);
-		return;
 	}
 
 	/* Align blocks to erase group size to avoid erasing other partitions */
Signature · 1 line
2.25.1
#7 lore raw

PATCH v4 7/9 fastboot: Move part_get_info_by_name_or_alias after raw_part_get_info_by_name

In reply to Sean Anderson

This makes the next commit more readable by doing the move now.

---

(no changes since v1)

 drivers/fastboot/fb_mmc.c | 44 +++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 22 deletions(-)
drivers/fastboot/fb_mmc.c +22 -22
index 75347bb99b..71eeb02c8f 100644
@@ -28,28 +28,6 @@ struct fb_mmc_sparse {
 	struct blk_desc	*dev_desc;
 };
 
-static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
-		const char *name, struct disk_partition *info)
-{
-	int ret;
-
-	ret = part_get_info_by_name(dev_desc, name, info);
-	if (ret < 0) {
-		/* strlen("fastboot_partition_alias_") + PART_NAME_LEN + 1 */
-		char env_alias_name[25 + PART_NAME_LEN + 1];
-		char *aliased_part_name;
-
-		/* check for alias */
-		strcpy(env_alias_name, "fastboot_partition_alias_");
-		strncat(env_alias_name, name, PART_NAME_LEN);
-		aliased_part_name = env_get(env_alias_name);
-		if (aliased_part_name != NULL)
-			ret = part_get_info_by_name(dev_desc,
-					aliased_part_name, info);
-	}
-	return ret;
-}
-
 static int raw_part_get_info_by_name(struct blk_desc *dev_desc,
 				     const char *name,
 				     struct disk_partition *info)
@@ -98,6 +76,28 @@ static int raw_part_get_info_by_name(struct blk_desc *dev_desc,
 	return 0;
 }
 
+static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
+		const char *name, struct disk_partition *info)
+{
+	int ret;
+
+	ret = part_get_info_by_name(dev_desc, name, info);
+	if (ret < 0) {
+		/* strlen("fastboot_partition_alias_") + PART_NAME_LEN + 1 */
+		char env_alias_name[25 + PART_NAME_LEN + 1];
+		char *aliased_part_name;
+
+		/* check for alias */
+		strcpy(env_alias_name, "fastboot_partition_alias_");
+		strncat(env_alias_name, name, PART_NAME_LEN);
+		aliased_part_name = env_get(env_alias_name);
+		if (aliased_part_name != NULL)
+			ret = part_get_info_by_name(dev_desc,
+					aliased_part_name, info);
+	}
+	return ret;
+}
+
 /**
  * fb_mmc_blk_write() - Write/erase MMC in chunks of FASTBOOT_MAX_BLK_WRITE
  *
Signature · 1 line
2.25.1
#8 lore raw

PATCH v4 8/9 fastboot: Allow u-boot-style partitions

In reply to Sean Anderson

This adds support for partitions of the form "dev.hwpart:part" and "dev#partname". This allows one to flash to eMMC boot partitions without having to use CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT. It also allows one to flash to an entire device without needing CONFIG_FASTBOOT_MMC_USER_NAME. Lastly, one can also flash MMC devices other than CONFIG_FASTBOOT_FLASH_MMC_DEV.

Because devices can be specified explicitly, CONFIG_FASTBOOT_FLASH_MMC_DEV is used only when necessary for existing functionality. For those cases, fastboot_mmc_get_dev has been added as a helper function. This allows

There should be no conflicts with the existing system, but just in case, I have ordered detection of these names after all existing names.

The fastboot_mmc_part test has been updated for these new names.

---

Changes in v4:
- Fix missing closing brace

 drivers/fastboot/fb_mmc.c | 157 ++++++++++++++++++++++++--------------
 test/dm/fastboot.c        |  37 ++++++++-
 2 files changed, 132 insertions(+), 62 deletions(-)
drivers/fastboot/fb_mmc.c +98 -59
index 71eeb02c8f..8e74e50e91 100644
@@ -76,12 +76,37 @@ static int raw_part_get_info_by_name(struct blk_desc *dev_desc,
 	return 0;
 }
 
-static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
-		const char *name, struct disk_partition *info)
+static int do_get_part_info(struct blk_desc **dev_desc, const char *name,
+			    struct disk_partition *info)
 {
 	int ret;
 
-	ret = part_get_info_by_name(dev_desc, name, info);
+	/* First try partition names on the default device */
+	*dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	if (*dev_desc) {
+		ret = part_get_info_by_name(*dev_desc, name, info);
+		if (ret >= 0)
+			return ret;
+
+		/* Then try raw partitions */
+		ret = raw_part_get_info_by_name(*dev_desc, name, info);
+		if (ret >= 0)
+			return ret;
+	}
+
+	/* Then try dev.hwpart:part */
+	ret = part_get_info_by_dev_and_name_or_num("mmc", name, dev_desc,
+						   info, true);
+	return ret;
+}
+
+static int part_get_info_by_name_or_alias(struct blk_desc **dev_desc,
+					  const char *name,
+					  struct disk_partition *info)
+{
+	int ret;
+
+	ret = do_get_part_info(dev_desc, name, info);
 	if (ret < 0) {
 		/* strlen("fastboot_partition_alias_") + PART_NAME_LEN + 1 */
 		char env_alias_name[25 + PART_NAME_LEN + 1];
@@ -92,8 +117,8 @@ static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
 		strncat(env_alias_name, name, PART_NAME_LEN);
 		aliased_part_name = env_get(env_alias_name);
 		if (aliased_part_name != NULL)
-			ret = part_get_info_by_name(dev_desc,
-					aliased_part_name, info);
+			ret = do_get_part_info(dev_desc, aliased_part_name,
+					       info);
 	}
 	return ret;
 }
@@ -430,27 +455,49 @@ int fastboot_mmc_get_part_info(const char *part_name,
 			       struct blk_desc **dev_desc,
 			       struct disk_partition *part_info, char *response)
 {
-	int r = 0;
+	int ret;
 
-	*dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!*dev_desc) {
-		fastboot_fail("block device not found", response);
-		return -ENOENT;
-	}
 	if (!part_name || !strcmp(part_name, "")) {
 		fastboot_fail("partition not given", response);
 		return -ENOENT;
 	}
 
-	if (raw_part_get_info_by_name(*dev_desc, part_name, part_info) < 0) {
-		r = part_get_info_by_name_or_alias(*dev_desc, part_name, part_info);
-		if (r < 0) {
-			fastboot_fail("partition not found", response);
-			return r;
+	ret = part_get_info_by_name_or_alias(dev_desc, part_name, part_info);
+	if (ret < 0) {
+		switch (ret) {
+		case -ENOSYS:
+		case -EINVAL:
+			fastboot_fail("invalid partition or device", response);
+			break;
+		case -ENODEV:
+			fastboot_fail("no such device", response);
+			break;
+		case -ENOENT:
+			fastboot_fail("no such partition", response);
+			break;
+		case -EPROTONOSUPPORT:
+			fastboot_fail("unknown partition table type", response);
+			break;
+		default:
+			fastboot_fail("unanticipated error", response);
+			break;
 		}
 	}
 
-	return r;
+	return ret;
+}
+
+static struct blk_desc *fastboot_mmc_get_dev(char *response)
+{
+	struct blk_desc *ret = blk_get_dev("mmc",
+					   CONFIG_FASTBOOT_FLASH_MMC_DEV);
+
+	if (!ret || ret->type == DEV_TYPE_UNKNOWN) {
+		pr_err("invalid mmc device\n");
+		fastboot_fail("invalid mmc device", response);
+		return NULL;
+	}
+	return ret;
 }
 
 /**
@@ -467,22 +514,19 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
 	struct blk_desc *dev_desc;
 	struct disk_partition info;
 
-	dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
 #ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT
 	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) {
-		fb_mmc_boot_ops(dev_desc, download_buffer, 1,
-				download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, download_buffer, 1,
+					download_bytes, response);
 		return;
 	}
 	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) {
-		fb_mmc_boot_ops(dev_desc, download_buffer, 2,
-				download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, download_buffer, 1,
+					download_bytes, response);
 		return;
 	}
 #endif
@@ -494,6 +538,10 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
 	if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0 ||
 	    strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) {
 #endif
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
 		printf("%s: updating MBR, Primary and Backup GPT(s)\n",
 		       __func__);
 		if (is_valid_gpt_buf(dev_desc, download_buffer)) {
@@ -517,6 +565,10 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
 
 #if CONFIG_IS_ENABLED(DOS_PARTITION)
 	if (strcmp(cmd, CONFIG_FASTBOOT_MBR_NAME) == 0) {
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
 		printf("%s: updating MBR\n", __func__);
 		if (is_valid_dos_buf(download_buffer)) {
 			printf("%s: invalid MBR - refusing to write to flash\n",
@@ -539,19 +591,16 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
 
 #ifdef CONFIG_ANDROID_BOOT_IMAGE
 	if (strncasecmp(cmd, "zimage", 6) == 0) {
-		fb_mmc_update_zimage(dev_desc, download_buffer,
-				     download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_update_zimage(dev_desc, download_buffer,
+					     download_bytes, response);
 		return;
 	}
 #endif
 
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info) != 0) {
-		if (part_get_info_by_name_or_alias(dev_desc, cmd, &info) < 0) {
-			pr_err("cannot find partition: '%s'\n", cmd);
-			fastboot_fail("cannot find partition", response);
-			return;
-		}
-	}
+	if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info, response) < 0)
+		return;
 
 	if (is_sparse_image(download_buffer)) {
 		struct fb_mmc_sparse sparse_priv;
@@ -594,28 +643,19 @@ void fastboot_mmc_erase(const char *cmd, char *response)
 	lbaint_t blks, blks_start, blks_size, grp_size;
 	struct mmc *mmc = find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV);
 
-	if (mmc == NULL) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
-	dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
 #ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT
 	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) {
 		/* erase EMMC boot1 */
-		fb_mmc_boot_ops(dev_desc, NULL, 1, 0, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, NULL, 1, 0, response);
 		return;
 	}
 	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) {
 		/* erase EMMC boot2 */
-		fb_mmc_boot_ops(dev_desc, NULL, 2, 0, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, NULL, 1, 0, response);
 		return;
 	}
 #endif
@@ -623,6 +663,10 @@ void fastboot_mmc_erase(const char *cmd, char *response)
 #ifdef CONFIG_FASTBOOT_MMC_USER_SUPPORT
 	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) {
 		/* erase EMMC userdata */
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
 		if (fb_mmc_erase_mmc_hwpart(dev_desc))
 			fastboot_fail("Failed to erase EMMC_USER", response);
 		else
@@ -631,13 +675,8 @@ void fastboot_mmc_erase(const char *cmd, char *response)
 	}
 #endif
 
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info) != 0) {
-		if (part_get_info_by_name_or_alias(dev_desc, cmd, &info) < 0) {
-			pr_err("cannot find partition: '%s'\n", cmd);
-			fastboot_fail("cannot find partition", response);
-			return;
-		}
-	}
+	if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info, response) < 0)
+		return;
 
 	/* Align blocks to erase group size to avoid erasing other partitions */
 	grp_size = mmc->erase_grp_size;
test/dm/fastboot.c +34 -3
index 8f905d8fa8..e7f8c362b8 100644
@@ -35,9 +35,12 @@ static int dm_test_fastboot_mmc_part(struct unit_test_state *uts)
 		},
 	};
 
-	ut_assertok(blk_get_device_by_str("mmc",
-					  __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV),
-					  &mmc_dev_desc));
+	/*
+	 * There are a lot of literal 0s I don't want to have to construct from
+	 * MMC_DEV.
+	 */
+	ut_asserteq(0, CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	ut_assertok(blk_get_device_by_str("mmc", "0", &mmc_dev_desc));
 	if (CONFIG_IS_ENABLED(RANDOM_UUID)) {
 		gen_rand_uuid_str(parts[0].uuid, UUID_STR_FORMAT_STD);
 		gen_rand_uuid_str(parts[1].uuid, UUID_STR_FORMAT_STD);
@@ -59,6 +62,34 @@ static int dm_test_fastboot_mmc_part(struct unit_test_state *uts)
 						  &part_info, response));
 	ut_assertok(env_set(FB_ALIAS_PREFIX "test3", NULL));
 
+	/* "New" partition labels */
+	ut_asserteq(1, fastboot_mmc_get_part_info("#test1", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(1, fastboot_mmc_get_part_info("0#test1", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0#test1", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(1, fastboot_mmc_get_part_info("0:1", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0:1", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(1, fastboot_mmc_get_part_info("0", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(0, fastboot_mmc_get_part_info("0:0", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(0, fastboot_mmc_get_part_info("0.0:0", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(0, fastboot_mmc_get_part_info("1", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(0, fastboot_mmc_get_part_info("1.0", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(1, fastboot_mmc_get_part_info(":1", &fb_dev_desc,
+						  &part_info, response));
+	ut_asserteq(0, fastboot_mmc_get_part_info(":0", &fb_dev_desc,
+						  &part_info, response));
+
 	return 0;
 }
 DM_TEST(dm_test_fastboot_mmc_part, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
Signature · 1 line
2.25.1
#9 lore raw

PATCH v4 8/9 fastboot: Allow u-boot-style partitions

Hi Sean,

Quoted 6 lines

This adds support for partitions of the form "dev.hwpart:part" and "dev#partname". This allows one to flash to eMMC boot partitions without having to use CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT. It also allows one to flash to an entire device without needing CONFIG_FASTBOOT_MMC_USER_NAME. Lastly, one can also flash MMC devices other than CONFIG_FASTBOOT_FLASH_MMC_DEV.

This patch series causes following build errors:
https://dev.azure.com/lukma633/U-Boot/_build/results?buildId=20&view=results

I saw the v5 of this patch series. Could you check if it pass with green the CI tests?

Thanks in advance,

Quoted 376 lines

Because devices can be specified explicitly, CONFIG_FASTBOOT_FLASH_MMC_DEV is used only when necessary for existing functionality. For those cases, fastboot_mmc_get_dev has been added as a helper function. This allows

There should be no conflicts with the existing system, but just in case, I have ordered detection of these names after all existing names.

The fastboot_mmc_part test has been updated for these new names.

---

Changes in v4:
- Fix missing closing brace

 drivers/fastboot/fb_mmc.c | 157

++++++++++++++++++++++++-------------- test/dm/fastboot.c |
37 ++++++++- 2 files changed, 132 insertions(+), 62 deletions(-)

drivers/fastboot/fb_mmc.c +17 -3
index 71eeb02c8f..8e74e50e91 100644
@@ -76,12 +76,37 @@ static int raw_part_get_info_by_name(struct
 blk_desc *dev_desc, return 0;
 }
 
-static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
-		const char *name, struct disk_partition *info)
+static int do_get_part_info(struct blk_desc **dev_desc, const char
 *name,
+			    struct disk_partition *info)
 {
 	int ret;
 
-	ret = part_get_info_by_name(dev_desc, name, info);
+	/* First try partition names on the default device */
+	*dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	if (*dev_desc) {
+		ret = part_get_info_by_name(*dev_desc, name, info);
+		if (ret >= 0)
+			return ret;
+
+		/* Then try raw partitions */
+		ret = raw_part_get_info_by_name(*dev_desc, name,
 info);
+		if (ret >= 0)
+			return ret;
+	}
+
+	/* Then try dev.hwpart:part */
+	ret = part_get_info_by_dev_and_name_or_num("mmc", name,

dev_desc,

drivers/fastboot/fb_mmc.c +7 -0
+						   info, true);
+	return ret;
+}
+
+static int part_get_info_by_name_or_alias(struct blk_desc **dev_desc,
+					  const char *name,
+					  struct disk_partition

*info) +{

drivers/fastboot/fb_mmc.c +3 -0
+	int ret;
+
+	ret = do_get_part_info(dev_desc, name, info);
 	if (ret < 0) {
 		/* strlen("fastboot_partition_alias_") +

PART_NAME_LEN + 1 */ char env_alias_name[25 + PART_NAME_LEN + 1];

drivers/fastboot/fb_mmc.c +2 -2
@@ -92,8 +117,8 @@ static int part_get_info_by_name_or_alias(struct
 blk_desc *dev_desc, strncat(env_alias_name, name, PART_NAME_LEN);
 		aliased_part_name = env_get(env_alias_name);
 		if (aliased_part_name != NULL)
-			ret = part_get_info_by_name(dev_desc,
-					aliased_part_name, info);
+			ret = do_get_part_info(dev_desc,
 aliased_part_name,
+					       info);
 	}
 	return ret;

}

drivers/fastboot/fb_mmc.c +19 -11
@@ -430,27 +455,49 @@ int fastboot_mmc_get_part_info(const char
 *part_name, struct blk_desc **dev_desc,
 			       struct disk_partition *part_info,
 char *response) {
-	int r = 0;
+	int ret;
 
-	*dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!*dev_desc) {
-		fastboot_fail("block device not found", response);
-		return -ENOENT;
-	}
 	if (!part_name || !strcmp(part_name, "")) {
 		fastboot_fail("partition not given", response);
 		return -ENOENT;
 	}
 
-	if (raw_part_get_info_by_name(*dev_desc, part_name,
 part_info) < 0) {
-		r = part_get_info_by_name_or_alias(*dev_desc,
 part_name, part_info);
-		if (r < 0) {
-			fastboot_fail("partition not found",
 response);
-			return r;
+	ret = part_get_info_by_name_or_alias(dev_desc, part_name,
 part_info);
+	if (ret < 0) {
+		switch (ret) {
+		case -ENOSYS:
+		case -EINVAL:
+			fastboot_fail("invalid partition or device",
 response);
+			break;
+		case -ENODEV:
+			fastboot_fail("no such device", response);
+			break;
+		case -ENOENT:
+			fastboot_fail("no such partition", response);
+			break;
+		case -EPROTONOSUPPORT:
+			fastboot_fail("unknown partition table
 type", response);
+			break;
+		default:
+			fastboot_fail("unanticipated error",

response);

drivers/fastboot/fb_mmc.c +8 -1
+			break;
 		}
 	}
 
-	return r;
+	return ret;
+}
+
+static struct blk_desc *fastboot_mmc_get_dev(char *response)
+{
+	struct blk_desc *ret = blk_get_dev("mmc",
+

CONFIG_FASTBOOT_FLASH_MMC_DEV); +

drivers/fastboot/fb_mmc.c +14 -11
+	if (!ret || ret->type == DEV_TYPE_UNKNOWN) {
+		pr_err("invalid mmc device\n");
+		fastboot_fail("invalid mmc device", response);
+		return NULL;
+	}
+	return ret;
 }
 
 /**
@@ -467,22 +514,19 @@ void fastboot_mmc_flash_write(const char *cmd,
 void *download_buffer, struct blk_desc *dev_desc;
 	struct disk_partition info;
 
-	dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
 #ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT
 	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) {
-		fb_mmc_boot_ops(dev_desc, download_buffer, 1,
-				download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, download_buffer, 1,
+					download_bytes, response);
 		return;
 	}
 	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) {
-		fb_mmc_boot_ops(dev_desc, download_buffer, 2,
-				download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, download_buffer, 1,
+					download_bytes, response);
 		return;
 	}
 #endif
@@ -494,6 +538,10 @@ void fastboot_mmc_flash_write(const char *cmd,

void *download_buffer, if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0 || strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) {
#endif

drivers/fastboot/fb_mmc.c +4 -0
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
 		printf("%s: updating MBR, Primary and Backup

GPT(s)\n", __func__);

drivers/fastboot/fb_mmc.c +4 -0
 		if (is_valid_gpt_buf(dev_desc, download_buffer)) {
@@ -517,6 +565,10 @@ void fastboot_mmc_flash_write(const char *cmd,
 void *download_buffer, 
 #if CONFIG_IS_ENABLED(DOS_PARTITION)
 	if (strcmp(cmd, CONFIG_FASTBOOT_MBR_NAME) == 0) {
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
 		printf("%s: updating MBR\n", __func__);
 		if (is_valid_dos_buf(download_buffer)) {
 			printf("%s: invalid MBR - refusing to write

to flash\n", @@ -539,19 +591,16 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
#ifdef CONFIG_ANDROID_BOOT_IMAGE

drivers/fastboot/fb_mmc.c +3 -2
 	if (strncasecmp(cmd, "zimage", 6) == 0) {
-		fb_mmc_update_zimage(dev_desc, download_buffer,
-				     download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_update_zimage(dev_desc,

download_buffer,

drivers/fastboot/fb_mmc.c +1 -0
+					     download_bytes,

response); return;

drivers/fastboot/fb_mmc.c +0 -2
 	}
 #endif
 
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info) != 0) {
-		if (part_get_info_by_name_or_alias(dev_desc, cmd,

&info) < 0) {

drivers/fastboot/fb_mmc.c +0 -2
-			pr_err("cannot find partition: '%s'\n", cmd);
-			fastboot_fail("cannot find partition",

response);

drivers/fastboot/fb_mmc.c +1 -3
-			return;
-		}
-	}
+	if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info,

response) < 0)

drivers/fastboot/fb_mmc.c +11 -15
+		return;
 
 	if (is_sparse_image(download_buffer)) {
 		struct fb_mmc_sparse sparse_priv;
@@ -594,28 +643,19 @@ void fastboot_mmc_erase(const char *cmd, char
 *response) lbaint_t blks, blks_start, blks_size, grp_size;
 	struct mmc *mmc =
 find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV); 
-	if (mmc == NULL) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
-	dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
 #ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT
 	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) {
 		/* erase EMMC boot1 */
-		fb_mmc_boot_ops(dev_desc, NULL, 1, 0, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, NULL, 1, 0,
 response); return;
 	}
 	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) {
 		/* erase EMMC boot2 */
-		fb_mmc_boot_ops(dev_desc, NULL, 2, 0, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, NULL, 1, 0,
 response); return;
 	}
 #endif
@@ -623,6 +663,10 @@ void fastboot_mmc_erase(const char *cmd, char
 *response) #ifdef CONFIG_FASTBOOT_MMC_USER_SUPPORT
 	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) {
 		/* erase EMMC userdata */
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
 		if (fb_mmc_erase_mmc_hwpart(dev_desc))
 			fastboot_fail("Failed to erase EMMC_USER",

response); else

drivers/fastboot/fb_mmc.c +2 -7
@@ -631,13 +675,8 @@ void fastboot_mmc_erase(const char *cmd, char
 *response) }
 #endif
 
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info) != 0) {
-		if (part_get_info_by_name_or_alias(dev_desc, cmd,
 &info) < 0) {
-			pr_err("cannot find partition: '%s'\n", cmd);
-			fastboot_fail("cannot find partition",
 response);
-			return;
-		}
-	}
+	if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info,
 response) < 0)
+		return;

/* Align blocks to erase group size to avoid erasing other
partitions */ grp_size = mmc->erase_grp_size;

test/dm/fastboot.c +2 -3
index 8f905d8fa8..e7f8c362b8 100644
@@ -35,9 +35,12 @@ static int dm_test_fastboot_mmc_part(struct
 unit_test_state *uts) },
 	};
 
-	ut_assertok(blk_get_device_by_str("mmc",
-
 __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV),
-					  &mmc_dev_desc));
+	/*
+	 * There are a lot of literal 0s I don't want to have to

construct from

test/dm/fastboot.c +4 -0
+	 * MMC_DEV.
+	 */
+	ut_asserteq(0, CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	ut_assertok(blk_get_device_by_str("mmc", "0",

&mmc_dev_desc)); if (CONFIG_IS_ENABLED(RANDOM_UUID)) {
gen_rand_uuid_str(parts[0].uuid,
UUID_STR_FORMAT_STD); gen_rand_uuid_str(parts[1].uuid, UUID_STR_FORMAT_STD); @@ -59,6 +62,34 @@ static int dm_test_fastboot_mmc_part(struct unit_test_state *uts) &part_info, response)); ut_assertok(env_set(FB_ALIAS_PREFIX "test3", NULL));

test/dm/fastboot.c +2 -0
+	/* "New" partition labels */
+	ut_asserteq(1, fastboot_mmc_get_part_info("#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0:1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0:1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +2 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0", &fb_dev_desc,
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("0:0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("0.0:0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +2 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("1", &fb_dev_desc,
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("1.0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +2 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info(":1", &fb_dev_desc,
+						  &part_info,

response));

test/dm/fastboot.c +2 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info(":0", &fb_dev_desc,
+						  &part_info,
Quoted 5 lines

response)); +
return 0;
}
DM_TEST(dm_test_fastboot_mmc_part, UT_TESTF_SCAN_PDATA |
UT_TESTF_SCAN_FDT);

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210205/fbfa555d/attachment.sig>

#10 lore raw

PATCH v4 8/9 fastboot: Allow u-boot-style partitions

Quoted 11 lines · Lukasz Majewski

Hi Sean,

Quoted 6 lines

This adds support for partitions of the form "dev.hwpart:part" and "dev#partname". This allows one to flash to eMMC boot partitions without having to use CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT. It also allows one to flash to an entire device without needing CONFIG_FASTBOOT_MMC_USER_NAME. Lastly, one can also flash MMC devices other than CONFIG_FASTBOOT_FLASH_MMC_DEV.

This patch series causes following build errors:

https://dev.azure.com/lukma633/U-Boot/_build/results?buildId=20&view=results

Yes, I saw those errors; they should be addressed in v5.

Quoted 3 lines

I saw the v5 of this patch series. Could you check if it pass with green the CI tests?

It is building at [1].

[1]
https://dev.azure.com/u-boot/u-boot/_build/results?buildId=1748&view=results.

--Sean

Quoted 398 lines

Thanks in advance,

Quoted 376 lines

Because devices can be specified explicitly, CONFIG_FASTBOOT_FLASH_MMC_DEV is used only when necessary for existing functionality. For those cases, fastboot_mmc_get_dev has been added as a helper function. This allows

There should be no conflicts with the existing system, but just in case, I have ordered detection of these names after all existing names.

The fastboot_mmc_part test has been updated for these new names.

---

Changes in v4:
- Fix missing closing brace

  drivers/fastboot/fb_mmc.c | 157

++++++++++++++++++++++++-------------- test/dm/fastboot.c |
37 ++++++++- 2 files changed, 132 insertions(+), 62 deletions(-)

drivers/fastboot/fb_mmc.c +17 -3
index 71eeb02c8f..8e74e50e91 100644
@@ -76,12 +76,37 @@ static int raw_part_get_info_by_name(struct
 blk_desc *dev_desc, return 0;
  }
 
-static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
-		const char *name, struct disk_partition *info)
+static int do_get_part_info(struct blk_desc **dev_desc, const char
 *name,
+			    struct disk_partition *info)
  {
  	int ret;
 
-	ret = part_get_info_by_name(dev_desc, name, info);
+	/* First try partition names on the default device */
+	*dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	if (*dev_desc) {
+		ret = part_get_info_by_name(*dev_desc, name, info);
+		if (ret >= 0)
+			return ret;
+
+		/* Then try raw partitions */
+		ret = raw_part_get_info_by_name(*dev_desc, name,
 info);
+		if (ret >= 0)
+			return ret;
+	}
+
+	/* Then try dev.hwpart:part */
+	ret = part_get_info_by_dev_and_name_or_num("mmc", name,

dev_desc,

drivers/fastboot/fb_mmc.c +7 -0
+						   info, true);
+	return ret;
+}
+
+static int part_get_info_by_name_or_alias(struct blk_desc **dev_desc,
+					  const char *name,
+					  struct disk_partition

*info) +{

drivers/fastboot/fb_mmc.c +3 -0
+	int ret;
+
+	ret = do_get_part_info(dev_desc, name, info);
  	if (ret < 0) {
  		/* strlen("fastboot_partition_alias_") +

PART_NAME_LEN + 1 */ char env_alias_name[25 + PART_NAME_LEN + 1];

drivers/fastboot/fb_mmc.c +2 -2
@@ -92,8 +117,8 @@ static int part_get_info_by_name_or_alias(struct
 blk_desc *dev_desc, strncat(env_alias_name, name, PART_NAME_LEN);
  		aliased_part_name = env_get(env_alias_name);
  		if (aliased_part_name != NULL)
-			ret = part_get_info_by_name(dev_desc,
-					aliased_part_name, info);
+			ret = do_get_part_info(dev_desc,
 aliased_part_name,
+					       info);
  	}
  	return ret;
  }
drivers/fastboot/fb_mmc.c +19 -11
@@ -430,27 +455,49 @@ int fastboot_mmc_get_part_info(const char
 *part_name, struct blk_desc **dev_desc,
  			       struct disk_partition *part_info,
 char *response) {
-	int r = 0;
+	int ret;
 
-	*dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!*dev_desc) {
-		fastboot_fail("block device not found", response);
-		return -ENOENT;
-	}
  	if (!part_name || !strcmp(part_name, "")) {
  		fastboot_fail("partition not given", response);
  		return -ENOENT;
  	}
 
-	if (raw_part_get_info_by_name(*dev_desc, part_name,
 part_info) < 0) {
-		r = part_get_info_by_name_or_alias(*dev_desc,
 part_name, part_info);
-		if (r < 0) {
-			fastboot_fail("partition not found",
 response);
-			return r;
+	ret = part_get_info_by_name_or_alias(dev_desc, part_name,
 part_info);
+	if (ret < 0) {
+		switch (ret) {
+		case -ENOSYS:
+		case -EINVAL:
+			fastboot_fail("invalid partition or device",
 response);
+			break;
+		case -ENODEV:
+			fastboot_fail("no such device", response);
+			break;
+		case -ENOENT:
+			fastboot_fail("no such partition", response);
+			break;
+		case -EPROTONOSUPPORT:
+			fastboot_fail("unknown partition table
 type", response);
+			break;
+		default:
+			fastboot_fail("unanticipated error",

response);

drivers/fastboot/fb_mmc.c +8 -1
+			break;
  		}
  	}
 
-	return r;
+	return ret;
+}
+
+static struct blk_desc *fastboot_mmc_get_dev(char *response)
+{
+	struct blk_desc *ret = blk_get_dev("mmc",
+

CONFIG_FASTBOOT_FLASH_MMC_DEV); +

drivers/fastboot/fb_mmc.c +14 -11
+	if (!ret || ret->type == DEV_TYPE_UNKNOWN) {
+		pr_err("invalid mmc device\n");
+		fastboot_fail("invalid mmc device", response);
+		return NULL;
+	}
+	return ret;
  }
 
  /**
@@ -467,22 +514,19 @@ void fastboot_mmc_flash_write(const char *cmd,
 void *download_buffer, struct blk_desc *dev_desc;
  	struct disk_partition info;
 
-	dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
  #ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) {
-		fb_mmc_boot_ops(dev_desc, download_buffer, 1,
-				download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, download_buffer, 1,
+					download_bytes, response);
  		return;
  	}
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) {
-		fb_mmc_boot_ops(dev_desc, download_buffer, 2,
-				download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, download_buffer, 1,
+					download_bytes, response);
  		return;
  	}
  #endif
@@ -494,6 +538,10 @@ void fastboot_mmc_flash_write(const char *cmd,

void *download_buffer, if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0 || strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) {
#endif

drivers/fastboot/fb_mmc.c +4 -0
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
  		printf("%s: updating MBR, Primary and Backup

GPT(s)\n", __func__);
if (is_valid_gpt_buf(dev_desc, download_buffer)) {

drivers/fastboot/fb_mmc.c +4 -0
@@ -517,6 +565,10 @@ void fastboot_mmc_flash_write(const char *cmd,
 void *download_buffer,
  #if CONFIG_IS_ENABLED(DOS_PARTITION)
  	if (strcmp(cmd, CONFIG_FASTBOOT_MBR_NAME) == 0) {
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
  		printf("%s: updating MBR\n", __func__);
  		if (is_valid_dos_buf(download_buffer)) {
  			printf("%s: invalid MBR - refusing to write

to flash\n", @@ -539,19 +591,16 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
#ifdef CONFIG_ANDROID_BOOT_IMAGE
if (strncasecmp(cmd, "zimage", 6) == 0) {

drivers/fastboot/fb_mmc.c +3 -2
-		fb_mmc_update_zimage(dev_desc, download_buffer,
-				     download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_update_zimage(dev_desc,

download_buffer,

drivers/fastboot/fb_mmc.c +1 -0
+					     download_bytes,

response); return;
}
#endif

drivers/fastboot/fb_mmc.c +0 -2
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info) != 0) {
-		if (part_get_info_by_name_or_alias(dev_desc, cmd,

&info) < 0) {

drivers/fastboot/fb_mmc.c +0 -2
-			pr_err("cannot find partition: '%s'\n", cmd);
-			fastboot_fail("cannot find partition",

response);

drivers/fastboot/fb_mmc.c +1 -3
-			return;
-		}
-	}
+	if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info,

response) < 0)

drivers/fastboot/fb_mmc.c +11 -15
+		return;
 
  	if (is_sparse_image(download_buffer)) {
  		struct fb_mmc_sparse sparse_priv;
@@ -594,28 +643,19 @@ void fastboot_mmc_erase(const char *cmd, char
 *response) lbaint_t blks, blks_start, blks_size, grp_size;
  	struct mmc *mmc =
 find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (mmc == NULL) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
-	dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
  #ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) {
  		/* erase EMMC boot1 */
-		fb_mmc_boot_ops(dev_desc, NULL, 1, 0, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, NULL, 1, 0,
 response); return;
  	}
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) {
  		/* erase EMMC boot2 */
-		fb_mmc_boot_ops(dev_desc, NULL, 2, 0, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, NULL, 1, 0,
 response); return;
  	}
  #endif
@@ -623,6 +663,10 @@ void fastboot_mmc_erase(const char *cmd, char
 *response) #ifdef CONFIG_FASTBOOT_MMC_USER_SUPPORT
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) {
  		/* erase EMMC userdata */
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
  		if (fb_mmc_erase_mmc_hwpart(dev_desc))
  			fastboot_fail("Failed to erase EMMC_USER",

response); else

drivers/fastboot/fb_mmc.c +2 -7
@@ -631,13 +675,8 @@ void fastboot_mmc_erase(const char *cmd, char
 *response) }
  #endif
 
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info) != 0) {
-		if (part_get_info_by_name_or_alias(dev_desc, cmd,
 &info) < 0) {
-			pr_err("cannot find partition: '%s'\n", cmd);
-			fastboot_fail("cannot find partition",
 response);
-			return;
-		}
-	}
+	if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info,
 response) < 0)
+		return;

/* Align blocks to erase group size to avoid erasing other
partitions */ grp_size = mmc->erase_grp_size;

test/dm/fastboot.c +2 -3
index 8f905d8fa8..e7f8c362b8 100644
@@ -35,9 +35,12 @@ static int dm_test_fastboot_mmc_part(struct
 unit_test_state *uts) },
  	};
 
-	ut_assertok(blk_get_device_by_str("mmc",
-
 __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV),
-					  &mmc_dev_desc));
+	/*
+	 * There are a lot of literal 0s I don't want to have to

construct from

test/dm/fastboot.c +4 -0
+	 * MMC_DEV.
+	 */
+	ut_asserteq(0, CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	ut_assertok(blk_get_device_by_str("mmc", "0",

&mmc_dev_desc)); if (CONFIG_IS_ENABLED(RANDOM_UUID)) {
gen_rand_uuid_str(parts[0].uuid,
UUID_STR_FORMAT_STD); gen_rand_uuid_str(parts[1].uuid, UUID_STR_FORMAT_STD); @@ -59,6 +62,34 @@ static int dm_test_fastboot_mmc_part(struct unit_test_state *uts) &part_info, response)); ut_assertok(env_set(FB_ALIAS_PREFIX "test3", NULL));

test/dm/fastboot.c +2 -0
+	/* "New" partition labels */
+	ut_asserteq(1, fastboot_mmc_get_part_info("#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0:1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0:1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +2 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0", &fb_dev_desc,
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("0:0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("0.0:0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +2 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("1", &fb_dev_desc,
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("1.0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +2 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info(":1", &fb_dev_desc,
+						  &part_info,

response));

test/dm/fastboot.c +2 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info(":0", &fb_dev_desc,
+						  &part_info,
Quoted 5 lines

response)); +
return 0;
}
DM_TEST(dm_test_fastboot_mmc_part, UT_TESTF_SCAN_PDATA |
UT_TESTF_SCAN_FDT);

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de

#11 lore raw

PATCH v4 8/9 fastboot: Allow u-boot-style partitions

Hi Sean,

Quoted 17 lines · Lukasz Majewski
Quoted 11 lines

Hi Sean,

Quoted 6 lines

This adds support for partitions of the form "dev.hwpart:part" and "dev#partname". This allows one to flash to eMMC boot partitions without having to use CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT. It also allows one to flash to an entire device without needing CONFIG_FASTBOOT_MMC_USER_NAME. Lastly, one can also flash MMC devices other than CONFIG_FASTBOOT_FLASH_MMC_DEV.

This patch series causes following build errors:

https://dev.azure.com/lukma633/U-Boot/_build/results?buildId=20&view=results

Yes, I saw those errors; they should be addressed in v5.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

I saw the v5 of this patch series. Could you check if it pass with green the CI tests?

It is building at [1].

[1]
https://dev.azure.com/u-boot/u-boot/_build/results?buildId=1748&view=results.

Interesting as
https://dev.azure.com/lukma633/U-Boot/_build/results?buildId=22&view=logs&j=425537f6-562f-5a62-0856-6c59be70cbe4&t=62b0f1ee-aadf-504c-f243-098b7c952989

Still shows errors after applying patch v5 version.

I'm using this series applied on top of Marek's usb tree:
https://github.com/lmajewski/u-boot-dfu/commits/testing

Could you look on this issue?

Quoted 418 lines

--Sean

Quoted 416 lines

Thanks in advance,

Quoted 394 lines

Because devices can be specified explicitly, CONFIG_FASTBOOT_FLASH_MMC_DEV is used only when necessary for existing functionality. For those cases, fastboot_mmc_get_dev has been added as a helper function. This allows

There should be no conflicts with the existing system, but just in case, I have ordered detection of these names after all existing names.

The fastboot_mmc_part test has been updated for these new names.

---

Changes in v4:
- Fix missing closing brace

  drivers/fastboot/fb_mmc.c | 157

++++++++++++++++++++++++-------------- test/dm/fastboot.c |
37 ++++++++- 2 files changed, 132 insertions(+), 62 deletions(-)

drivers/fastboot/fb_mmc.c +6 -3
index 71eeb02c8f..8e74e50e91 100644
@@ -76,12 +76,37 @@ static int raw_part_get_info_by_name(struct
 blk_desc *dev_desc, return 0;
  }
 
-static int part_get_info_by_name_or_alias(struct blk_desc
 *dev_desc,
-		const char *name, struct disk_partition *info)
+static int do_get_part_info(struct blk_desc **dev_desc, const
 char *name,
+			    struct disk_partition *info)
  {
  	int ret;
 
-	ret = part_get_info_by_name(dev_desc, name, info);
+	/* First try partition names on the default device */
+	*dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	if (*dev_desc) {
+		ret = part_get_info_by_name(*dev_desc, name,

info);

drivers/fastboot/fb_mmc.c +5 -0
+		if (ret >= 0)
+			return ret;
+
+		/* Then try raw partitions */
+		ret = raw_part_get_info_by_name(*dev_desc, name,

info);

drivers/fastboot/fb_mmc.c +6 -0
+		if (ret >= 0)
+			return ret;
+	}
+
+	/* Then try dev.hwpart:part */
+	ret = part_get_info_by_dev_and_name_or_num("mmc", name,

dev_desc,

drivers/fastboot/fb_mmc.c +5 -0
+						   info, true);
+	return ret;
+}
+
+static int part_get_info_by_name_or_alias(struct blk_desc

**dev_desc,

drivers/fastboot/fb_mmc.c +2 -0
+					  const char *name,
+					  struct disk_partition

*info) +{

drivers/fastboot/fb_mmc.c +3 -0
+	int ret;
+
+	ret = do_get_part_info(dev_desc, name, info);
  	if (ret < 0) {
  		/* strlen("fastboot_partition_alias_") +

PART_NAME_LEN + 1 */ char env_alias_name[25 + PART_NAME_LEN + 1];

drivers/fastboot/fb_mmc.c +0 -0
@@ -92,8 +117,8 @@ static int
 part_get_info_by_name_or_alias(struct blk_desc *dev_desc,

strncat(env_alias_name, name, PART_NAME_LEN); aliased_part_name = env_get(env_alias_name); if (aliased_part_name != NULL)

drivers/fastboot/fb_mmc.c +1 -2
-			ret = part_get_info_by_name(dev_desc,
-					aliased_part_name, info);
+			ret = do_get_part_info(dev_desc,

aliased_part_name,

drivers/fastboot/fb_mmc.c +11 -11
+					       info);
  	}
  	return ret;
  }
@@ -430,27 +455,49 @@ int fastboot_mmc_get_part_info(const char
 *part_name, struct blk_desc **dev_desc,
  			       struct disk_partition *part_info,
 char *response) {
-	int r = 0;
+	int ret;
 
-	*dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!*dev_desc) {
-		fastboot_fail("block device not found",
 response);
-		return -ENOENT;
-	}
  	if (!part_name || !strcmp(part_name, "")) {
  		fastboot_fail("partition not given", response);
  		return -ENOENT;
  	}
 
-	if (raw_part_get_info_by_name(*dev_desc, part_name,
 part_info) < 0) {
-		r = part_get_info_by_name_or_alias(*dev_desc,
 part_name, part_info);
-		if (r < 0) {
-			fastboot_fail("partition not found",
 response);
-			return r;
+	ret = part_get_info_by_name_or_alias(dev_desc, part_name,
 part_info);
+	if (ret < 0) {
+		switch (ret) {
+		case -ENOSYS:
+		case -EINVAL:
+			fastboot_fail("invalid partition or
 device", response);
+			break;
+		case -ENODEV:
+			fastboot_fail("no such device",

response);

drivers/fastboot/fb_mmc.c +3 -0
+			break;
+		case -ENOENT:
+			fastboot_fail("no such partition",

response);

drivers/fastboot/fb_mmc.c +3 -0
+			break;
+		case -EPROTONOSUPPORT:
+			fastboot_fail("unknown partition table

type", response);

drivers/fastboot/fb_mmc.c +3 -0
+			break;
+		default:
+			fastboot_fail("unanticipated error",

response);

drivers/fastboot/fb_mmc.c +8 -1
+			break;
  		}
  	}
 
-	return r;
+	return ret;
+}
+
+static struct blk_desc *fastboot_mmc_get_dev(char *response)
+{
+	struct blk_desc *ret = blk_get_dev("mmc",
+

CONFIG_FASTBOOT_FLASH_MMC_DEV); +

drivers/fastboot/fb_mmc.c +14 -11
+	if (!ret || ret->type == DEV_TYPE_UNKNOWN) {
+		pr_err("invalid mmc device\n");
+		fastboot_fail("invalid mmc device", response);
+		return NULL;
+	}
+	return ret;
  }
 
  /**
@@ -467,22 +514,19 @@ void fastboot_mmc_flash_write(const char
 *cmd, void *download_buffer, struct blk_desc *dev_desc;
  	struct disk_partition info;
 
-	dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
  #ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) {
-		fb_mmc_boot_ops(dev_desc, download_buffer, 1,
-				download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc,
 download_buffer, 1,
+					download_bytes,
 response); return;
  	}
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) {
-		fb_mmc_boot_ops(dev_desc, download_buffer, 2,
-				download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc,
 download_buffer, 1,
+					download_bytes,

response); return;
}
#endif

drivers/fastboot/fb_mmc.c +0 -0
@@ -494,6 +538,10 @@ void fastboot_mmc_flash_write(const char
 *cmd, void *download_buffer, if (strcmp(cmd,
 CONFIG_FASTBOOT_GPT_NAME) == 0 || strcmp(cmd,

CONFIG_FASTBOOT_MMC_USER_NAME) == 0) { #endif

drivers/fastboot/fb_mmc.c +4 -0
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
  		printf("%s: updating MBR, Primary and Backup

GPT(s)\n", __func__);
if (is_valid_gpt_buf(dev_desc,
download_buffer)) { @@ -517,6 +565,10 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
#if CONFIG_IS_ENABLED(DOS_PARTITION)
if (strcmp(cmd, CONFIG_FASTBOOT_MBR_NAME) == 0) {

drivers/fastboot/fb_mmc.c +4 -0
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
  		printf("%s: updating MBR\n", __func__);
  		if (is_valid_dos_buf(download_buffer)) {
  			printf("%s: invalid MBR - refusing to

write to flash\n", @@ -539,19 +591,16 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
#ifdef CONFIG_ANDROID_BOOT_IMAGE
if (strncasecmp(cmd, "zimage", 6) == 0) {

drivers/fastboot/fb_mmc.c +3 -2
-		fb_mmc_update_zimage(dev_desc, download_buffer,
-				     download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_update_zimage(dev_desc,

download_buffer,

drivers/fastboot/fb_mmc.c +1 -0
+					     download_bytes,

response); return;
}
#endif

drivers/fastboot/fb_mmc.c +0 -1
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info) !=

0) {

drivers/fastboot/fb_mmc.c +0 -1
-		if (part_get_info_by_name_or_alias(dev_desc, cmd,

&info) < 0) {

drivers/fastboot/fb_mmc.c +0 -1
-			pr_err("cannot find partition: '%s'\n",

cmd);

drivers/fastboot/fb_mmc.c +0 -1
-			fastboot_fail("cannot find partition",

response);

drivers/fastboot/fb_mmc.c +1 -3
-			return;
-		}
-	}
+	if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info,

response) < 0)

drivers/fastboot/fb_mmc.c +7 -15
+		return;
 
  	if (is_sparse_image(download_buffer)) {
  		struct fb_mmc_sparse sparse_priv;
@@ -594,28 +643,19 @@ void fastboot_mmc_erase(const char *cmd,
 char *response) lbaint_t blks, blks_start, blks_size, grp_size;
  	struct mmc *mmc =
 find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (mmc == NULL) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
-	dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
  #ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) {
  		/* erase EMMC boot1 */
-		fb_mmc_boot_ops(dev_desc, NULL, 1, 0, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, NULL, 1, 0,
 response); return;
  	}
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) {
  		/* erase EMMC boot2 */
-		fb_mmc_boot_ops(dev_desc, NULL, 2, 0, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, NULL, 1, 0,
 response); return;
  	}
  #endif
drivers/fastboot/fb_mmc.c +4 -0
@@ -623,6 +663,10 @@ void fastboot_mmc_erase(const char *cmd, char
 *response) #ifdef CONFIG_FASTBOOT_MMC_USER_SUPPORT
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) {
  		/* erase EMMC userdata */
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
  		if (fb_mmc_erase_mmc_hwpart(dev_desc))
  			fastboot_fail("Failed to erase

EMMC_USER", response); else

drivers/fastboot/fb_mmc.c +1 -7
@@ -631,13 +675,8 @@ void fastboot_mmc_erase(const char *cmd, char
 *response) }
  #endif
 
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info) !=
 0) {
-		if (part_get_info_by_name_or_alias(dev_desc, cmd,
 &info) < 0) {
-			pr_err("cannot find partition: '%s'\n",
 cmd);
-			fastboot_fail("cannot find partition",
 response);
-			return;
-		}
-	}
+	if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info,

response) < 0)

drivers/fastboot/fb_mmc.c +1 -0
+		return;
 
  	/* Align blocks to erase group size to avoid erasing

other partitions */ grp_size = mmc->erase_grp_size;

test/dm/fastboot.c +2 -3
index 8f905d8fa8..e7f8c362b8 100644
@@ -35,9 +35,12 @@ static int dm_test_fastboot_mmc_part(struct
 unit_test_state *uts) },
  	};
 
-	ut_assertok(blk_get_device_by_str("mmc",
-
 __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV),
-					  &mmc_dev_desc));
+	/*
+	 * There are a lot of literal 0s I don't want to have to

construct from

test/dm/fastboot.c +4 -0
+	 * MMC_DEV.
+	 */
+	ut_asserteq(0, CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	ut_assertok(blk_get_device_by_str("mmc", "0",

&mmc_dev_desc)); if (CONFIG_IS_ENABLED(RANDOM_UUID)) {
gen_rand_uuid_str(parts[0].uuid,
UUID_STR_FORMAT_STD); gen_rand_uuid_str(parts[1].uuid, UUID_STR_FORMAT_STD); @@ -59,6 +62,34 @@ static int dm_test_fastboot_mmc_part(struct unit_test_state *uts) &part_info, response)); ut_assertok(env_set(FB_ALIAS_PREFIX "test3", NULL));

test/dm/fastboot.c +2 -0
+	/* "New" partition labels */
+	ut_asserteq(1, fastboot_mmc_get_part_info("#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0:1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0:1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("0:0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("0.0:0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("1.0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info(":1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info(":0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,
Quoted 5 lines

response)); +
return 0;
}
DM_TEST(dm_test_fastboot_mmc_part, UT_TESTF_SCAN_PDATA |
UT_TESTF_SCAN_FDT);

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.de

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210206/24f218d4/attachment.sig>

#12 lore raw

PATCH v4 8/9 fastboot: Allow u-boot-style partitions

Quoted 24 lines · Lukasz Majewski

Hi Sean,

Quoted 22 lines · Lukasz Majewski
Quoted 11 lines

Hi Sean,

Quoted 6 lines

This adds support for partitions of the form "dev.hwpart:part" and "dev#partname". This allows one to flash to eMMC boot partitions without having to use CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT. It also allows one to flash to an entire device without needing CONFIG_FASTBOOT_MMC_USER_NAME. Lastly, one can also flash MMC devices other than CONFIG_FASTBOOT_FLASH_MMC_DEV.

This patch series causes following build errors:

https://dev.azure.com/lukma633/U-Boot/_build/results?buildId=20&view=results

Yes, I saw those errors; they should be addressed in v5.

Quoted 3 lines

I saw the v5 of this patch series. Could you check if it pass with green the CI tests?

It is building at [1].

Quoted 8 lines
Quoted 3 lines

[1]
https://dev.azure.com/u-boot/u-boot/_build/results?buildId=1748&view=results.

Interesting as
https://dev.azure.com/lukma633/U-Boot/_build/results?buildId=22&view=logs&j=425537f6-562f-5a62-0856-6c59be70cbe4&t=62b0f1ee-aadf-504c-f243-098b7c952989

Still shows errors after applying patch v5 version.

It looks like it's due to the following construct in fastboot.h

#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
FASTBOOT_COMMAND_OEM_BOOTBUS,
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
FASTBOOT_COMMAND_ACMD,
FASTBOOT_COMMAND_UCMD,
#endif

Which was added in 427f563 ("fastboot: add UUU command UCmd and ACmd support")

It seems like Heiko made an error while rebasing, CCing him.

--Sean

Quoted 438 lines

I'm using this series applied on top of Marek's usb tree:
https://github.com/lmajewski/u-boot-dfu/commits/testing

Could you look on this issue?

Quoted 418 lines

--Sean

Quoted 416 lines

Thanks in advance,

Quoted 394 lines

Because devices can be specified explicitly, CONFIG_FASTBOOT_FLASH_MMC_DEV is used only when necessary for existing functionality. For those cases, fastboot_mmc_get_dev has been added as a helper function. This allows

There should be no conflicts with the existing system, but just in case, I have ordered detection of these names after all existing names.

The fastboot_mmc_part test has been updated for these new names.

---

Changes in v4:
- Fix missing closing brace

  drivers/fastboot/fb_mmc.c | 157

++++++++++++++++++++++++-------------- test/dm/fastboot.c |
37 ++++++++- 2 files changed, 132 insertions(+), 62 deletions(-)

drivers/fastboot/fb_mmc.c +6 -3
index 71eeb02c8f..8e74e50e91 100644
@@ -76,12 +76,37 @@ static int raw_part_get_info_by_name(struct
 blk_desc *dev_desc, return 0;
  }
 
-static int part_get_info_by_name_or_alias(struct blk_desc
 *dev_desc,
-		const char *name, struct disk_partition *info)
+static int do_get_part_info(struct blk_desc **dev_desc, const
 char *name,
+			    struct disk_partition *info)
  {
  	int ret;
 
-	ret = part_get_info_by_name(dev_desc, name, info);
+	/* First try partition names on the default device */
+	*dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	if (*dev_desc) {
+		ret = part_get_info_by_name(*dev_desc, name,

info);

drivers/fastboot/fb_mmc.c +5 -0
+		if (ret >= 0)
+			return ret;
+
+		/* Then try raw partitions */
+		ret = raw_part_get_info_by_name(*dev_desc, name,

info);

drivers/fastboot/fb_mmc.c +6 -0
+		if (ret >= 0)
+			return ret;
+	}
+
+	/* Then try dev.hwpart:part */
+	ret = part_get_info_by_dev_and_name_or_num("mmc", name,

dev_desc,

drivers/fastboot/fb_mmc.c +5 -0
+						   info, true);
+	return ret;
+}
+
+static int part_get_info_by_name_or_alias(struct blk_desc

**dev_desc,

drivers/fastboot/fb_mmc.c +2 -0
+					  const char *name,
+					  struct disk_partition

*info) +{

drivers/fastboot/fb_mmc.c +3 -0
+	int ret;
+
+	ret = do_get_part_info(dev_desc, name, info);
  	if (ret < 0) {
  		/* strlen("fastboot_partition_alias_") +

PART_NAME_LEN + 1 */ char env_alias_name[25 + PART_NAME_LEN + 1];

drivers/fastboot/fb_mmc.c +0 -0
@@ -92,8 +117,8 @@ static int
 part_get_info_by_name_or_alias(struct blk_desc *dev_desc,

strncat(env_alias_name, name, PART_NAME_LEN); aliased_part_name = env_get(env_alias_name); if (aliased_part_name != NULL)

drivers/fastboot/fb_mmc.c +1 -2
-			ret = part_get_info_by_name(dev_desc,
-					aliased_part_name, info);
+			ret = do_get_part_info(dev_desc,

aliased_part_name,

drivers/fastboot/fb_mmc.c +11 -11
+					       info);
  	}
  	return ret;
  }
@@ -430,27 +455,49 @@ int fastboot_mmc_get_part_info(const char
 *part_name, struct blk_desc **dev_desc,
  			       struct disk_partition *part_info,
 char *response) {
-	int r = 0;
+	int ret;
 
-	*dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!*dev_desc) {
-		fastboot_fail("block device not found",
 response);
-		return -ENOENT;
-	}
  	if (!part_name || !strcmp(part_name, "")) {
  		fastboot_fail("partition not given", response);
  		return -ENOENT;
  	}
 
-	if (raw_part_get_info_by_name(*dev_desc, part_name,
 part_info) < 0) {
-		r = part_get_info_by_name_or_alias(*dev_desc,
 part_name, part_info);
-		if (r < 0) {
-			fastboot_fail("partition not found",
 response);
-			return r;
+	ret = part_get_info_by_name_or_alias(dev_desc, part_name,
 part_info);
+	if (ret < 0) {
+		switch (ret) {
+		case -ENOSYS:
+		case -EINVAL:
+			fastboot_fail("invalid partition or
 device", response);
+			break;
+		case -ENODEV:
+			fastboot_fail("no such device",

response);

drivers/fastboot/fb_mmc.c +3 -0
+			break;
+		case -ENOENT:
+			fastboot_fail("no such partition",

response);

drivers/fastboot/fb_mmc.c +3 -0
+			break;
+		case -EPROTONOSUPPORT:
+			fastboot_fail("unknown partition table

type", response);

drivers/fastboot/fb_mmc.c +3 -0
+			break;
+		default:
+			fastboot_fail("unanticipated error",

response);

drivers/fastboot/fb_mmc.c +8 -1
+			break;
  		}
  	}
 
-	return r;
+	return ret;
+}
+
+static struct blk_desc *fastboot_mmc_get_dev(char *response)
+{
+	struct blk_desc *ret = blk_get_dev("mmc",
+

CONFIG_FASTBOOT_FLASH_MMC_DEV); +

drivers/fastboot/fb_mmc.c +14 -11
+	if (!ret || ret->type == DEV_TYPE_UNKNOWN) {
+		pr_err("invalid mmc device\n");
+		fastboot_fail("invalid mmc device", response);
+		return NULL;
+	}
+	return ret;
  }
 
  /**
@@ -467,22 +514,19 @@ void fastboot_mmc_flash_write(const char
 *cmd, void *download_buffer, struct blk_desc *dev_desc;
  	struct disk_partition info;
 
-	dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
  #ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) {
-		fb_mmc_boot_ops(dev_desc, download_buffer, 1,
-				download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc,
 download_buffer, 1,
+					download_bytes,
 response); return;
  	}
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) {
-		fb_mmc_boot_ops(dev_desc, download_buffer, 2,
-				download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc,
 download_buffer, 1,
+					download_bytes,

response); return;
}
#endif

drivers/fastboot/fb_mmc.c +0 -0
@@ -494,6 +538,10 @@ void fastboot_mmc_flash_write(const char
 *cmd, void *download_buffer, if (strcmp(cmd,
 CONFIG_FASTBOOT_GPT_NAME) == 0 || strcmp(cmd,

CONFIG_FASTBOOT_MMC_USER_NAME) == 0) { #endif

drivers/fastboot/fb_mmc.c +4 -0
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
  		printf("%s: updating MBR, Primary and Backup

GPT(s)\n", __func__);
if (is_valid_gpt_buf(dev_desc,
download_buffer)) { @@ -517,6 +565,10 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
#if CONFIG_IS_ENABLED(DOS_PARTITION)
if (strcmp(cmd, CONFIG_FASTBOOT_MBR_NAME) == 0) {

drivers/fastboot/fb_mmc.c +4 -0
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
  		printf("%s: updating MBR\n", __func__);
  		if (is_valid_dos_buf(download_buffer)) {
  			printf("%s: invalid MBR - refusing to

write to flash\n", @@ -539,19 +591,16 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer,
#ifdef CONFIG_ANDROID_BOOT_IMAGE
if (strncasecmp(cmd, "zimage", 6) == 0) {

drivers/fastboot/fb_mmc.c +3 -2
-		fb_mmc_update_zimage(dev_desc, download_buffer,
-				     download_bytes, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_update_zimage(dev_desc,

download_buffer,

drivers/fastboot/fb_mmc.c +1 -0
+					     download_bytes,

response); return;
}
#endif

drivers/fastboot/fb_mmc.c +0 -1
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info) !=

0) {

drivers/fastboot/fb_mmc.c +0 -1
-		if (part_get_info_by_name_or_alias(dev_desc, cmd,

&info) < 0) {

drivers/fastboot/fb_mmc.c +0 -1
-			pr_err("cannot find partition: '%s'\n",

cmd);

drivers/fastboot/fb_mmc.c +0 -1
-			fastboot_fail("cannot find partition",

response);

drivers/fastboot/fb_mmc.c +1 -3
-			return;
-		}
-	}
+	if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info,

response) < 0)

drivers/fastboot/fb_mmc.c +7 -15
+		return;
 
  	if (is_sparse_image(download_buffer)) {
  		struct fb_mmc_sparse sparse_priv;
@@ -594,28 +643,19 @@ void fastboot_mmc_erase(const char *cmd,
 char *response) lbaint_t blks, blks_start, blks_size, grp_size;
  	struct mmc *mmc =
 find_mmc_device(CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (mmc == NULL) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
-	dev_desc = blk_get_dev("mmc",
 CONFIG_FASTBOOT_FLASH_MMC_DEV);
-	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-		pr_err("invalid mmc device\n");
-		fastboot_fail("invalid mmc device", response);
-		return;
-	}
-
  #ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) {
  		/* erase EMMC boot1 */
-		fb_mmc_boot_ops(dev_desc, NULL, 1, 0, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, NULL, 1, 0,
 response); return;
  	}
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) {
  		/* erase EMMC boot2 */
-		fb_mmc_boot_ops(dev_desc, NULL, 2, 0, response);
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (dev_desc)
+			fb_mmc_boot_ops(dev_desc, NULL, 1, 0,
 response); return;
  	}
  #endif
drivers/fastboot/fb_mmc.c +4 -0
@@ -623,6 +663,10 @@ void fastboot_mmc_erase(const char *cmd, char
 *response) #ifdef CONFIG_FASTBOOT_MMC_USER_SUPPORT
  	if (strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) {
  		/* erase EMMC userdata */
+		dev_desc = fastboot_mmc_get_dev(response);
+		if (!dev_desc)
+			return;
+
  		if (fb_mmc_erase_mmc_hwpart(dev_desc))
  			fastboot_fail("Failed to erase

EMMC_USER", response); else

drivers/fastboot/fb_mmc.c +1 -7
@@ -631,13 +675,8 @@ void fastboot_mmc_erase(const char *cmd, char
 *response) }
  #endif
 
-	if (raw_part_get_info_by_name(dev_desc, cmd, &info) !=
 0) {
-		if (part_get_info_by_name_or_alias(dev_desc, cmd,
 &info) < 0) {
-			pr_err("cannot find partition: '%s'\n",
 cmd);
-			fastboot_fail("cannot find partition",
 response);
-			return;
-		}
-	}
+	if (fastboot_mmc_get_part_info(cmd, &dev_desc, &info,

response) < 0)

drivers/fastboot/fb_mmc.c +1 -0
+		return;
 
  	/* Align blocks to erase group size to avoid erasing

other partitions */ grp_size = mmc->erase_grp_size;

test/dm/fastboot.c +2 -3
index 8f905d8fa8..e7f8c362b8 100644
@@ -35,9 +35,12 @@ static int dm_test_fastboot_mmc_part(struct
 unit_test_state *uts) },
  	};
 
-	ut_assertok(blk_get_device_by_str("mmc",
-
 __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV),
-					  &mmc_dev_desc));
+	/*
+	 * There are a lot of literal 0s I don't want to have to

construct from

test/dm/fastboot.c +4 -0
+	 * MMC_DEV.
+	 */
+	ut_asserteq(0, CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	ut_assertok(blk_get_device_by_str("mmc", "0",

&mmc_dev_desc)); if (CONFIG_IS_ENABLED(RANDOM_UUID)) {
gen_rand_uuid_str(parts[0].uuid,
UUID_STR_FORMAT_STD); gen_rand_uuid_str(parts[1].uuid, UUID_STR_FORMAT_STD); @@ -59,6 +62,34 @@ static int dm_test_fastboot_mmc_part(struct unit_test_state *uts) &part_info, response)); ut_assertok(env_set(FB_ALIAS_PREFIX "test3", NULL));

test/dm/fastboot.c +2 -0
+	/* "New" partition labels */
+	ut_asserteq(1, fastboot_mmc_get_part_info("#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0#test1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0:1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0:1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info("0.0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("0:0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("0.0:0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info("1.0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(1, fastboot_mmc_get_part_info(":1",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,

response));

test/dm/fastboot.c +1 -0
+	ut_asserteq(0, fastboot_mmc_get_part_info(":0",

&fb_dev_desc,

test/dm/fastboot.c +1 -0
+						  &part_info,
Quoted 5 lines

response)); +
return 0;
}
DM_TEST(dm_test_fastboot_mmc_part, UT_TESTF_SCAN_PDATA |
UT_TESTF_SCAN_FDT);

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
lukma at denx.de

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de

#13 lore raw

PATCH v4 8/9 fastboot: Allow u-boot-style partitions

Hello Sean, Lukasz,

Quoted 44 lines · Sean Anderson
Quoted 28 lines · Lukasz Majewski

Hi Sean,

Quoted 16 lines · Lukasz Majewski

? > Hi Sean,
? >
? >> This adds support for partitions of the form "dev.hwpart:part" and ? >> "dev#partname". This allows one to flash to eMMC boot partitions ? >> without having to use CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT. It also ? >> allows one to flash to an entire device without needing ? >> CONFIG_FASTBOOT_MMC_USER_NAME. Lastly, one can also flash MMC ? >> devices other than CONFIG_FASTBOOT_FLASH_MMC_DEV.
? >
? > This patch series causes following build errors:
? >
https://dev.azure.com/lukma633/U-Boot/_build/results?buildId=20&view=results

Yes, I saw those errors; they should be addressed in v5.

Quoted 9 lines

? >
? > I saw the v5 of this patch series. Could you check if it pass with ? > green the CI tests?

It is building at [1].

[1]
https://dev.azure.com/u-boot/u-boot/_build/results?buildId=1748&view=results.

Quoted 5 lines

Interesting as
https://dev.azure.com/lukma633/U-Boot/_build/results?buildId=22&view=logs&j=425537f6-562f-5a62-0856-6c59be70cbe4&t=62b0f1ee-aadf-504c-f243-098b7c952989

Still shows errors after applying patch v5 version.

It looks like it's due to the following construct in fastboot.h

#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
????FASTBOOT_COMMAND_OEM_BOOTBUS,
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
????FASTBOOT_COMMAND_ACMD,
????FASTBOOT_COMMAND_UCMD,
#endif

Quoted 3 lines

Which was added in 427f563 ("fastboot: add UUU command UCmd and ACmd support")

It seems like Heiko made an error while rebasing, CCing him.

Yes, sorry... once not triggered azure build before posting...

I send a v4, after azure build succeeds.

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#14 lore raw

PATCH v4 9/9 fastboot: Partition specification

In reply to Sean Anderson

This documents the way U-Boot understands partitions specifications. This also updates the fastboot documentation for the changes in the previous commit.

---

Changes in v4:
- Expand documentation, making it more man-page-like

Changes in v2:
- Move partition documentation under doc/usage

 doc/android/fastboot.rst |  4 ++
 doc/usage/index.rst      |  1 +
 doc/usage/partitions.rst | 80 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 doc/usage/partitions.rst
doc/android/fastboot.rst +4 -0
index 16b11399b3..ce513a2a0f 100644
@@ -154,6 +154,10 @@ The device index starts from ``a`` and refers to the interface (e.g. USB
 controller, SD/MMC controller) or disk index. The partition index starts
 from ``1`` and describes the partition number on the particular device.
 
+Alternatively, partition types may be specified using :ref:`U-Boot's partition
+syntax <partitions>`. This allows specifying partitions like ``0.1``,
+``0#boot``, or ``:3``. The interface is always ``mmc``.
+
 Writing Partition Table
 -----------------------
 
doc/usage/index.rst +1 -0
index 83cfbafd90..d45467caf2 100644
@@ -6,6 +6,7 @@ Use U-Boot
 
    fdt_overlays
    netconsole
+   partitions
 
 Shell commands
 --------------
doc/usage/partitions.rst new file +80 -0

80 lines not on this page · raw message

Signature · 1 line
2.25.1