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

Wolfgang Denk wd at denx.de
Mon Apr 3 20:17:33 UTC 2017


Dear Joakim,

In message <1491221969.4177.81.camel at infinera.com> you wrote:
> 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.

I doubt this will work for configurations that use embedded
environment.

> 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.

Did you look in the code only, or in all files?

> Anyhow, I am faced wit two choices, either remove the env_ptr or
> convert it to a function call.

Probably neither will work for all use cases.  You remember the good
old times when we had parallel NOR flash with a few smaller sectors
somewhere near the beginning or the end of the device?  It was
pretty usual to use these small sectors for the environment, and it
was the task of thelinker script to "wrap" the rest of the code
around these reserved sectors.  For this, the environment location
must be known not only in the code, but also in the linker script.

Without thorough checking , at least these files look suspicious to
me:

arch/powerpc/cpu/mpc5xx/u-boot.lds:  . = env_start;
arch/powerpc/cpu/mpc5xx/u-boot.lds:  .ppcenv :
arch/powerpc/cpu/mpc5xx/u-boot.lds:    common/env_embedded.o (.ppcenv)
arch/powerpc/cpu/mpc5xxx/u-boot-customlayout.lds:    . = DEFINED(env_offset) ? env_offset : .;
arch/powerpc/cpu/mpc5xxx/u-boot-customlayout.lds:    common/env_embedded.o              (.ppcenv*)
board/tqc/tqm8xx/u-boot.lds:    . = DEFINED(env_offset) ? env_offset : .;
board/tqc/tqm8xx/u-boot.lds:    common/env_embedded.o   (.ppcenv*)
board/freescale/mx31ads/u-boot.lds:       . = DEFINED(env_offset) ? env_offset : .;
board/freescale/mx31ads/u-boot.lds:       common/env_embedded.o(.text*)

Please have a look at these, and verify that the image layout does
not change for these with any such changes.

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
An expert is a person who avoids the small errors while  sweeping  on
to the grand fallacy.


More information about the U-Boot mailing list