]> git.ipfire.org Git - thirdparty/u-boot.git/blobdiff - env/nand.c
include: env: Add phytec RAUC boot logic
[thirdparty/u-boot.git] / env / nand.c
index 9f3dc635cf1f0804d93f5ce0ec8748e00af92340..df300b13179312babc6ee3c47e2cba1d165c30fb 100644 (file)
 #include <command.h>
 #include <env.h>
 #include <env_internal.h>
+#include <asm/global_data.h>
 #include <linux/stddef.h>
 #include <malloc.h>
 #include <memalign.h>
 #include <nand.h>
 #include <search.h>
 #include <errno.h>
+#include <u-boot/crc.h>
 
 #if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_NAND) && \
                !defined(CONFIG_SPL_BUILD)
 #error CONFIG_ENV_OFFSET_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_NAND
 #endif
 
-#if defined(CONFIG_ENV_SIZE_REDUND) && \
-       (CONFIG_ENV_SIZE_REDUND != CONFIG_ENV_SIZE)
-#error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE
-#endif
-
-#ifndef CONFIG_ENV_RANGE
-#define CONFIG_ENV_RANGE       CONFIG_ENV_SIZE
-#endif
-
 #if defined(ENV_IS_EMBEDDED)
 static env_t *env_ptr = &environment;
 #elif defined(CONFIG_NAND_ENV_DST)
@@ -110,8 +103,7 @@ static int env_nand_init(void)
        gd->env_addr = (ulong)env_ptr->data;
 
 #else /* ENV_IS_EMBEDDED || CONFIG_NAND_ENV_DST */
-       gd->env_addr    = (ulong)&default_environment[0];
-       gd->env_valid   = ENV_VALID;
+       gd->env_valid   = ENV_INVALID;
 #endif /* ENV_IS_EMBEDDED || CONFIG_NAND_ENV_DST */
 
        return 0;
@@ -205,10 +197,6 @@ static int env_nand_save(void)
 #endif
        };
 
-
-       if (CONFIG_ENV_RANGE < CONFIG_ENV_SIZE)
-               return 1;
-
        ret = env_export(env_new);
        if (ret)
                return ret;
@@ -335,7 +323,7 @@ static int env_nand_load(void)
        read2_fail = readenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) tmp_env2);
 
        ret = env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
-                               read2_fail);
+                               read2_fail, H_EXTERNAL);
 
 done:
        free(tmp_env1);
@@ -376,7 +364,7 @@ static int env_nand_load(void)
                return -EIO;
        }
 
-       return env_import(buf, 1);
+       return env_import(buf, 1, H_EXTERNAL);
 #endif /* ! ENV_IS_EMBEDDED */
 
        return 0;