Save environment data to mmc.
PATCH 1/1 Save environment data to mmc.
This patch is to save environment data to mmc card. It uses interfaces defined in generic mmc.
--- common/Makefile | 1 + common/cmd_nvedit.c | 3 +- common/env_mmc.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++++ include/environment.h | 18 +++++ lib_arm/board.c | 10 ++-- lib_ppc/board.c | 12 ++-- 6 files changed, 198 insertions(+), 12 deletions(-) create mode 100644 common/env_mmc.c
common/Makefile +1 -0
@@ -54,6 +54,7 @@ COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o COBJS-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o COBJS-$(CONFIG_ENV_IS_IN_MG_DISK) += env_mgdisk.o +COBJS-$(CONFIG_ENV_IS_IN_MMC) += env_mmc.o COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o
common/cmd_nvedit.c +2 -1
@@ -60,9 +60,10 @@ DECLARE_GLOBAL_DATA_PTR; !defined (CONFIG_ENV_IS_IN_NVRAM ) && \ !defined (CONFIG_ENV_IS_IN_ONENAND ) && \ !defined (CONFIG_ENV_IS_IN_SPI_FLASH ) && \ + !defined (CONFIG_ENV_IS_IN_MMC ) && \ !defined(CONFIG_ENV_IS_NOWHERE)# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\ -SPI_FLASH|MG_DISK|NVRAM|NOWHERE} +SPI_FLASH|MG_DISK|NVRAM|MMC|NOWHERE}#endif #define XMK_STR (x) #x
common/env_mmc.c new file +166 -0
166 lines not on this page · raw message
include/environment.h +18 -0
@@ -94,6 +94,24 @@# endif #endif /* CONFIG_ENV_IS_IN_MG_DISK */ +#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 */ +/* Embedded env is only supported for some flash types */ #ifdef CONFIG_ENV_IS_EMBEDDED # if !defined(CONFIG_ENV_IS_IN_FLASH) && \
lib_arm/board.c +5 -5
@@ -335,6 +335,11 @@ void start_armboot (void)nand_init ();/* go init the NAND */ #endif +#ifdef CONFIG_GENERIC_MMC +puts ("MMC: " ); +mmc_initialize (gd->bd); +#endif +#if defined(CONFIG_CMD_ONENAND )onenand_init ();#endif
@@ -416,11 +421,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
lib_ppc/board.c +6 -6
@@ -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 +/* relocate environment function pointers etc. */ env_relocate ();
@@ -932,12 +938,6 @@ void board_init_r (gd_t *id, ulong dest_addr)scsi_init ();#endif -#ifdef CONFIG_GENERIC_MMC -WATCHDOG_RESET (); -puts ("MMC: " ); -mmc_initialize (bd); -#endif -#if defined(CONFIG_CMD_DOC )WATCHDOG_RESET ();puts ("DOC: " );
Signature · 1 line
1.6.0.4
PATCH 1/1 Save environment data to mmc.
common/env_mmc.c line 39
Quoted 7 lines · Terry Lv
common/env_mmc.c +5
-0+#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)
common/env_mmc.c line 42
Quoted 3 lines
common/env_mmc.c +3
-0+#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.
common/env_mmc.c line 45
Quoted 3 lines
common/env_mmc.c +3
-0+#endif + +#if defined(CONFIG_ENV_SIZE_REDUND ) && (CONFIG_ENV_SIZE_REDUND <CONFIG_ENV_SIZE )
Ditto.
common/env_mmc.c line 100
Quoted 5 lines
common/env_mmc.c +5
-0+ +#ifdef CMD_SAVEENV + +inline int write_env (struct mmc *mmc,unsigned long size, +unsigned long offset,const void *buffer)
Line too long.
common/env_mmc.c line 105
Quoted 5 lines
common/env_mmc.c +5
-0+{ +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 ?
common/env_mmc.c line 113
Quoted 3 lines
common/env_mmc.c +3
-0+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.
common/env_mmc.c
Quoted 1 line
common/env_mmc.c +1
-0+ blk_start = (offset %512 ) ? ((offset /512 ) +1 ) : (offset /512 );
Already said, a macro is much more readable to perform alignment.
Quoted 9 lines
include/environment.h +7
-0+#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
include/environment.h line 113
Quoted 10 lines
include/environment.h +10
-0+# 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.
Quoted 17 lines
include/environment.h +1
-0+/* Embedded env is only supported for some flash types */ #ifdef CONFIG_ENV_IS_EMBEDDED # if !defined(CONFIG_ENV_IS_IN_FLASH) && \lib_arm/board.c +4
-0+#ifdef CONFIG_GENERIC_MMC +puts ("MMC: " ); +mmc_initialize (gd->bd); +#endif lib_ppc/board.c +0
-0
lib_ppc/board.c void board_init_r (gd_t *id, ulong dest_addr) · line 783
Quoted 8 lines
lib_ppc/board.c +5
-0@@ -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
Signature · 5 lines
===================================================================== 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 =====================================================================
PATCH 1/1 Save environment data to mmc.
Hi Babic,
Thanks for reviewing the patch.
I will send out a new patch to fix the problems you point out.
For setting block numbers for MMC offset, I just don't want env mmc to be different. I want users to use it as similiar as other env devices.
For the initalization for ARM and PPC, It will be added for all architectures.
Thanks a lot ~~
Yours
Terry
-----Original Message-----
From: Stefano Babic [mailto:sbabic at denx.de]
Sent: 2010?3?3? 1:03
To: Lv Terry-R65388
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] Save environment data to mmc.
common/env_mmc.c line 39
Quoted 7 lines · Terry Lv
common/env_mmc.c +5
-0+#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)
common/env_mmc.c
Quoted 3 lines
common/env_mmc.c +3
-0+#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.
common/env_mmc.c
Quoted 4 lines
common/env_mmc.c +4
-0+#endif + +#if defined(CONFIG_ENV_SIZE_REDUND ) && (CONFIG_ENV_SIZE_REDUND < +CONFIG_ENV_SIZE )
Ditto.
common/env_mmc.c line 100
Quoted 5 lines
common/env_mmc.c +5
-0+ +#ifdef CMD_SAVEENV + +inline int write_env (struct mmc *mmc,unsigned long size, +unsigned long offset,const void *buffer)
Line too long.
common/env_mmc.c line 105
Quoted 5 lines
common/env_mmc.c +5
-0+{ +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 ?
common/env_mmc.c line 113
Quoted 3 lines
common/env_mmc.c +3
-0+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.
common/env_mmc.c
Quoted 1 line
common/env_mmc.c +1
-0+ blk_start = (offset %512 ) ? ((offset /512 ) +1 ) : (offset /512 );
Already said, a macro is much more readable to perform alignment.
Quoted 6 lines
include/environment.h +4
-0+#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
include/environment.h line 113
Quoted 10 lines
include/environment.h +10
-0+# 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.
Quoted 16 lines
+
/* Embedded env is only supported for some flash types */ #ifdefCONFIG_ENV_IS_EMBEDDED# if !defined(CONFIG_ENV_IS_IN_FLASH) && \lib_arm/board.c index 5e3d7f6..f846d0d renamed from lib_arm/board.c +0
-0100644
lib_arm/board.c index 5e3d7f6..f846d0d renamed from lib_arm/board.c +4
-0+#ifdef CONFIG_GENERIC_MMC + puts ("MMC: "); + mmc_initialize (gd->bd); +#endiflib_ppc/board.c index 765f97a..9b3f84c renamed from lib_ppc/board.c +0
-0100644
lib_ppc/board.c void board_init_r (gd_t *id, ulong dest_addr) · line 783
Quoted 8 lines
lib_ppc/board.c +5
-0@@ -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 =====================================================================
PATCH 1/1 Save environment data to mmc.
Hi, Terry,
Quoted 14 lines
-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Lv Terry-R65388
Sent: 2010?3?4? 11:01
To: Stefano Babic
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] Save environment data to mmc.Hi Babic,
Thanks for reviewing the patch.
I will send out a new patch to fix the problems you point out.
Quoted 8 lines
For setting block numbers for MMC offset, I just don't
want env mmc to be different. I want users to use it as similiar as other env devices.For the initalization for ARM and PPC, It will be added
for all architectures.Thanks a lot ??
Had better not put comments on the top of the email, need follow the community style.
Quoted 146 lines
Yours
Terry-----Original Message-----
From: Stefano Babic [mailto:sbabic at denx.de]
Sent: 2010?3?3? 1:03
To: Lv Terry-R65388
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] Save environment data to mmc.common/env_mmc.c line 39
Quoted 7 lines · Terry Lv
common/env_mmc.c +5
-0+#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 fromenv_nand.c, this should be:#if
defined(CONFIG_CMD_SAVEENV)&&defined(CONFIG_CMD_MMC)common/env_mmc.c
Quoted 3 lines
common/env_mmc.c +3
-0+#define CMD_SAVEENV +#elif defined(CONFIG_ENV_OFFSET_REDUND) #error Cannot use +CONFIG_ENV_OFFSET_REDUND without CONFIG_CMD_ENV & CONFIG_CMD_MMCLine too long.
common/env_mmc.c
Quoted 4 lines
common/env_mmc.c +4
-0+#endif + +#if defined(CONFIG_ENV_SIZE_REDUND ) && (CONFIG_ENV_SIZE_REDUND < +CONFIG_ENV_SIZE )Ditto.
common/env_mmc.c
Quoted 5 lines
common/env_mmc.c +5
-0+ +#ifdef CMD_SAVEENV + +inline int write_env (struct mmc *mmc,unsigned long size, + unsigned longoffset, const void *buffer)
Line too long.
common/env_mmc.c
Quoted 4 lines
common/env_mmc.c +4
-0+{ +uint blk_start =0 , blk_cnt =0 , n =0 ; + + blk_start = (offset % 512) ? ((offset / 512) + 1) :(offset / 512);
common/env_mmc.c
Quoted 1 line
common/env_mmc.c +1
-0+ 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 ?common/env_mmc.c line 113
Quoted 3 lines
common/env_mmc.c +3
-0+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.common/env_mmc.c
Quoted 1 line
common/env_mmc.c +1
-0+ blk_start = (offset % 512) ? ((offset / 512) + 1) :(offset / 512);
Already said, a macro is much more readable to perform alignment.
include/environment.h
Quoted 5 lines
include/environment.h +3
-0+#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"include/environment.h
Quoted 7 lines
include/environment.h +7
-0+# 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#include/environment.h line 113
Quoted 4 lines
include/environment.h +4
-0+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.
lib_arm/board.c index
Quoted 4 lines
+
/* Embedded env is only supported for some flash types */ #ifdefCONFIG_ENV_IS_EMBEDDED# if !defined(CONFIG_ENV_IS_IN_FLASH) && ?lib_arm/board.c index renamed from lib_arm/board.c +0
-05e3d7f6..f846d0d
lib_ppc/board.c index
Quoted 8 lines
100644
lib_arm/board.c index renamed from lib_arm/board.c +4
-0+#ifdef CONFIG_GENERIC_MMC + puts ("MMC: "); + mmc_initialize (gd->bd); +#endiflib_ppc/board.c index renamed from lib_ppc/board.c +0
-0765f97a..9b3f84c
lib_ppc/board.c void board_init_r (gd_t *id, ulong dest_addr) · line 783
Quoted 12 lines
100644
lib_ppc/board.c +5
-0@@ -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
=====================================================================_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot