From: "Marek Behún" <kabel@kernel.org>
To: "Simon Glass" <sjg@chromium.org>, "Stefan Roese" <sr@denx.de>,
"Pali Rohár" <pali@kernel.org>
Cc: u-boot@lists.denx.de, "Marek Behún" <marek.behun@nic.cz>
Subject: [PATCH 0/5] Board specific runtime determined default env
Date: Thu, 28 Oct 2021 05:28:05 +0200 [thread overview]
Message-ID: <20211028032810.18146-1-kabel@kernel.org> (raw)
From: Marek Behún <marek.behun@nic.cz>
Hello Simon, Stefan, Pali,
this series adds support for board specific runtime determined
default environment variables.
IMPORTANT: This series depends on the series
http://patchwork.ozlabs.org/project/uboot/list/?series=268452
Currently the
env default [-a]
command uses the default_environment[] buffer to get the default
env variables.
Sometimes it makes sense to have runtime determined default env
settings.
For example the ESPRESSObin board has 4 variants
([ddr3 vs ddr4] x [emmc vs sd]), and each uses different device tree.
Thus the `fdtfile` env variable has different values for these 4
variants. (We can't set this variable via env_set() in some board init
function, because then the user would be unable to overwrite it.)
In order for the command
env default fdtfile
to work as the user would expect, we need to support overwriting default
environment in runtime.
Pali solved this for ESPRESSObin by declaring the default_environment[]
buffer read-write, instead of read-only, and adding ad-hoc code into
board_late_init() that writes into the default_environment[] buffer.
This ad-hoc code works, but it would be better to have a generic API
for this, since there are other boards which could benefit.
The first 3 patches in this series fix and simplify code in
env/common.c.
The 4th patch adds support for board specific runtime determined
default environment in such a way that if a board code defines function
const char *board_special_default_env(unsigned i, const char **name);
The default weak implementation of this function is trivial and just
returns NULL.
This function is to be defined in board code, and when defined, it must
return the value of the i-th runtime determined default env variable,
while storing its name into *name.
For example:
const char *board_special_default_env(unsigned i, const char **name)
{
switch (i) {
case 0:
*name = "board";
return is_ddr4() ? "my_board_ddr4" : "my_board";
case 1:
*name = "fdtfile";
return is_ddr4() ? "my-board-ddr4.dtb" : "my-board.dtb";
default:
return NULL;
}
The last patch (NOT TESTED) converts the ESPRESSObin ad-hoc code to
use this API.
Marek
Marek Behún (5):
env: Don't set ready flag if import failed in env_set_default()
env: Fix env_get() when returning empty string using env_get_f()
env: Simplify env_get_default()
env: Add support for board specific special default environment
arm: mvebu: Espressobin: Use new API for setting default env at
runtime
board/Marvell/mvebu_armada-37xx/board.c | 120 ++++++++++------
configs/mvebu_espressobin-88f3720_defconfig | 1 -
env/common.c | 150 ++++++++++++++++----
include/configs/mvebu_armada-37xx.h | 17 +--
include/env_default.h | 2 -
include/env_internal.h | 4 -
6 files changed, 199 insertions(+), 95 deletions(-)
--
2.32.0
next reply other threads:[~2021-10-28 3:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-28 3:28 Marek Behún [this message]
2021-10-28 3:28 ` [PATCH 1/5] env: Don't set ready flag if import failed in env_set_default() Marek Behún
2021-10-29 3:17 ` Simon Glass
2021-10-28 3:28 ` [PATCH 2/5] env: Fix env_get() when returning empty string using env_get_f() Marek Behún
2021-10-29 3:17 ` Simon Glass
2021-10-29 8:51 ` Marek Behún
2021-10-29 9:03 ` Pali Rohár
2021-10-31 13:07 ` Simon Glass
2021-10-31 15:27 ` Marek Behún
2021-10-28 3:28 ` [PATCH 3/5] env: Simplify env_get_default() Marek Behún
2021-10-29 3:17 ` Simon Glass
2021-10-28 3:28 ` [PATCH 4/5] env: Add support for board specific special default environment Marek Behún
2021-10-29 3:17 ` Simon Glass
2021-10-29 8:57 ` Marek Behún
2021-10-31 13:07 ` Simon Glass
2021-10-28 3:28 ` [PATCH 5/5] arm: mvebu: Espressobin: Use new API for setting default env at runtime Marek Behún
2021-10-29 3:17 ` Simon Glass
2021-10-31 20:15 ` Pali Rohár
2021-11-02 14:57 ` Simon Glass
2021-11-03 10:48 ` Pali Rohár
2021-10-29 3:17 ` [PATCH 0/5] Board specific runtime determined default env Simon Glass
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=20211028032810.18146-1-kabel@kernel.org \
--to=kabel@kernel.org \
--cc=marek.behun@nic.cz \
--cc=pali@kernel.org \
--cc=sjg@chromium.org \
--cc=sr@denx.de \
--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