Hi Frank, On 06/04/19 20:12, Frank Wunderlich wrote: > "mmc eraseenv" allows to erase the section on mmc where env is stored >
Why do we need a specific command for MMC ? If we need such a command, should it not unaware of the storage ? That is a "env eraseenv", and this calls the corresponding function for SPI /MMC / NAND /.. ? Best regards, Stefano Babic > Signed-off-by: Frank Wunderlich <[email protected]> > --- > cmd/mmc.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/cmd/mmc.c b/cmd/mmc.c > index 8bc3648193..b8e2c353b4 100644 > --- a/cmd/mmc.c > +++ b/cmd/mmc.c > @@ -441,6 +441,37 @@ static int do_mmc_erase(cmd_tbl_t *cmdtp, int flag, > > return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; > } > + > +static int do_mmc_erase_env(cmd_tbl_t *cmdtp, int flag, > + int argc, char * const argv[]) > +{ > + struct mmc *mmc; > + u32 blk, cnt, n; > + > + if (argc != 1) > + return CMD_RET_USAGE; > + > + mmc = init_mmc_device(curr_device, false); > + > + if (!mmc) > + return CMD_RET_FAILURE; > + > + blk = CONFIG_ENV_OFFSET / mmc->read_bl_len; > + cnt = CONFIG_ENV_SIZE / mmc->read_bl_len; > + > + printf("\nMMC erase env: dev # %d, block # %d (0x%8x), count %d > (0x%8x)", > + curr_device, blk, blk * mmc->read_bl_len, > + cnt, cnt * mmc->read_bl_len); > + > + if (mmc_getwp(mmc) == 1) { > + printf("Error: card is write protected!\n"); > + return CMD_RET_FAILURE; > + } > + n = blk_derase(mmc_get_blk_desc(mmc), blk, cnt); > + printf("%d blocks erased: %s\n", n, (n == cnt) ? "OK" : "ERROR"); > + > + return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; > +} > #endif > > static int do_mmc_rescan(cmd_tbl_t *cmdtp, int flag, > @@ -878,6 +909,7 @@ static cmd_tbl_t cmd_mmc[] = { > #if CONFIG_IS_ENABLED(MMC_WRITE) > U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""), > U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""), > + U_BOOT_CMD_MKENT(eraseenv, 1, 0, do_mmc_erase_env, "", ""), > #endif > #if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) > U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""), > @@ -940,6 +972,7 @@ U_BOOT_CMD( > "mmc swrite addr blk#\n" > #endif > "mmc erase blk# cnt\n" > + "mmc eraseenv - erase environment\n" > "mmc rescan\n" > "mmc part - lists available partition on current mmc device\n" > "mmc dev [dev] [part] - show or set current mmc device [partition]\n" > -- > 2.17.1 > > _______________________________________________ > U-Boot mailing list > [email protected] > https://lists.denx.de/listinfo/u-boot > -- ===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected] ===================================================================== _______________________________________________ U-Boot mailing list [email protected] https://lists.denx.de/listinfo/u-boot

