]> git.sur5r.net Git - u-boot/blobdiff - common/env_common.c
setenv(): Delete 0-length environment variables
[u-boot] / common / env_common.c
index f366fdbeb2345f58d4d8b88a6a74e28273f74789..439a4a905b937a66dd098a6505e144b67dc0c713 100644 (file)
@@ -91,14 +91,20 @@ uchar default_environment[] = {
 #ifdef CONFIG_ETH3ADDR
        "eth3addr="     MK_STR(CONFIG_ETH3ADDR)         "\0"
 #endif
+#ifdef CONFIG_ETH4ADDR
+       "eth4addr="     MK_STR(CONFIG_ETH4ADDR)         "\0"
+#endif
+#ifdef CONFIG_ETH5ADDR
+       "eth5addr="     MK_STR(CONFIG_ETH5ADDR)         "\0"
+#endif
 #ifdef CONFIG_IPADDR
        "ipaddr="       MK_STR(CONFIG_IPADDR)           "\0"
 #endif
 #ifdef CONFIG_SERVERIP
        "serverip="     MK_STR(CONFIG_SERVERIP)         "\0"
 #endif
-#ifdef CFG_AUTOLOAD
-       "autoload="     CFG_AUTOLOAD                    "\0"
+#ifdef CONFIG_SYS_AUTOLOAD
+       "autoload="     CONFIG_SYS_AUTOLOAD                     "\0"
 #endif
 #ifdef CONFIG_PREBOOT
        "preboot="      CONFIG_PREBOOT                  "\0"
@@ -133,10 +139,6 @@ uchar default_environment[] = {
        "\0"
 };
 
-#if defined(CFG_ENV_IS_IN_NAND)                /* Environment is in Nand Flash */
-int default_environment_size = sizeof(default_environment);
-#endif
-
 void env_crc_update (void)
 {
        env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE);
@@ -203,10 +205,29 @@ uchar *env_get_addr (int index)
        }
 }
 
+void set_default_env(void)
+{
+       if (sizeof(default_environment) > ENV_SIZE) {
+               puts ("*** Error - default environment is too large\n\n");
+               return;
+       }
+
+       memset(env_ptr, 0, sizeof(env_t));
+       memcpy(env_ptr->data, default_environment,
+              sizeof(default_environment));
+#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
+       env_ptr->flags = 0xFF;
+#endif
+       env_crc_update ();
+       gd->env_valid = 1;
+}
+
 void env_relocate (void)
 {
+#ifndef CONFIG_RELOC_FIXUP_WORKS
        DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__,
                gd->reloc_off);
+#endif
 
 #ifdef CONFIG_AMIGAONEG3SE
        enable_nvram();
@@ -217,39 +238,26 @@ void env_relocate (void)
         * The environment buffer is embedded with the text segment,
         * just relocate the environment pointer
         */
+#ifndef CONFIG_RELOC_FIXUP_WORKS
        env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off);
+#endif
        DEBUGF ("%s[%d] embedded ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
 #else
        /*
         * We must allocate a buffer for the environment
         */
-       env_ptr = (env_t *)malloc (CFG_ENV_SIZE);
+       env_ptr = (env_t *)malloc (CONFIG_ENV_SIZE);
        DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
 #endif
 
        if (gd->env_valid == 0) {
-#if defined(CONFIG_GTH)        || defined(CFG_ENV_IS_NOWHERE)  /* Environment not changable */
+#if defined(CONFIG_GTH)        || defined(CONFIG_ENV_IS_NOWHERE)       /* Environment not changable */
                puts ("Using default environment\n\n");
 #else
                puts ("*** Warning - bad CRC, using default environment\n\n");
                show_boot_progress (-60);
 #endif
-
-               if (sizeof(default_environment) > ENV_SIZE)
-               {
-                       puts ("*** Error - default environment is too large\n\n");
-                       return;
-               }
-
-               memset (env_ptr, 0, sizeof(env_t));
-               memcpy (env_ptr->data,
-                       default_environment,
-                       sizeof(default_environment));
-#ifdef CFG_REDUNDAND_ENVIRONMENT
-               env_ptr->flags = 0xFF;
-#endif
-               env_crc_update ();
-               gd->env_valid = 1;
+               set_default_env();
        }
        else {
                env_relocate_spec ();