summaryrefslogtreecommitdiff
path: root/env/sf.c
diff options
context:
space:
mode:
Diffstat (limited to 'env/sf.c')
-rw-r--r--env/sf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/env/sf.c b/env/sf.c
index d9ed08a78e..06cc62e005 100644
--- a/env/sf.c
+++ b/env/sf.c
@@ -72,7 +72,7 @@ static int env_sf_save(void)
{
env_t env_new;
char *saved_buffer = NULL, flag = ENV_REDUND_OBSOLETE;
- u32 saved_size, saved_offset, sector;
+ u32 saved_size = 0, saved_offset = 0, sector;
u32 sect_size = CONFIG_ENV_SECT_SIZE;
int ret;
@@ -80,6 +80,9 @@ static int env_sf_save(void)
if (ret)
return ret;
+ if (IS_ENABLED(CONFIG_ENV_SECT_SIZE_AUTO))
+ sect_size = env_flash->mtd.erasesize;
+
ret = env_export(&env_new);
if (ret)
return -EIO;
@@ -187,7 +190,7 @@ out:
#else
static int env_sf_save(void)
{
- u32 saved_size, saved_offset, sector;
+ u32 saved_size = 0, saved_offset = 0, sector;
u32 sect_size = CONFIG_ENV_SECT_SIZE;
char *saved_buffer = NULL;
int ret = 1;
@@ -197,6 +200,9 @@ static int env_sf_save(void)
if (ret)
return ret;
+ if (IS_ENABLED(CONFIG_ENV_SECT_SIZE_AUTO))
+ sect_size = env_flash->mtd.erasesize;
+
/* Is the sector larger than the env (i.e. embedded) */
if (sect_size > CONFIG_ENV_SIZE) {
saved_size = sect_size - CONFIG_ENV_SIZE;