Files
poky/meta/packages/uboot/u-boot-mkimage-openmoko-native/default-env.patch
Marcin Juszkiewicz 70abc059eb u-boot: import OpenMoko uboot from OE
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3014 311d38ba-8fff-0310-9ca6-ca027cbcb966
2007-10-29 11:00:19 +00:00

102 lines
2.6 KiB
Diff

common/env_common.c (default_env): new function that resets the environment to
the default value
common/env_common.c (env_relocate): use default_env instead of own copy
common/env_nand.c (env_relocate_spec): use default_env instead of own copy
include/environment.h: added default_env prototype
- Werner Almesberger <werner@openmoko.org>
Index: u-boot/common/env_common.c
===================================================================
--- u-boot.orig/common/env_common.c
+++ u-boot/common/env_common.c
@@ -202,6 +202,25 @@ uchar *env_get_addr (int index)
}
}
+void 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 CFG_REDUNDAND_ENVIRONMENT
+ env_ptr->flags = 0xFF;
+#endif
+ env_crc_update ();
+ gd->env_valid = 1;
+}
+
void env_relocate (void)
{
DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__,
@@ -245,23 +264,8 @@ void env_relocate (void)
gd->env_valid = 0;
#endif
- if (gd->env_valid == 0) {
- 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;
- }
+ if (gd->env_valid == 0)
+ default_env();
else {
env_relocate_spec ();
}
Index: u-boot/common/env_nand.c
===================================================================
--- u-boot.orig/common/env_nand.c
+++ u-boot/common/env_nand.c
@@ -313,19 +313,7 @@ void env_relocate_spec (void)
static void use_default()
{
puts ("*** Warning - bad CRC or NAND, using default environment\n\n");
-
- if (default_environment_size > CFG_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,
- default_environment_size);
- env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE);
- gd->env_valid = 1;
-
+ default_env();
}
#endif
Index: u-boot/include/environment.h
===================================================================
--- u-boot.orig/include/environment.h
+++ u-boot/include/environment.h
@@ -107,4 +107,7 @@ typedef struct environment_s {
unsigned char data[ENV_SIZE]; /* Environment data */
} env_t;
+
+void default_env(void);
+
#endif /* _ENVIRONMENT_H_ */