aboutsummaryrefslogtreecommitdiff
path: root/env
diff options
context:
space:
mode:
authorPatrick Delaunay2020-07-28 11:51:26 +0200
committerTom Rini2020-07-31 10:13:00 -0400
commit0718f7432749af284828e22b0934366244c3ad62 (patch)
tree9d18f27258949193b0ec60d1fc0dfc6cb8d362b9 /env
parentf6de047e02bee81ecec711a19e11619b108ce1b1 (diff)
env: ext4: add support of command env erase
Add support of opts erase for env in ext4, this opts is used by command 'env erase'. This command only fill the env file (CONFIG_ENV_EXT4_FILE) with 0, the CRC and the saved environment becomes invalid. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Diffstat (limited to 'env')
-rw-r--r--env/ext4.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/env/ext4.c b/env/ext4.c
index 0a10a5e0500..cc36504154f 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -99,6 +99,23 @@ static int env_ext4_save(void)
return 0;
}
+static int env_ext4_erase(void)
+{
+ env_t env_new;
+ int err;
+
+ memset(&env_new, 0, sizeof(env_t));
+
+ err = env_ext4_save_buffer(&env_new);
+ if (err)
+ return err;
+
+ gd->env_valid = ENV_INVALID;
+ puts("done\n");
+
+ return 0;
+}
+
static int env_ext4_load(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -156,4 +173,6 @@ U_BOOT_ENV_LOCATION(ext4) = {
ENV_NAME("EXT4")
.load = env_ext4_load,
.save = ENV_SAVE_PTR(env_ext4_save),
+ .erase = CONFIG_IS_ENABLED(CMD_ERASEENV) ? env_ext4_erase :
+ NULL,
};