[U-Boot] [RFC] Added simple hack to ignore the environment variables in flash.

Jason Kridner jkridner at beagleboard.org
Wed Jan 14 21:19:08 CET 2009


I'm looking for a way to get u-boot to ignore the environment variables in flash 
if there is an autoscript on the SD card.  The easiest way I can find is to simply
ignore the environment variables completely and boot u-boot itself off of the SD 
card.

I see there are some other CONFIG's that do somewhat the same thing, but not
quite.

On a Beagle Board, the experience is:
* No SD card with u-boot.bin, boot u-boot.bin w/o OVERRIDE and read environment
  from flash.
* SD card with u-boot.bin w/ OVERRIDE is read.  Environment in flash is ignored
  so default environment is used.  The board defaults cause it to read an
  autoscr file from the SD card, allowing you to always boot, even if the
  environment variables in the flash are bad and there is no access to the
  serial console.

Any comments on if the below can be a suitable approach?

Signed-off-by: Jason Kridner <jkridner at beagleboard.org>
---
 common/env_common.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/common/env_common.c b/common/env_common.c
index 6be3bb0..6f39f10 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -251,8 +251,12 @@ void env_relocate (void)
 	DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
 #endif
 
+#ifdef CONFIG_OVERRIDE_BOOTENV
+	gd->env_valid = 0;
+#endif
 	if (gd->env_valid == 0) {
-#if defined(CONFIG_GTH)	|| defined(CONFIG_ENV_IS_NOWHERE)	/* Environment not changable */
+#if defined(CONFIG_GTH)	|| defined(CONFIG_ENV_IS_NOWHERE) \
+	|| defined(CONFIG_OVERRIDE_BOOTENV)			/* Environment not changable */
 		puts ("Using default environment\n\n");
 #else
 		puts ("*** Warning - bad CRC, using default environment\n\n");
-- 
1.6.0.4.790.gaa14a



More information about the U-Boot mailing list