From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joakim Tjernlund Date: Tue, 4 Apr 2017 10:24:21 +0000 Subject: [U-Boot] Remove global variable env_t *env_ptr ? In-Reply-To: <20170404105529.3740f49f@jawa> References: <1491221969.4177.81.camel@infinera.com> <20170404105529.3740f49f@jawa> Message-ID: <1491301459.28343.1.camel@infinera.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: u-boot@lists.denx.de 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 > >