[PATCH 0/9] 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

From: Benjamin Hahn B.Hahn@phytec.de
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.
Signed-off-by: Benjamin Hahn B.Hahn@phytec.de Signed-off-by: Daniel Schultz d.schultz@phytec.de --- include/env/phytec/overlays.env | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 include/env/phytec/overlays.env
diff --git a/include/env/phytec/overlays.env b/include/env/phytec/overlays.env new file mode 100644 index 00000000000..febb991f4f5 --- /dev/null +++ b/include/env/phytec/overlays.env @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2024 PHYTEC Messtechnik GmbH + * Author: Benjamin Hahn b.hahn@phytec.de + */ + +/* 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;

Am Dienstag, dem 02.07.2024 um 22:41 -0700 schrieb Daniel Schultz:
From: Benjamin Hahn B.Hahn@phytec.de
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.
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
include/env/phytec/overlays.env | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 include/env/phytec/overlays.env
diff --git a/include/env/phytec/overlays.env b/include/env/phytec/overlays.env new file mode 100644 index 00000000000..febb991f4f5 --- /dev/null +++ b/include/env/phytec/overlays.env @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/*
- Copyright (C) 2024 PHYTEC Messtechnik GmbH
- Author: Benjamin Hahn b.hahn@phytec.de
- */
+/* 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;

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(-)
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

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

From: Benjamin Hahn B.Hahn@phytec.de
Include the common overlays env file for phycore_imx93. The common overlays env file supports disabling loading overlays by setting the no_overlays variable.
Signed-off-by: Benjamin Hahn B.Hahn@phytec.de Signed-off-by: Daniel Schultz d.schultz@phytec.de --- board/phytec/phycore_imx93/phycore_imx93.env | 25 ++------------------ 1 file changed, 2 insertions(+), 23 deletions(-)
diff --git a/board/phytec/phycore_imx93/phycore_imx93.env b/board/phytec/phycore_imx93/phycore_imx93.env index 27bfadfa140..09542f5aa7d 100644 --- a/board/phytec/phycore_imx93/phycore_imx93.env +++ b/board/phytec/phycore_imx93/phycore_imx93.env @@ -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;

From: Benjamin Hahn B.Hahn@phytec.de
Rename existing environment variables according to the bootstd doc. Renamed variables are fdto_addr, bootenv_addr, fdt_addr and fdt_file.
Signed-off-by: Benjamin Hahn B.Hahn@phytec.de Signed-off-by: Daniel Schultz d.schultz@phytec.de --- .../phytec/phycore_imx8mp/phycore_imx8mp.env | 20 +++++++++---------- board/phytec/phycore_imx93/phycore_imx93.env | 20 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/board/phytec/phycore_imx8mp/phycore_imx8mp.env b/board/phytec/phycore_imx8mp/phycore_imx8mp.env index 4ed5dc7e272..f8f878e8f3a 100644 --- a/board/phytec/phycore_imx8mp/phycore_imx8mp.env +++ b/board/phytec/phycore_imx8mp/phycore_imx8mp.env @@ -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; diff --git a/board/phytec/phycore_imx93/phycore_imx93.env b/board/phytec/phycore_imx93/phycore_imx93.env index 09542f5aa7d..ab65cfce5fd 100644 --- a/board/phytec/phycore_imx93/phycore_imx93.env +++ b/board/phytec/phycore_imx93/phycore_imx93.env @@ -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;

From: Benjamin Hahn B.Hahn@phytec.de
Rename existing environment variables according to the bootstd doc. Renamed variables are fdto_addr, bootenv_addr, fdt_addr.
Signed-off-by: Benjamin Hahn B.Hahn@phytec.de Signed-off-by: Daniel Schultz d.schultz@phytec.de --- include/env/phytec/overlays.env | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/include/env/phytec/overlays.env b/include/env/phytec/overlays.env index febb991f4f5..78721cde654 100644 --- a/include/env/phytec/overlays.env +++ b/include/env/phytec/overlays.env @@ -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;

This environment include can be used to boot from a MMC device for PHYTEC's K3-based SoMs.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- include/env/phytec/k3_mmc.env | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 include/env/phytec/k3_mmc.env
diff --git a/include/env/phytec/k3_mmc.env b/include/env/phytec/k3_mmc.env new file mode 100644 index 00000000000..e1208a6eea1 --- /dev/null +++ b/include/env/phytec/k3_mmc.env @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2024 PHYTEC Messtechnik GmbH + * Author: Daniel Schultz d.schultz@phytec.de + */ + +/* 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}

Include the overlays.env file and run the apply routine before booting the Kernel.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- include/env/phytec/k3_mmc.env | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/include/env/phytec/k3_mmc.env b/include/env/phytec/k3_mmc.env index e1208a6eea1..3d3595ceb7e 100644 --- a/include/env/phytec/k3_mmc.env +++ b/include/env/phytec/k3_mmc.env @@ -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}

Use our common environment file to implement MMC boot.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- board/phytec/phycore_am62x/phycore_am62x.env | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/board/phytec/phycore_am62x/phycore_am62x.env b/board/phytec/phycore_am62x/phycore_am62x.env index 2d6475d408f..046bbd22f25 100644 --- a/board/phytec/phycore_am62x/phycore_am62x.env +++ b/board/phytec/phycore_am62x/phycore_am62x.env @@ -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}

On Jul 02, 2024 at 22:42:01 -0700, Daniel Schultz wrote:
Use our common environment file to implement MMC boot.
Signed-off-by: Daniel Schultz d.schultz@phytec.de
Reviewed-by: Dhruva Gole d-gole@ti.com
board/phytec/phycore_am62x/phycore_am62x.env | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
[...]

Use our common environment file to implement MMC boot.
Signed-off-by: Daniel Schultz d.schultz@phytec.de --- board/phytec/phycore_am64x/phycore_am64x.env | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/board/phytec/phycore_am64x/phycore_am64x.env b/board/phytec/phycore_am64x/phycore_am64x.env index e24a958f51d..18f0fa5b4c3 100644 --- a/board/phytec/phycore_am64x/phycore_am64x.env +++ b/board/phytec/phycore_am64x/phycore_am64x.env @@ -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}

On Tue, Jul 02, 2024 at 10:41:53PM -0700, Daniel Schultz wrote:
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!

Am 03.07.24 um 07:41 schrieb 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.
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
For this series,
Reviewed-by: Wadim Egorov w.egorov@phytec.de

On Tue, Jul 02, 2024 at 10:41:53PM -0700, Daniel Schultz wrote:
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.
participants (5)
-
Daniel Schultz
-
Dhruva Gole
-
Teresa Remmet
-
Tom Rini
-
Wadim Egorov