summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Li <Frank.Li@nxp.com>2018-05-25 16:56:25 -0500
committerFrank Li <Frank.Li@nxp.com>2018-07-11 13:50:01 -0500
commitca96e0bd1aea1996904b0a71fb1d74c3f5176929 (patch)
tree9fa3e9972816ca1f50d513df80f51c9412565d12
parentf3f834587a8fe0bceba99233250d8ff239950f1f (diff)
MLK-18406 fastboot support all partition
uuu can write to any position of mmc sdps: boot -f ../mkimage_imx8dv/imx-mkimage/iMX8QX/flash.bin FB: ucmd setenv fastboot_dev mmc FB: ucmd setenv mmcdev ${emmc_dev} FB: ucmd mmc dev ${emmc_dev} FB: flash -raw2sparse all xx.sdcard Signed-off-by: Frank Li <Frank.Li@nxp.com>
-rw-r--r--arch/arm/cpu/armv8/imx8/cpu.c2
-rwxr-xr-xdrivers/usb/gadget/f_fastboot.c37
-rw-r--r--include/configs/imx8qxp_mek.h4
3 files changed, 34 insertions, 9 deletions
diff --git a/arch/arm/cpu/armv8/imx8/cpu.c b/arch/arm/cpu/armv8/imx8/cpu.c
index ce343d78c3..369fcdb2bf 100644
--- a/arch/arm/cpu/armv8/imx8/cpu.c
+++ b/arch/arm/cpu/armv8/imx8/cpu.c
@@ -836,7 +836,7 @@ int mmc_get_env_dev(void)
break;
default:
/* If not boot from sd/mmc, use default value */
- return CONFIG_SYS_MMC_ENV_DEV;
+ return getenv_ulong("mmcdev", 10, CONFIG_SYS_MMC_ENV_DEV);
}
return board_mmc_get_env_dev(devno);
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 78a694ad53..95aab1e080 100755
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -301,6 +301,8 @@ static struct usb_gadget_strings *fastboot_strings[] = {
#define TEE_HWPARTITION_ID 2
#endif
+#define FASTBOOT_PARTITION_ALL "all"
+
#define ANDROID_MBR_OFFSET 0
#define ANDROID_MBR_SIZE 0x200
#ifdef CONFIG_BOOTLOADER_OFFSET_33K
@@ -328,6 +330,7 @@ enum {
#ifdef CONFIG_FLASH_MCUFIRMWARE_SUPPORT
PTN_M4_OS_INDEX,
#endif
+ PTN_ALL_INDEX,
PTN_BOOTLOADER_INDEX,
};
static unsigned int download_bytes_unpadded;
@@ -828,6 +831,7 @@ static lbaint_t mmc_sparse_write(struct sparse_storage *info,
{
#define SPARSE_FILL_BUF_SIZE (2 * 1024 * 1024)
+
struct blk_desc *dev_desc = (struct blk_desc *)info->priv;
ulong ret = 0;
void *data;
@@ -1005,13 +1009,20 @@ static void process_flash_mmc(const char *cmdbuf)
return;
}
- if (part_get_info(dev_desc,
- ptn->partition_index, &info)) {
- printf("Bad partition index:%d for partition:%s\n",
- ptn->partition_index, ptn->name);
- return;
- }
+ if( strncmp(ptn->name, FASTBOOT_PARTITION_ALL,
+ strlen(FASTBOOT_PARTITION_ALL)) == 0) {
+ info.blksz = dev_desc->blksz;
+ info.size = dev_desc->lba;
+ info.start = 0;
+ } else {
+ if (part_get_info(dev_desc,
+ ptn->partition_index, &info)) {
+ printf("Bad partition index:%d for partition:%s\n",
+ ptn->partition_index, ptn->name);
+ return;
+ }
+ }
printf("writing to partition '%s' for sparse, buffer size %d\n",
ptn->name, download_bytes);
@@ -1404,6 +1415,12 @@ static int _fastboot_parts_load_from_ptable(void)
strcpy(ptable[PTN_M4_OS_INDEX].fstype, "raw");
#endif
+ strcpy(ptable[PTN_ALL_INDEX].name, FASTBOOT_PARTITION_ALL);
+ ptable[PTN_ALL_INDEX].start = 0;
+ ptable[PTN_ALL_INDEX].length = dev_desc->lba;
+ ptable[PTN_ALL_INDEX].partition_id = user_partition;
+ strcpy(ptable[PTN_ALL_INDEX].fstype, "device");
+
/* Bootloader */
strcpy(ptable[PTN_BOOTLOADER_INDEX].name, FASTBOOT_PARTITION_BOOTLOADER);
ptable[PTN_BOOTLOADER_INDEX].start =
@@ -3195,6 +3212,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req)
strcpy(response, "OKAY");
fastboot_tx_write_str(response);
+ setenv_hex("fastboot_bytes", download_bytes);
printf("\ndownloading of %d bytes finished\n", download_bytes);
@@ -3587,10 +3605,13 @@ static void cb_run_uboot_cmd(struct usb_ep *ep, struct usb_request *req)
fastboot_tx_write_str("FAILmissing command");
return;
}
- if(run_command(cmd, 0))
+ if(run_command(cmd, 0)) {
fastboot_tx_write_str("FAIL");
- else
+ } else {
fastboot_tx_write_str("OKAY");
+ /* cmd may impact fastboot related environment*/
+ fastboot_setup();
+ }
return ;
}
diff --git a/include/configs/imx8qxp_mek.h b/include/configs/imx8qxp_mek.h
index 3e5f1eb7ed..eb0785909e 100644
--- a/include/configs/imx8qxp_mek.h
+++ b/include/configs/imx8qxp_mek.h
@@ -168,6 +168,8 @@
"mmcpart=" __stringify(CONFIG_SYS_MMC_IMG_LOAD_PART) "\0" \
"mmcroot=" CONFIG_MMCROOT " rootwait rw\0" \
"mmcautodetect=yes\0" \
+ "emmc_dev=0\0"\
+ "sd_dev=1\0"\
"mmcargs=setenv bootargs console=${console},${baudrate} root=${mmcroot} " \
"video=imxdpufb5:off video=imxdpufb6:off video=imxdpufb7:off\0" \
"loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
@@ -279,6 +281,8 @@
#define CONFIG_MMCROOT "/dev/mmcblk1p2" /* USDHC2 */
#define CONFIG_SYS_FSL_USDHC_NUM 2
+#define CONFIG_BOOTLOADER_OFFSET_32K
+
/* Size of malloc() pool */
#define CONFIG_SYS_MALLOC_LEN ((CONFIG_ENV_SIZE + (32*1024)) * 1024)