public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Crash in env_relocate_spec() of env_mmc.c
@ 2010-10-08  8:03 Stefano Babic
  2010-10-08 11:04 ` Sergei Shtylyov
  2010-10-08 13:39 ` Steve Sakoman
  0 siblings, 2 replies; 9+ messages in thread
From: Stefano Babic @ 2010-10-08  8:03 UTC (permalink / raw)
  To: u-boot

mmc_initialize is not called at the startup if the
relocation takes place and the environment is stored
into a MMC card.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 arch/arm/lib/board.c |   10 +++++-----
 common/env_mmc.c     |   11 +++++------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 5f2dfd0..704ddcb 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -775,6 +775,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	nand_init();		/* go init the NAND */
 #endif
 
+#ifdef CONFIG_GENERIC_MMC
+	puts ("MMC:   ");
+	mmc_initialize (bd);
+#endif
+
 #if defined(CONFIG_CMD_ONENAND)
 	onenand_init();
 #endif
@@ -854,11 +859,6 @@ extern void davinci_eth_set_mac_addr (const u_int8_t *addr);
 	board_late_init ();
 #endif
 
-#ifdef CONFIG_GENERIC_MMC
-	puts ("MMC:   ");
-	mmc_initialize (gd->bd);
-#endif
-
 #ifdef CONFIG_BITBANGMII
 	bb_miiphy_init();
 #endif
diff --git a/common/env_mmc.c b/common/env_mmc.c
index 14203b6..cb7c448 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -130,24 +130,23 @@ void env_relocate_spec(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
 	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
+	char buf[CONFIG_ENV_SIZE];
 
 	if (init_mmc_for_env(mmc))
 		return;
 
-	if (read_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, env_ptr))
-		return use_default();
-
-	if (crc32(0, env_ptr->data, ENV_SIZE) != env_ptr->crc)
+	if (read_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf))
 		return use_default();
 
 	gd->env_valid = 1;
+
+	env_import(buf, 1);
 #endif
 }
 
 #if !defined(ENV_IS_EMBEDDED)
 static void use_default()
 {
-	puts ("*** Warning - bad CRC or MMC, using default environment\n\n");
-	set_default_env();
+	set_default_env("*** Warning - bad CRC or MMC, using default environment\n\n");
 }
 #endif
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-10-08 18:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-08  8:03 [U-Boot] [PATCH] Crash in env_relocate_spec() of env_mmc.c Stefano Babic
2010-10-08 11:04 ` Sergei Shtylyov
2010-10-08 11:26   ` Stefano Babic
2010-10-08 13:39 ` Steve Sakoman
2010-10-08 13:42   ` Steve Sakoman
2010-10-08 16:05     ` Stefano Babic
2010-10-08 16:21       ` Steve Sakoman
2010-10-08 18:13         ` Stefano Babic
2010-10-08 16:03   ` Stefano Babic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox