The FRDM i.MX 93 board can be booted in a USB-serial download
mode where the bootrom pauses and expects the host to upload
a U-Boot binary which will boot directly into fastboot mode.
The host is then expected to use 'uuu' to flash storage devices.

The current implementation of this will only enter fastboot mode
after the regular boot command completes, which means that U-Boot will
prefer to boot existing OSes even when the USB-serial download mode has
been explicitly set.

Fix the USB-based fastboot launching to prepend bootcmd instead,
following the example of phyCORE-i.MX91/93. And if bootcmd has been
customised then this behaviour will be skipped.

Signed-off-by: Daniel Drake <[email protected]>
---
This replaces the series "imx: consistently enter fastboot on USB serial
download boot", because I concluded that the generic approach doesn't
really make sense:
https://lore.kernel.org/r/[email protected]
---
 board/nxp/imx93_frdm/imx93_frdm.c   | 7 +++++--
 board/nxp/imx93_frdm/imx93_frdm.env | 4 ----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/board/nxp/imx93_frdm/imx93_frdm.c 
b/board/nxp/imx93_frdm/imx93_frdm.c
index e187de74a72..b6e4e97c988 100644
--- a/board/nxp/imx93_frdm/imx93_frdm.c
+++ b/board/nxp/imx93_frdm/imx93_frdm.c
@@ -106,8 +106,11 @@ int board_late_init(void)
        }
 
        if (get_boot_device() == USB_BOOT) {
-               printf("USB boot detected. Will enter fasboot mode\n");
-               env_set_ulong("dofastboot", 1);
+               const char *bootcmd = env_get("bootcmd");
+
+               printf("USB boot detected. Will enter fastboot mode\n");
+               if (bootcmd && !strcmp(bootcmd, CONFIG_BOOTCOMMAND))
+                       env_set("bootcmd", "fastboot 0; " CONFIG_BOOTCOMMAND);
        }
 
        clear_pd_alert();
diff --git a/board/nxp/imx93_frdm/imx93_frdm.env 
b/board/nxp/imx93_frdm/imx93_frdm.env
index 96096bc51a0..b68ab18258e 100644
--- a/board/nxp/imx93_frdm/imx93_frdm.env
+++ b/board/nxp/imx93_frdm/imx93_frdm.env
@@ -26,12 +26,8 @@ fastboot_partition_alias_all=0:0
 fastboot_partition_alias_bootloader=0.1
 emmc_dev=0
 sd_dev=1
-dofastboot=0
 
 bsp_bootcmd=
-       if test ${dofastboot} = 1; then
-               fastboot 0;
-       fi;
        echo Running BSP bootcmd ...;
        mmc dev ${mmcdev};
        run mmcargs;

---
base-commit: 709a97a05df66e394f40d249105d0baade46f107
change-id: 20261106-imx93-frdm-usb-boot-fastboot-f6902c9adcf8

Best regards,
-- 
Daniel Drake <[email protected]>

Reply via email to