[U-Boot] Remove global variable env_t *env_ptr ?

Joakim Tjernlund Joakim.Tjernlund at infinera.com
Tue Apr 4 10:24:21 UTC 2017


On Tue, 2017-04-04 at 10:55 +0200, Lukasz Majewski wrote:
> Hi Joakim,
> 
> > I am looking at adding support for runtime sizing of CONFIG_ENV_ADDR
> > as we need to replace out flash but we don't want to create a new
> > u-boot binairy just for this simple change.
> 
> Please correct me if I did not understand your use case correctly.
> 
> Other boards have separate regions in flash to store ENV variables -
> even redundancy is supported (from ./include/mccmon6.h)
> 
> /* Envs are stored in NOR flash */
> #define CONFIG_ENV_IS_IN_FLASH
> #define CONFIG_ENV_SECT_SIZE    (SZ_128K)
> #define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x40000)
> 
> #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
> #define CONFIG_ENV_ADDR_REDUND  (CONFIG_SYS_FLASH_BASE + 0x60000)
> #define CONFIG_ENV_SIZE_REDUND  CONFIG_ENV_SIZE

Use case is when CONFIG_ENV_SECT_SIZE and/or CONFIG_ENV_ADDR are non constants.
Then, in my case, these becomes:
#define CONFIG_ENV_SECT_SIZE    (get_env_sect_size())
#define CONFIG_ENV_ADDR    (get_env_address())

Jocke
> 
> You can extract the ENV variables by using following script:
> 
> scripts/get_default_envs.sh > default_envs.txt
> 
> and then create updated env image (with [*]) to be stored on flash.
> 
> 
> Note:
> 
> [*] 
> ./tools/mkenvimage -s 131072 -o ${UBOOT_ENVS_DEFAULT} default_envs.txt
> 
> Best regards,
> Łukasz Majewski
> 
> > 
> > While converting env_flash.c I noted the global variable
> >  env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
> > which cannot be runtime decided.
> > Looking at users of this variable I only find one in pmc405de.c(not
> > sure what that board is doing) and for what I can tell this variable
> > is not correct for redundant env. either.
> > 
> > Anyhow, I am faced wit two choices, either remove the env_ptr or
> > convert it to a function call.
> > 
> > What do fellow u-booters think about env_ptr?
> > 
> >  Jocke
> > 


More information about the U-Boot mailing list