summaryrefslogtreecommitdiffstats
path: root/meta/packages/uboot/u-boot-mkimage-openmoko-native/default-env.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/uboot/u-boot-mkimage-openmoko-native/default-env.patch')
-rw-r--r--meta/packages/uboot/u-boot-mkimage-openmoko-native/default-env.patch101
1 files changed, 101 insertions, 0 deletions
diff --git a/meta/packages/uboot/u-boot-mkimage-openmoko-native/default-env.patch b/meta/packages/uboot/u-boot-mkimage-openmoko-native/default-env.patch
new file mode 100644
index 0000000000..b9ae4f29fe
--- /dev/null
+++ b/meta/packages/uboot/u-boot-mkimage-openmoko-native/default-env.patch
@@ -0,0 +1,101 @@
1common/env_common.c (default_env): new function that resets the environment to
2 the default value
3common/env_common.c (env_relocate): use default_env instead of own copy
4common/env_nand.c (env_relocate_spec): use default_env instead of own copy
5include/environment.h: added default_env prototype
6
7- Werner Almesberger <werner@openmoko.org>
8
9Index: u-boot/common/env_common.c
10===================================================================
11--- u-boot.orig/common/env_common.c
12+++ u-boot/common/env_common.c
13@@ -202,6 +202,25 @@ uchar *env_get_addr (int index)
14 }
15 }
16
17+void default_env(void)
18+{
19+ if (sizeof(default_environment) > ENV_SIZE)
20+ {
21+ puts ("*** Error - default environment is too large\n\n");
22+ return;
23+ }
24+
25+ memset (env_ptr, 0, sizeof(env_t));
26+ memcpy (env_ptr->data,
27+ default_environment,
28+ sizeof(default_environment));
29+#ifdef CFG_REDUNDAND_ENVIRONMENT
30+ env_ptr->flags = 0xFF;
31+#endif
32+ env_crc_update ();
33+ gd->env_valid = 1;
34+}
35+
36 void env_relocate (void)
37 {
38 DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__,
39@@ -245,23 +264,8 @@ void env_relocate (void)
40 gd->env_valid = 0;
41 #endif
42
43- if (gd->env_valid == 0) {
44- if (sizeof(default_environment) > ENV_SIZE)
45- {
46- puts ("*** Error - default environment is too large\n\n");
47- return;
48- }
49-
50- memset (env_ptr, 0, sizeof(env_t));
51- memcpy (env_ptr->data,
52- default_environment,
53- sizeof(default_environment));
54-#ifdef CFG_REDUNDAND_ENVIRONMENT
55- env_ptr->flags = 0xFF;
56-#endif
57- env_crc_update ();
58- gd->env_valid = 1;
59- }
60+ if (gd->env_valid == 0)
61+ default_env();
62 else {
63 env_relocate_spec ();
64 }
65Index: u-boot/common/env_nand.c
66===================================================================
67--- u-boot.orig/common/env_nand.c
68+++ u-boot/common/env_nand.c
69@@ -313,19 +313,7 @@ void env_relocate_spec (void)
70 static void use_default()
71 {
72 puts ("*** Warning - bad CRC or NAND, using default environment\n\n");
73-
74- if (default_environment_size > CFG_ENV_SIZE){
75- puts ("*** Error - default environment is too large\n\n");
76- return;
77- }
78-
79- memset (env_ptr, 0, sizeof(env_t));
80- memcpy (env_ptr->data,
81- default_environment,
82- default_environment_size);
83- env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE);
84- gd->env_valid = 1;
85-
86+ default_env();
87 }
88 #endif
89
90Index: u-boot/include/environment.h
91===================================================================
92--- u-boot.orig/include/environment.h
93+++ u-boot/include/environment.h
94@@ -107,4 +107,7 @@ typedef struct environment_s {
95 unsigned char data[ENV_SIZE]; /* Environment data */
96 } env_t;
97
98+
99+void default_env(void);
100+
101 #endif /* _ENVIRONMENT_H_ */