From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] __mmc_get_env_addr() is not being called?
Date: Fri, 16 Dec 2011 10:31:58 +0100 [thread overview]
Message-ID: <4EEB100E.4030809@denx.de> (raw)
In-Reply-To: <20111216055359.GA3519@S2100-06.ap.freescale.net>
On 16/12/2011 06:54, Shawn Guo wrote:
> Hi,
>
Hi Shawn,
> I'm running v2011.12-rc1 (with one missing usdhc patch applied) on
> mx6qarm2 board, and seeing a problem. When I install u-boot on a
> blank SD card, it boots fine with messge "*** Warning - bad CRC,
> using default environment" seen as expected. But once I run command
> 'save' to write envs to the card, the card stop booting.
>
> I tracked the issue a little bit, and found __mmc_get_env_addr() does
> not get called at all. Therefore when I run 'save' for the first time,
> the envs are written to offset 0 of the card, which in turn overwrites
> the boot image.
>
> I have not figured out why it does. But the following change fixes
> the problem for me.
>
> diff --git a/common/env_mmc.c b/common/env_mmc.c
> index 8441c77..3832fe4 100644
> --- a/common/env_mmc.c
> +++ b/common/env_mmc.c
> @@ -46,13 +46,11 @@ DECLARE_GLOBAL_DATA_PTR;
> #define CONFIG_ENV_OFFSET 0
> #endif
>
> -static int __mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
> +static int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
> {
> *env_addr = CONFIG_ENV_OFFSET;
> return 0;
> }
> -int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
> - __attribute__((weak, alias("__mmc_get_env_addr")));
>
> Any comment on why the change fixes the problem is appreciated.
The function is declared weak, this means that a specific architecture
could implement its own version. The reason why it does not work is that
there is a specific implementation in board/freescale/sdhc_boot.c, and
the mmc_get_env_addr() in this file is taken instead of the default when
CONFIG_ENV_IS_IN_MMC (as in our case) is set. Instead of your proposal,
we should surround mmc_get_env_addr() in sdhc_boot.c with something like
#ifndef CONFIG_MX6Q, or check if we can reuse this function, that really
does not use CONFIG_ENV_OFFSET at all.
I put Jason (board maintainer) in CC - Jason, what do mind ? Do you get
the same issue when you tested the board ?
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
next prev parent reply other threads:[~2011-12-16 9:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-16 5:54 [U-Boot] __mmc_get_env_addr() is not being called? Shawn Guo
2011-12-16 9:31 ` Stefano Babic [this message]
2011-12-19 5:21 ` Jason Liu
2011-12-16 9:33 ` Fabio Estevam
2011-12-16 9:42 ` Stefano Babic
2011-12-18 17:56 ` Kumar Gala
2011-12-19 6:37 ` Stefano Babic
2011-12-19 6:53 ` Jason Hui
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=4EEB100E.4030809@denx.de \
--to=sbabic@denx.de \
--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.