summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2018-08-28 00:29:02 -0700
committerYe Li <ye.li@nxp.com>2018-08-28 02:37:45 -0700
commita856985636d3a112d0b4741231bc3d3e20f2f1dc (patch)
tree00a68bed108ce104aea93eef54536dd277662fa6
parentb6a1a19c6649e59f986625e5b4a9fa886821dd88 (diff)
MLK-19356 fastboot: Fix ucmd issue in fastboot
After executing each ucmd, the ucmd callback function always call fastboot_setup to setup some enviroments. Because the mmc will be switched to user area by calling blk_get_dev in _fastboot_load_partitions. When running "mmc partconf" by ucmd, the PART_CONFIG EXTCSD is updated, but the part_config and hwpart variables in mmc and blk structure are not synced. So the old value will write to PART_CONFIG EXTCSD again when switch to user area. This patch changes the fastboot_setup, only load the partitions when the storage device is changed. Also force to re-init mmc before loading the partitions to sync mmc variables. Signed-off-by: Ye Li <ye.li@nxp.com> (cherry picked from commit c9cd93b25586ecd4ce9178da7b8141f60cdd9deb)
-rw-r--r--drivers/usb/gadget/f_fastboot.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index b7ceff6699..79ddb689a0 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -313,7 +313,7 @@ static struct usb_gadget_strings *fastboot_strings[] = {
#define MAX_PTN 32
struct fastboot_ptentry g_ptable[MAX_PTN];
unsigned int g_pcount;
-struct fastboot_device_info fastboot_devinfo;
+struct fastboot_device_info fastboot_devinfo = {0xff, 0xff};
enum {
@@ -1249,20 +1249,24 @@ static void parameters_setup(void)
CONFIG_FASTBOOT_BUF_SIZE;
}
-static int _fastboot_setup_dev(void)
+static int _fastboot_setup_dev(int *switched)
{
char *fastboot_env;
+ struct fastboot_device_info devinfo;;
+
fastboot_env = getenv("fastboot_dev");
if (fastboot_env) {
if (!strcmp(fastboot_env, "sata")) {
- fastboot_devinfo.type = DEV_SATA;
- fastboot_devinfo.dev_id = 0;
+ devinfo.type = DEV_SATA;
+ devinfo.dev_id = 0;
#if defined(CONFIG_FASTBOOT_STORAGE_MMC)
} else if (!strncmp(fastboot_env, "mmc", 3)) {
- fastboot_devinfo.type = DEV_MMC;
- fastboot_devinfo.dev_id = mmc_get_env_dev();
+ devinfo.type = DEV_MMC;
+ devinfo.dev_id = mmc_get_env_dev();
#endif
+ } else {
+ return 1;
}
} else {
return 1;
@@ -1274,6 +1278,16 @@ static int _fastboot_setup_dev(void)
fastboot_firmwareinfo.type = ANDROID_MCU_FRIMWARE_DEV_TYPE;
#endif
+ if (switched) {
+ if (devinfo.type != fastboot_devinfo.type || devinfo.dev_id != fastboot_devinfo.dev_id)
+ *switched = 1;
+ else
+ *switched = 0;
+ }
+
+ fastboot_devinfo.type = devinfo.type;
+ fastboot_devinfo.dev_id = devinfo.dev_id;
+
return 0;
}
@@ -1369,6 +1383,9 @@ static int _fastboot_parts_load_from_ptable(void)
printf("flash target is MMC:%d\n", mmc_no);
mmc = find_mmc_device(mmc_no);
+
+ /* Force to init mmc */
+ mmc->has_init = 0;
if (mmc && mmc_init(mmc))
printf("MMC card init failed!\n");
@@ -1738,6 +1755,7 @@ fail:
void fastboot_setup(void)
{
+ int sw, ret;
#ifdef CONFIG_USB_GADGET
struct tag_serialnr serialnr;
char serial[17];
@@ -1750,11 +1768,11 @@ void fastboot_setup(void)
board_fastboot_setup();
/*get the fastboot dev*/
- _fastboot_setup_dev();
-
+ ret = _fastboot_setup_dev(&sw);
/*load partitions information for the fastboot dev*/
- _fastboot_load_partitions();
+ if (!ret && sw)
+ _fastboot_load_partitions();
parameters_setup();
#ifdef CONFIG_AVB_SUPPORT