From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Save environment data to mmc.
Date: Tue, 02 Mar 2010 18:03:19 +0100 [thread overview]
Message-ID: <4B8D44D7.9040904@denx.de> (raw)
In-Reply-To: <12586139151465-git-send-email-r65388@freescale.com>
Terry Lv wrote:
> diff --git a/common/env_mmc.c b/common/env_mmc.c
> +#include <linux/stddef.h>
> +#include <malloc.h>
> +#include <mmc.h>
> +
> +#if defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_MMC)
This seems not correct. If not explicitely set, we get a compiler error.
Assuming you has taken this check from env_nand.c, this should be:
#if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_MMC)
> +#define CMD_SAVEENV
> +#elif defined(CONFIG_ENV_OFFSET_REDUND)
> +#error Cannot use CONFIG_ENV_OFFSET_REDUND without CONFIG_CMD_ENV & CONFIG_CMD_MMC
Line too long.
> +#endif
> +
> +#if defined(CONFIG_ENV_SIZE_REDUND) && (CONFIG_ENV_SIZE_REDUND < CONFIG_ENV_SIZE)
Ditto.
> +
> +#ifdef CMD_SAVEENV
> +
> +inline int write_env(struct mmc *mmc, unsigned long size,
> + unsigned long offset, const void *buffer)
Line too long.
> +{
> + uint blk_start = 0, blk_cnt = 0, n = 0;
> +
> + blk_start = (offset % 512) ? ((offset / 512) + 1) : (offset / 512);
> + blk_cnt = (size % 512) ? ((size / 512) + 1) : (size / 512);
The alignment to block size is repeated here and in the read function.
Should not better to set a macro (something like BLOCK_ALIGN) providing
the required alignment ?
> +int saveenv(void)
> +{
> + struct mmc *mmc = find_mmc_device(0);
Why is the MMC device hard-coded ? At least should be configurable with
a CONFIG_ option. There are boards with more than one MMC controller and
you constraint to use always the first one.
> + blk_start = (offset % 512) ? ((offset / 512) + 1) : (offset / 512);
Already said, a macro is much more readable to perform alignment.
> diff --git a/include/environment.h b/include/environment.h
> +#if defined(CONFIG_ENV_IS_IN_MMC)
> +# ifndef CONFIG_ENV_OFFSET
> +# error "Need to define CONFIG_ENV_OFFSET when using CONFIG_ENV_IS_IN_MMC"
> +# endif
> +# ifndef CONFIG_ENV_ADDR
> +# define CONFIG_ENV_ADDR (CONFIG_ENV_OFFSET)
> +# endif
> +# ifndef CONFIG_ENV_OFFSET
> +# define CONFIG_ENV_OFFSET (CONFIG_ENV_ADDR)
> +# endif
> +# ifdef CONFIG_ENV_OFFSET_REDUND
> +# define CONFIG_SYS_REDUNDAND_ENVIRONMENT
> +# endif
> +# ifdef CONFIG_ENV_IS_EMBEDDED
> +# define ENV_IS_EMBEDDED 1
> +# endif
> +#endif /* CONFIG_ENV_IS_IN_MMC */
You missed Wolfgang's comment. I think also that there is no reason to
set offset for the MMC and block numbers makes more sense.
> +
> /* Embedded env is only supported for some flash types */
> #ifdef CONFIG_ENV_IS_EMBEDDED
> # if !defined(CONFIG_ENV_IS_IN_FLASH) && \
> diff --git a/lib_arm/board.c b/lib_arm/board.c
> index 5e3d7f6..f846d0d 100644
> +#ifdef CONFIG_GENERIC_MMC
> + puts ("MMC: ");
> + mmc_initialize (gd->bd);
> +#endif
> diff --git a/lib_ppc/board.c b/lib_ppc/board.c
> index 765f97a..9b3f84c 100644
> --- a/lib_ppc/board.c
> +++ b/lib_ppc/board.c
> @@ -776,6 +776,12 @@ void board_init_r (gd_t *id, ulong dest_addr)
> nand_init(); /* go init the NAND */
> #endif
>
> +#ifdef CONFIG_GENERIC_MMC
> + WATCHDOG_RESET ();
> + puts ("MMC: ");
> + mmc_initialize (bd);
> +#endif
I am quite confused. You add the initialization only for ARM and PPC.
What about the other architectures ?
I tested your patch on mx51evk, environment is correctly read/written on
the SD situated on the back.
Regards,
Stefano
--
=====================================================================
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:[~2010-03-02 17:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-19 6:58 [U-Boot] [PATCH] Save environment data to mmc Terry Lv
2010-03-02 17:03 ` Stefano Babic [this message]
2010-03-04 3:01 ` Lv Terry-R65388
2010-03-04 3:07 ` Liu Hui-R64343
-- strict thread matches above, loose matches on Subject: below --
2010-04-29 7:40 Terry Lv
2010-04-29 14:33 ` Stefano Babic
2010-04-30 3:47 ` Lv Terry-R65388
2010-04-30 13:14 ` Stefano Babic
2010-04-28 7:52 Terry Lv
2010-04-28 13:30 ` Andy Fleming
2009-11-05 7:43 Terry Lv
2009-11-05 12:09 ` Mike Frysinger
2009-11-06 1:54 ` Lv Terry-R65388
2009-11-05 18:52 ` Wolfgang Denk
2009-11-04 10:02 Terry Lv
2009-11-04 11:01 ` Mike Frysinger
2009-11-05 7:45 ` Lv Terry-R65388
2009-11-04 9:51 Terry Lv
2009-11-04 9:55 ` Lv Terry-R65388
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=4B8D44D7.9040904@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.