All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot-Users] Embedded environment setup
@ 2007-03-23 17:20 Aggelos Manousarides
  2007-03-25 20:27 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Aggelos Manousarides @ 2007-03-23 17:20 UTC (permalink / raw)
  To: u-boot

I have a flash chip with equally sized sectors and I don't want to waste 
an entire sector for the environment. I have the u-boot environment 
embedded in the u-boot sector. The declarations in my board file are:

#define CFG_ENV_IS_IN_FLASH     1
#define CFG_MONITOR_BASE        (CFG_FLASH_BASE)
#define CFG_MONITOR_LEN         (256* 1024)
#define CFG_ENV_ADDR            (CFG_MONITOR_BASE + 16 * 1024)
#define CFG_ENV_SIZE            (32 * 1024)
#define CFG_ENV_SECT_SIZE       CFG_MONITOR_LEN


I use the CFI driver for this flash chip and I noticed that it protects 
one more sector than necessary my default. There is this piece of code 
in drivers/cfi_flash.c:

#ifdef CFG_ENV_IS_IN_FLASH
         flash_protect (FLAG_PROTECT_SET,
                        CFG_ENV_ADDR,
                        CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
                        flash_get_info(CFG_ENV_ADDR));
#endif

Because my CFG_ENV_SECT_SIZE exceeds the first sector, the second sector 
is locked as well. I believe that in this point the code should check if 
the environment is embedded in the flash before locking this section, 
since code directly above that has already locked the u-boot sector. I 
have modified it like that:

         /* Environment protection ON by default */
#ifdef CFG_ENV_IS_IN_FLASH
#ifndef ENV_IS_EMBEDDED
         flash_protect (FLAG_PROTECT_SET,
                        CFG_ENV_ADDR,
                        CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
                        flash_get_info(CFG_ENV_ADDR));
#endif
#endif

I tried to remove the CFG_ENV_SECT_SIZE declaration but this breaks the 
saveenv command. While trying to save the environment I got:

Saving Environment to Flash...
Error: start address not on sector boundary

--
Angelos Manousaridis

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

* [U-Boot-Users] Embedded environment setup
  2007-03-23 17:20 [U-Boot-Users] Embedded environment setup Aggelos Manousarides
@ 2007-03-25 20:27 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2007-03-25 20:27 UTC (permalink / raw)
  To: u-boot

In message <46040C60.5070505@inaccessnetworks.com> you wrote:
> I have a flash chip with equally sized sectors and I don't want to waste 
> an entire sector for the environment. I have the u-boot environment 
> embedded in the u-boot sector. The declarations in my board file are:

Do not do this. Do NOT do this. DO NOT DO THIS.

Please never mix U-Boot  code  and  environment  data  inone  sector.
Always use a separate sector (or two) for the environment.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, HRB 165235 Munich, CEO: Wolfgang Denk
Office:  Kirchenstr. 5,       D-82194 Groebenzell,            Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Though a program be but three lines long,
someday it will have to be maintained."
- The Tao of Programming

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

end of thread, other threads:[~2007-03-25 20:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-23 17:20 [U-Boot-Users] Embedded environment setup Aggelos Manousarides
2007-03-25 20:27 ` Wolfgang Denk

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.