diff mbox series

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

Message ID 20240703054202.2812540-3-d.schultz@phytec.de
State Superseded
Delegated to: Tom Rini
Headers show
Series Generalize PHYTEC Overlay Handling | expand

Commit Message

Daniel Schultz July 3, 2024, 5:41 a.m. UTC
From: Benjamin Hahn <B.Hahn@phytec.de>

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.

Signed-off-by: Benjamin Hahn <B.Hahn@phytec.de>
Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
---
 board/phytec/phycore_imx8mp/phycore_imx8mp.env | 15 +++++++++++++++
 configs/phycore-imx8mp_defconfig               |  6 +++---
 2 files changed, 18 insertions(+), 3 deletions(-)

Comments

Teresa Remmet July 4, 2024, 6:40 a.m. UTC | #1
Am Dienstag, dem 02.07.2024 um 22:41 -0700 schrieb Daniel Schultz:
> From: Benjamin Hahn <B.Hahn@phytec.de>
> 
> 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.
> 
> Signed-off-by: Benjamin Hahn <B.Hahn@phytec.de>
> Signed-off-by: Daniel Schultz <d.schultz@phytec.de>

Reviewed-by: Teresa Remmet <t.remmet@phytec.de>

> ---
>  board/phytec/phycore_imx8mp/phycore_imx8mp.env | 15 +++++++++++++++
>  configs/phycore-imx8mp_defconfig               |  6 +++---
>  2 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/board/phytec/phycore_imx8mp/phycore_imx8mp.env
> b/board/phytec/phycore_imx8mp/phycore_imx8mp.env
> index 7f6c5fd2c76..4ed5dc7e272 100644
> --- a/board/phytec/phycore_imx8mp/phycore_imx8mp.env
> +++ b/board/phytec/phycore_imx8mp/phycore_imx8mp.env
> @@ -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;
> diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-
> imx8mp_defconfig
> index 7b16e8ef58e..e20a43e2674 100644
> --- a/configs/phycore-imx8mp_defconfig
> +++ b/configs/phycore-imx8mp_defconfig
> @@ -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
diff mbox series

Patch

diff --git a/board/phytec/phycore_imx8mp/phycore_imx8mp.env b/board/phytec/phycore_imx8mp/phycore_imx8mp.env
index 7f6c5fd2c76..4ed5dc7e272 100644
--- a/board/phytec/phycore_imx8mp/phycore_imx8mp.env
+++ b/board/phytec/phycore_imx8mp/phycore_imx8mp.env
@@ -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;
diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-imx8mp_defconfig
index 7b16e8ef58e..e20a43e2674 100644
--- a/configs/phycore-imx8mp_defconfig
+++ b/configs/phycore-imx8mp_defconfig
@@ -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