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

Wolfgang Denk wd at denx.de
Tue Apr 4 10:29:26 UTC 2017


Dear Joakim,

In message <1491293863.4177.92.camel at infinera.com> you wrote:
> 
> After a brief look I think we are good. Let me explain, I am only
> making it possible to #define CONFIG_ENV_ADDR, CONFIG_ENV_SECT_SIZE etc.
> as non constant data by moving the assignment of flash_addr etc. to runtime,
> removing the static variable(less relocs to perform too :), I not forcing
> anyone to do so and only for env_flash.c
>
> The only variable that I can't do away with it the:
>  env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
> as it is global. Nothing really uses this global variable(except pmc405de.c which is EPROM),
> not even the linker scripts below. They use #defines directly(CONFIG_ENV_OFFSET,
> CONFIG_SYS_FLASH_BASE etc. except for env_embedded.c which uses other variables)

But CONFIG_ENV_ADDR and CONFIG_ENV_OFFSET are somewhat related,
aren't they?

> As nothing really uses env_ptr and a variable isn't really a good interface(compare 
> with the errno variable) I propose that the env_ptr variable in code is removed but
> lets start with removing it for env_flash.c first.

But if you make it possible to change flash_addr at runtime, then
the assumptions of the linker and the actual placeent of the
environment sector in flash would no longer be in sync with the
code's view of thing.


Maybe you could be so kind and explain your use case?  To me it
looks as if you want to "switch" to a different location, i. e. to
alternative environment settings.  If this is what you want to do I
wonder if it's not easier (at least it does not require code
changes) to switch "profiles" by using "env import" ?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Just about every computer on the market today runs Unix,  except  the
Mac (and nobody cares about it).                   - Bill Joy 6/21/85


More information about the U-Boot mailing list