[U-Boot-Users] auto-save environment if using default environment?

w.wegner at astro-kom.de w.wegner at astro-kom.de
Tue Mar 25 14:36:24 CET 2008


Hi,

I just had the problem of fw_{print,save}env not being able to access
the environment because I was using the default (builtin) environment
after flashing U-Boot.
I wonder if I am the only one having this problem, or is it common
practice to flash the environment together with U-Boot during production?

I just made this small patch to auto-save the environment if it is
not found in flash but am wondering if
- I missed something and such a possibility does already exist?
  (I could not find a possibility to check from the command-line if
   the current environment comes from flash or is the built-in default
   environment, else it would be easier to make a script check and
   call saveenv before booting.)
- this small change is enough?
- something similar might be worth considering as a new regular feature?

Best regards,
Wolfgang


diff --git a/common/env_common.c b/common/env_common.c
index a494812..8acee8f 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -243,6 +243,11 @@ void env_relocate (void)
 #endif
 		env_crc_update ();
 		gd->env_valid = 1;
+#ifdef CFG_ENV_AUTOSAVE
+		gd->env_addr = (ulong)&(env_ptr->data);
+		puts ("Saving environment\n");
+		saveenv ();
+#endif
 	}
 	else {
 		env_relocate_spec ();





More information about the U-Boot mailing list