mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-01 08:59:33 +00:00
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 <patrick.delaunay@foss.st.com>
This commit is contained in:
parent
7596696bc5
commit
3acbc7b2aa
5 changed files with 52 additions and 27 deletions
|
@ -28,7 +28,7 @@ CONFIG_FASTBOOT_BUF_ADDR=0x56000000
|
|||
CONFIG_FASTBOOT_BUF_SIZE=0x1e00000
|
||||
CONFIG_FASTBOOT_FLASH=y
|
||||
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
|
||||
CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
|
||||
CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y
|
||||
CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
|
||||
CONFIG_DM_MMC=y
|
||||
CONFIG_MMC_HS200_SUPPORT=y
|
||||
|
|
|
@ -24,7 +24,7 @@ CONFIG_FASTBOOT_BUF_ADDR=0x56000000
|
|||
CONFIG_FASTBOOT_BUF_SIZE=0x1E00000
|
||||
CONFIG_FASTBOOT_FLASH=y
|
||||
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
|
||||
CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
|
||||
CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y
|
||||
CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
|
||||
CONFIG_DM_MMC=y
|
||||
CONFIG_MMC_HS200_SUPPORT=y
|
||||
|
|
|
@ -52,7 +52,7 @@ CONFIG_FASTBOOT_BUF_ADDR=0x4d000000
|
|||
CONFIG_FASTBOOT_BUF_SIZE=0x4000000
|
||||
CONFIG_FASTBOOT_FLASH=y
|
||||
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
|
||||
CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT=y
|
||||
CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y
|
||||
CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
|
||||
# CONFIG_INPUT is not set
|
||||
CONFIG_DM_MMC=y
|
||||
|
|
|
@ -104,18 +104,19 @@ config FASTBOOT_FLASH_NAND_TRIMFFS
|
|||
When flashing NAND enable the DROP_FFS flag to drop trailing all-0xff
|
||||
pages.
|
||||
|
||||
config FASTBOOT_MMC_BOOT1_SUPPORT
|
||||
bool "Enable EMMC_BOOT1 flash/erase"
|
||||
depends on FASTBOOT_FLASH_MMC && EFI_PARTITION && ARCH_MEDIATEK
|
||||
config FASTBOOT_MMC_BOOT_SUPPORT
|
||||
bool "Enable EMMC_BOOT flash/erase"
|
||||
depends on FASTBOOT_FLASH_MMC
|
||||
help
|
||||
The fastboot "flash" and "erase" commands normally does operations
|
||||
on EMMC userdata. Define this to enable the special commands to
|
||||
flash/erase EMMC_BOOT1.
|
||||
The default target name for updating EMMC_BOOT1 is "mmc0boot0".
|
||||
on eMMC userdata. Define this to enable the special commands to
|
||||
flash/erase eMMC boot partition.
|
||||
The default target name for updating eMMC boot partition 1/2 is
|
||||
CONFIG_FASTBOOT_MMC_BOOT1_NAME/CONFIG_FASTBOOT_MMC_BOOT2_NAME.
|
||||
|
||||
config FASTBOOT_MMC_BOOT1_NAME
|
||||
string "Target name for updating EMMC_BOOT1"
|
||||
depends on FASTBOOT_MMC_BOOT1_SUPPORT
|
||||
depends on FASTBOOT_MMC_BOOT_SUPPORT
|
||||
default "mmc0boot0"
|
||||
help
|
||||
The fastboot "flash" and "erase" commands support operations on
|
||||
|
@ -124,6 +125,17 @@ config FASTBOOT_MMC_BOOT1_NAME
|
|||
defined here.
|
||||
The default target name for updating EMMC_BOOT1 is "mmc0boot0".
|
||||
|
||||
config FASTBOOT_MMC_BOOT2_NAME
|
||||
string "Target name for updating EMMC_BOOT2"
|
||||
depends on FASTBOOT_MMC_BOOT_SUPPORT
|
||||
default "mmc0boot1"
|
||||
help
|
||||
The fastboot "flash" and "erase" commands support operations on
|
||||
EMMC_BOOT2. This occurs when the specified "EMMC_BOOT2 name" on
|
||||
the "fastboot flash" and "fastboot erase" commands match the value
|
||||
defined here.
|
||||
The default target name for updating EMMC_BOOT2 is "mmc0boot1".
|
||||
|
||||
config FASTBOOT_MMC_USER_SUPPORT
|
||||
bool "Enable eMMC userdata partition flash/erase"
|
||||
depends on FASTBOOT_FLASH_MMC
|
||||
|
|
|
@ -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,9 +470,14 @@ 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,
|
||||
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;
|
||||
}
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue