[PATCH] config: imx: Add support for Phytec's phycore imx8mm running SDP gadget

Benjamin Hahn B.Hahn at phytec.de
Mon Aug 19 15:29:14 CEST 2024


Hi Lukasz,
did you test this? It does not work for me. When I try it, the U-Boot 
hangs in SPL. Here is what I got:
 From Host:

bhahn at llp-hahn:~/git-repos/u-boot$ sudo uuu -b spl build/mini/flash.bin
uuu (Universal Update Utility) for nxp imx chips -- lib1.4.193

Success 0    Failure 0


7:3      1/ 1 [=================100%=================] SDP: boot -f 
build/mini/flash.bin


Log on target:

U-Boot SPL 2024.10-rc2-00131-g0303f2240376 (Aug 19 2024 - 15:18:36 +0200)
WDT:   Started watchdog at 30280000 with servicing every 1000ms (60s timeout)
Trying to boot from USB SDP

U-Boot SPL 2024.10-rc2-00131-g0303f2240376 (Aug 19 2024 - 15:18:36 +0200)
WDT:   Started watchdog at 30280000 with servicing every 1000ms (60s timeout)
Trying to boot from USB SDP

To me it looks like there are some changes missing to get this feature 
to work.
You can take a look at my commits where I added this feature for imx8mp.
199229e28b2b2da57c52ee46452f930785cf6002 ("phycore-imx8mp: add USB mass 
storage support")
8dcf1df48dff339b172d1bce2a38a965ee4aafca ("phycore-imx8mp: add support 
for booting and flashing emmc via UUU")


Here are the changes I needed to do on top of your patch to get this 
feature to work for mini:

diff --git a/arch/arm/dts/imx8mm-phyboard-polis-rdk-u-boot.dtsi 
b/arch/arm/dts/imx8mm-phyboard-polis-rdk-u-boot.dtsi
index 516e52e1f5de..cdaff2f8da9b 100644
--- a/arch/arm/dts/imx8mm-phyboard-polis-rdk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-phyboard-polis-rdk-u-boot.dtsi
@@ -69,3 +69,8 @@
  &wdog1 {
         bootph-pre-ram;
  };
+
+&usbotg1 {
+       dr_mode = "peripheral";
+       u-boot,dm-spl;
+};
diff --git a/board/phytec/phycore_imx8mm/phycore-imx8mm.c 
b/board/phytec/phycore_imx8mm/phycore-imx8mm.c
index 06cffbca3a69..00fdd4edbe36 100644
--- a/board/phytec/phycore_imx8mm/phycore-imx8mm.c
+++ b/board/phytec/phycore_imx8mm/phycore-imx8mm.c
@@ -45,6 +45,10 @@ int board_late_init(void)
         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);
+               break;
         default:
                 break;
         }
diff --git a/configs/phycore-imx8mm_defconfig 
b/configs/phycore-imx8mm_defconfig
index beb2f1e9f031..e8d3ffe8c05d 100644
--- a/configs/phycore-imx8mm_defconfig
+++ b/configs/phycore-imx8mm_defconfig
@@ -31,7 +31,7 @@ CONFIG_FIT_EXTERNAL_OFFSET=0x3000
  CONFIG_SPL_LOAD_FIT=y
  CONFIG_OF_SYSTEM_SETUP=y
  CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="mmc dev ${mmcdev}; if mmc rescan; then if run 
loadimage; then run mmcboot; else run netboot; fi; fi;"
+CONFIG_BOOTCOMMAND="if test ${dofastboot} = 1; then fastboot 0; fi; mmc 
dev ${mmcdev}; if mmc rescan; then if run loadimage; then run mmcboot; 
else run netboot; fi; fi;"
  CONFIG_DEFAULT_FDT_FILE="oftree"
  CONFIG_SYS_CBSIZE=2048
  CONFIG_SYS_PBSIZE=2074
@@ -153,3 +153,11 @@ CONFIG_CI_UDC=y
  CONFIG_SDP_LOADADDR=0x40400000
  CONFIG_SPL_USB_SDP_SUPPORT=y
  CONFIG_IMX_WATCHDOG=y
+CONFIG_CMD_USB_SDP=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=2
+CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y
+CONFIG_FASTBOOT_MMC_BOOT1_NAME="mmc2boot0"
+CONFIG_FASTBOOT_MMC_BOOT2_NAME="mmc2boot1"
+CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
+CONFIG_FASTBOOT_MMC_USER_NAME="mmc2"
diff --git a/include/configs/phycore_imx8mm.h 
b/include/configs/phycore_imx8mm.h
index dd7cfdba52d2..f3a750089dd5 100644
--- a/include/configs/phycore_imx8mm.h
+++ b/include/configs/phycore_imx8mm.h
@@ -26,6 +26,11 @@
         "fdt_addr=0x48000000\0" \
         "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
         "ip_dyn=yes\0" \
+       "dofastboot=0\0" \
+       "fastboot_raw_partition_bootloader=66 8128\0" \
+       "fastboot_raw_partition_all=0 4194304\0" \
+       "emmc_dev=2\0" \
+       "sd_dev=1\0" \
         "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
         "mmcpart=1\0" \
         "mmcroot=2\0" \


With these changes booting via SDP with uuu and flashing emmc with uuu 
should work. Sadly I did not find a way to be able to flash eMMC and 
SD-Card over uuu with the same bootloader because it was necessary for 
me to specify the device to flash in CONFIG_FASTBOOT_FLASH_MMC_DEV.

with kind regards,
Benjamin

On 15.08.24 10:45, Lukasz Majewski wrote:
> After this change it would be possible to boot SDP gadget when Phytec's
> Phycore imx8mm module has USB ROM boot selected.
>
> With this change it shall be possible to flash eMMC/SD card content with
> uuu program.
>
> Signed-off-by: Lukasz Majewski <lukma at denx.de>
> ---
>   configs/phycore-imx8mm_defconfig | 18 +++++++++++++++++-
>   1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/configs/phycore-imx8mm_defconfig b/configs/phycore-imx8mm_defconfig
> index 6748e6fafb..beb2f1e9f0 100644
> --- a/configs/phycore-imx8mm_defconfig
> +++ b/configs/phycore-imx8mm_defconfig
> @@ -25,6 +25,7 @@ CONFIG_SPL=y
>   CONFIG_ENV_OFFSET_REDUND=0x3E0000
>   CONFIG_SYS_LOAD_ADDR=0x40480000
>   CONFIG_PCI=y
> +# CONFIG_ANDROID_BOOT_IMAGE is not set
>   CONFIG_FIT=y
>   CONFIG_FIT_EXTERNAL_OFFSET=0x3000
>   CONFIG_SPL_LOAD_FIT=y
> @@ -57,6 +58,7 @@ CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2
>   CONFIG_SYS_EEPROM_SIZE=4096
>   CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=5
>   CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=5
> +# CONFIG_CMD_BIND is not set
>   CONFIG_CMD_CLK=y
>   CONFIG_CMD_FUSE=y
>   CONFIG_CMD_GPIO=y
> @@ -86,6 +88,10 @@ CONFIG_SPL_CLK_COMPOSITE_CCF=y
>   CONFIG_CLK_COMPOSITE_CCF=y
>   CONFIG_SPL_CLK_IMX8MM=y
>   CONFIG_CLK_IMX8MM=y
> +CONFIG_USB_FUNCTION_FASTBOOT=y
> +CONFIG_FASTBOOT_BUF_ADDR=0x42800000
> +CONFIG_FASTBOOT_BUF_SIZE=0x20000000
> +CONFIG_FASTBOOT_UUU_SUPPORT=y
>   CONFIG_MXC_GPIO=y
>   CONFIG_DM_I2C=y
>   CONFIG_MISC=y
> @@ -116,7 +122,6 @@ CONFIG_FEC_MXC=y
>   CONFIG_MII=y
>   CONFIG_NVME_PCI=y
>   CONFIG_PCIE_DW_IMX=y
> -CONFIG_PHY=y
>   CONFIG_PHY_IMX8M_PCIE=y
>   CONFIG_PINCTRL=y
>   CONFIG_SPL_PINCTRL=y
> @@ -136,4 +141,15 @@ CONFIG_SYSRESET_PSCI=y
>   CONFIG_SYSRESET_WATCHDOG=y
>   CONFIG_DM_THERMAL=y
>   CONFIG_IMX_TMU=y
> +CONFIG_USB=y
> +CONFIG_SPL_USB_HOST=y
> +CONFIG_USB_EHCI_HCD=y
> +CONFIG_MXC_USB_OTG_HACTIVE=y
> +CONFIG_USB_GADGET=y
> +CONFIG_SPL_USB_GADGET=y
> +CONFIG_USB_GADGET_VENDOR_NUM=0x0525
> +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
> +CONFIG_CI_UDC=y
> +CONFIG_SDP_LOADADDR=0x40400000
> +CONFIG_SPL_USB_SDP_SUPPORT=y
>   CONFIG_IMX_WATCHDOG=y




More information about the U-Boot mailing list