public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] mx28: Saving env vars on MMC
@ 2011-11-25  2:05 Fabio Estevam
  2011-11-25  7:12 ` Stefano Babic
  0 siblings, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2011-11-25  2:05 UTC (permalink / raw)
  To: u-boot

Hi,

I am trying to save environment variables on a SD card of a MX28EVK board.

'save' command reports no errors, but if I reboot the board then the
board no longer boots.

In order to recover the boot, I need to reformat the SD card and
reflash the u-boot.sd image.

I am trying the following configuration taken from FSL U-boot:

/*
 * MMC Driver
 */
#define CONFIG_ENV_IS_IN_MMC
#define CONFIG_ENV_OFFSET	0x400
#define CONFIG_ENV_SIZE		0x20000 - 0x400
#define CONFIG_SYS_MMC_ENV_DEV 0
#ifdef	CONFIG_CMD_MMC
#define	CONFIG_MMC
#define	CONFIG_GENERIC_MMC
#define	CONFIG_MXS_MMC
#endif

Not sure on the CONFIG_ENV_OFFSET and CONFIG_ENV_SIZE values.

Has anyone tried saving env vars on MX28? Any suggestions?

Thanks,

Fabio Estevam

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

* [U-Boot] mx28: Saving env vars on MMC
  2011-11-25  2:05 [U-Boot] mx28: Saving env vars on MMC Fabio Estevam
@ 2011-11-25  7:12 ` Stefano Babic
  2011-11-25  8:13   ` Marek Vasut
  0 siblings, 1 reply; 9+ messages in thread
From: Stefano Babic @ 2011-11-25  7:12 UTC (permalink / raw)
  To: u-boot

On 25/11/2011 03:05, Fabio Estevam wrote:
> Hi,
> 
> I am trying to save environment variables on a SD card of a MX28EVK board.
> 
> 'save' command reports no errors, but if I reboot the board then the
> board no longer boots.
> 
> In order to recover the boot, I need to reformat the SD card and
> reflash the u-boot.sd image.
> 
> I am trying the following configuration taken from FSL U-boot:
> 
> /*
>  * MMC Driver
>  */
> #define CONFIG_ENV_IS_IN_MMC
> #define CONFIG_ENV_OFFSET	0x400

I do not know the details, but this offset is very low and it seems
taken from other i.MX (MX5). This can overwrite your U-Boot. The
write_env() function in env_mmc.c converts the offset in a block number,
and this means you are writing at the block #2.

Because 1 Block=512 byte, can you try to move the offset to a very high
block ?

> #define CONFIG_ENV_SIZE		0x20000 - 0x400

This seems too much...

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
=====================================================================

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

* [U-Boot] mx28: Saving env vars on MMC
  2011-11-25  7:12 ` Stefano Babic
@ 2011-11-25  8:13   ` Marek Vasut
  2011-11-25 13:20     ` Fabio Estevam
  0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2011-11-25  8:13 UTC (permalink / raw)
  To: u-boot

> On 25/11/2011 03:05, Fabio Estevam wrote:
> > Hi,
> > 
> > I am trying to save environment variables on a SD card of a MX28EVK
> > board.
> > 
> > 'save' command reports no errors, but if I reboot the board then the
> > board no longer boots.
> > 
> > In order to recover the boot, I need to reformat the SD card and
> > reflash the u-boot.sd image.
> > 
> > I am trying the following configuration taken from FSL U-boot:
> > 
> > /*
> > 
> >  * MMC Driver
> >  */
> > 
> > #define CONFIG_ENV_IS_IN_MMC
> > #define CONFIG_ENV_OFFSET	0x400
> 
> I do not know the details, but this offset is very low and it seems
> taken from other i.MX (MX5). This can overwrite your U-Boot. The
> write_env() function in env_mmc.c converts the offset in a block number,
> and this means you are writing at the block #2.
> 
> Because 1 Block=512 byte, can you try to move the offset to a very high
> block ?
> 
> > #define CONFIG_ENV_SIZE		0x20000 - 0x400
> 
> This seems too much...
> 
> Stefano

You have to be careful on the imx28 about the following:

1) sector 0 / first 512 bytes : That's where MBR is
2) sector 2048 + ... : That's where U-Boot is located

But it's strange, there's about 1MB of space between MBR and U-Boot ... can you 
actually check the first 2MB of the card and run binary diff on the good and bad 
card ? That way you'll see what changed.

M

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

* [U-Boot] mx28: Saving env vars on MMC
  2011-11-25  8:13   ` Marek Vasut
@ 2011-11-25 13:20     ` Fabio Estevam
  2011-11-25 13:42       ` Marek Vasut
  2011-11-25 14:30       ` Marek Vasut
  0 siblings, 2 replies; 9+ messages in thread
From: Fabio Estevam @ 2011-11-25 13:20 UTC (permalink / raw)
  To: u-boot

On Fri, Nov 25, 2011 at 6:13 AM, Marek Vasut <marek.vasut@gmail.com> wrote:

> You have to be careful on the imx28 about the following:
>
> 1) sector 0 / first 512 bytes : That's where MBR is
> 2) sector 2048 + ... : That's where U-Boot is located
>
> But it's strange, there's about 1MB of space between MBR and U-Boot ... can you
> actually check the first 2MB of the card and run binary diff on the good and bad
> card ? That way you'll see what changed.

What I see is that when I do a 'save' the env variables are written to
0 and this causes the boot to fail.

Has the mxsmmc driver been tested?

Regards,

Fabio Estevam

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

* [U-Boot] mx28: Saving env vars on MMC
  2011-11-25 13:20     ` Fabio Estevam
@ 2011-11-25 13:42       ` Marek Vasut
  2011-11-25 14:30       ` Marek Vasut
  1 sibling, 0 replies; 9+ messages in thread
From: Marek Vasut @ 2011-11-25 13:42 UTC (permalink / raw)
  To: u-boot

> On Fri, Nov 25, 2011 at 6:13 AM, Marek Vasut <marek.vasut@gmail.com> wrote:
> > You have to be careful on the imx28 about the following:
> > 
> > 1) sector 0 / first 512 bytes : That's where MBR is
> > 2) sector 2048 + ... : That's where U-Boot is located
> > 
> > But it's strange, there's about 1MB of space between MBR and U-Boot ...
> > can you actually check the first 2MB of the card and run binary diff on
> > the good and bad card ? That way you'll see what changed.
> 
> What I see is that when I do a 'save' the env variables are written to
> 0 and this causes the boot to fail.
> 
> Has the mxsmmc driver been tested?

Definitelly, yes. Do you want to look into it or shall I do that ?

Now it might be worth trying to trace if there's a problem in the env_mmc (aka. 
who introduces the 0)

M

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

* [U-Boot] mx28: Saving env vars on MMC
  2011-11-25 13:20     ` Fabio Estevam
  2011-11-25 13:42       ` Marek Vasut
@ 2011-11-25 14:30       ` Marek Vasut
  2011-11-25 15:06         ` Fabio Estevam
  1 sibling, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2011-11-25 14:30 UTC (permalink / raw)
  To: u-boot

> On Fri, Nov 25, 2011 at 6:13 AM, Marek Vasut <marek.vasut@gmail.com> wrote:
> > You have to be careful on the imx28 about the following:
> > 
> > 1) sector 0 / first 512 bytes : That's where MBR is
> > 2) sector 2048 + ... : That's where U-Boot is located
> > 
> > But it's strange, there's about 1MB of space between MBR and U-Boot ...
> > can you actually check the first 2MB of the card and run binary diff on
> > the good and bad card ? That way you'll see what changed.
> 
> What I see is that when I do a 'save' the env variables are written to
> 0 and this causes the boot to fail.
> 
> Has the mxsmmc driver been tested?
> 
> Regards,
> 
> Fabio Estevam

I did the following change and tested u-boot on m28evk. I saved env, restarted 
board etc.

1) Env was successfully saved to MMC sector 2 (at offset 1024 bytes from start).
2) Env was successfully loaded from MMC after reset

Basically ... give it a go, Fabio, maybe you just missed something :)

PATCH:

diff --git a/include/configs/m28evk.h b/include/configs/m28evk.h
index d4bd207..25edab8 100644
--- a/include/configs/m28evk.h
+++ b/include/configs/m28evk.h                                                                                                                                                      
@@ -147,7 +147,7 @@                                                                                                                                                                 
 #define        NAND_MAX_CHIPS                  8                                                                                                                                   
                                                                                                                                                                                    
 /* Environment is in NAND */                                                                                                                                                       
-#define        CONFIG_ENV_IS_IN_NAND                                                                                                                                               
+/*#define      CONFIG_ENV_IS_IN_NAND                                                                                                                                               
 #define        CONFIG_ENV_SIZE                 (16 * 1024)                                                                                                                         
 #define        CONFIG_ENV_SIZE_REDUND          CONFIG_ENV_SIZE                                                                                                                     
 #define        CONFIG_ENV_SECT_SIZE            (128 * 1024)                                                                                                                        
@@ -155,6 +155,12 @@                                                                                                                                                                
 #define        CONFIG_ENV_OFFSET               0x300000                                                                                                                            
 #define        CONFIG_ENV_OFFSET_REDUND        \                                                                                                                                   
                (CONFIG_ENV_OFFSET + CONFIG_ENV_RANGE)                                                                                                                              
+*/
+
+#define        CONFIG_ENV_IS_IN_MMC
+#define        CONFIG_SYS_MMC_ENV_DEV  0
+#define        CONFIG_ENV_SIZE                 (16 * 1024)
+#define        CONFIG_ENV_OFFSET               1024
 
 #define        CONFIG_CMD_UBI
 #define        CONFIG_CMD_UBIFS

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

* [U-Boot] mx28: Saving env vars on MMC
  2011-11-25 14:30       ` Marek Vasut
@ 2011-11-25 15:06         ` Fabio Estevam
  2011-11-25 15:13           ` Marek Vasut
  0 siblings, 1 reply; 9+ messages in thread
From: Fabio Estevam @ 2011-11-25 15:06 UTC (permalink / raw)
  To: u-boot

On Fri, Nov 25, 2011 at 12:30 PM, Marek Vasut <marek.vasut@gmail.com> wrote:

> I did the following change and tested u-boot on m28evk. I saved env, restarted
> board etc.
>
> 1) Env was successfully saved to MMC sector 2 (at offset 1024 bytes from start).
> 2) Env was successfully loaded from MMC after reset
>
> Basically ... give it a go, Fabio, maybe you just missed something :)

Thanks for trying it on your board, Marek.

I applied the same changes here and I still get a corrupted card after
running "save".

Will keep investigating.

Thanks,

Fabio Estevam

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

* [U-Boot] mx28: Saving env vars on MMC
  2011-11-25 15:06         ` Fabio Estevam
@ 2011-11-25 15:13           ` Marek Vasut
  2011-11-26 21:33             ` Fabio Estevam
  0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2011-11-25 15:13 UTC (permalink / raw)
  To: u-boot

> On Fri, Nov 25, 2011 at 12:30 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> > I did the following change and tested u-boot on m28evk. I saved env,
> > restarted board etc.
> > 
> > 1) Env was successfully saved to MMC sector 2 (at offset 1024 bytes from
> > start). 2) Env was successfully loaded from MMC after reset
> > 
> > Basically ... give it a go, Fabio, maybe you just missed something :)
> 
> Thanks for trying it on your board, Marek.
> 
> I applied the same changes here and I still get a corrupted card after
> running "save".
> 
> Will keep investigating.
> 
> Thanks,
> 
> Fabio Estevam

Still writing to block 0 then?

Can you push your current preliminary MX28EVK stuff somewhere so I can check ?

M

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

* [U-Boot] mx28: Saving env vars on MMC
  2011-11-25 15:13           ` Marek Vasut
@ 2011-11-26 21:33             ` Fabio Estevam
  0 siblings, 0 replies; 9+ messages in thread
From: Fabio Estevam @ 2011-11-26 21:33 UTC (permalink / raw)
  To: u-boot

On Fri, Nov 25, 2011 at 1:13 PM, Marek Vasut <marek.vasut@gmail.com> wrote:

>
> Still writing to block 0 then?
>
> Can you push your current preliminary MX28EVK stuff somewhere so I can check ?

I managed to fix this and now I can successfully save environment
variables on the SD card.

Will do more tests on Monday on a MX53QSB, to make sure my changes
don't break other boards and then will submit a patch.

Thanks,

Fabio Estevam

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

end of thread, other threads:[~2011-11-26 21:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-25  2:05 [U-Boot] mx28: Saving env vars on MMC Fabio Estevam
2011-11-25  7:12 ` Stefano Babic
2011-11-25  8:13   ` Marek Vasut
2011-11-25 13:20     ` Fabio Estevam
2011-11-25 13:42       ` Marek Vasut
2011-11-25 14:30       ` Marek Vasut
2011-11-25 15:06         ` Fabio Estevam
2011-11-25 15:13           ` Marek Vasut
2011-11-26 21:33             ` Fabio Estevam

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