summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Hahn <[email protected]>2025-11-28 17:38:44 +0100
committerFabio Estevam <[email protected]>2025-11-29 18:02:13 -0300
commit76612e93c3cd0422171a62ebddf3afc36d5cd9a2 (patch)
tree28ca07e2d82f9efb9d75e8ccda5706dd2153cdb4
parent27d6ea356193badc418d79e27ce6cf33120aa743 (diff)
phytec: change preferred bootdevice dynamically
We want to change the bootdevice dynamically, so that when booting U-Boot from sdcard, kernel is also preferably booted from sdcard by default. If the user decides to set their own bootorder, this should not be overwritten. This was already implemented for imx8mp-libra-fpsc board, but as we set the default value for boot_targets in devicetree now, the env_get_default will return NULL. Also env_get might return NULL when boot_targets is not set. A string compare with NULL is unsafe and should be avoided. To fix this we only change the env value if the variable was not set before (NULL), as this is the new default value. In any other case the user has changed the value so it will not be overwritten. Also let standardboot set bootcmd automatically. For this CONFIG_USE_BOOTCOMMAND needs to be activated. Signed-off-by: Benjamin Hahn <[email protected]>
-rw-r--r--board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.c2
-rw-r--r--board/phytec/phycore_imx8mm/phycore-imx8mm.c2
-rw-r--r--board/phytec/phycore_imx8mp/phycore-imx8mp.c5
-rw-r--r--board/phytec/phycore_imx8mp/phycore_imx8mp.env6
-rw-r--r--configs/phycore-imx8mp_defconfig1
5 files changed, 7 insertions, 9 deletions
diff --git a/board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.c b/board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.c
index ffa21da1b34..dbbcbec18cd 100644
--- a/board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.c
+++ b/board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.c
@@ -60,7 +60,7 @@ 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")))
+ if (!env_get("boot_targets"))
env_set("boot_targets", "mmc1 mmc2 ethernet");
break;
case MMC3_BOOT:
diff --git a/board/phytec/phycore_imx8mm/phycore-imx8mm.c b/board/phytec/phycore_imx8mm/phycore-imx8mm.c
index 06cffbca3a6..f6ae0bf0308 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 (!env_get("boot_targets"))
+ env_set("boot_targets", "mmc1 mmc2 ethernet");
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 bf2d5ce01fa..b345dc7c985 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 (!env_get("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 f825c7bc61f..c339c315c30 100644
--- a/board/phytec/phycore_imx8mp/phycore_imx8mp.env
+++ b/board/phytec/phycore_imx8mp/phycore_imx8mp.env
@@ -1,11 +1,5 @@
-bootcmd=
- if test ${dofastboot} = 1; then
- fastboot 0;
- fi;
- bootflow scan -lb;
boot_script_dhcp=net_boot_fit.scr.uimg
console=ttymxc0,115200
-dofastboot=0
emmc_dev=2 /* This is needed by built-in uuu flash scripts */
fastboot_raw_partition_all=0 4194304
fastboot_raw_partition_bootloader=64 8128
diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-imx8mp_defconfig
index c497f0bcd91..2fcf7db9e5c 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