@@ -43,7 +43,7 @@ __weak const char *env_ext4_get_dev_part(void)
return (const char *)CONFIG_ENV_EXT4_DEVICE_AND_PART;
}
-#if defined(CONFIG_CMD_SAVEENV)
+#if defined(CONFIG_CMD_SAVEENV) || defined(CONFIG_CMD_ERASEENV)
static int env_ext4_save_buffer(env_t *env_new)
{
struct blk_desc *dev_desc = NULL;
@@ -102,6 +102,25 @@ static int env_ext4_save(void)
}
#endif /* CONFIG_CMD_SAVEENV */
+#if defined(CONFIG_CMD_ERASEENV)
+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;
+}
+#endif
+
static int env_ext4_load(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -161,4 +180,7 @@ U_BOOT_ENV_LOCATION(ext4) = {
#ifdef CONFIG_CMD_SAVEENV
.save = env_save_ptr(env_ext4_save),
#endif
+#if defined(CONFIG_CMD_ERASEENV)
+ .erase = env_ext4_erase,
+#endif
};
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 at st.com> --- env/ext4.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)