All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Sakoman <steve@sakoman.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] env_mmc: Fix crashing bug encountered after enabling ARM relocation
Date: Fri, 08 Oct 2010 14:49:29 -0700	[thread overview]
Message-ID: <1286574569.2105.1.camel@quadra> (raw)

The crash was occuring in env_relocate because it was being called prior
to mmc_initialize.  This patch moves the MMC initialization earlier in
the init process.

This patch also cleans up the env_relocate_spec code in env_mmc.c

Developed jointly with Stefano Babic

Signed-off-by: Steve Sakoman <steve.sakoman@linaro.org>
---

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 5f2dfd0..0e2f129 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -779,6 +779,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	onenand_init();
 #endif
 
+#ifdef CONFIG_GENERIC_MMC
+       puts ("MMC:   ");
+       mmc_initialize (bd);
+#endif
+
 #ifdef CONFIG_HAS_DATAFLASH
 	AT91F_DataflashInit();
 	dataflash_print_info();
@@ -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 cc288d4..d443ff5 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -129,18 +129,21 @@ inline int read_env(struct mmc *mmc, unsigned long size,
 void env_relocate_spec(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
+       char buf[CONFIG_ENV_SIZE];
+
 	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
 
-	if (init_mmc_for_env(mmc))
+	if (init_mmc_for_env(mmc)) {
+		use_default();
 		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)
-		return use_default();
+	if (read_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) {
+		use_default();
+		return;
+	}
 
-	gd->env_valid = 1;
+	env_import(buf, 1);
 #endif
 }
 

             reply	other threads:[~2010-10-08 21:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-08 21:49 Steve Sakoman [this message]
2010-10-09 21:49 ` [U-Boot] env_mmc: Fix crashing bug encountered after enabling ARM relocation Paulraj, Sandeep
2010-10-10  9:27   ` stefano babic
2010-10-10 11:46 ` Sergei Shtylyov
2010-10-10 13:42   ` Steve Sakoman
2010-10-10 14:52     ` Sergei Shtylyov
2010-10-10 15:47       ` Steve Sakoman
2010-10-10 15:53         ` Sergei Shtylyov
2010-10-10 20:08           ` Steve Sakoman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1286574569.2105.1.camel@quadra \
    --to=steve@sakoman.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.