From 68261e4ca35d6b5eaa0c75a0579ec59d8c6f4503 Mon Sep 17 00:00:00 2001 From: "faqiang.zhu" Date: Thu, 20 Dec 2018 15:54:50 +0800 Subject: [PATCH] MA-13303 fix the issue with 8qm boot from eMMC to flash SD For mek_8qm, bootloader offset in SD card is 32kb, in eMMC bootpartition, it's 0kb. This patch fix the issue that bootloader offset used in uboot is always based on the device that the board boot from. Now, if uboot environment variable "target_ubootdev" is set, bootloader offset used in uboot is based on the device "target_ubootdev" specified. So boot from eMMC to flash SD, the board can boot from SD and vice versa. Change-Id: Ia2cd64ba6ece02b98ea3d2addbce00b1661077de Signed-off-by: faqiang.zhu --- drivers/usb/gadget/f_fastboot.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 8926a94..8963c64 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -762,8 +762,7 @@ static ulong bootloader_mmc_offset(void) if (is_imx8m() || (is_imx8() && is_soc_rev(CHIP_REV_A))) return 0x8400; else if (is_imx8qm()) { - int dev_no = mmc_get_env_dev(); - if (MEK_8QM_EMMC == dev_no) + if (MEK_8QM_EMMC == fastboot_devinfo.dev_id) /* target device is eMMC boot0 partition, bootloader offset is 0x0 */ return 0x0; else @@ -908,6 +907,11 @@ static int get_fastboot_target_dev(char *mmc_dev, struct fastboot_ptentry *ptn) sizeof(FASTBOOT_PARTITION_BOOTLOADER))) && (env_get("target_ubootdev"))) { dev = simple_strtoul(env_get("target_ubootdev"), NULL, 10); + + /* if target_ubootdev is set, it must be that users want to change + * fastboot device, then fastboot environment need to be updated */ + fastboot_setup(); + target_mmc = find_mmc_device(dev); if ((target_mmc == NULL) || mmc_init(target_mmc)) { printf("MMC card init failed!\n"); @@ -1247,7 +1251,10 @@ static int _fastboot_setup_dev(int *switched) #if defined(CONFIG_FASTBOOT_STORAGE_MMC) } else if (!strncmp(fastboot_env, "mmc", 3)) { devinfo.type = DEV_MMC; - devinfo.dev_id = mmc_get_env_dev(); + if(env_get("target_ubootdev")) + devinfo.dev_id = simple_strtoul(env_get("target_ubootdev"), NULL, 10); + else + devinfo.dev_id = mmc_get_env_dev(); #endif } else { return 1; -- 1.9.1