From: Patrick Delaunay <patrick.delaunay@st.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 07/14] cmd: env: add env load command
Date: Thu, 25 Jun 2020 09:59:51 +0200 [thread overview]
Message-ID: <20200625075958.9868-8-patrick.delaunay@st.com> (raw)
In-Reply-To: <20200625075958.9868-1-patrick.delaunay@st.com>
Add the new command env load to load the environment from
the current location gd->env_load_prio.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
Changes in v3:
- new: add 'env load' command
cmd/Kconfig | 6 ++++++
cmd/nvedit.c | 14 ++++++++++++++
env/env.c | 28 ++++++++++++++++++++++++++++
include/env.h | 7 +++++++
4 files changed, 55 insertions(+)
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 1de57988ae..679b1c32b4 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -610,6 +610,12 @@ config CMD_NVEDIT_INFO
[-q] : quiet output
The result of multiple evaluations will be combined with AND.
+config CMD_NVEDIT_LOAD
+ bool "env load"
+ help
+ Load all environment variables from the compiled-in persistent
+ storage.
+
endmenu
menu "Memory commands"
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 0f9cea96f3..7a39d9cd66 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -794,6 +794,14 @@ U_BOOT_CMD(
);
#endif
#endif
+
+#if defined(CONFIG_CMD_NVEDIT_LOAD)
+static int do_env_load(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ return env_reload() ? 1 : 0;
+}
+#endif
#endif /* CONFIG_SPL_BUILD */
int env_match(uchar *s1, int i2)
@@ -1346,6 +1354,9 @@ static struct cmd_tbl cmd_env_sub[] = {
#endif
#if defined(CONFIG_CMD_NVEDIT_INFO)
U_BOOT_CMD_MKENT(info, 3, 0, do_env_info, "", ""),
+#endif
+#if defined(CONFIG_CMD_NVEDIT_LOAD)
+ U_BOOT_CMD_MKENT(load, 1, 0, do_env_load, "", ""),
#endif
U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_env_print, "", ""),
#if defined(CONFIG_CMD_RUN)
@@ -1442,6 +1453,9 @@ static char env_help_text[] =
"env erase - erase environment\n"
#endif
#endif
+#if defined(CONFIG_CMD_NVEDIT_LOAD)
+ "env load - load environment\n"
+#endif
#if defined(CONFIG_CMD_NVEDIT_EFI)
"env set -e [-nv][-bs][-rt][-at][-a][-i addr,size][-v] name [arg ...]\n"
" - set UEFI variable; unset if '-i' or 'arg' not specified\n"
diff --git a/env/env.c b/env/env.c
index a1696cd77e..7ad9623ef2 100644
--- a/env/env.c
+++ b/env/env.c
@@ -230,6 +230,34 @@ int env_load(void)
return -ENODEV;
}
+int env_reload(void)
+{
+ struct env_driver *drv;
+
+ drv = env_driver_lookup(ENVOP_LOAD, gd->env_load_prio);
+ if (drv) {
+ int ret;
+
+ printf("Loading Environment from %s... ", drv->name);
+
+ if (!env_has_inited(drv->location)) {
+ printf("not initialized\n");
+ return -ENODEV;
+ }
+
+ ret = drv->load();
+ if (ret)
+ printf("Failed (%d)\n", ret);
+ else
+ printf("OK\n");
+
+ if (!ret)
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
int env_save(void)
{
struct env_driver *drv;
diff --git a/include/env.h b/include/env.h
index d6c2d751d6..68e0f4fa56 100644
--- a/include/env.h
+++ b/include/env.h
@@ -265,6 +265,13 @@ int env_set_default_vars(int nvars, char *const vars[], int flags);
*/
int env_load(void);
+/**
+ * env_reload() - Re-Load the environment from current storage
+ *
+ * @return 0 if OK, -ve on error
+ */
+int env_reload(void);
+
/**
* env_save() - Save the environment to storage
*
--
2.17.1
next prev parent reply other threads:[~2020-06-25 7:59 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 7:59 [PATCH v3 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
2020-06-25 7:59 ` [PATCH v3 01/14] env: add absolute path at CONFIG_ENV_EXT4_FILE Patrick Delaunay
2020-06-25 7:59 ` [PATCH v3 02/14] env: ext4: set gd->env_valid Patrick Delaunay
2020-06-25 7:59 ` [PATCH v3 03/14] env: sf: avoid space in backend name Patrick Delaunay
2020-06-26 20:54 ` Tom Rini
2020-06-25 7:59 ` [PATCH v3 04/14] env: correctly handle env_load_prio Patrick Delaunay
2020-06-26 20:55 ` Tom Rini
2020-06-25 7:59 ` [PATCH v3 05/14] env: nowhere: add .load ops Patrick Delaunay
2020-06-26 20:55 ` Tom Rini
2020-07-26 20:50 ` Tom Rini
2020-06-25 7:59 ` [PATCH v3 06/14] env: the ops driver load becomes mandatory in struct env_driver Patrick Delaunay
2020-06-26 20:55 ` Tom Rini
2020-06-25 7:59 ` Patrick Delaunay [this message]
2020-06-26 20:55 ` [PATCH v3 07/14] cmd: env: add env load command Tom Rini
2020-06-25 7:59 ` [PATCH v3 08/14] cmd: env: add env select command Patrick Delaunay
2020-06-26 20:54 ` Tom Rini
2020-06-30 11:42 ` Patrick DELAUNAY
2020-06-25 7:59 ` [PATCH v3 09/14] configs: sandbox: activate env in ext4 support Patrick Delaunay
2020-06-25 7:59 ` [PATCH v3 10/14] configs: sandbox: activate command env select and env load Patrick Delaunay
2020-06-25 7:59 ` [PATCH v3 11/14] test: environment in ext4 Patrick Delaunay
2020-07-06 21:53 ` Stephen Warren
2020-06-25 7:59 ` [PATCH v3 12/14] env: ext4: introduce new function env_ext4_save_buffer Patrick Delaunay
2020-06-25 7:59 ` [PATCH v3 13/14] env: ext4: add support of command env erase Patrick Delaunay
2020-06-25 7:59 ` [PATCH v3 14/14] test: sandbox: add test for erase command Patrick Delaunay
2020-07-06 21:54 ` Stephen Warren
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=20200625075958.9868-8-patrick.delaunay@st.com \
--to=patrick.delaunay@st.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