public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/4] Fastboot MBR and generic partition support
@ 2016-09-09  8:27 Petr Kulhavy
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 1/4] disk: part: implement generic function part_get_info_by_name() Petr Kulhavy
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Petr Kulhavy @ 2016-09-09  8:27 UTC (permalink / raw)
  To: u-boot

This set extends the Fastboot implementation from GPT-only to any partition
support.  Further it adds a special target "mbr" (configurable) to write the
DOS MBR.

Version 2: 
Add a fourth patch into the set to move CONFIG_FASTBOOT_GPT_NAME and
CONFIG_FASTBOOT_MBR_NAME into cmd/fastboot/Kconfig

Petr Kulhavy (4):
  disk: part: implement generic function part_get_info_by_name()
  fastboot: add support for writing MBR
  disk: part: refactor generic name creation for DOS and ISO
  fastboot: move FASTBOOT_FLASH options into Kconfig

 README                      |  9 +++++-
 cmd/fastboot/Kconfig        | 24 ++++++++++++++++
 common/fb_mmc.c             | 41 +++++++++++++++++++--------
 disk/part.c                 | 58 +++++++++++++++++++++++++++++++++++++
 disk/part_amiga.c           |  1 +
 disk/part_dos.c             | 52 +++++++++++++++-------------------
 disk/part_efi.c             | 20 +------------
 disk/part_iso.c             | 26 ++---------------
 disk/part_mac.c             |  1 +
 doc/README.android-fastboot | 38 +++++++++++++++++++++++++
 include/part.h              | 69 +++++++++++++++++++++++++++++++++++++--------
 include/part_efi.h          |  1 -
 12 files changed, 243 insertions(+), 97 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 1/4] disk: part: implement generic function part_get_info_by_name()
  2016-09-09  8:27 [U-Boot] [PATCH v2 0/4] Fastboot MBR and generic partition support Petr Kulhavy
@ 2016-09-09  8:27 ` Petr Kulhavy
  2016-09-12 17:35   ` Steve Rae
                     ` (2 more replies)
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 2/4] fastboot: add support for writing MBR Petr Kulhavy
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 19+ messages in thread
From: Petr Kulhavy @ 2016-09-09  8:27 UTC (permalink / raw)
  To: u-boot

So far partition search by name has been supported only on the EFI partition
table. This patch extends the search to all partition tables.

Rename part_get_info_efi_by_name() to part_get_info_by_name(), move it from
part_efi.c into part.c and make it a generic function which traverses all part
drivers and searches all partitions (in the order given by the linked list).

For this a new variable struct part_driver.max_entries is added, which limits
the number of partitions searched. For EFI this was GPT_ENTRY_NUMBERS.
Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables.

Signed-off-by: Petr Kulhavy <brain@jikos.cz>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
v1: initial
v2: no change

 common/fb_mmc.c   |  4 ++--
 disk/part.c       | 26 ++++++++++++++++++++++++++
 disk/part_amiga.c |  1 +
 disk/part_dos.c   |  1 +
 disk/part_efi.c   | 20 +-------------------
 disk/part_iso.c   |  1 +
 disk/part_mac.c   |  1 +
 include/part.h    | 32 ++++++++++++++++++++------------
 8 files changed, 53 insertions(+), 33 deletions(-)

diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index 8d0524d..a0a4a83 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -27,7 +27,7 @@ static int part_get_info_efi_by_name_or_alias(struct blk_desc *dev_desc,
 {
 	int ret;
 
-	ret = part_get_info_efi_by_name(dev_desc, name, info);
+	ret = part_get_info_by_name(dev_desc, name, info);
 	if (ret) {
 		/* strlen("fastboot_partition_alias_") + 32(part_name) + 1 */
 		char env_alias_name[25 + 32 + 1];
@@ -38,7 +38,7 @@ static int part_get_info_efi_by_name_or_alias(struct blk_desc *dev_desc,
 		strncat(env_alias_name, name, 32);
 		aliased_part_name = getenv(env_alias_name);
 		if (aliased_part_name != NULL)
-			ret = part_get_info_efi_by_name(dev_desc,
+			ret = part_get_info_by_name(dev_desc,
 					aliased_part_name, info);
 	}
 	return ret;
diff --git a/disk/part.c b/disk/part.c
index 6a1c02d..8317e80 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -615,3 +615,29 @@ cleanup:
 	free(dup_str);
 	return ret;
 }
+
+int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
+	disk_partition_t *info)
+{
+	struct part_driver *first_drv =
+		ll_entry_start(struct part_driver, part_driver);
+	const int n_drvs = ll_entry_count(struct part_driver, part_driver);
+	struct part_driver *part_drv;
+
+	for (part_drv = first_drv; part_drv != first_drv + n_drvs; part_drv++) {
+		int ret;
+		int i;
+		for (i = 1; i < part_drv->max_entries; i++) {
+			ret = part_drv->get_info(dev_desc, i, info);
+			if (ret != 0) {
+				/* no more entries in table */
+				break;
+			}
+			if (strcmp(name, (const char *)info->name) == 0) {
+				/* matched */
+				return 0;
+			}
+		}
+	}
+	return -1;
+}
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index d4316b8..25fe56c 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -381,6 +381,7 @@ static void part_print_amiga(struct blk_desc *dev_desc)
 U_BOOT_PART_TYPE(amiga) = {
 	.name		= "AMIGA",
 	.part_type	= PART_TYPE_AMIGA,
+	.max_entries	= AMIGA_ENTRY_NUMBERS,
 	.get_info	= part_get_info_amiga,
 	.print		= part_print_amiga,
 	.test		= part_test_amiga,
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 511917a..8226601 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -300,6 +300,7 @@ int part_get_info_dos(struct blk_desc *dev_desc, int part,
 U_BOOT_PART_TYPE(dos) = {
 	.name		= "DOS",
 	.part_type	= PART_TYPE_DOS,
+	.max_entries	= DOS_ENTRY_NUMBERS,
 	.get_info	= part_get_info_ptr(part_get_info_dos),
 	.print		= part_print_ptr(part_print_dos),
 	.test		= part_test_dos,
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 8d67c09..1924338 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -296,25 +296,6 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
 	return 0;
 }
 
-int part_get_info_efi_by_name(struct blk_desc *dev_desc,
-	const char *name, disk_partition_t *info)
-{
-	int ret;
-	int i;
-	for (i = 1; i < GPT_ENTRY_NUMBERS; i++) {
-		ret = part_get_info_efi(dev_desc, i, info);
-		if (ret != 0) {
-			/* no more entries in table */
-			return -1;
-		}
-		if (strcmp(name, (const char *)info->name) == 0) {
-			/* matched */
-			return 0;
-		}
-	}
-	return -2;
-}
-
 static int part_test_efi(struct blk_desc *dev_desc)
 {
 	ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, dev_desc->blksz);
@@ -958,6 +939,7 @@ static int is_pte_valid(gpt_entry * pte)
 U_BOOT_PART_TYPE(a_efi) = {
 	.name		= "EFI",
 	.part_type	= PART_TYPE_EFI,
+	.max_entries	= GPT_ENTRY_NUMBERS,
 	.get_info	= part_get_info_ptr(part_get_info_efi),
 	.print		= part_print_ptr(part_print_efi),
 	.test		= part_test_efi,
diff --git a/disk/part_iso.c b/disk/part_iso.c
index f9a741d..78fc97e 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -257,6 +257,7 @@ static int part_test_iso(struct blk_desc *dev_desc)
 U_BOOT_PART_TYPE(iso) = {
 	.name		= "ISO",
 	.part_type	= PART_TYPE_ISO,
+	.max_entries	= ISO_ENTRY_NUMBERS,
 	.get_info	= part_get_info_iso,
 	.print		= part_print_iso,
 	.test		= part_test_iso,
diff --git a/disk/part_mac.c b/disk/part_mac.c
index 3952b8d..b6c082e 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -239,6 +239,7 @@ static int part_get_info_mac(struct blk_desc *dev_desc, int part,
 U_BOOT_PART_TYPE(mac) = {
 	.name		= "MAC",
 	.part_type	= PART_TYPE_MAC,
+	.max_entries	= MAC_ENTRY_NUMBERS,
 	.get_info	= part_get_info_mac,
 	.print		= part_print_mac,
 	.test		= part_test_mac,
diff --git a/include/part.h b/include/part.h
index 226b5be..bd8fd49 100644
--- a/include/part.h
+++ b/include/part.h
@@ -28,6 +28,11 @@ struct block_drvr {
 #define PART_TYPE_AMIGA		0x04
 #define PART_TYPE_EFI		0x05
 
+/* maximum number of partition entries supported by search */
+#define DOS_ENTRY_NUMBERS	8
+#define ISO_ENTRY_NUMBERS	64
+#define MAC_ENTRY_NUMBERS	64
+#define AMIGA_ENTRY_NUMBERS	8
 /*
  * Type string for U-Boot bootable partitions
  */
@@ -146,6 +151,20 @@ int blk_get_device_by_str(const char *ifname, const char *dev_str,
 int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 			    struct blk_desc **dev_desc,
 			    disk_partition_t *info, int allow_whole_dev);
+
+/**
+ * part_get_info_by_name() - Search for a partition by name
+ *                           among all available registered partitions
+ *
+ * @param dev_desc - block device descriptor
+ * @param gpt_name - the specified table entry name
+ * @param info - returns the disk partition info
+ *
+ * @return - '0' on match, '-1' on no match, otherwise error
+ */
+int part_get_info_by_name(struct blk_desc *dev_desc,
+			      const char *name, disk_partition_t *info);
+
 extern const struct block_drvr block_drvr[];
 #else
 static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
@@ -189,6 +208,7 @@ static inline int blk_get_device_part_str(const char *ifname,
 struct part_driver {
 	const char *name;
 	int part_type;
+	const int max_entries;	/* maximum number of entries to search */
 
 	/**
 	 * get_info() - Get information about a partition
@@ -225,18 +245,6 @@ struct part_driver {
 #include <part_efi.h>
 /* disk/part_efi.c */
 /**
- * part_get_info_efi_by_name() - Find the specified GPT partition table entry
- *
- * @param dev_desc - block device descriptor
- * @param gpt_name - the specified table entry name
- * @param info - returns the disk partition info
- *
- * @return - '0' on match, '-1' on no match, otherwise error
- */
-int part_get_info_efi_by_name(struct blk_desc *dev_desc,
-			      const char *name, disk_partition_t *info);
-
-/**
  * write_gpt_table() - Write the GUID Partition Table to disk
  *
  * @param dev_desc - block device descriptor
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 2/4] fastboot: add support for writing MBR
  2016-09-09  8:27 [U-Boot] [PATCH v2 0/4] Fastboot MBR and generic partition support Petr Kulhavy
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 1/4] disk: part: implement generic function part_get_info_by_name() Petr Kulhavy
@ 2016-09-09  8:27 ` Petr Kulhavy
  2016-09-12 17:38   ` Steve Rae
                     ` (2 more replies)
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 3/4] disk: part: refactor generic name creation for DOS and ISO Petr Kulhavy
                   ` (2 subsequent siblings)
  4 siblings, 3 replies; 19+ messages in thread
From: Petr Kulhavy @ 2016-09-09  8:27 UTC (permalink / raw)
  To: u-boot

Add special target "mbr" (otherwise configurable via CONFIG_FASTBOOT_MBR_NAME)
to write MBR partition table.
Partitions are now searched using the generic function which finds any
partiiton by name. For MBR the partition names hda1, sda1, etc. are used.

Signed-off-by: Petr Kulhavy <brain@jikos.cz>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
v1: initial
v2: no change

 README                      |  7 +++++++
 common/fb_mmc.c             | 40 ++++++++++++++++++++++++++++++++++------
 disk/part_dos.c             | 20 ++++++++++++++++++++
 doc/README.android-fastboot | 37 +++++++++++++++++++++++++++++++++++++
 include/part.h              | 23 +++++++++++++++++++++++
 5 files changed, 121 insertions(+), 6 deletions(-)

diff --git a/README b/README
index 30d7ee3..f6ef8b8 100644
--- a/README
+++ b/README
@@ -1682,6 +1682,13 @@ The following options need to be configured:
 		"fastboot flash" command line matches this value.
 		Default is GPT_ENTRY_NAME (currently "gpt") if undefined.
 
+		CONFIG_FASTBOOT_MBR_NAME
+		The fastboot "flash" command supports writing the downloaded
+		image to DOS MBR.
+		This occurs when the "partition name" specified on the
+		"fastboot flash" command line matches this value.
+		If not defined the default value "mbr" is used.
+
 - Journaling Flash filesystem support:
 		CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE,
 		CONFIG_JFFS2_NAND_DEV
diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index a0a4a83..4bc68a7 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -14,15 +14,20 @@
 #include <mmc.h>
 #include <div64.h>
 
-#ifndef CONFIG_FASTBOOT_GPT_NAME
+#if defined(CONFIG_EFI_PARTITION) && !defined(CONFIG_FASTBOOT_GPT_NAME)
 #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME
 #endif
 
+
+#if defined(CONFIG_DOS_PARTITION) && !defined(CONFIG_FASTBOOT_MBR_NAME)
+#define CONFIG_FASTBOOT_MBR_NAME "mbr"
+#endif
+
 struct fb_mmc_sparse {
 	struct blk_desc	*dev_desc;
 };
 
-static int part_get_info_efi_by_name_or_alias(struct blk_desc *dev_desc,
+static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
 		const char *name, disk_partition_t *info)
 {
 	int ret;
@@ -103,6 +108,7 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
 		return;
 	}
 
+#ifdef CONFIG_EFI_PARTITION
 	if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0) {
 		printf("%s: updating MBR, Primary and Backup GPT(s)\n",
 		       __func__);
@@ -114,14 +120,36 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
 		}
 		if (write_mbr_and_gpt_partitions(dev_desc, download_buffer)) {
 			printf("%s: writing GPT partitions failed\n", __func__);
-			fastboot_fail(
-				      "writing GPT partitions failed");
+			fastboot_fail("writing GPT partitions failed");
 			return;
 		}
 		printf("........ success\n");
 		fastboot_okay("");
 		return;
-	} else if (part_get_info_efi_by_name_or_alias(dev_desc, cmd, &info)) {
+	}
+#endif
+
+#ifdef CONFIG_DOS_PARTITION
+	if (strcmp(cmd, CONFIG_FASTBOOT_MBR_NAME) == 0) {
+		printf("%s: updating MBR\n", __func__);
+		if (is_valid_dos_buf(download_buffer)) {
+			printf("%s: invalid MBR - refusing to write to flash\n",
+			       __func__);
+			fastboot_fail("invalid MBR partition");
+			return;
+		}
+		if (write_mbr_partition(dev_desc, download_buffer)) {
+			printf("%s: writing MBR partition failed\n", __func__);
+			fastboot_fail("writing MBR partition failed");
+			return;
+		}
+		printf("........ success\n");
+		fastboot_okay("");
+		return;
+	}
+#endif
+
+	if (part_get_info_by_name_or_alias(dev_desc, cmd, &info)) {
 		error("cannot find partition: '%s'\n", cmd);
 		fastboot_fail("cannot find partition");
 		return;
@@ -172,7 +200,7 @@ void fb_mmc_erase(const char *cmd)
 		return;
 	}
 
-	ret = part_get_info_efi_by_name_or_alias(dev_desc, cmd, &info);
+	ret = part_get_info_by_name_or_alias(dev_desc, cmd, &info);
 	if (ret) {
 		error("cannot find partition: '%s'", cmd);
 		fastboot_fail("cannot find partition");
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 8226601..8e6aae5 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -297,6 +297,26 @@ int part_get_info_dos(struct blk_desc *dev_desc, int part,
 	return part_get_info_extended(dev_desc, 0, 0, 1, part, info, 0);
 }
 
+int is_valid_dos_buf(void *buf)
+{
+	return test_block_type(buf) == DOS_MBR ? 0 : -1;
+}
+
+int write_mbr_partition(struct blk_desc *dev_desc, void *buf)
+{
+	if (is_valid_dos_buf(buf))
+		return -1;
+
+	/* write MBR */
+	if (blk_dwrite(dev_desc, 0, 1, buf) != 1) {
+		printf("%s: failed writing '%s' (1 blks at 0x0)\n",
+		       __func__, "MBR");
+		return 1;
+	}
+
+	return 0;
+}
+
 U_BOOT_PART_TYPE(dos) = {
 	.name		= "DOS",
 	.part_type	= PART_TYPE_DOS,
diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot
index ce12bc5..dea7066 100644
--- a/doc/README.android-fastboot
+++ b/doc/README.android-fastboot
@@ -59,6 +59,43 @@ To define a partition alias add an environment variable similar to:
 fastboot_partition_alias_<alias partition name>=<actual partition name>
 Example: fastboot_partition_alias_boot=LNX
 
+Partition Names
+===============
+The Fastboot implementation in U-boot allows to write images into disk
+partitions (currently on eMMC). Target partitions are referred on the host
+computer by their names.
+
+For GPT/EFI the respective partition name is used.
+
+For MBR the partitions are referred by generic names according to the
+following schema:
+
+  <device type> <device index letter> <partition index>
+
+Example: hda3, sdb1, usbda1
+
+The device type is as follows:
+
+  * IDE, ATAPI and SATA disks: hd
+  * SCSI disks: sd
+  * USB media: usbd
+  * Disk on chip: docd
+  * other: xx
+
+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.
+
+Writing Partition Table
+=======================
+Fastboot also allows to write the partition table to the media. This can be
+done by writing the respective partition table image to a special target
+"gpt" or "mbr". These names can be customized by defining the following
+configuration options:
+
+CONFIG_FASTBOOT_GPT_NAME
+CONFIG_FASTBOOT_MBR_NAME
+
 In Action
 =========
 Enter into fastboot by executing the fastboot command in u-boot and you
diff --git a/include/part.h b/include/part.h
index bd8fd49..b17c219 100644
--- a/include/part.h
+++ b/include/part.h
@@ -351,4 +351,27 @@ int gpt_verify_partitions(struct blk_desc *dev_desc,
 			  gpt_header *gpt_head, gpt_entry **gpt_pte);
 #endif
 
+#ifdef CONFIG_DOS_PARTITION
+/**
+ * is_valid_dos_buf() - Ensure that a DOS MBR image is valid
+ *
+ * @param buf - buffer which contains the MBR
+ *
+ * @return - '0' on success, otherwise error
+ */
+int is_valid_dos_buf(void *buf);
+
+/**
+ * write_mbr_partition() - write DOS MBR
+ *
+ * @param dev_desc - block device descriptor
+ * @param buf - buffer which contains the MBR
+ *
+ * @return - '0' on success, otherwise error
+ */
+int write_mbr_partition(struct blk_desc *dev_desc, void *buf);
+
+#endif
+
+
 #endif /* _PART_H */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 3/4] disk: part: refactor generic name creation for DOS and ISO
  2016-09-09  8:27 [U-Boot] [PATCH v2 0/4] Fastboot MBR and generic partition support Petr Kulhavy
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 1/4] disk: part: implement generic function part_get_info_by_name() Petr Kulhavy
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 2/4] fastboot: add support for writing MBR Petr Kulhavy
@ 2016-09-09  8:27 ` Petr Kulhavy
  2016-09-12 17:39   ` Steve Rae
                     ` (2 more replies)
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 4/4] fastboot: move FASTBOOT_FLASH options into Kconfig Petr Kulhavy
  2016-09-12 17:42 ` [U-Boot] [PATCH v2 0/4] Fastboot MBR and generic partition support Steve Rae
  4 siblings, 3 replies; 19+ messages in thread
From: Petr Kulhavy @ 2016-09-09  8:27 UTC (permalink / raw)
  To: u-boot

In both DOS and ISO partition tables the same code to create partition name
like "hda1" was repeated.

Code moved to into a new function part_set_generic_name() in part.c and optimized.
Added recognition of MMC and SD types, name is like "mmcsda1".

Signed-off-by: Petr Kulhavy <brain@jikos.cz>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
v1: initial
v2: no change

 disk/part.c                 | 32 ++++++++++++++++++++++++++++++++
 disk/part_dos.c             | 31 ++-----------------------------
 disk/part_iso.c             | 25 +------------------------
 doc/README.android-fastboot |  1 +
 include/part.h              | 14 ++++++++++++++
 5 files changed, 50 insertions(+), 53 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index 8317e80..9f51a07 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -641,3 +641,35 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
 	}
 	return -1;
 }
+
+void part_set_generic_name(const struct blk_desc *dev_desc,
+	int part_num, char *name)
+{
+	char *devtype;
+
+	switch (dev_desc->if_type) {
+	case IF_TYPE_IDE:
+	case IF_TYPE_SATA:
+	case IF_TYPE_ATAPI:
+		devtype = "hd";
+		break;
+	case IF_TYPE_SCSI:
+		devtype = "sd";
+		break;
+	case IF_TYPE_USB:
+		devtype = "usbd";
+		break;
+	case IF_TYPE_DOC:
+		devtype = "docd";
+		break;
+	case IF_TYPE_MMC:
+	case IF_TYPE_SD:
+		devtype = "mmcsd";
+		break;
+	default:
+		devtype = "xx";
+		break;
+	}
+
+	sprintf(name, "%s%c%d", devtype, 'a' + dev_desc->devnum, part_num);
+}
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 8e6aae5..ed78334 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -209,35 +209,8 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
 			info->start = (lbaint_t)(ext_part_sector +
 					le32_to_int(pt->start4));
 			info->size  = (lbaint_t)le32_to_int(pt->size4);
-			switch(dev_desc->if_type) {
-				case IF_TYPE_IDE:
-				case IF_TYPE_SATA:
-				case IF_TYPE_ATAPI:
-					sprintf((char *)info->name, "hd%c%d",
-						'a' + dev_desc->devnum,
-						part_num);
-					break;
-				case IF_TYPE_SCSI:
-					sprintf((char *)info->name, "sd%c%d",
-						'a' + dev_desc->devnum,
-						part_num);
-					break;
-				case IF_TYPE_USB:
-					sprintf((char *)info->name, "usbd%c%d",
-						'a' + dev_desc->devnum,
-						part_num);
-					break;
-				case IF_TYPE_DOC:
-					sprintf((char *)info->name, "docd%c%d",
-						'a' + dev_desc->devnum,
-						part_num);
-					break;
-				default:
-					sprintf((char *)info->name, "xx%c%d",
-						'a' + dev_desc->devnum,
-						part_num);
-					break;
-			}
+			part_set_generic_name(dev_desc, part_num,
+					      (char *)info->name);
 			/* sprintf(info->type, "%d, pt->sys_ind); */
 			strcpy((char *)info->type, "U-Boot");
 			info->bootable = is_bootable(pt);
diff --git a/disk/part_iso.c b/disk/part_iso.c
index 78fc97e..bb8ed65 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -137,30 +137,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
 	entry_num=1;
 	offset=0x20;
 	strcpy((char *)info->type, "U-Boot");
-	switch(dev_desc->if_type) {
-		case IF_TYPE_IDE:
-		case IF_TYPE_SATA:
-		case IF_TYPE_ATAPI:
-			sprintf ((char *)info->name, "hd%c%d",
-				'a' + dev_desc->devnum, part_num);
-			break;
-		case IF_TYPE_SCSI:
-			sprintf ((char *)info->name, "sd%c%d",
-				'a' + dev_desc->devnum, part_num);
-			break;
-		case IF_TYPE_USB:
-			sprintf ((char *)info->name, "usbd%c%d",
-				'a' + dev_desc->devnum, part_num);
-			break;
-		case IF_TYPE_DOC:
-			sprintf ((char *)info->name, "docd%c%d",
-				'a' + dev_desc->devnum, part_num);
-			break;
-		default:
-			sprintf ((char *)info->name, "xx%c%d",
-				'a' + dev_desc->devnum, part_num);
-			break;
-	}
+	part_set_generic_name(dev_desc, part_num, (char *)info->name);
 	/* the bootcatalog (including validation Entry) is limited to 2048Bytes
 	 * (63 boot entries + validation entry) */
 	 while(offset<2048) {
diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot
index dea7066..b8afa15 100644
--- a/doc/README.android-fastboot
+++ b/doc/README.android-fastboot
@@ -79,6 +79,7 @@ The device type is as follows:
   * IDE, ATAPI and SATA disks: hd
   * SCSI disks: sd
   * USB media: usbd
+  * MMC and SD cards: mmcsd
   * Disk on chip: docd
   * other: xx
 
diff --git a/include/part.h b/include/part.h
index b17c219..0979005 100644
--- a/include/part.h
+++ b/include/part.h
@@ -165,6 +165,20 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 int part_get_info_by_name(struct blk_desc *dev_desc,
 			      const char *name, disk_partition_t *info);
 
+/**
+ * part_set_generic_name() - create generic partition like hda1 or sdb2
+ *
+ * Helper function for partition tables, which don't hold partition names
+ * (DOS, ISO). Generates partition name out of the device type and partition
+ * number.
+ *
+ * @dev_desc:	pointer to the block device
+ * @part_num:	partition number for which the name is generated
+ * @name:	buffer where the name is written
+ */
+void part_set_generic_name(const struct blk_desc *dev_desc,
+	int part_num, char *name);
+
 extern const struct block_drvr block_drvr[];
 #else
 static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 4/4] fastboot: move FASTBOOT_FLASH options into Kconfig
  2016-09-09  8:27 [U-Boot] [PATCH v2 0/4] Fastboot MBR and generic partition support Petr Kulhavy
                   ` (2 preceding siblings ...)
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 3/4] disk: part: refactor generic name creation for DOS and ISO Petr Kulhavy
@ 2016-09-09  8:27 ` Petr Kulhavy
  2016-09-09 13:56   ` Tom Rini
                     ` (2 more replies)
  2016-09-12 17:42 ` [U-Boot] [PATCH v2 0/4] Fastboot MBR and generic partition support Steve Rae
  4 siblings, 3 replies; 19+ messages in thread
From: Petr Kulhavy @ 2016-09-09  8:27 UTC (permalink / raw)
  To: u-boot

Move FASTBOOT_MBR_NAME and FASTBOOT_GPT_NAME into Kconfig.
Add dependency on the FASTBOOT_FLASH setting (also for FASTBOOT_MBR_NAME).
Remove the now redundant GPT_ENTRY_NAME.

Signed-off-by: Petr Kulhavy <brain@jikos.cz>
---
v2: initial

 README               |  2 +-
 cmd/fastboot/Kconfig | 24 ++++++++++++++++++++++++
 common/fb_mmc.c      |  9 ---------
 include/part_efi.h   |  1 -
 4 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/README b/README
index f6ef8b8..9852f88 100644
--- a/README
+++ b/README
@@ -1680,7 +1680,7 @@ The following options need to be configured:
 		to generate and write the Backup GUID Partition Table.)
 		This occurs when the specified "partition name" on the
 		"fastboot flash" command line matches this value.
-		Default is GPT_ENTRY_NAME (currently "gpt") if undefined.
+		The default is "gpt" if undefined.
 
 		CONFIG_FASTBOOT_MBR_NAME
 		The fastboot "flash" command supports writing the downloaded
diff --git a/cmd/fastboot/Kconfig b/cmd/fastboot/Kconfig
index a93d1c0..5d2facc 100644
--- a/cmd/fastboot/Kconfig
+++ b/cmd/fastboot/Kconfig
@@ -50,11 +50,35 @@ config FASTBOOT_FLASH
 
 config FASTBOOT_FLASH_MMC_DEV
 	int "Define FASTBOOT MMC FLASH default device"
+	depends on FASTBOOT_FLASH
 	help
 	  The fastboot "flash" command requires additional information
 	  regarding the non-volatile storage device. Define this to
 	  the eMMC device that fastboot should use to store the image.
 
+config FASTBOOT_GPT_NAME
+	string "Target name for updating GPT"
+	depends on FASTBOOT_FLASH
+	default "gpt"
+	help
+	  The fastboot "flash" command supports writing the downloaded
+	  image to the Protective MBR and the Primary GUID Partition
+	  Table. (Additionally, this downloaded image is post-processed
+	  to generate and write the Backup GUID Partition Table.)
+	  This occurs when the specified "partition name" on the
+	  "fastboot flash" command line matches the value defined here.
+	  The default target name for updating GPT is "gpt".
+
+config FASTBOOT_MBR_NAME
+	string "Target name for updating MBR"
+	depends on FASTBOOT_FLASH
+	default "mbr"
+	help
+	  The fastboot "flash" command allows to write the downloaded image
+	  to the Master Boot Record. This occurs when the "partition name"
+	  specified on the "fastboot flash" command line matches the value
+	  defined here. The default target name for updating MBR is "mbr".
+
 endif # USB_FUNCTION_FASTBOOT
 
 endmenu
diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index 4bc68a7..ea8ec4a 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -14,15 +14,6 @@
 #include <mmc.h>
 #include <div64.h>
 
-#if defined(CONFIG_EFI_PARTITION) && !defined(CONFIG_FASTBOOT_GPT_NAME)
-#define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME
-#endif
-
-
-#if defined(CONFIG_DOS_PARTITION) && !defined(CONFIG_FASTBOOT_MBR_NAME)
-#define CONFIG_FASTBOOT_MBR_NAME "mbr"
-#endif
-
 struct fb_mmc_sparse {
 	struct blk_desc	*dev_desc;
 };
diff --git a/include/part_efi.h b/include/part_efi.h
index c8fc873..317c044 100644
--- a/include/part_efi.h
+++ b/include/part_efi.h
@@ -27,7 +27,6 @@
 #define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
 #define GPT_HEADER_REVISION_V1 0x00010000
 #define GPT_PRIMARY_PARTITION_TABLE_LBA 1ULL
-#define GPT_ENTRY_NAME "gpt"
 #define GPT_ENTRY_NUMBERS		128
 #define GPT_ENTRY_SIZE			128
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 4/4] fastboot: move FASTBOOT_FLASH options into Kconfig
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 4/4] fastboot: move FASTBOOT_FLASH options into Kconfig Petr Kulhavy
@ 2016-09-09 13:56   ` Tom Rini
  2016-09-12 17:41     ` Steve Rae
  2016-09-19  0:57   ` Simon Glass
  2016-10-03 13:37   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2 siblings, 1 reply; 19+ messages in thread
From: Tom Rini @ 2016-09-09 13:56 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 09, 2016 at 10:27:18AM +0200, Petr Kulhavy wrote:

> Move FASTBOOT_MBR_NAME and FASTBOOT_GPT_NAME into Kconfig.
> Add dependency on the FASTBOOT_FLASH setting (also for FASTBOOT_MBR_NAME).
> Remove the now redundant GPT_ENTRY_NAME.
> 
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160909/8e81ceac/attachment.sig>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 1/4] disk: part: implement generic function part_get_info_by_name()
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 1/4] disk: part: implement generic function part_get_info_by_name() Petr Kulhavy
@ 2016-09-12 17:35   ` Steve Rae
  2016-09-19  0:57   ` Simon Glass
  2016-10-03 13:36   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2 siblings, 0 replies; 19+ messages in thread
From: Steve Rae @ 2016-09-12 17:35 UTC (permalink / raw)
  To: u-boot

Hi Petr,

On Fri, Sep 9, 2016 at 1:27 AM, Petr Kulhavy <brain@jikos.cz> wrote:
> So far partition search by name has been supported only on the EFI partition
> table. This patch extends the search to all partition tables.
>
> Rename part_get_info_efi_by_name() to part_get_info_by_name(), move it from
> part_efi.c into part.c and make it a generic function which traverses all part
> drivers and searches all partitions (in the order given by the linked list).
>
> For this a new variable struct part_driver.max_entries is added, which limits
> the number of partitions searched. For EFI this was GPT_ENTRY_NUMBERS.
> Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables.
>
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
> v1: initial
> v2: no change
>
>  common/fb_mmc.c   |  4 ++--
>  disk/part.c       | 26 ++++++++++++++++++++++++++
>  disk/part_amiga.c |  1 +
>  disk/part_dos.c   |  1 +
>  disk/part_efi.c   | 20 +-------------------
>  disk/part_iso.c   |  1 +
>  disk/part_mac.c   |  1 +
>  include/part.h    | 32 ++++++++++++++++++++------------
>  8 files changed, 53 insertions(+), 33 deletions(-)
>
> diff --git a/common/fb_mmc.c b/common/fb_mmc.c
> index 8d0524d..a0a4a83 100644
> --- a/common/fb_mmc.c
> +++ b/common/fb_mmc.c
> @@ -27,7 +27,7 @@ static int part_get_info_efi_by_name_or_alias(struct blk_desc *dev_desc,
>  {
>         int ret;
>
> -       ret = part_get_info_efi_by_name(dev_desc, name, info);
> +       ret = part_get_info_by_name(dev_desc, name, info);
>         if (ret) {
>                 /* strlen("fastboot_partition_alias_") + 32(part_name) + 1 */
>                 char env_alias_name[25 + 32 + 1];
> @@ -38,7 +38,7 @@ static int part_get_info_efi_by_name_or_alias(struct blk_desc *dev_desc,
>                 strncat(env_alias_name, name, 32);
>                 aliased_part_name = getenv(env_alias_name);
>                 if (aliased_part_name != NULL)
> -                       ret = part_get_info_efi_by_name(dev_desc,
> +                       ret = part_get_info_by_name(dev_desc,
>                                         aliased_part_name, info);
>         }
>         return ret;
> diff --git a/disk/part.c b/disk/part.c
> index 6a1c02d..8317e80 100644
> --- a/disk/part.c
> +++ b/disk/part.c
> @@ -615,3 +615,29 @@ cleanup:
>         free(dup_str);
>         return ret;
>  }
> +
> +int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
> +       disk_partition_t *info)
> +{
> +       struct part_driver *first_drv =
> +               ll_entry_start(struct part_driver, part_driver);
> +       const int n_drvs = ll_entry_count(struct part_driver, part_driver);
> +       struct part_driver *part_drv;
> +
> +       for (part_drv = first_drv; part_drv != first_drv + n_drvs; part_drv++) {
> +               int ret;
> +               int i;
> +               for (i = 1; i < part_drv->max_entries; i++) {
> +                       ret = part_drv->get_info(dev_desc, i, info);
> +                       if (ret != 0) {
> +                               /* no more entries in table */
> +                               break;
> +                       }
> +                       if (strcmp(name, (const char *)info->name) == 0) {
> +                               /* matched */
> +                               return 0;
> +                       }
> +               }
> +       }
> +       return -1;
> +}

I am a little concerned about the additional feature in this code...
This function previously only searched for the "name" in the device
specified by "FASTBOOT_FLASH_MMC_DEV",
now it seems to be searching through multiple entries (... the
"part_drv" loop ...)
Anyway, it seems to still work properly on my boards, so I guess it is
OK for now....



> diff --git a/disk/part_amiga.c b/disk/part_amiga.c
> index d4316b8..25fe56c 100644
> --- a/disk/part_amiga.c
> +++ b/disk/part_amiga.c
> @@ -381,6 +381,7 @@ static void part_print_amiga(struct blk_desc *dev_desc)
>  U_BOOT_PART_TYPE(amiga) = {
>         .name           = "AMIGA",
>         .part_type      = PART_TYPE_AMIGA,
> +       .max_entries    = AMIGA_ENTRY_NUMBERS,
>         .get_info       = part_get_info_amiga,
>         .print          = part_print_amiga,
>         .test           = part_test_amiga,
> diff --git a/disk/part_dos.c b/disk/part_dos.c
> index 511917a..8226601 100644
> --- a/disk/part_dos.c
> +++ b/disk/part_dos.c
> @@ -300,6 +300,7 @@ int part_get_info_dos(struct blk_desc *dev_desc, int part,
>  U_BOOT_PART_TYPE(dos) = {
>         .name           = "DOS",
>         .part_type      = PART_TYPE_DOS,
> +       .max_entries    = DOS_ENTRY_NUMBERS,
>         .get_info       = part_get_info_ptr(part_get_info_dos),
>         .print          = part_print_ptr(part_print_dos),
>         .test           = part_test_dos,
> diff --git a/disk/part_efi.c b/disk/part_efi.c
> index 8d67c09..1924338 100644
> --- a/disk/part_efi.c
> +++ b/disk/part_efi.c
> @@ -296,25 +296,6 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
>         return 0;
>  }
>
> -int part_get_info_efi_by_name(struct blk_desc *dev_desc,
> -       const char *name, disk_partition_t *info)
> -{
> -       int ret;
> -       int i;
> -       for (i = 1; i < GPT_ENTRY_NUMBERS; i++) {
> -               ret = part_get_info_efi(dev_desc, i, info);
> -               if (ret != 0) {
> -                       /* no more entries in table */
> -                       return -1;
> -               }
> -               if (strcmp(name, (const char *)info->name) == 0) {
> -                       /* matched */
> -                       return 0;
> -               }
> -       }
> -       return -2;
> -}
> -
>  static int part_test_efi(struct blk_desc *dev_desc)
>  {
>         ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, dev_desc->blksz);
> @@ -958,6 +939,7 @@ static int is_pte_valid(gpt_entry * pte)
>  U_BOOT_PART_TYPE(a_efi) = {
>         .name           = "EFI",
>         .part_type      = PART_TYPE_EFI,
> +       .max_entries    = GPT_ENTRY_NUMBERS,
>         .get_info       = part_get_info_ptr(part_get_info_efi),
>         .print          = part_print_ptr(part_print_efi),
>         .test           = part_test_efi,
> diff --git a/disk/part_iso.c b/disk/part_iso.c
> index f9a741d..78fc97e 100644
> --- a/disk/part_iso.c
> +++ b/disk/part_iso.c
> @@ -257,6 +257,7 @@ static int part_test_iso(struct blk_desc *dev_desc)
>  U_BOOT_PART_TYPE(iso) = {
>         .name           = "ISO",
>         .part_type      = PART_TYPE_ISO,
> +       .max_entries    = ISO_ENTRY_NUMBERS,
>         .get_info       = part_get_info_iso,
>         .print          = part_print_iso,
>         .test           = part_test_iso,
> diff --git a/disk/part_mac.c b/disk/part_mac.c
> index 3952b8d..b6c082e 100644
> --- a/disk/part_mac.c
> +++ b/disk/part_mac.c
> @@ -239,6 +239,7 @@ static int part_get_info_mac(struct blk_desc *dev_desc, int part,
>  U_BOOT_PART_TYPE(mac) = {
>         .name           = "MAC",
>         .part_type      = PART_TYPE_MAC,
> +       .max_entries    = MAC_ENTRY_NUMBERS,
>         .get_info       = part_get_info_mac,
>         .print          = part_print_mac,
>         .test           = part_test_mac,
> diff --git a/include/part.h b/include/part.h
> index 226b5be..bd8fd49 100644
> --- a/include/part.h
> +++ b/include/part.h
> @@ -28,6 +28,11 @@ struct block_drvr {
>  #define PART_TYPE_AMIGA                0x04
>  #define PART_TYPE_EFI          0x05
>
> +/* maximum number of partition entries supported by search */
> +#define DOS_ENTRY_NUMBERS      8
> +#define ISO_ENTRY_NUMBERS      64
> +#define MAC_ENTRY_NUMBERS      64
> +#define AMIGA_ENTRY_NUMBERS    8
>  /*
>   * Type string for U-Boot bootable partitions
>   */
> @@ -146,6 +151,20 @@ int blk_get_device_by_str(const char *ifname, const char *dev_str,
>  int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
>                             struct blk_desc **dev_desc,
>                             disk_partition_t *info, int allow_whole_dev);
> +
> +/**
> + * part_get_info_by_name() - Search for a partition by name
> + *                           among all available registered partitions
> + *
> + * @param dev_desc - block device descriptor
> + * @param gpt_name - the specified table entry name
> + * @param info - returns the disk partition info
> + *
> + * @return - '0' on match, '-1' on no match, otherwise error
> + */
> +int part_get_info_by_name(struct blk_desc *dev_desc,
> +                             const char *name, disk_partition_t *info);
> +
>  extern const struct block_drvr block_drvr[];
>  #else
>  static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
> @@ -189,6 +208,7 @@ static inline int blk_get_device_part_str(const char *ifname,
>  struct part_driver {
>         const char *name;
>         int part_type;
> +       const int max_entries;  /* maximum number of entries to search */
>
>         /**
>          * get_info() - Get information about a partition
> @@ -225,18 +245,6 @@ struct part_driver {
>  #include <part_efi.h>
>  /* disk/part_efi.c */
>  /**
> - * part_get_info_efi_by_name() - Find the specified GPT partition table entry
> - *
> - * @param dev_desc - block device descriptor
> - * @param gpt_name - the specified table entry name
> - * @param info - returns the disk partition info
> - *
> - * @return - '0' on match, '-1' on no match, otherwise error
> - */
> -int part_get_info_efi_by_name(struct blk_desc *dev_desc,
> -                             const char *name, disk_partition_t *info);
> -
> -/**
>   * write_gpt_table() - Write the GUID Partition Table to disk
>   *
>   * @param dev_desc - block device descriptor
> --
> 2.7.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.deenteries
> http://lists.denx.de/mailman/listinfo/u-boot

Acked-by: Steve Rae <steve.rae@raedomain.com>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 2/4] fastboot: add support for writing MBR
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 2/4] fastboot: add support for writing MBR Petr Kulhavy
@ 2016-09-12 17:38   ` Steve Rae
  2016-09-19  0:57   ` Simon Glass
  2016-10-03 13:36   ` [U-Boot] [U-Boot,v2,2/4] " Tom Rini
  2 siblings, 0 replies; 19+ messages in thread
From: Steve Rae @ 2016-09-12 17:38 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 9, 2016 at 1:27 AM, Petr Kulhavy <brain@jikos.cz> wrote:
> Add special target "mbr" (otherwise configurable via CONFIG_FASTBOOT_MBR_NAME)
> to write MBR partition table.
> Partitions are now searched using the generic function which finds any
> partiiton by name. For MBR the partition names hda1, sda1, etc. are used.
>
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
> v1: initial
> v2: no change
>
>  README                      |  7 +++++++
>  common/fb_mmc.c             | 40 ++++++++++++++++++++++++++++++++++------
>  disk/part_dos.c             | 20 ++++++++++++++++++++
>  doc/README.android-fastboot | 37 +++++++++++++++++++++++++++++++++++++
>  include/part.h              | 23 +++++++++++++++++++++++
>  5 files changed, 121 insertions(+), 6 deletions(-)
>
> diff --git a/README b/README
> index 30d7ee3..f6ef8b8 100644
> --- a/README
> +++ b/README
> @@ -1682,6 +1682,13 @@ The following options need to be configured:
>                 "fastboot flash" command line matches this value.
>                 Default is GPT_ENTRY_NAME (currently "gpt") if undefined.
>
> +               CONFIG_FASTBOOT_MBR_NAME
> +               The fastboot "flash" command supports writing the downloaded
> +               image to DOS MBR.
> +               This occurs when the "partition name" specified on the
> +               "fastboot flash" command line matches this value.
> +               If not defined the default value "mbr" is used.
> +
>  - Journaling Flash filesystem support:
>                 CONFIG_JFFS2_NAND, CONFIG_JFFS2_NAND_OFF, CONFIG_JFFS2_NAND_SIZE,
>                 CONFIG_JFFS2_NAND_DEV
> diff --git a/common/fb_mmc.c b/common/fb_mmc.c
> index a0a4a83..4bc68a7 100644
> --- a/common/fb_mmc.c
> +++ b/common/fb_mmc.c
> @@ -14,15 +14,20 @@
>  #include <mmc.h>
>  #include <div64.h>
>
> -#ifndef CONFIG_FASTBOOT_GPT_NAME
> +#if defined(CONFIG_EFI_PARTITION) && !defined(CONFIG_FASTBOOT_GPT_NAME)
>  #define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME
>  #endif
>
> +
> +#if defined(CONFIG_DOS_PARTITION) && !defined(CONFIG_FASTBOOT_MBR_NAME)
> +#define CONFIG_FASTBOOT_MBR_NAME "mbr"
> +#endif
> +
>  struct fb_mmc_sparse {
>         struct blk_desc *dev_desc;
>  };
>
> -static int part_get_info_efi_by_name_or_alias(struct blk_desc *dev_desc,
> +static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
>                 const char *name, disk_partition_t *info)
>  {
>         int ret;
> @@ -103,6 +108,7 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
>                 return;
>         }
>
> +#ifdef CONFIG_EFI_PARTITION
>         if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0) {
>                 printf("%s: updating MBR, Primary and Backup GPT(s)\n",
>                        __func__);
> @@ -114,14 +120,36 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
>                 }
>                 if (write_mbr_and_gpt_partitions(dev_desc, download_buffer)) {
>                         printf("%s: writing GPT partitions failed\n", __func__);
> -                       fastboot_fail(
> -                                     "writing GPT partitions failed");
> +                       fastboot_fail("writing GPT partitions failed");
>                         return;
>                 }
>                 printf("........ success\n");
>                 fastboot_okay("");
>                 return;
> -       } else if (part_get_info_efi_by_name_or_alias(dev_desc, cmd, &info)) {
> +       }
> +#endif
> +
> +#ifdef CONFIG_DOS_PARTITION
> +       if (strcmp(cmd, CONFIG_FASTBOOT_MBR_NAME) == 0) {
> +               printf("%s: updating MBR\n", __func__);
> +               if (is_valid_dos_buf(download_buffer)) {
> +                       printf("%s: invalid MBR - refusing to write to flash\n",
> +                              __func__);
> +                       fastboot_fail("invalid MBR partition");
> +                       return;
> +               }
> +               if (write_mbr_partition(dev_desc, download_buffer)) {
> +                       printf("%s: writing MBR partition failed\n", __func__);
> +                       fastboot_fail("writing MBR partition failed");
> +                       return;
> +               }
> +               printf("........ success\n");
> +               fastboot_okay("");
> +               return;
> +       }
> +#endif
> +
> +       if (part_get_info_by_name_or_alias(dev_desc, cmd, &info)) {
>                 error("cannot find partition: '%s'\n", cmd);
>                 fastboot_fail("cannot find partition");
>                 return;
> @@ -172,7 +200,7 @@ void fb_mmc_erase(const char *cmd)
>                 return;
>         }
>
> -       ret = part_get_info_efi_by_name_or_alias(dev_desc, cmd, &info);
> +       ret = part_get_info_by_name_or_alias(dev_desc, cmd, &info);
>         if (ret) {
>                 error("cannot find partition: '%s'", cmd);
>                 fastboot_fail("cannot find partition");
> diff --git a/disk/part_dos.c b/disk/part_dos.c
> index 8226601..8e6aae5 100644
> --- a/disk/part_dos.c
> +++ b/disk/part_dos.c
> @@ -297,6 +297,26 @@ int part_get_info_dos(struct blk_desc *dev_desc, int part,
>         return part_get_info_extended(dev_desc, 0, 0, 1, part, info, 0);
>  }
>
> +int is_valid_dos_buf(void *buf)
> +{
> +       return test_block_type(buf) == DOS_MBR ? 0 : -1;
> +}
> +
> +int write_mbr_partition(struct blk_desc *dev_desc, void *buf)
> +{
> +       if (is_valid_dos_buf(buf))
> +               return -1;
> +
> +       /* write MBR */
> +       if (blk_dwrite(dev_desc, 0, 1, buf) != 1) {
> +               printf("%s: failed writing '%s' (1 blks at 0x0)\n",
> +                      __func__, "MBR");
> +               return 1;
> +       }
> +
> +       return 0;
> +}
> +
>  U_BOOT_PART_TYPE(dos) = {
>         .name           = "DOS",
>         .part_type      = PART_TYPE_DOS,
> diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot
> index ce12bc5..dea7066 100644
> --- a/doc/README.android-fastboot
> +++ b/doc/README.android-fastboot
> @@ -59,6 +59,43 @@ To define a partition alias add an environment variable similar to:
>  fastboot_partition_alias_<alias partition name>=<actual partition name>
>  Example: fastboot_partition_alias_boot=LNX
>
> +Partition Names
> +===============
> +The Fastboot implementation in U-boot allows to write images into disk
> +partitions (currently on eMMC). Target partitions are referred on the host
> +computer by their names.
> +
> +For GPT/EFI the respective partition name is used.
> +
> +For MBR the partitions are referred by generic names according to the
> +following schema:
> +
> +  <device type> <device index letter> <partition index>
> +
> +Example: hda3, sdb1, usbda1
> +
> +The device type is as follows:
> +
> +  * IDE, ATAPI and SATA disks: hd
> +  * SCSI disks: sd
> +  * USB media: usbd
> +  * Disk on chip: docd
> +  * other: xx
> +
> +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.
> +
> +Writing Partition Table
> +=======================
> +Fastboot also allows to write the partition table to the media. This can be
> +done by writing the respective partition table image to a special target
> +"gpt" or "mbr". These names can be customized by defining the following
> +configuration options:
> +
> +CONFIG_FASTBOOT_GPT_NAME
> +CONFIG_FASTBOOT_MBR_NAME
> +
>  In Action
>  =========
>  Enter into fastboot by executing the fastboot command in u-boot and you
> diff --git a/include/part.h b/include/part.h
> index bd8fd49..b17c219 100644
> --- a/include/part.h
> +++ b/include/part.h
> @@ -351,4 +351,27 @@ int gpt_verify_partitions(struct blk_desc *dev_desc,
>                           gpt_header *gpt_head, gpt_entry **gpt_pte);
>  #endif
>
> +#ifdef CONFIG_DOS_PARTITION
> +/**
> + * is_valid_dos_buf() - Ensure that a DOS MBR image is valid
> + *
> + * @param buf - buffer which contains the MBR
> + *
> + * @return - '0' on success, otherwise error
> + */
> +int is_valid_dos_buf(void *buf);
> +
> +/**
> + * write_mbr_partition() - write DOS MBR
> + *
> + * @param dev_desc - block device descriptor
> + * @param buf - buffer which contains the MBR
> + *
> + * @return - '0' on success, otherwise error
> + */
> +int write_mbr_partition(struct blk_desc *dev_desc, void *buf);
> +
> +#endif
> +
> +
>  #endif /* _PART_H */
> --
> 2.7.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

Acked-by: Steve Rae <steve.rae@raedomain.com>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 3/4] disk: part: refactor generic name creation for DOS and ISO
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 3/4] disk: part: refactor generic name creation for DOS and ISO Petr Kulhavy
@ 2016-09-12 17:39   ` Steve Rae
  2016-09-19  0:57   ` Simon Glass
  2016-10-03 13:37   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2 siblings, 0 replies; 19+ messages in thread
From: Steve Rae @ 2016-09-12 17:39 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 9, 2016 at 1:27 AM, Petr Kulhavy <brain@jikos.cz> wrote:
> In both DOS and ISO partition tables the same code to create partition name
> like "hda1" was repeated.
>
> Code moved to into a new function part_set_generic_name() in part.c and optimized.
> Added recognition of MMC and SD types, name is like "mmcsda1".
>
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
> v1: initial
> v2: no change
>
>  disk/part.c                 | 32 ++++++++++++++++++++++++++++++++
>  disk/part_dos.c             | 31 ++-----------------------------
>  disk/part_iso.c             | 25 +------------------------
>  doc/README.android-fastboot |  1 +
>  include/part.h              | 14 ++++++++++++++
>  5 files changed, 50 insertions(+), 53 deletions(-)
>
> diff --git a/disk/part.c b/disk/part.c
> index 8317e80..9f51a07 100644
> --- a/disk/part.c
> +++ b/disk/part.c
> @@ -641,3 +641,35 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
>         }
>         return -1;
>  }
> +
> +void part_set_generic_name(const struct blk_desc *dev_desc,
> +       int part_num, char *name)
> +{
> +       char *devtype;
> +
> +       switch (dev_desc->if_type) {
> +       case IF_TYPE_IDE:
> +       case IF_TYPE_SATA:
> +       case IF_TYPE_ATAPI:
> +               devtype = "hd";
> +               break;
> +       case IF_TYPE_SCSI:
> +               devtype = "sd";
> +               break;
> +       case IF_TYPE_USB:
> +               devtype = "usbd";
> +               break;
> +       case IF_TYPE_DOC:
> +               devtype = "docd";
> +               break;
> +       case IF_TYPE_MMC:
> +       case IF_TYPE_SD:
> +               devtype = "mmcsd";
> +               break;
> +       default:
> +               devtype = "xx";
> +               break;
> +       }
> +
> +       sprintf(name, "%s%c%d", devtype, 'a' + dev_desc->devnum, part_num);
> +}
> diff --git a/disk/part_dos.c b/disk/part_dos.c
> index 8e6aae5..ed78334 100644
> --- a/disk/part_dos.c
> +++ b/disk/part_dos.c
> @@ -209,35 +209,8 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
>                         info->start = (lbaint_t)(ext_part_sector +
>                                         le32_to_int(pt->start4));
>                         info->size  = (lbaint_t)le32_to_int(pt->size4);
> -                       switch(dev_desc->if_type) {
> -                               case IF_TYPE_IDE:
> -                               case IF_TYPE_SATA:
> -                               case IF_TYPE_ATAPI:
> -                                       sprintf((char *)info->name, "hd%c%d",
> -                                               'a' + dev_desc->devnum,
> -                                               part_num);
> -                                       break;
> -                               case IF_TYPE_SCSI:
> -                                       sprintf((char *)info->name, "sd%c%d",
> -                                               'a' + dev_desc->devnum,
> -                                               part_num);
> -                                       break;
> -                               case IF_TYPE_USB:
> -                                       sprintf((char *)info->name, "usbd%c%d",
> -                                               'a' + dev_desc->devnum,
> -                                               part_num);
> -                                       break;
> -                               case IF_TYPE_DOC:
> -                                       sprintf((char *)info->name, "docd%c%d",
> -                                               'a' + dev_desc->devnum,
> -                                               part_num);
> -                                       break;
> -                               default:
> -                                       sprintf((char *)info->name, "xx%c%d",
> -                                               'a' + dev_desc->devnum,
> -                                               part_num);
> -                                       break;
> -                       }
> +                       part_set_generic_name(dev_desc, part_num,
> +                                             (char *)info->name);
>                         /* sprintf(info->type, "%d, pt->sys_ind); */
>                         strcpy((char *)info->type, "U-Boot");
>                         info->bootable = is_bootable(pt);
> diff --git a/disk/part_iso.c b/disk/part_iso.c
> index 78fc97e..bb8ed65 100644
> --- a/disk/part_iso.c
> +++ b/disk/part_iso.c
> @@ -137,30 +137,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
>         entry_num=1;
>         offset=0x20;
>         strcpy((char *)info->type, "U-Boot");
> -       switch(dev_desc->if_type) {
> -               case IF_TYPE_IDE:
> -               case IF_TYPE_SATA:
> -               case IF_TYPE_ATAPI:
> -                       sprintf ((char *)info->name, "hd%c%d",
> -                               'a' + dev_desc->devnum, part_num);
> -                       break;
> -               case IF_TYPE_SCSI:
> -                       sprintf ((char *)info->name, "sd%c%d",
> -                               'a' + dev_desc->devnum, part_num);
> -                       break;
> -               case IF_TYPE_USB:
> -                       sprintf ((char *)info->name, "usbd%c%d",
> -                               'a' + dev_desc->devnum, part_num);
> -                       break;
> -               case IF_TYPE_DOC:
> -                       sprintf ((char *)info->name, "docd%c%d",
> -                               'a' + dev_desc->devnum, part_num);
> -                       break;
> -               default:
> -                       sprintf ((char *)info->name, "xx%c%d",
> -                               'a' + dev_desc->devnum, part_num);
> -                       break;
> -       }
> +       part_set_generic_name(dev_desc, part_num, (char *)info->name);
>         /* the bootcatalog (including validation Entry) is limited to 2048Bytes
>          * (63 boot entries + validation entry) */
>          while(offset<2048) {
> diff --git a/doc/README.android-fastboot b/doc/README.android-fastboot
> index dea7066..b8afa15 100644
> --- a/doc/README.android-fastboot
> +++ b/doc/README.android-fastboot
> @@ -79,6 +79,7 @@ The device type is as follows:
>    * IDE, ATAPI and SATA disks: hd
>    * SCSI disks: sd
>    * USB media: usbd
> +  * MMC and SD cards: mmcsd
>    * Disk on chip: docd
>    * other: xx
>
> diff --git a/include/part.h b/include/part.h
> index b17c219..0979005 100644
> --- a/include/part.h
> +++ b/include/part.h
> @@ -165,6 +165,20 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
>  int part_get_info_by_name(struct blk_desc *dev_desc,
>                               const char *name, disk_partition_t *info);
>
> +/**
> + * part_set_generic_name() - create generic partition like hda1 or sdb2
> + *
> + * Helper function for partition tables, which don't hold partition names
> + * (DOS, ISO). Generates partition name out of the device type and partition
> + * number.
> + *
> + * @dev_desc:  pointer to the block device
> + * @part_num:  partition number for which the name is generated
> + * @name:      buffer where the name is written
> + */
> +void part_set_generic_name(const struct blk_desc *dev_desc,
> +       int part_num, char *name);
> +
>  extern const struct block_drvr block_drvr[];
>  #else
>  static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
> --
> 2.7.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

Acked-by: Steve Rae <steve.rae@raedomain.com>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 4/4] fastboot: move FASTBOOT_FLASH options into Kconfig
  2016-09-09 13:56   ` Tom Rini
@ 2016-09-12 17:41     ` Steve Rae
  0 siblings, 0 replies; 19+ messages in thread
From: Steve Rae @ 2016-09-12 17:41 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 9, 2016 at 6:56 AM, Tom Rini <trini@konsulko.com> wrote:
> On Fri, Sep 09, 2016 at 10:27:18AM +0200, Petr Kulhavy wrote:
>
>> Move FASTBOOT_MBR_NAME and FASTBOOT_GPT_NAME into Kconfig.
>> Add dependency on the FASTBOOT_FLASH setting (also for FASTBOOT_MBR_NAME).
>> Remove the now redundant GPT_ENTRY_NAME.
>>
>> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
>
> Reviewed-by: Tom Rini <trini@konsulko.com>
>
> --
> Tom
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>

Acked-by: Steve Rae <steve.rae@raedomain.com>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 0/4] Fastboot MBR and generic partition support
  2016-09-09  8:27 [U-Boot] [PATCH v2 0/4] Fastboot MBR and generic partition support Petr Kulhavy
                   ` (3 preceding siblings ...)
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 4/4] fastboot: move FASTBOOT_FLASH options into Kconfig Petr Kulhavy
@ 2016-09-12 17:42 ` Steve Rae
  4 siblings, 0 replies; 19+ messages in thread
From: Steve Rae @ 2016-09-12 17:42 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 9, 2016 at 1:27 AM, Petr Kulhavy <brain@jikos.cz> wrote:
> This set extends the Fastboot implementation from GPT-only to any partition
> support.  Further it adds a special target "mbr" (configurable) to write the
> DOS MBR.
>
> Version 2:
> Add a fourth patch into the set to move CONFIG_FASTBOOT_GPT_NAME and
> CONFIG_FASTBOOT_MBR_NAME into cmd/fastboot/Kconfig
>
> Petr Kulhavy (4):
>   disk: part: implement generic function part_get_info_by_name()
>   fastboot: add support for writing MBR
>   disk: part: refactor generic name creation for DOS and ISO
>   fastboot: move FASTBOOT_FLASH options into Kconfig
>
>  README                      |  9 +++++-
>  cmd/fastboot/Kconfig        | 24 ++++++++++++++++
>  common/fb_mmc.c             | 41 +++++++++++++++++++--------
>  disk/part.c                 | 58 +++++++++++++++++++++++++++++++++++++
>  disk/part_amiga.c           |  1 +
>  disk/part_dos.c             | 52 +++++++++++++++-------------------
>  disk/part_efi.c             | 20 +------------
>  disk/part_iso.c             | 26 ++---------------
>  disk/part_mac.c             |  1 +
>  doc/README.android-fastboot | 38 +++++++++++++++++++++++++
>  include/part.h              | 69 +++++++++++++++++++++++++++++++++++++--------
>  include/part_efi.h          |  1 -
>  12 files changed, 243 insertions(+), 97 deletions(-)
>
> --
> 2.7.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

Thanks for this !

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 1/4] disk: part: implement generic function part_get_info_by_name()
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 1/4] disk: part: implement generic function part_get_info_by_name() Petr Kulhavy
  2016-09-12 17:35   ` Steve Rae
@ 2016-09-19  0:57   ` Simon Glass
  2016-10-03 13:36   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2016-09-19  0:57 UTC (permalink / raw)
  To: u-boot

On 9 September 2016 at 02:27, Petr Kulhavy <brain@jikos.cz> wrote:
> So far partition search by name has been supported only on the EFI partition
> table. This patch extends the search to all partition tables.
>
> Rename part_get_info_efi_by_name() to part_get_info_by_name(), move it from
> part_efi.c into part.c and make it a generic function which traverses all part
> drivers and searches all partitions (in the order given by the linked list).
>
> For this a new variable struct part_driver.max_entries is added, which limits
> the number of partitions searched. For EFI this was GPT_ENTRY_NUMBERS.
> Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables.
>
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
> v1: initial
> v2: no change
>
>  common/fb_mmc.c   |  4 ++--
>  disk/part.c       | 26 ++++++++++++++++++++++++++
>  disk/part_amiga.c |  1 +
>  disk/part_dos.c   |  1 +
>  disk/part_efi.c   | 20 +-------------------
>  disk/part_iso.c   |  1 +
>  disk/part_mac.c   |  1 +
>  include/part.h    | 32 ++++++++++++++++++++------------
>  8 files changed, 53 insertions(+), 33 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 2/4] fastboot: add support for writing MBR
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 2/4] fastboot: add support for writing MBR Petr Kulhavy
  2016-09-12 17:38   ` Steve Rae
@ 2016-09-19  0:57   ` Simon Glass
  2016-10-03 13:36   ` [U-Boot] [U-Boot,v2,2/4] " Tom Rini
  2 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2016-09-19  0:57 UTC (permalink / raw)
  To: u-boot

On 9 September 2016 at 02:27, Petr Kulhavy <brain@jikos.cz> wrote:
> Add special target "mbr" (otherwise configurable via CONFIG_FASTBOOT_MBR_NAME)
> to write MBR partition table.
> Partitions are now searched using the generic function which finds any
> partiiton by name. For MBR the partition names hda1, sda1, etc. are used.
>
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
> v1: initial
> v2: no change
>
>  README                      |  7 +++++++
>  common/fb_mmc.c             | 40 ++++++++++++++++++++++++++++++++++------
>  disk/part_dos.c             | 20 ++++++++++++++++++++
>  doc/README.android-fastboot | 37 +++++++++++++++++++++++++++++++++++++
>  include/part.h              | 23 +++++++++++++++++++++++
>  5 files changed, 121 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 3/4] disk: part: refactor generic name creation for DOS and ISO
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 3/4] disk: part: refactor generic name creation for DOS and ISO Petr Kulhavy
  2016-09-12 17:39   ` Steve Rae
@ 2016-09-19  0:57   ` Simon Glass
  2016-10-03 13:37   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2016-09-19  0:57 UTC (permalink / raw)
  To: u-boot

On 9 September 2016 at 02:27, Petr Kulhavy <brain@jikos.cz> wrote:
> In both DOS and ISO partition tables the same code to create partition name
> like "hda1" was repeated.
>
> Code moved to into a new function part_set_generic_name() in part.c and optimized.
> Added recognition of MMC and SD types, name is like "mmcsda1".
>
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
> v1: initial
> v2: no change
>
>  disk/part.c                 | 32 ++++++++++++++++++++++++++++++++
>  disk/part_dos.c             | 31 ++-----------------------------
>  disk/part_iso.c             | 25 +------------------------
>  doc/README.android-fastboot |  1 +
>  include/part.h              | 14 ++++++++++++++
>  5 files changed, 50 insertions(+), 53 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [PATCH v2 4/4] fastboot: move FASTBOOT_FLASH options into Kconfig
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 4/4] fastboot: move FASTBOOT_FLASH options into Kconfig Petr Kulhavy
  2016-09-09 13:56   ` Tom Rini
@ 2016-09-19  0:57   ` Simon Glass
  2016-10-03 13:37   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2016-09-19  0:57 UTC (permalink / raw)
  To: u-boot

On 9 September 2016 at 02:27, Petr Kulhavy <brain@jikos.cz> wrote:
> Move FASTBOOT_MBR_NAME and FASTBOOT_GPT_NAME into Kconfig.
> Add dependency on the FASTBOOT_FLASH setting (also for FASTBOOT_MBR_NAME).
> Remove the now redundant GPT_ENTRY_NAME.
>
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
> ---
> v2: initial
>
>  README               |  2 +-
>  cmd/fastboot/Kconfig | 24 ++++++++++++++++++++++++
>  common/fb_mmc.c      |  9 ---------
>  include/part_efi.h   |  1 -
>  4 files changed, 25 insertions(+), 11 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [U-Boot, v2, 1/4] disk: part: implement generic function part_get_info_by_name()
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 1/4] disk: part: implement generic function part_get_info_by_name() Petr Kulhavy
  2016-09-12 17:35   ` Steve Rae
  2016-09-19  0:57   ` Simon Glass
@ 2016-10-03 13:36   ` Tom Rini
  2 siblings, 0 replies; 19+ messages in thread
From: Tom Rini @ 2016-10-03 13:36 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 09, 2016 at 10:27:15AM +0200, Petr Kulhavy wrote:

> So far partition search by name has been supported only on the EFI partition
> table. This patch extends the search to all partition tables.
> 
> Rename part_get_info_efi_by_name() to part_get_info_by_name(), move it from
> part_efi.c into part.c and make it a generic function which traverses all part
> drivers and searches all partitions (in the order given by the linked list).
> 
> For this a new variable struct part_driver.max_entries is added, which limits
> the number of partitions searched. For EFI this was GPT_ENTRY_NUMBERS.
> Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables.
> 
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Acked-by: Steve Rae <steve.rae@raedomain.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161003/30ffc00a/attachment.sig>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [U-Boot,v2,2/4] fastboot: add support for writing MBR
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 2/4] fastboot: add support for writing MBR Petr Kulhavy
  2016-09-12 17:38   ` Steve Rae
  2016-09-19  0:57   ` Simon Glass
@ 2016-10-03 13:36   ` Tom Rini
  2 siblings, 0 replies; 19+ messages in thread
From: Tom Rini @ 2016-10-03 13:36 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 09, 2016 at 10:27:16AM +0200, Petr Kulhavy wrote:

> Add special target "mbr" (otherwise configurable via CONFIG_FASTBOOT_MBR_NAME)
> to write MBR partition table.
> Partitions are now searched using the generic function which finds any
> partiiton by name. For MBR the partition names hda1, sda1, etc. are used.
> 
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Acked-by: Steve Rae <steve.rae@raedomain.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161003/f4d4518d/attachment.sig>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [U-Boot, v2, 3/4] disk: part: refactor generic name creation for DOS and ISO
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 3/4] disk: part: refactor generic name creation for DOS and ISO Petr Kulhavy
  2016-09-12 17:39   ` Steve Rae
  2016-09-19  0:57   ` Simon Glass
@ 2016-10-03 13:37   ` Tom Rini
  2 siblings, 0 replies; 19+ messages in thread
From: Tom Rini @ 2016-10-03 13:37 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 09, 2016 at 10:27:17AM +0200, Petr Kulhavy wrote:

> In both DOS and ISO partition tables the same code to create partition name
> like "hda1" was repeated.
> 
> Code moved to into a new function part_set_generic_name() in part.c and optimized.
> Added recognition of MMC and SD types, name is like "mmcsda1".
> 
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Acked-by: Steve Rae <steve.rae@raedomain.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161003/7478ca3a/attachment.sig>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [U-Boot] [U-Boot, v2, 4/4] fastboot: move FASTBOOT_FLASH options into Kconfig
  2016-09-09  8:27 ` [U-Boot] [PATCH v2 4/4] fastboot: move FASTBOOT_FLASH options into Kconfig Petr Kulhavy
  2016-09-09 13:56   ` Tom Rini
  2016-09-19  0:57   ` Simon Glass
@ 2016-10-03 13:37   ` Tom Rini
  2 siblings, 0 replies; 19+ messages in thread
From: Tom Rini @ 2016-10-03 13:37 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 09, 2016 at 10:27:18AM +0200, Petr Kulhavy wrote:

> Move FASTBOOT_MBR_NAME and FASTBOOT_GPT_NAME into Kconfig.
> Add dependency on the FASTBOOT_FLASH setting (also for FASTBOOT_MBR_NAME).
> Remove the now redundant GPT_ENTRY_NAME.
> 
> Signed-off-by: Petr Kulhavy <brain@jikos.cz>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Acked-by: Steve Rae <steve.rae@raedomain.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

But also note that I had to add back in code to define the gpt/mbr
default names as until DOS_PARTITION and EFI_PARTITION are in Kconfig we
can get code that fails to build here otherwise.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161003/c32c9b2e/attachment.sig>

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2016-10-03 13:37 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-09  8:27 [U-Boot] [PATCH v2 0/4] Fastboot MBR and generic partition support Petr Kulhavy
2016-09-09  8:27 ` [U-Boot] [PATCH v2 1/4] disk: part: implement generic function part_get_info_by_name() Petr Kulhavy
2016-09-12 17:35   ` Steve Rae
2016-09-19  0:57   ` Simon Glass
2016-10-03 13:36   ` [U-Boot] [U-Boot, v2, " Tom Rini
2016-09-09  8:27 ` [U-Boot] [PATCH v2 2/4] fastboot: add support for writing MBR Petr Kulhavy
2016-09-12 17:38   ` Steve Rae
2016-09-19  0:57   ` Simon Glass
2016-10-03 13:36   ` [U-Boot] [U-Boot,v2,2/4] " Tom Rini
2016-09-09  8:27 ` [U-Boot] [PATCH v2 3/4] disk: part: refactor generic name creation for DOS and ISO Petr Kulhavy
2016-09-12 17:39   ` Steve Rae
2016-09-19  0:57   ` Simon Glass
2016-10-03 13:37   ` [U-Boot] [U-Boot, v2, " Tom Rini
2016-09-09  8:27 ` [U-Boot] [PATCH v2 4/4] fastboot: move FASTBOOT_FLASH options into Kconfig Petr Kulhavy
2016-09-09 13:56   ` Tom Rini
2016-09-12 17:41     ` Steve Rae
2016-09-19  0:57   ` Simon Glass
2016-10-03 13:37   ` [U-Boot] [U-Boot, v2, " Tom Rini
2016-09-12 17:42 ` [U-Boot] [PATCH v2 0/4] Fastboot MBR and generic partition support Steve Rae

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox