@@ -766,7 +766,7 @@ U_BOOT_CMD(
static int do_env_erase(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
- return env_erase() ? 1 : 0;
+ return env_erase(false) ? 1 : 0;
}
U_BOOT_CMD(
eraseenv, 1, 0, do_env_erase,
@@ -256,7 +256,7 @@ int env_save(void)
return -ENODEV;
}
-int env_erase(void)
+int env_erase(bool use_redund)
{
struct env_driver *drv;
@@ -271,7 +271,7 @@ int env_erase(void)
return -ENODEV;
printf("Erasing Environment on %s... ", drv->name);
- ret = drv->erase();
+ ret = drv->erase(use_redund);
if (ret)
printf("Failed (%d)\n", ret);
else
@@ -244,7 +244,7 @@ fini:
}
#if defined(CONFIG_CMD_ERASEENV)
-static int env_mmc_erase(void)
+static int env_mmc_erase(bool use_redund)
{
int dev = mmc_get_env_dev();
struct mmc *mmc = find_mmc_device(dev);
@@ -253,7 +253,12 @@ static int env_mmc_erase(void)
if (!mmc)
return CMD_RET_FAILURE;
- blk = CONFIG_ENV_OFFSET / mmc->read_bl_len;
+#ifdef CONFIG_ENV_OFFSET_REDUND
+ if (use_redund)
+ blk = CONFIG_ENV_OFFSET_REDUND / mmc->read_bl_len;
+ else
+#endif
+ 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%x), count %d (0x%x)\n",
@@ -233,7 +233,7 @@ struct env_driver {
*
* @return 0 if OK, -ve on error
*/
- int (*erase)(void);
+ int (*erase)(bool use_redund);
/**
* init() - Set up the initial pre-relocation environment
@@ -318,7 +318,7 @@ int env_save(void);
*
* @return 0 if OK, -ve on error
*/
-int env_erase(void);
+int env_erase(bool use_redund);
/**
* env_fix_drivers() - Updates envdriver as per relocation
allow env erase on secondary offset using CONFIG_ENV_OFFSET_REDUND Suggested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Signed-off-by: Frank Wunderlich <frank-w@public-files.de> --- cmd/nvedit.c | 2 +- env/env.c | 4 ++-- env/mmc.c | 9 +++++++-- include/environment.h | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) -- 2.17.1