Skip to contentSkip to conversation

Embedded environment setup

U-Boot-Users Aggelos Manousarides 2 participants 2 messages Mar 23, 2007 – Mar 25, 2007

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 3 lines · In message <[email protected]> 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

Signature · 6 lines
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