[U-Boot-Users] Embedded environment setup

Aggelos Manousarides amanous at inaccessnetworks.com
Fri Mar 23 18:20:32 CET 2007


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




More information about the U-Boot mailing list