[U-Boot] [PATCH v4 3/4] env: add option to use redundant offset
Frank Wunderlich
frank-w at public-files.de
Sun Apr 28 08:51:27 UTC 2019
allow env erase on secondary offset using CONFIG_ENV_OFFSET_REDUND
Suggested-by: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
Signed-off-by: Frank Wunderlich <frank-w at 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(-)
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 0cbd8e8984..2071bcf443 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -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,
diff --git a/env/env.c b/env/env.c
index d3cbe2f915..bf7f3b9684 100644
--- a/env/env.c
+++ b/env/env.c
@@ -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
diff --git a/env/mmc.c b/env/mmc.c
index 9ae9b1a66a..647bc693fa 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -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",
diff --git a/include/environment.h b/include/environment.h
index de67cf4f0e..a823948da2 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -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
--
2.17.1
More information about the U-Boot
mailing list