Skip to contentSkip to conversation

Generalize PHYTEC Overlay Handling

PATCH Superseded Daniel Schultz 5 participants 16 messages Jul 3, 2024 – Jul 16, 2024 Arm i.MX and Layerscape

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Generalize PHYTEC Overlay Handling

The overlays are specified in the bootenv.txt file that is loaded into the environment. Then these overlays get loaded and applied via a script. These scripts for loading and applying devicetree overlays are identical for many phytec boards.
Create a common overlays.env that can be included.
Add support for devicetree overlays to phycore-imx8mp and include the overlays.env for phycore-imx93.
Rename existing environment variables according to bootstd doc. Move MMC boot logic into a common k3_mmc.env file and include the new overlays.env file as well.

Benjamin Hahn (5):
include: env: phytec: Create env file for loading and applying
overlays
phycore-imx8mp: Add overlay and bootenv.txt support
phycore_imx93: include common overlays.env
board: phytec: renaming of variables according to bootstd doc
include: env: phytec: renaming of variables according to bootstd doc

Daniel Schultz (4):
include: env: phytec: Add common mmc boot for K3 SoMs
include: env: phytec: k3_mmc: Apply overlays during boot
board: phytec: phycore_am62x: Use k3_mmc.env logic
board: phytec: phycore_am64x: Use k3_mmc.env logic

 board/phytec/phycore_am62x/phycore_am62x.env  | 11 +----
 board/phytec/phycore_am64x/phycore_am64x.env  | 12 +----
 .../phytec/phycore_imx8mp/phycore_imx8mp.env  | 27 ++++++++---
 board/phytec/phycore_imx93/phycore_imx93.env  | 45 +++++--------------
 configs/phycore-imx8mp_defconfig              |  6 +--
 include/env/phytec/k3_mmc.env                 | 21 +++++++++
 include/env/phytec/overlays.env               | 38 ++++++++++++++++
 7 files changed, 98 insertions(+), 62 deletions(-)
 create mode 100644 include/env/phytec/k3_mmc.env
 create mode 100644 include/env/phytec/overlays.env
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/9 include: env: phytec: Create env file for loading and applying overlays

From: Benjamin Hahn <[email protected]>

The env scripts for loading and applying overlays are identical for many PHYTEC Boards. Create a common env that can be included.

The env variables bootenv_addr and fdto_addr are board specific and need to be set in the board specific file. The env variable get_cmd also needs to be set in board specific files and can be set to tftp or dhcp.

---
 include/env/phytec/overlays.env | 37 +++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 include/env/phytec/overlays.env
include/env/phytec/overlays.env new file +37 -0
new file mode 100644
index 00000000000..febb991f4f5
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later  */
+/*
+ * Copyright (C) 2024 PHYTEC Messtechnik GmbH
+ * Author: Benjamin Hahn <[email protected]>
+ */
+
+/* Logic to load and apply overlays. Load overlays from bootenv.txt into
+ * environment and apply those overlays.
+ * The variables bootenv_addr and fdto_addr are board specific. */
+
+bootenv=bootenv.txt
+mmc_load_bootenv=load mmc ${mmcdev}:${mmcpart} ${bootenv_addr} ${bootenv}
+mmc_load_overlay=load mmc ${mmcdev}:${mmcpart} ${fdto_addr} ${overlay}
+mmc_apply_overlays=
+	fdt address ${fdt_addr};
+	if test ${no_overlays} = 0; then
+		for overlay in ${overlays};
+		do;
+			if run mmc_load_overlay; then
+				fdt resize ${filesize};
+				fdt apply ${fdto_addr};
+			fi;
+		done;
+	fi;
+net_load_bootenv=${get_cmd} ${bootenv_addr} ${bootenv}
+net_load_overlay=${get_cmd} ${fdto_addr} ${overlay}
+net_apply_overlays=
+	fdt address ${fdt_addr};
+	if test ${no_overlays} = 0; then
+		for overlay in ${overlays};
+		do;
+			if run net_load_overlay; then
+				fdt resize ${filesize};
+				fdt apply ${fdto_addr};
+			fi;
+		done;
+	fi;
Signature · 1 line
2.25.1
#3 lore raw

PATCH 2/9 phycore-imx8mp: Add overlay and bootenv.txt support

In reply to Daniel Schultz

From: Benjamin Hahn <[email protected]>

Add support for loading bootenv.txt as well as loading and applying overlays during boot from mmc and net.

${no_bootenv}: Prevent loading external bootenv.txt environment. Use

	       ${overlays} variable directly from u-boot environment.

${no_overlay}: Do not load overlays defined in ${overlays} variable.
Overlays loaded over the extension command are still being applied.

---
 board/phytec/phycore_imx8mp/phycore_imx8mp.env | 15 +++++++++++++++
 configs/phycore-imx8mp_defconfig               |  6 +++---
 2 files changed, 18 insertions(+), 3 deletions(-)
board/phytec/phycore_imx8mp/phycore_imx8mp.env +15 -0
index 7f6c5fd2c76..4ed5dc7e272 100644
@@ -1,4 +1,5 @@
 #include <env/phytec/rauc.env>
+#include <env/phytec/overlays.env>
 
 bootcmd=
 	if test ${dofastboot} = 1; then
@@ -16,6 +17,8 @@ bootcmd=
 		fi;
 	fi;
 console=ttymxc0,115200
+bootenv_addr=0x49100000
+fdto_addr=0x49000000
 dofastboot=0
 emmc_dev=2
 fastboot_raw_partition_all=0 4194304
@@ -32,8 +35,14 @@ mmcargs=
 mmcautodetect=yes
 mmcboot=
 	echo Booting from mmc ...;
+	if test ${no_bootenv} = 0; then
+		if run mmc_load_bootenv; then
+			env import -t ${bootenv_addr} ${filesize};
+		fi;
+	fi;
 	run mmcargs;
 	if run loadfdt; then
+		run mmc_apply_overlays;
 		booti ${loadaddr} - ${fdt_addr};
 	else
 		echo WARN: Cannot load the DT;
@@ -51,9 +60,15 @@ netboot=
 	else
 		setenv get_cmd tftp;
 	fi;
+	if test ${no_bootenv} = 0; then
+		if run net_load_bootenv; then
+			env import -t ${bootenv_addr} ${filesize};
+		fi;
+	fi;
 	${get_cmd} ${loadaddr} ${image};
 	run netargs;
 	if ${get_cmd} ${fdt_addr} ${fdt_file}; then
+		run net_apply_overlays;
 		booti ${loadaddr} - ${fdt_addr};
 	else
 		echo WARN: Cannot load the DT;
configs/phycore-imx8mp_defconfig +3 -3
index 7b16e8ef58e..e20a43e2674 100644
@@ -5,6 +5,7 @@ CONFIG_SYS_MALLOC_LEN=0x2000000
 CONFIG_SPL_GPIO=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_PHYTEC_SOM_DETECTION=y
 CONFIG_ENV_SIZE=0x10000
 CONFIG_ENV_OFFSET=0x3C0000
 CONFIG_SYS_I2C_MXC_I2C1=y
@@ -12,7 +13,7 @@ CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="freescale/imx8mp-phyboard-pollux-rdk"
 CONFIG_SPL_TEXT_BASE=0x920000
 CONFIG_TARGET_PHYCORE_IMX8MP=y
-CONFIG_PHYTEC_SOM_DETECTION=y
+CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_SYS_MONITOR_LEN=524288
 CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
@@ -49,8 +50,6 @@ CONFIG_SPL_POWER=y
 CONFIG_SPL_WATCHDOG=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="u-boot=> "
-# CONFIG_CMD_EXPORTENV is not set
-# CONFIG_CMD_IMPORTENV is not set
 # CONFIG_CMD_CRC32 is not set
 CONFIG_CMD_EEPROM=y
 CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2
@@ -74,6 +73,7 @@ CONFIG_CMD_EXT2=y
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
Signature · 1 line
2.25.1
#5 lore raw

PATCH 3/9 phycore_imx93: include common overlays.env

In reply to Daniel Schultz

From: Benjamin Hahn <[email protected]>

Include the common overlays env file for phycore_imx93. The common overlays env file supports disabling loading overlays by setting the no_overlays variable.

---
 board/phytec/phycore_imx93/phycore_imx93.env | 25 ++------------------
 1 file changed, 2 insertions(+), 23 deletions(-)
board/phytec/phycore_imx93/phycore_imx93.env +2 -23
index 27bfadfa140..09542f5aa7d 100644
@@ -1,5 +1,7 @@
 /* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
 
+#include <env/phytec/overlays.env>
+
 image=Image
 console=ttyLP0
 fdt_addr=0x83000000
@@ -7,8 +9,6 @@ fdto_addr=0x830c0000
 bootenv_addr=0x83500000
 fdt_file=CONFIG_DEFAULT_FDT_FILE
 ip_dyn=yes
-bootenv=bootenv.txt
-mmc_load_bootenv=fatload mmc ${mmcdev}:${mmcpart} ${bootenv_addr} ${bootenv}
 mmcdev=CONFIG_SYS_MMC_ENV_DEV
 mmcpart=1
 mmcroot=2
@@ -17,16 +17,6 @@ mmcargs=setenv bootargs console=${console},${baudrate} earlycon
 	root=/dev/mmcblk${mmcdev}p${mmcroot} ${raucargs} rootwait rw
 loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
 loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
-mmc_load_overlay=fatload mmc ${mmcdev}:${mmcpart} ${fdto_addr} ${overlay}
-mmc_apply_overlays=
-	fdt address ${fdt_addr};
-	for overlay in ${overlays};
-	do;
-		if run mmc_load_overlay; then
-			fdt resize ${filesize};
-			fdt apply ${fdto_addr};
-		fi;
-	done;
 mmcboot=
 	echo Booting from mmc ...;
 	if run mmc_load_bootenv; then
@@ -42,17 +32,6 @@ mmcboot=
 nfsroot=/nfs
 netargs=setenv bootargs console=${console},${baudrate} earlycon
 	root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
-net_load_bootenv=${get_cmd} ${bootenv_addr} ${bootenv}
-net_load_overlay=${get_cmd} ${fdto_addr} ${overlay}
-net_apply_overlays=
-	fdt address ${fdt_addr};
-	for overlay in ${overlays};
-	do;
-		if run net_load_overlay; then
-			fdt resize ${filesize};
-			fdt apply ${fdto_addr};
-		fi;
-	done;
 netboot=
 	echo Booting from net ...;
 	run netargs;
Signature · 1 line
2.25.1
#6 lore raw

PATCH 4/9 board: phytec: renaming of variables according to bootstd doc

In reply to Daniel Schultz

From: Benjamin Hahn <[email protected]>

Rename existing environment variables according to the bootstd doc. Renamed variables are fdto_addr, bootenv_addr, fdt_addr and fdt_file.

---
 .../phytec/phycore_imx8mp/phycore_imx8mp.env  | 20 +++++++++----------
 board/phytec/phycore_imx93/phycore_imx93.env  | 20 +++++++++----------
 2 files changed, 20 insertions(+), 20 deletions(-)
board/phytec/phycore_imx8mp/phycore_imx8mp.env +10 -10
index 4ed5dc7e272..f8f878e8f3a 100644
@@ -17,17 +17,17 @@ bootcmd=
 		fi;
 	fi;
 console=ttymxc0,115200
-bootenv_addr=0x49100000
-fdto_addr=0x49000000
+bootenv_addr_r=0x49100000
+fdtoverlay_addr_r=0x49000000
 dofastboot=0
 emmc_dev=2
 fastboot_raw_partition_all=0 4194304
 fastboot_raw_partition_bootloader=64 8128
-fdt_addr=0x48000000
-fdt_file=CONFIG_DEFAULT_FDT_FILE
+fdt_addr_r=0x48000000
+fdtfile=CONFIG_DEFAULT_FDT_FILE
 image=Image
 ip_dyn=yes
-loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
+loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}
 loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
 mmcargs=
 	setenv bootargs console=${console}
@@ -37,13 +37,13 @@ mmcboot=
 	echo Booting from mmc ...;
 	if test ${no_bootenv} = 0; then
 		if run mmc_load_bootenv; then
-			env import -t ${bootenv_addr} ${filesize};
+			env import -t ${bootenv_addr_r} ${filesize};
 		fi;
 	fi;
 	run mmcargs;
 	if run loadfdt; then
 		run mmc_apply_overlays;
-		booti ${loadaddr} - ${fdt_addr};
+		booti ${loadaddr} - ${fdt_addr_r};
 	else
 		echo WARN: Cannot load the DT;
 	fi;
@@ -62,14 +62,14 @@ netboot=
 	fi;
 	if test ${no_bootenv} = 0; then
 		if run net_load_bootenv; then
-			env import -t ${bootenv_addr} ${filesize};
+			env import -t ${bootenv_addr_r} ${filesize};
 		fi;
 	fi;
 	${get_cmd} ${loadaddr} ${image};
 	run netargs;
-	if ${get_cmd} ${fdt_addr} ${fdt_file}; then
+	if ${get_cmd} ${fdt_addr_r} ${fdtfile}; then
 		run net_apply_overlays;
-		booti ${loadaddr} - ${fdt_addr};
+		booti ${loadaddr} - ${fdt_addr_r};
 	else
 		echo WARN: Cannot load the DT;
 	fi;
board/phytec/phycore_imx93/phycore_imx93.env +10 -10
index 09542f5aa7d..ab65cfce5fd 100644
@@ -4,10 +4,10 @@
 
 image=Image
 console=ttyLP0
-fdt_addr=0x83000000
-fdto_addr=0x830c0000
-bootenv_addr=0x83500000
-fdt_file=CONFIG_DEFAULT_FDT_FILE
+fdt_addr_r=0x83000000
+fdtoverlay_addr_r=0x830c0000
+bootenv_addr_r=0x83500000
+fdtfile=CONFIG_DEFAULT_FDT_FILE
 ip_dyn=yes
 mmcdev=CONFIG_SYS_MMC_ENV_DEV
 mmcpart=1
@@ -16,16 +16,16 @@ mmcautodetect=yes
 mmcargs=setenv bootargs console=${console},${baudrate} earlycon
 	root=/dev/mmcblk${mmcdev}p${mmcroot} ${raucargs} rootwait rw
 loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
-loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
+loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}
 mmcboot=
 	echo Booting from mmc ...;
 	if run mmc_load_bootenv; then
-		env import -t ${bootenv_addr} ${filesize};
+		env import -t ${bootenv_addr_r} ${filesize};
 	fi;
 	run mmcargs;
 	if run loadfdt; then
 		run mmc_apply_overlays;
-		booti ${loadaddr} - ${fdt_addr};
+		booti ${loadaddr} - ${fdt_addr_r};
 	else
 		echo WARN: Cannot load the DT;
 	fi;
@@ -41,12 +41,12 @@ netboot=
 		setenv get_cmd tftp;
 	fi;
 	if run net_load_bootenv; then
-		env import -t ${bootenv_addr} ${filesize};
+		env import -t ${bootenv_addr_r} ${filesize};
 	fi;
 	${get_cmd} ${loadaddr} ${image};
-	if ${get_cmd} ${fdt_addr} ${fdt_file}; then
+	if ${get_cmd} ${fdt_addr_r} ${fdtfile}; then
 		run net_apply_overlays;
-		booti ${loadaddr} - ${fdt_addr};
+		booti ${loadaddr} - ${fdt_addr_r};
 	else
 		echo WARN: Cannot load the DT;
 	fi;
Signature · 1 line
2.25.1
#7 lore raw

PATCH 5/9 include: env: phytec: renaming of variables according to bootstd doc

In reply to Daniel Schultz

From: Benjamin Hahn <[email protected]>

Rename existing environment variables according to the bootstd doc. Renamed variables are fdto_addr, bootenv_addr, fdt_addr.

---
 include/env/phytec/overlays.env | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
include/env/phytec/overlays.env +10 -9
index febb991f4f5..78721cde654 100644
@@ -6,32 +6,33 @@
 
 /* Logic to load and apply overlays. Load overlays from bootenv.txt into
  * environment and apply those overlays.
- * The variables bootenv_addr and fdto_addr are board specific. */
+ * The variables bootenv_addr_r and fdtoverlay_addr_r are board specific.
+ * get_cmd can be either tftp or dhcp. */
 
 bootenv=bootenv.txt
-mmc_load_bootenv=load mmc ${mmcdev}:${mmcpart} ${bootenv_addr} ${bootenv}
-mmc_load_overlay=load mmc ${mmcdev}:${mmcpart} ${fdto_addr} ${overlay}
+mmc_load_bootenv=load mmc ${mmcdev}:${mmcpart} ${bootenv_addr_r} ${bootenv}
+mmc_load_overlay=load mmc ${mmcdev}:${mmcpart} ${fdtoverlay_addr_r} ${overlay}
 mmc_apply_overlays=
-	fdt address ${fdt_addr};
+	fdt address ${fdt_addr_r};
 	if test ${no_overlays} = 0; then
 		for overlay in ${overlays};
 		do;
 			if run mmc_load_overlay; then
 				fdt resize ${filesize};
-				fdt apply ${fdto_addr};
+				fdt apply ${fdtoverlay_addr_r};
 			fi;
 		done;
 	fi;
-net_load_bootenv=${get_cmd} ${bootenv_addr} ${bootenv}
-net_load_overlay=${get_cmd} ${fdto_addr} ${overlay}
+net_load_bootenv=${get_cmd} ${bootenv_addr_r} ${bootenv}
+net_load_overlay=${get_cmd} ${fdtoverlay_addr_r} ${overlay}
 net_apply_overlays=
-	fdt address ${fdt_addr};
+	fdt address ${fdt_addr_r};
 	if test ${no_overlays} = 0; then
 		for overlay in ${overlays};
 		do;
 			if run net_load_overlay; then
 				fdt resize ${filesize};
-				fdt apply ${fdto_addr};
+				fdt apply ${fdtoverlay_addr_r};
 			fi;
 		done;
 	fi;
Signature · 1 line
2.25.1
#8 lore raw

PATCH 6/9 include: env: phytec: Add common mmc boot for K3 SoMs

In reply to Daniel Schultz

This environment include can be used to boot from a MMC device for PHYTEC's K3-based SoMs.

---
 include/env/phytec/k3_mmc.env | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 include/env/phytec/k3_mmc.env
include/env/phytec/k3_mmc.env new file +18 -0
new file mode 100644
index 00000000000..e1208a6eea1
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2024 PHYTEC Messtechnik GmbH
+ * Author: Daniel Schultz <[email protected]>
+ */
+
+/* Logic for TI K3 based SoCs to boot from a MMC device. */
+
+mmcargs=setenv bootargs console=${console} earlycon=${earlycon}
+	root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait rw
+loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} Image
+loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}
+mmcboot=run mmcargs;
+	mmc dev ${mmcdev};
+	mmc rescan;
+	run loadimage;
+	run loadfdt;
+	booti ${loadaddr} - ${fdt_addr_r}
Signature · 1 line
2.25.1
#9 lore raw

PATCH 7/9 include: env: phytec: k3_mmc: Apply overlays during boot

In reply to Daniel Schultz

Include the overlays.env file and run the apply routine before booting the Kernel.

---
 include/env/phytec/k3_mmc.env | 3 +++
 1 file changed, 3 insertions(+)
include/env/phytec/k3_mmc.env +3 -0
index e1208a6eea1..3d3595ceb7e 100644
@@ -6,6 +6,8 @@
 
 /* Logic for TI K3 based SoCs to boot from a MMC device. */
 
+#include <env/phytec/overlays.env>
+
 mmcargs=setenv bootargs console=${console} earlycon=${earlycon}
 	root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait rw
 loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} Image
@@ -15,4 +17,5 @@ mmcboot=run mmcargs;
 	mmc rescan;
 	run loadimage;
 	run loadfdt;
+	run mmc_apply_overlays;
 	booti ${loadaddr} - ${fdt_addr_r}
Signature · 1 line
2.25.1
#10 lore raw

PATCH 8/9 board: phytec: phycore_am62x: Use k3_mmc.env logic

In reply to Daniel Schultz

Use our common environment file to implement MMC boot.

---
 board/phytec/phycore_am62x/phycore_am62x.env | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
board/phytec/phycore_am62x/phycore_am62x.env +1 -10
index 2d6475d408f..046bbd22f25 100644
@@ -1,4 +1,5 @@
 #include <env/ti/k3_dfu.env>
+#include <env/phytec/k3_mmc.env>
 
 fdtaddr=0x88000000
 loadaddr=0x82000000
@@ -14,13 +15,3 @@ mmcroot=2
 mmcpart=1
 console=ttyS2,115200n8
 earlycon=ns16550a,mmio32,0x02800000
-mmcargs=setenv bootargs console=${console} earlycon=${earlycon}
-	root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait rw
-loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} Image
-loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdtaddr} ${fdtfile}
-mmcboot=run mmcargs;
-	mmc dev ${mmcdev};
-	mmc rescan;
-	run loadimage;
-	run loadfdt;
-	booti ${loadaddr} - ${fdtaddr}
Signature · 1 line
2.25.1
#12 lore raw

PATCH 9/9 board: phytec: phycore_am64x: Use k3_mmc.env logic

In reply to Daniel Schultz

Use our common environment file to implement MMC boot.

---
 board/phytec/phycore_am64x/phycore_am64x.env | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
board/phytec/phycore_am64x/phycore_am64x.env +2 -10
index e24a958f51d..18f0fa5b4c3 100644
@@ -1,3 +1,5 @@
+#include <env/phytec/k3_mmc.env>
+
 fdtaddr=0x88000000
 loadaddr=0x82000000
 scriptaddr=0x80000000
@@ -12,13 +14,3 @@ mmcroot=2
 mmcpart=1
 console=ttyS2,115200n8
 earlycon=ns16550a,mmio32,0x02800000
-mmcargs=setenv bootargs console=${console} earlycon=${earlycon}
-	root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait rw
-loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} Image
-loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdtaddr} ${fdtfile}
-mmcboot=run mmcargs;
-	mmc dev ${mmcdev};
-	mmc rescan;
-	run loadimage;
-	run loadfdt;
-	booti ${loadaddr} - ${fdtaddr}
Signature · 1 line
2.25.1
#13 lore raw
In reply to Daniel Schultz
Quoted 10 lines · Daniel Schultz

The overlays are specified in the bootenv.txt file that is loaded into the environment. Then these overlays get loaded and applied via a script. These scripts for loading and applying devicetree overlays are identical for many phytec boards.
Create a common overlays.env that can be included.
Add support for devicetree overlays to phycore-imx8mp and include the overlays.env for phycore-imx93.
Rename existing environment variables according to bootstd doc. Move MMC boot logic into a common k3_mmc.env file and include the new overlays.env file as well.

Looks good, thanks for doing this!

Signature · 1 line
Tom
Reviewed-by on the v1 series
#14 lore raw
In reply to Daniel Schultz

Am 03.07.24 um 07:41 schrieb Daniel Schultz:

Quoted 19 lines

The overlays are specified in the bootenv.txt file that is loaded into the environment. Then these overlays get loaded and applied via a script. These scripts for loading and applying devicetree overlays are identical for many phytec boards.
Create a common overlays.env that can be included.
Add support for devicetree overlays to phycore-imx8mp and include the overlays.env for phycore-imx93.
Rename existing environment variables according to bootstd doc. Move MMC boot logic into a common k3_mmc.env file and include the new overlays.env file as well.

Benjamin Hahn (5):
include: env: phytec: Create env file for loading and applying
overlays
phycore-imx8mp: Add overlay and bootenv.txt support
phycore_imx93: include common overlays.env
board: phytec: renaming of variables according to bootstd doc
include: env: phytec: renaming of variables according to bootstd doc

Quoted 5 lines

Daniel Schultz (4):
include: env: phytec: Add common mmc boot for K3 SoMs
include: env: phytec: k3_mmc: Apply overlays during boot
board: phytec: phycore_am62x: Use k3_mmc.env logic
board: phytec: phycore_am64x: Use k3_mmc.env logic

For this series,

Reviewed-by on v1 1/9
#2 lore raw

Re: [PATCH 1/9] include: env: phytec: Create env file for loading and applying overlays

In reply to Daniel Schultz

Am Dienstag, dem 02.07.2024 um 22:41 -0700 schrieb Daniel Schultz:

Quoted 6 lines

From: Benjamin Hahn <[email protected]>

The env scripts for loading and applying overlays are identical for many
PHYTEC Boards. Create a common env that can be included.

Quoted 8 lines

The env variables bootenv_addr and fdto_addr are board specific and need
to be set in the board specific file. The env variable get_cmd also needs to be set in board specific files and can be set to tftp or dhcp.

Quoted 53 lines

---
 include/env/phytec/overlays.env | 37
+++++++++++++++++++++++++++++++++

 1 file changed, 37 insertions(+)

 create mode 100644 include/env/phytec/overlays.env

include/env/phytec/overlays.env new file +7 -0
new file mode 100644
index 00000000000..febb991f4f5
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later  */
+/*
+ * Copyright (C) 2024 PHYTEC Messtechnik GmbH
+ * Author: Benjamin Hahn <[email protected]>
+ */
+
+/* Logic to load and apply overlays. Load overlays from bootenv.txt

into
+ * environment and apply those overlays.
+ * The variables bootenv_addr and fdto_addr are board specific. */

include/env/phytec/overlays.env new file +3 -0
+
+bootenv=bootenv.txt
+mmc_load_bootenv=load mmc ${mmcdev}:${mmcpart} ${bootenv_addr}

${bootenv}
+mmc_load_overlay=load mmc ${mmcdev}:${mmcpart} ${fdto_addr} ${overlay}

include/env/phytec/overlays.env new file +24 -0
+mmc_apply_overlays=
+       fdt address ${fdt_addr};
+       if test ${no_overlays} = 0; then
+               for overlay in ${overlays};
+               do;
+                       if run mmc_load_overlay; then
+                               fdt resize ${filesize};
+                               fdt apply ${fdto_addr};
+                       fi;
+               done;
+       fi;
+net_load_bootenv=${get_cmd} ${bootenv_addr} ${bootenv}
+net_load_overlay=${get_cmd} ${fdto_addr} ${overlay}
+net_apply_overlays=
+       fdt address ${fdt_addr};
+       if test ${no_overlays} = 0; then
+               for overlay in ${overlays};
+               do;
+                       if run net_load_overlay; then
+                               fdt resize ${filesize};
+                               fdt apply ${fdto_addr};
+                       fi;
+               done;
+       fi;
Signature · 5 lines
PHYTEC Messtechnik GmbH | Barcelona-Allee 1 | 55129 Mainz, Germany

Geschäftsführer: Dipl.-Ing. Michael Mitezki, Dipl.-Ing. Bodo Huber,
Dipl.-Ing. (FH) Markus Lickes | Handelsregister Mainz HRB 4656 |
Finanzamt Mainz | St.Nr. 266500608, DE 149059855
Reviewed-by on v1 2/9
#4 lore raw

Re: [PATCH 2/9] phycore-imx8mp: Add overlay and bootenv.txt support

In reply to Daniel Schultz

Am Dienstag, dem 02.07.2024 um 22:41 -0700 schrieb Daniel Schultz:

Quoted 5 lines

From: Benjamin Hahn <[email protected]>

Add support for loading bootenv.txt as well as loading and applying overlays during boot from mmc and net.

Quoted 8 lines

${no_bootenv}: Prevent loading external bootenv.txt environment. Use ${overlays} variable directly from u-boot environment. ${no_overlay}: Do not load overlays defined in ${overlays} variable. Overlays loaded over the extension command are still being applied.

Quoted 95 lines

---
 board/phytec/phycore_imx8mp/phycore_imx8mp.env | 15 +++++++++++++++ configs/phycore-imx8mp_defconfig               |  6 +++---

 2 files changed, 18 insertions(+), 3 deletions(-)
board/phytec/phycore_imx8mp/phycore_imx8mp.env +1 -0
index 7f6c5fd2c76..4ed5dc7e272 100644
@@ -1,4 +1,5 @@
  #include <env/phytec/rauc.env>
+#include <env/phytec/overlays.env>


 bootcmd=
        if test ${dofastboot} = 1; then

board/phytec/phycore_imx8mp/phycore_imx8mp.env +0 -0
@@ -16,6 +17,8 @@ bootcmd=
                 fi;
         fi;

 console=ttymxc0,115200

board/phytec/phycore_imx8mp/phycore_imx8mp.env +2 -0
+bootenv_addr=0x49100000
+fdto_addr=0x49000000

 dofastboot=0
 emmc_dev=2
 fastboot_raw_partition_all=0 4194304

board/phytec/phycore_imx8mp/phycore_imx8mp.env +0 -0
@@ -32,8 +35,14 @@ mmcargs=

 mmcautodetect=yes
 mmcboot=
        echo Booting from mmc ...;
+       if test ${no_bootenv} = 0; then
+               if run mmc_load_bootenv; then
+                       env import -t ${bootenv_addr} ${filesize}; +               fi;
+       fi;
        run mmcargs;
        if run loadfdt; then
+               run mmc_apply_overlays;
                booti ${loadaddr} - ${fdt_addr};
        else
                echo WARN: Cannot load the DT;

board/phytec/phycore_imx8mp/phycore_imx8mp.env +0 -0
@@ -51,9 +60,15 @@ netboot=

        else
                setenv get_cmd tftp;
        fi;
+       if test ${no_bootenv} = 0; then
+               if run net_load_bootenv; then
+                       env import -t ${bootenv_addr} ${filesize}; +               fi;
+       fi;
        ${get_cmd} ${loadaddr} ${image};
        run netargs;
        if ${get_cmd} ${fdt_addr} ${fdt_file}; then
+               run net_apply_overlays;
                booti ${loadaddr} - ${fdt_addr};
        else
                echo WARN: Cannot load the DT;

configs/phycore- renamed from configs/phycore-imx8mp_defconfig +0 -0

imx8mp_defconfig
index 7b16e8ef58e..e20a43e2674 100644

configs/phycore-imx8mp_defconfig +0 -0
@@ -5,6 +5,7 @@ CONFIG_SYS_MALLOC_LEN=0x2000000

 CONFIG_SPL_GPIO=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_PHYTEC_SOM_DETECTION=y
 CONFIG_ENV_SIZE=0x10000
 CONFIG_ENV_OFFSET=0x3C0000
 CONFIG_SYS_I2C_MXC_I2C1=y

configs/phycore-imx8mp_defconfig +0 -0
@@ -12,7 +13,7 @@ CONFIG_DM_GPIO=y

 CONFIG_DEFAULT_DEVICE_TREE="freescale/imx8mp-phyboard-pollux-rdk" CONFIG_SPL_TEXT_BASE=0x920000 CONFIG_TARGET_PHYCORE_IMX8MP=y

configs/phycore-imx8mp_defconfig +1 -1
-CONFIG_PHYTEC_SOM_DETECTION=y
+CONFIG_OF_LIBFDT_OVERLAY=y

 CONFIG_SYS_MONITOR_LEN=524288
 CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y

configs/phycore-imx8mp_defconfig +0 -0
@@ -49,8 +50,6 @@ CONFIG_SPL_POWER=y

 CONFIG_SPL_WATCHDOG=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="u-boot=> "

configs/phycore-imx8mp_defconfig +0 -2
-# CONFIG_CMD_EXPORTENV is not set
-# CONFIG_CMD_IMPORTENV is not set

 # CONFIG_CMD_CRC32 is not set
 CONFIG_CMD_EEPROM=y
 CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2

configs/phycore-imx8mp_defconfig +0 -0
@@ -74,6 +73,7 @@ CONFIG_CMD_EXT2=y

 CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y

Signature · 5 lines
PHYTEC Messtechnik GmbH | Barcelona-Allee 1 | 55129 Mainz, Germany

Geschäftsführer: Dipl.-Ing. Michael Mitezki, Dipl.-Ing. Bodo Huber,
Dipl.-Ing. (FH) Markus Lickes | Handelsregister Mainz HRB 4656 |
Finanzamt Mainz | St.Nr. 266500608, DE 149059855
Reviewed-by on v1 8/9
#11 lore raw

Re: [PATCH 8/9] board: phytec: phycore_am62x: Use k3_mmc.env logic

In reply to Daniel Schultz
Quoted 4 lines · Daniel Schultz

Use our common environment file to implement MMC boot.

---

Quoted 2 lines
 board/phytec/phycore_am62x/phycore_am62x.env | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

[...]

Signature · 2 lines
Best regards,
Dhruva
#15 lore raw
In reply to Daniel Schultz
Quoted 10 lines · Daniel Schultz

The overlays are specified in the bootenv.txt file that is loaded into the environment. Then these overlays get loaded and applied via a script. These scripts for loading and applying devicetree overlays are identical for many phytec boards.
Create a common overlays.env that can be included.
Add support for devicetree overlays to phycore-imx8mp and include the overlays.env for phycore-imx93.
Rename existing environment variables according to bootstd doc. Move MMC boot logic into a common k3_mmc.env file and include the new overlays.env file as well.

Can you please rebase this to current master? Thanks.

Signature · 1 line
Tom