[U-Boot] [PATCH v6 17/18] distro: add boot for UBI in GPT over MTD

Patrick Delaunay patrick.delaunay at st.com
Thu May 11 07:52:07 UTC 2017


Now that we can expose boot for UBI partition on MTD devices
(NOR and NAND).

This patch adds the distro script to automatically
payloads from UBI volume called boot detected in a bootable partition
in GPT partition in the MTD device.

example to start from nor0 and nand0:

	func(EFIMTD, nor, 0) \
	func(EFIMTD, nand, 0)

Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
---

Changes in v6:
- add distro support for UBI volume in GPT partition in MTD device

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 include/config_distro_bootcmd.h | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 0e01e82..39584e0 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -68,6 +68,45 @@
 	BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC
 #endif
 
+#ifdef CONFIG_EFI_PARTITION_MTD
+#define BOOTENV_SHARED_EFIMTD \
+	"scan_efi_mtd_for_ubi=" \
+		"mtdparts gpt ${mtddev}${devnum}; " \
+		"part list ${mtddev} ${devnum} -bootable devplist; " \
+		"env exists devplist || setenv devplist 1; " \
+		"for distro_bootpart in ${devplist}; do " \
+			"setexpr mtd_bootpart ${distro_bootpart} - 1;" \
+			"if ubi part ${mtddev}${devnum},${mtd_bootpart} &&" \
+			"   ubifsmount ubi0; then " \
+				"setenv devtype ubi; " \
+				"setenv distro_bootpart 0; " \
+				"run scan_dev_for_boot;" \
+				"ubi detach;" \
+			"fi;" \
+		"done\0" \
+	\
+	"nor_boot=" \
+		"if sf probe ${devnum}; then " \
+			"setenv mtddev nor;" \
+			"run scan_efi_mtd_for_ubi;" \
+		"fi\0" \
+	\
+	"nand_boot=" \
+		"if nand device ${devnum}; then " \
+			"setenv mtddev nand;" \
+			"run scan_efi_mtd_for_ubi;" \
+		"fi\0"
+
+#define BOOTENV_DEV_EFIMTD BOOTENV_DEV_BLKDEV
+#define BOOTENV_DEV_NAME_EFIMTD	BOOTENV_DEV_NAME_BLKDEV
+#else
+#define BOOTENV_SHARED_EFIMTD
+#define BOOTENV_DEV_EFIMTD \
+	BOOT_TARGET_DEVICES_references_EFIMTD_without_CONFIG_EFI_PARTITION_MTD
+#define BOOTENV_DEV_NAME_EFIMTD \
+	BOOT_TARGET_DEVICES_references_EFIMTD_without_CONFIG_EFI_PARTITION_MTD
+#endif
+
 #ifdef CONFIG_CMD_UBIFS
 #define BOOTENV_SHARED_UBIFS \
 	"ubifs_boot=" \
@@ -322,6 +361,7 @@
 	BOOTENV_SHARED_IDE \
 	BOOTENV_SHARED_UBIFS \
 	BOOTENV_SHARED_EFI \
+	BOOTENV_SHARED_EFIMTD \
 	"boot_prefixes=/ /boot/\0" \
 	"boot_scripts=boot.scr.uimg boot.scr\0" \
 	"boot_script_dhcp=boot.scr.uimg\0" \
-- 
1.9.1



More information about the U-Boot mailing list