]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
phytec: change preferred bootdevice dynamically
authorBenjamin Hahn <B.Hahn@phytec.de>
Fri, 28 Nov 2025 16:38:44 +0000 (17:38 +0100)
committerFabio Estevam <festevam@nabladev.com>
Sat, 29 Nov 2025 21:02:13 +0000 (18:02 -0300)
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 <B.Hahn@phytec.de>
board/phytec/imx8mp-libra-fpsc/imx8mp-libra-fpsc.c
board/phytec/phycore_imx8mm/phycore-imx8mm.c
board/phytec/phycore_imx8mp/phycore-imx8mp.c
board/phytec/phycore_imx8mp/phycore_imx8mp.env
configs/phycore-imx8mp_defconfig

index ffa21da1b34309f716f6bc3e5bd875df5abb00b7..dbbcbec18cd9379bdc59cdee880c0cb6f17592c1 100644 (file)
@@ -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:
index 06cffbca3a690154318e1aae020c8987c66d8055..f6ae0bf03087064ad58bafd3facb587a84d96ef6 100644 (file)
@@ -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);
index bf2d5ce01fa5c5a2079bb886093fd6d4a43970c5..b345dc7c9856fd1fb149a1a7d6718a910c57be22 100644 (file)
@@ -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;
index f825c7bc61ff8e07cd6f4f7e7e65b4c288d3e00c..c339c315c3081f3eeb0a2ce9a2ddef83638afa68 100644 (file)
@@ -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
index c497f0bcd9131abab0b751ec9cc81194405b1f19..2fcf7db9e5c810402fea7b7aa3dde38125cf029b 100644 (file)
@@ -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