Allow erasing mmc0, speed up erase
- Add in the ability to erase the whole MMC, using the name of the
partition table (as we are able to do on LK)
- Modify erase to not use the FASTBOOT_MAX_BLK_WRITE, just erase
everything in one call.
- Erase more than one erase_grp_size at a time: MMC spec allows for
erasing more than one erase group at a time, so erase everything in one
command.
Change-Id: I57f1d531053992c5c654e61f13dbd3c505facf5b
diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index a6ebf09..cca4ccd 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -91,20 +91,20 @@
lbaint_t blks = 0;
int i;
- for (i = 0; i < blkcnt; i += FASTBOOT_MAX_BLK_WRITE) {
- cur_blkcnt = min((int)blkcnt - i, FASTBOOT_MAX_BLK_WRITE);
- if (buffer) {
+ if (!buffer) {
+ if (fastboot_progress_callback)
+ fastboot_progress_callback("erasing");
+ blks = blk_derase(block_dev, blk, blkcnt);
+ } else {
+ for (i = 0; i < blkcnt; i += FASTBOOT_MAX_BLK_WRITE) {
+ cur_blkcnt = min((int)blkcnt - i, FASTBOOT_MAX_BLK_WRITE);
if (fastboot_progress_callback)
fastboot_progress_callback("writing");
blks_written = blk_dwrite(block_dev, blk, cur_blkcnt,
buffer + (i * block_dev->blksz));
- } else {
- if (fastboot_progress_callback)
- fastboot_progress_callback("erasing");
- blks_written = blk_derase(block_dev, blk, cur_blkcnt);
+ blk += blks_written;
+ blks += blks_written;
}
- blk += blks_written;
- blks += blks_written;
}
return blks;
}
@@ -506,6 +506,13 @@
struct special_partition *part = get_special_partition(cmd);
ret = part_get_info_by_name_or_alias(dev_desc, cmd, &info);
+
+#if CONFIG_IS_ENABLED(EFI_PARTITION)
+ if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0) {
+ ret = part_get_info_whole_disk(dev_desc, &info);
+ }
+#endif
+
if (ret < 0 && !part) {
pr_err("cannot find partition: '%s'\n", cmd);
fastboot_fail("cannot find partition", response);
diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
index b52ff9f..0641bc0 100644
--- a/drivers/mmc/mmc_write.c
+++ b/drivers/mmc/mmc_write.c
@@ -109,8 +109,7 @@
blk_r = ((blkcnt - blk) > mmc->ssr.au) ?
mmc->ssr.au : (blkcnt - blk);
} else {
- blk_r = ((blkcnt - blk) > mmc->erase_grp_size) ?
- mmc->erase_grp_size : (blkcnt - blk);
+ blk_r = blkcnt;
}
err = mmc_erase_t(mmc, start + blk, blk_r);
if (err)