[PATCH 1/6] phytec: change preferred bootdevice dynamically

Benjamin Hahn B.Hahn at phytec.de
Wed Nov 26 16:30:30 CET 2025


On 25.11.25 18:23, Benjamin Hahn wrote:
> Change the preferred bootdevice dynamically based on the device the
> U-Boot is loaded from. The same way is already implemented for
> imx8mp-libra-fpsc board. Also let standardboot set bootcmd variable
> automatically.
>
> Signed-off-by: Benjamin Hahn <B.Hahn at phytec.de>
> ---
>   board/phytec/phycore_imx8mm/phycore-imx8mm.c   | 2 ++
>   board/phytec/phycore_imx8mp/phycore-imx8mp.c   | 5 ++++-
>   board/phytec/phycore_imx8mp/phycore_imx8mp.env | 6 ------
>   configs/phycore-imx8mp_defconfig               | 1 -
>   4 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/board/phytec/phycore_imx8mm/phycore-imx8mm.c b/board/phytec/phycore_imx8mm/phycore-imx8mm.c
> index 06cffbca3a69..7d569d475e63 100644
> --- a/board/phytec/phycore_imx8mm/phycore-imx8mm.c
> +++ b/board/phytec/phycore_imx8mm/phycore-imx8mm.c
> @@ -41,6 +41,8 @@ int board_late_init(void)
>   	switch (get_boot_device()) {
>   	case SD2_BOOT:
>   		env_set_ulong("mmcdev", 1);
> +		if (!strcmp(env_get("boot_targets"), env_get_default("boot_targets")))
> +			env_set("boot_targets", "mmc1 mmc2 usb ethernet");

This does not work with setting boot_targets for standardboot in the 
devicetree, as it will not be set in the default env. Also strcmp with 
NULL needs to be considered.

I will send a v2.

Benjamin

>   		break;
>   	case MMC3_BOOT:
>   		env_set_ulong("mmcdev", 2);
> diff --git a/board/phytec/phycore_imx8mp/phycore-imx8mp.c b/board/phytec/phycore_imx8mp/phycore-imx8mp.c
> index bf2d5ce01fa5..25cf889d357c 100644
> --- a/board/phytec/phycore_imx8mp/phycore-imx8mp.c
> +++ b/board/phytec/phycore_imx8mp/phycore-imx8mp.c
> @@ -76,13 +76,16 @@ int board_late_init(void)
>   	switch (get_boot_device()) {
>   	case SD2_BOOT:
>   		env_set_ulong("mmcdev", 1);
> +		if (!strcmp(env_get("boot_targets"), env_get_default("boot_targets")))
> +			env_set("boot_targets", "mmc1 mmc2 usb ethernet");
>   		break;
>   	case MMC3_BOOT:
>   		env_set_ulong("mmcdev", 2);
>   		break;
>   	case USB_BOOT:
>   		printf("Detect USB boot. Will enter fastboot mode!\n");
> -		env_set_ulong("dofastboot", 1);
> +		if (!strcmp(env_get("bootcmd"), env_get_default("bootcmd")))
> +			env_set("bootcmd", "fastboot 0; bootflow scan -lb;");
>   		break;
>   	default:
>   		break;
> diff --git a/board/phytec/phycore_imx8mp/phycore_imx8mp.env b/board/phytec/phycore_imx8mp/phycore_imx8mp.env
> index 70044997adb8..323199b041b1 100644
> --- a/board/phytec/phycore_imx8mp/phycore_imx8mp.env
> +++ b/board/phytec/phycore_imx8mp/phycore_imx8mp.env
> @@ -1,8 +1,3 @@
> -bootcmd=
> -	if test ${dofastboot} = 1; then
> -		fastboot 0;
> -	fi;
> -	bootflow scan -lb;
>   #ifdef CONFIG_BOOTMETH_RAUC
>   bootmeths=rauc script efi
>   #else
> @@ -12,7 +7,6 @@ boot_targets=mmc2 mmc1 usb ethernet
>   bootenv_addr_r=0x49100000
>   boot_script_dhcp=boot.scr.uimg
>   console=ttymxc0,115200
> -dofastboot=0
>   fastboot_raw_partition_all=0 4194304
>   fastboot_raw_partition_bootloader=64 8128
>   fdt_addr_r=0x48000000
> diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-imx8mp_defconfig
> index c497f0bcd913..2fcf7db9e5c8 100644
> --- a/configs/phycore-imx8mp_defconfig
> +++ b/configs/phycore-imx8mp_defconfig
> @@ -38,7 +38,6 @@ CONFIG_BOOTSTD_FULL=y
>   CONFIG_OF_BOARD_SETUP=y
>   CONFIG_OF_SYSTEM_SETUP=y
>   CONFIG_FDT_FIXUP_PARTITIONS=y
> -# CONFIG_USE_BOOTCOMMAND is not set
>   CONFIG_DEFAULT_FDT_FILE="oftree"
>   CONFIG_SYS_CBSIZE=2048
>   CONFIG_SYS_PBSIZE=2074
>



More information about the U-Boot mailing list