[PATCH v4 14/14] smegw01: Convert CFG_EXTRA_ENV_SETTINGS to an env file

Fabio Estevam festevam at gmail.com
Wed Apr 26 15:25:33 CEST 2023


From: Fabio Estevam <festevam at denx.de>

Currently, it is recommended to move from CFG_EXTRA_ENV_SETTINGS to
an env file, so do the conversion.

Suggested-by: Tom Rini <trini at konsulko.com>
Signed-off-by: Fabio Estevam <festevam at denx.de>
---
Changes since v3:
- New patch added as per Tom Rini's suggestion.

Cc: Tom Rini <trini at konsulko.com>

 board/storopack/smegw01/smegw01.env | 76 ++++++++++++++++++++++++++++
 include/configs/smegw01.h           | 77 ++++-------------------------
 2 files changed, 85 insertions(+), 68 deletions(-)
 create mode 100644 board/storopack/smegw01/smegw01.env

diff --git a/board/storopack/smegw01/smegw01.env b/board/storopack/smegw01/smegw01.env
new file mode 100644
index 000000000000..d2e6b3cf64f6
--- /dev/null
+++ b/board/storopack/smegw01/smegw01.env
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+altbootcmd=
+	echo Performing rollback...;
+	if test "${mmcpart_committed}" = 1; then
+		setenv mmcpart 2;
+		setenv mmcpart_committed 2;
+	else
+		setenv mmcpart 1;
+		setenv mmcpart_committed 1;
+	fi;
+	setenv bootcount 0;
+	setenv upgrade_available;
+	setenv ustate 3;
+	saveenv;
+	run bootcmd;
+boot_emmc=setenv mmcdev_wanted 1; run persist_mmcdev; run bootcmd;
+boot_sd=setenv mmcdev_wanted 0; run persist_mmcdev; run bootcmd;
+bootcmd=run finduuid; run distro_bootcmd
+bootdelay=2
+bootlimit=3
+bootm_size=0x10000000
+commit_mmc=
+	if test "${ustate}" = 1 -a "${mmcpart}" != "${mmcpart_committed}"; then
+		setenv mmcpart_committed ${mmcpart};
+		saveenv;
+	fi;
+console=ttymxc0
+fdt_addr=0x83000000
+fdtfile=imx7d-smegw01.dtb
+fit_addr=0x88000000
+image=fitImage
+loadaddr=0x80800000
+loadbootpart=mmc partconf 1 boot_part
+loadimage=load mmc ${mmcdev}:${gpt_partition_entry} ${fit_addr} boot/${image}
+loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed}
+mmcargs=
+	setenv bootargs console=${console},${baudrate} root=/dev/mmcblk${mmcdev}p${gpt_partition_entry} rootwait rw SM_ROOT_DEV=${mmcdev} SM_ROOT_PART=${gpt_partition_entry} SM_BOOT_PART=${boot_part}
+mmcboot=
+	echo Booting...;
+	echo mmcdev: ${mmcdev};
+	run commit_mmc;
+	echo mmcpart: ${mmcpart_committed};
+	run loadpart;
+	echo gptpart: ${gpt_partition_entry};
+	run loadbootpart;
+	if run loadimage; then
+		;
+	else
+		run altbootcmd;
+	fi;
+	run mmcargs;
+	if bootm ${fit_addr}; then
+		;
+	else
+		run altbootcmd;
+	fi;
+mmcdev=1
+mmcpart=1
+mmcpart_committed=1
+persist_mmcdev=
+	if test "${mmcdev}" != "${mmcdev_wanted}"; then
+		setenv mmcdev "${mmcdev_wanted}";
+		saveenv;
+	fi;
+setup_boot_menu=
+	if test "${mmcdev}" = 1; then
+		setenv emmc_priority 0;
+		setenv sd_priority 1;
+	else
+		setenv emmc_priority 1;
+		setenv sd_priority 0;
+	fi;
+	setenv bootmenu_${emmc_priority} eMMC=run boot_emmc;
+	setenv bootmenu_${sd_priority} SD=run boot_sd;
+SETUP_BOOT_MENU
diff --git a/include/configs/smegw01.h b/include/configs/smegw01.h
index 6f373973ab84..d1c442577478 100644
--- a/include/configs/smegw01.h
+++ b/include/configs/smegw01.h
@@ -24,19 +24,17 @@
 
 #ifdef CONFIG_SYS_BOOT_LOCKED
 #define EXTRA_ENV_FLAGS
-#define SETUP_BOOT_MENU "setup_boot_menu=setenv bootmenu_0 eMMC=run bootcmd\0"
+#define SETUP_BOOT_MENU setup_boot_menu=setenv bootmenu_0 eMMC=run bootcmd
 #else
 #define EXTRA_ENV_FLAGS "mmcdev:dw,"
-#define SETUP_BOOT_MENU "setup_boot_menu=" \
-	"if test \"${mmcdev}\" = 1; then " \
-		"setenv emmc_priority 0;" \
-		"setenv sd_priority 1;" \
-	"else " \
-		"setenv emmc_priority 1;" \
-		"setenv sd_priority 0;" \
-	"fi;" \
-	"setenv bootmenu_${emmc_priority} eMMC=run boot_emmc;" \
-	"setenv bootmenu_${sd_priority} SD=run boot_sd;\0"
+#define SETUP_BOOT_MENU setup_boot_menu= \
+			if test "${mmcdev}" = 1; then \
+				setenv emmc_priority 0; \
+				setenv sd_priority 1; \
+			else setenv emmc_priority 1; \
+				setenv sd_priority 0; \
+			fi; \
+			setenv bootmenu_${emmc_priority} eMMC=run boot_emmc;setenv bootmenu_${sd_priority} SD=run boot_sd;
 #endif
 
 #define CFG_ENV_FLAGS_LIST_STATIC \
@@ -48,63 +46,6 @@
 	"upgrade_available:dw," \
 	EXTRA_ENV_FLAGS
 
-#define CFG_EXTRA_ENV_SETTINGS \
-	"image=fitImage\0" \
-	"console=ttymxc0\0" \
-	"fdtfile=imx7d-smegw01.dtb\0" \
-	"fdt_addr=0x83000000\0" \
-	"bootm_size=0x10000000\0" \
-	"mmcdev=1\0" \
-	"mmcpart=1\0" \
-	"mmcpart_committed=1\0" \
-	"mmcargs=setenv bootargs console=${console},${baudrate} " \
-		"root=/dev/mmcblk${mmcdev}p${gpt_partition_entry} rootwait rw " \
-		__stringify(EXTRA_BOOTPARAMS) " SM_ROOT_DEV=${mmcdev} SM_ROOT_PART=${gpt_partition_entry} SM_BOOT_PART=${boot_part}\0" \
-	"commit_mmc=if test \"${ustate}\" = 1 -a \"${mmcpart}\" != \"${mmcpart_committed}\"; then " \
-	              "setenv mmcpart_committed ${mmcpart};" \
-								"saveenv;" \
-						  "fi;\0" \
-	"bootlimit=3\0" \
-	"fit_addr=0x88000000\0" \
-	"loadimage=load mmc ${mmcdev}:${gpt_partition_entry} ${fit_addr} boot/${image}\0" \
-	"loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed}\0" \
-	"loadbootpart=mmc partconf 1 boot_part\0" \
-	"boot_sd=setenv mmcdev_wanted 0; run persist_mmcdev; run bootcmd;\0" \
-	"boot_emmc=setenv mmcdev_wanted 1; run persist_mmcdev; run bootcmd;\0" \
-	"persist_mmcdev=" \
-		"if test \"${mmcdev}\" != \"${mmcdev_wanted}\"; then " \
-			"setenv mmcdev \"${mmcdev_wanted}\";" \
-			"saveenv;" \
-		"fi;\0" \
-	"mmcboot=echo Booting...; " \
-		"echo mmcdev: ${mmcdev}; " \
-	  "run commit_mmc; " \
-		"echo mmcpart: ${mmcpart_committed}; " \
-		"run loadpart; " \
-		"echo gptpart: ${gpt_partition_entry}; " \
-		"run loadbootpart; " \
-		"if run loadimage; then " \
-			"; " \
-		"else " \
-			"run altbootcmd; " \
-		"fi; " \
-		"run mmcargs; " \
-		"if bootm ${fit_addr}; then " \
-			"; " \
-		"else " \
-			"run altbootcmd; " \
-		"fi;\0" \
-	"altbootcmd=echo Performing rollback...; " \
-		"if test \"${mmcpart_committed}\" = 1; then " \
-			"setenv mmcpart 2; " \
-			"setenv mmcpart_committed 2;" \
-		"else " \
-			"setenv mmcpart 1; " \
-			"setenv mmcpart_committed 1;" \
-		"fi; setenv bootcount 0; setenv upgrade_available; setenv ustate 3; saveenv; " \
-		"run bootcmd;\0" \
-		SETUP_BOOT_MENU
-
 /* Physical Memory Map */
 #define PHYS_SDRAM			MMDC0_ARB_BASE_ADDR
 
-- 
2.34.1



More information about the U-Boot mailing list