From 7596696bc5c6062c52f07e2ed99e3b2eebb3a33e Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 27 Jan 2021 14:46:46 +0100 Subject: fastboot: mmc: Add CONFIG_FASTBOOT_MMC_USER_SUPPORT Split userdata and boot partition support for eMMC update and correct the description (update is supported). The new configuration CONFIG_FASTBOOT_MMC_USER_SUPPORT allows to activate support of userdata partition update, based on target name=CONFIG_FASTBOOT_MMC_USER_NAME This patch also removes the unnecessary dependency with ARCH_MEDIATEK and EFI_PARTITION. Signed-off-by: Patrick Delaunay --- drivers/fastboot/fb_mmc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/fastboot/fb_mmc.c') diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index 4e26cef9417..b5d4c90bfce 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -174,7 +174,8 @@ static void write_raw_image(struct blk_desc *dev_desc, fastboot_okay(NULL, response); } -#ifdef CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT +#if defined(CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT) || \ + defined(CONFIG_FASTBOOT_MMC_USER_SUPPORT) static int fb_mmc_erase_mmc_hwpart(struct blk_desc *dev_desc) { lbaint_t blks; @@ -193,7 +194,9 @@ static int fb_mmc_erase_mmc_hwpart(struct blk_desc *dev_desc) return 0; } +#endif +#ifdef CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT static void fb_mmc_boot1_ops(struct blk_desc *dev_desc, void *buffer, u32 buff_sz, char *response) { @@ -473,7 +476,7 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, #endif #if CONFIG_IS_ENABLED(EFI_PARTITION) -#ifndef CONFIG_FASTBOOT_MMC_USER_NAME +#ifndef CONFIG_FASTBOOT_MMC_USER_SUPPORT if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0) { #else if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0 || @@ -603,7 +606,7 @@ void fastboot_mmc_erase(const char *cmd, char *response) } #endif -#ifdef CONFIG_FASTBOOT_MMC_USER_NAME +#ifdef CONFIG_FASTBOOT_MMC_USER_SUPPORT if (strcmp(cmd, CONFIG_FASTBOOT_MMC_USER_NAME) == 0) { /* erase EMMC userdata */ if (fb_mmc_erase_mmc_hwpart(dev_desc)) -- cgit v1.2.3 From 3acbc7b2aa14fe19ee341fc91a54849185708274 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 27 Jan 2021 14:46:47 +0100 Subject: fastboot: mmc: extend flash/erase for both emmc hwpart 1 and 2 Update the code and the configs for eMMC boot and userdata partitions acces - FASTBOOT_MMC_BOOT_SUPPORT: boot partition 1 and 2 (erase/write) - FASTBOOT_MMC_BOOT1_NAME: boot partition 1, default name="mmc0boot0" - FASTBOOT_MMC_BOOT2_NAME: boot partition 2, default name="mmc0boot1" This patch also removes the unnecessary dependency with ARCH_MEDIATEK and EFI_PARTITION. Signed-off-by: Patrick Delaunay --- drivers/fastboot/fb_mmc.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'drivers/fastboot/fb_mmc.c') diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index b5d4c90bfce..611074a3e43 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -174,7 +174,7 @@ static void write_raw_image(struct blk_desc *dev_desc, fastboot_okay(NULL, response); } -#if defined(CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT) || \ +#if defined(CONFIG_FASTBOOT_MMC_BOOT_SUPPORT) || \ defined(CONFIG_FASTBOOT_MMC_USER_SUPPORT) static int fb_mmc_erase_mmc_hwpart(struct blk_desc *dev_desc) { @@ -196,16 +196,16 @@ static int fb_mmc_erase_mmc_hwpart(struct blk_desc *dev_desc) } #endif -#ifdef CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT -static void fb_mmc_boot1_ops(struct blk_desc *dev_desc, void *buffer, - u32 buff_sz, char *response) +#ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT +static void fb_mmc_boot_ops(struct blk_desc *dev_desc, void *buffer, + int hwpart, u32 buff_sz, char *response) { lbaint_t blkcnt; lbaint_t blks; unsigned long blksz; - // To operate on EMMC_BOOT1 (mmc0boot0), we first change the hwpart - if (blk_dselect_hwpart(dev_desc, 1)) { + // To operate on EMMC_BOOT1/2 (mmc0boot0/1) we first change the hwpart + if (blk_dselect_hwpart(dev_desc, hwpart)) { pr_err("Failed to select hwpart\n"); fastboot_fail("Failed to select hwpart", response); return; @@ -224,21 +224,24 @@ static void fb_mmc_boot1_ops(struct blk_desc *dev_desc, void *buffer, return; } - debug("Start Flashing Image to EMMC_BOOT1...\n"); + debug("Start Flashing Image to EMMC_BOOT%d...\n", hwpart); blks = fb_mmc_blk_write(dev_desc, 0, blkcnt, buffer); if (blks != blkcnt) { - pr_err("Failed to write EMMC_BOOT1\n"); - fastboot_fail("Failed to write EMMC_BOOT1", response); + pr_err("Failed to write EMMC_BOOT%d\n", hwpart); + fastboot_fail("Failed to write EMMC_BOOT part", + response); return; } - printf("........ wrote %lu bytes to EMMC_BOOT1\n", - blkcnt * blksz); + printf("........ wrote %lu bytes to EMMC_BOOT%d\n", + blkcnt * blksz, hwpart); } else { /* erase */ if (fb_mmc_erase_mmc_hwpart(dev_desc)) { - fastboot_fail("Failed to erase EMMC_BOOT1", response); + pr_err("Failed to erase EMMC_BOOT%d\n", hwpart); + fastboot_fail("Failed to erase EMMC_BOOT part", + response); return; } } @@ -467,10 +470,15 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, return; } -#ifdef CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT +#ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) { - fb_mmc_boot1_ops(dev_desc, download_buffer, - download_bytes, response); + fb_mmc_boot_ops(dev_desc, download_buffer, 1, + download_bytes, response); + return; + } + if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) { + fb_mmc_boot_ops(dev_desc, download_buffer, 2, + download_bytes, response); return; } #endif @@ -598,10 +606,15 @@ void fastboot_mmc_erase(const char *cmd, char *response) return; } -#ifdef CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT +#ifdef CONFIG_FASTBOOT_MMC_BOOT_SUPPORT if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT1_NAME) == 0) { /* erase EMMC boot1 */ - fb_mmc_boot1_ops(dev_desc, NULL, 0, response); + fb_mmc_boot_ops(dev_desc, NULL, 1, 0, response); + return; + } + if (strcmp(cmd, CONFIG_FASTBOOT_MMC_BOOT2_NAME) == 0) { + /* erase EMMC boot2 */ + fb_mmc_boot_ops(dev_desc, NULL, 2, 0, response); return; } #endif -- cgit v1.2.3 From adb5daf0905a190375e46d59f1244b13c3cdc640 Mon Sep 17 00:00:00 2001 From: Roman Stratiienko Date: Wed, 27 Jan 2021 17:40:16 +0200 Subject: fastboot: reinit partition after storing GPT or MBR In case MMC has MBR system and fastboot writes GPT, MMC is still recognized as MBR. Invoke part_init() to purge cached data and update information about partition table type. Signed-off-by: Roman Stratiienko --- drivers/fastboot/fb_mmc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/fastboot/fb_mmc.c') diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index 611074a3e43..50532acb847 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -504,6 +504,7 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, response); return; } + part_init(dev_desc); printf("........ success\n"); fastboot_okay(NULL, response); return; @@ -525,6 +526,7 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, response); return; } + part_init(dev_desc); printf("........ success\n"); fastboot_okay(NULL, response); return; -- cgit v1.2.3