From: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] Remove global variable env_t *env_ptr ?
Date: Tue, 4 Apr 2017 08:17:45 +0000 [thread overview]
Message-ID: <1491293863.4177.92.camel@infinera.com> (raw)
In-Reply-To: <20170403201733.E7CE11201A5@gemini.denx.de>
On Mon, 2017-04-03 at 22:17 +0200, Wolfgang Denk wrote:
> Dear Joakim,
Dear Wolfgang,
>
> In message <1491221969.4177.81.camel@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.
I see, I don't think so but will look closer.
>
> > 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?
code only, for the use of the env_ptr variable only as this is the variable I looking at.
>
> > 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
Sure do, this is the reason I am having this problem. The new flashes do
not have such smaller sectors, they are all uniform :(
> 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.
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)
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.
>
> 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
>
next prev parent reply other threads:[~2017-04-04 8:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-03 12:19 [U-Boot] Remove global variable env_t *env_ptr ? Joakim Tjernlund
2017-04-03 20:17 ` Wolfgang Denk
2017-04-04 8:17 ` Joakim Tjernlund [this message]
2017-04-04 10:29 ` Wolfgang Denk
2017-04-04 8:55 ` Lukasz Majewski
2017-04-04 10:24 ` Joakim Tjernlund
2017-04-04 10:31 ` Wolfgang Denk
2017-04-04 10:44 ` Joakim Tjernlund
2017-04-04 11:27 ` Wolfgang Denk
2017-04-04 13:21 ` Joakim Tjernlund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1491293863.4177.92.camel@infinera.com \
--to=joakim.tjernlund@infinera.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox