]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/env_nand.c
NAND: env: remember the flags used in the previous environment
[people/ms/u-boot.git] / common / env_nand.c
index 2682f07fdcd8c1173a2c89e160643138128924ba..980425a8ee8df5d4592cf25a53170dbdd2b8813e 100644 (file)
@@ -181,7 +181,10 @@ int writeenv(size_t offset, u_char *buf)
 
        return 0;
 }
+
 #ifdef CONFIG_ENV_OFFSET_REDUND
+static unsigned char env_flags;
+
 int saveenv(void)
 {
        env_t   env_new;
@@ -205,7 +208,7 @@ int saveenv(void)
                return 1;
        }
        env_new.crc   = crc32(0, env_new.data, ENV_SIZE);
-       env_new.flags = ACTIVE_FLAG;
+       env_new.flags = ++env_flags; /* increase the serial */
 
        if(gd->env_valid == 1) {
                puts("Erasing redundant NAND...\n");
@@ -399,6 +402,7 @@ void env_relocate_spec(void)
        else
                ep = tmp_env2;
 
+       env_flags = ep->flags;
        env_import((char *)ep, 0);
 
        free(tmp_env1);