From: Michael Walle <michael@walle.cc>
To: u-boot@lists.denx.de
Subject: [PATCH v4 2/3] env: Access Environment in SPI flashes before relocation
Date: Sat, 31 Oct 2020 01:25:16 +0100 [thread overview]
Message-ID: <f3601b07cc1286e74e81fcbaab31fbe1@walle.cc> (raw)
In-Reply-To: <20201031000703.GZ5340@bill-the-cat>
Hi,
Am 2020-10-31 01:07, schrieb Tom Rini:
[..]
>> > +static int env_sf_init(void)
>> > +{
>> > +#if defined(INITENV) && (CONFIG_ENV_ADDR != 0x0)
>> > + return env_sf_init_addr();
>> > +#elif defined(CONFIG_ENV_SPI_EARLY)
>> > + return env_sf_init_early();
>> > +#endif
>> > + /*
>> > + * we must return with 0 if there is nothing done,
>> > + * else env_set_inited() get not called in env_init()
>> > + */
>> > + return 0;
>> > +}
>> > +
>> > U_BOOT_ENV_LOCATION(sf) = {
>> > .location = ENVL_SPI_FLASH,
>> > ENV_NAME("SPIFlash")
>> > .load = env_sf_load,
>> > .save = CONFIG_IS_ENABLED(SAVEENV) ? ENV_SAVE_PTR(env_sf_save) :
>> > NULL,
>> > -#if defined(INITENV) && (CONFIG_ENV_ADDR != 0x0)
>> > .init = env_sf_init,
>> > -#endif
>>
>> This will break my board (the new kontron sl28). Before the
>> change, the environment is loaded from SPI, after this patch
>> the environment won't be loaded anymore. If I delete the
>> .init callback, the behavior is the same as before.
>>
>> The problem here is that returning 0 in env_sf_init() is not
>> enough because if the .init callback is not set, env_init() will
>> have ret defaulting to -ENOENT and in this case will load the
>> default environment and setting env_valid to ENV_VALID. I didn't
>> follow the whole call chain then. But this will then eventually
>> lead to loading the actual environment in a later stage.
>
> Ugh. The games we play in the env area really just need to be
> rewritten. So at this point I've merged the series, should I revert or
> do you see an easy fix for your platform? Thanks!
Mh, my board cannot be the only one with a late environment
from SPI flash, can it?
Returning 0 will call env_set_inited() and returning -ENOENT
will call the second part. I can't tell why it was done that
way. So I don't have a simple fix.
But I guess the following ugly ifdeffery could do it:
#if (defined(INITENV) && (CONFIG_ENV_ADDR != 0x0)) ||
defined(CONFIG_ENV_SPI_EARLY)
.init = env_sf_init,
#endif
I can try that tomorrow. Also the comment about the return
value should be removed (?).
-michael
next prev parent reply other threads:[~2020-10-31 0:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-10 8:28 [PATCH v4 0/3] env: Access Environment in SPI flashes before relocation Heiko Schocher
2020-10-10 8:28 ` [PATCH v4 1/3] env: split env_import_redund() into 2 functions Heiko Schocher
2020-10-12 3:35 ` Simon Glass
2020-10-30 18:46 ` Tom Rini
2020-10-10 8:28 ` [PATCH v4 2/3] env: Access Environment in SPI flashes before relocation Heiko Schocher
2020-10-12 3:35 ` Simon Glass
2020-10-30 18:46 ` Tom Rini
2020-10-30 23:51 ` Michael Walle
2020-10-31 0:07 ` Tom Rini
2020-10-31 0:25 ` Michael Walle [this message]
2020-11-02 5:20 ` Heiko Schocher
2020-10-10 8:28 ` [PATCH v4 3/3] imx6: enable early spi environment access on aristainetos boards Heiko Schocher
2020-10-30 18:46 ` Tom Rini
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=f3601b07cc1286e74e81fcbaab31fbe1@walle.cc \
--to=michael@walle.cc \
--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