Commit a8569856 authored by Ye Li's avatar Ye Li

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: 's avatarYe Li <ye.li@nxp.com>
(cherry picked from commit c9cd93b25586ecd4ce9178da7b8141f60cdd9deb)
parent b6a1a19c
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment