From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aggelos Manousarides Date: Fri, 23 Mar 2007 19:20:32 +0200 Subject: [U-Boot-Users] Embedded environment setup Message-ID: <46040C60.5070505@inaccessnetworks.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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