All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4
@ 2020-07-28  9:51 Patrick Delaunay
  2020-07-28  9:51 ` [PATCH v4 01/14] env: add absolute path at CONFIG_ENV_EXT4_FILE Patrick Delaunay
                   ` (13 more replies)
  0 siblings, 14 replies; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot


Hi,

V4 of the serie [1]: rebase on master branch and solve the SPL size
issue for board with SPL_ENV_IS_NOWHERE=y (pointed by Tom Rini in [2])

The buildman result for these boards are:

-------------------------------------------------
tools/buildman/buildman  -b sssddsqqs T1042RDB_PI_NAND_SECURE_BOOT
am335x_guardian am335x_guardian am335x_evm j721e_evm_r5
ls1021atwr_sdcard_ifc_SECURE_BOOT ls1043ardb_nand_SECURE_BOOT
ls1043ardb_sdcard_SECURE_BOOT ls1046ardb_qspi_spl
ls1088ardb_sdcard_qspi_SECURE_BOOT T1042RDB_PI_NAND_SECURE_BOOT -sS

Summary of 25 commits for 13 boards (12 threads, 1 job per thread)
01: Merge https://gitlab.denx.de/u-boot/custodians/u-boot-spi
   aarch64:  w+   ls1043ardb_sdcard_SECURE_BOOT ls1046ardb_sdcard_SECURE_BOOT ls1088ardb_sdcard_qspi_SECURE_BOOT
       arm:  w+   am335x_guardian j721e_evm_r5 ls1021atwr_sdcard_ifc_SECURE_BOOT
   powerpc:  w+   T1042RDB_PI_NAND_SECURE_BOOT
02: env: mmc: allow support of mmc_get_env_dev with OF_CONTROL
       arm: (for 7/7 boards) all +4534.9 bss -4.6 data +4537.1 text +2.3
03: env: mmc: correct the offset returned by mmc_offset_try_partition
       arm: (for 7/7 boards) bss +1.1 text -1.1
04: env: mmc: add redundancy support in mmc_offset_try_partition
05: stm32mp1: board: add support of CONFIG_ENV_IS_IN_MMC
06: stm32mp1: use a specific SD/eMMC partition for U-Boot enviromnent
07: configs:stm32mp1: activate env config in SPL
   aarch64: (for 5/5 boards) all -1.8 rodata -1.8
       arm: (for 7/7 boards) all +0.9 bss +3.4 rodata -2.6
08: cmd: env: add option for quiet output on env info
   aarch64: (for 5/5 boards) all +1.8 rodata +1.8
       arm: (for 7/7 boards) all -0.9 bss -3.4 rodata +2.6
09: cmd: env: check real location for env info command
10: configs: sandbox: Enable sub command 'env info'
11: test: env: add test for env info sub-command
12: env: add absolute path at CONFIG_ENV_EXT4_FILE
13: env: ext4: set gd->env_valid
14: env: sf: avoid space in backend name
   aarch64: (for 5/5 boards) all -0.2 rodata -0.2
15: env: correctly handle env_load_prio
   aarch64: (for 5/5 boards) all -8.0 spl/u-boot-spl:all -1.6 spl/u-boot-spl:text -1.6 text -8.0
       arm: (for 7/7 boards) all -2.3 bss +3.4 spl/u-boot-spl:all -1.7 spl/u-boot-spl:text -1.7 text -5.7
16: env: nowhere: add .load ops
17: env: the ops driver load becomes mandatory in struct env_driver
18: cmd: env: add env load command
19: cmd: env: add env select command
20: configs: sandbox: activate env in ext4 support
21: configs: sandbox: activate command env select and env load
22: test: environment in ext4
23: env: ext4: introduce new function env_ext4_save_buffer
24: env: ext4: add support of command env erase
25: test: sandbox: add test for erase command
-------------------------------------------------

In this serie, I add sandbox test with CONFIG_ENV_IS_NOWHERE
activated with EXT4 location: load, save and erase.

To test this feature, I add 2 new commands to change the
ENV location:
- env select [target]
- env load

To be able to test invalid file (bad CRC), I also add the support of
the command "env erase" for EXT4 env location.

[1] http://patchwork.ozlabs.org/project/uboot/list/?series=185725
[2] http://patchwork.ozlabs.org/project/uboot/patch/20200625075958.9868-6-patrick.delaunay at st.com/

Regards

Patrick


Changes in v4:
- don't use env_import in SPL to avoid to increase its size
  as it is only required for 'env load' command

Changes in v3:
- new
- new
- new: add load ops in nowhere
- new: load operation becomes mandatory
- new: add 'env load' command
- new: add 'env select' command
- change env_get_location to avoid gd->env_load_prio modification
- replace specific sandbox command by generic command
  'env select' and 'env load'
- change title "sandbox: support the change of env location"
- replace specific sandbox command by generic command
  'env select' and 'env load'
- update after Stephen Warren comments
- replace sandbox command by generic command 'env load' in test_env

Changes in v2:
- change cmd_tbl_t to struct cmd_tbl
- use CONFIG_IS_ENABLED to set .erase (same as .save)

Patrick Delaunay (14):
  env: add absolute path at CONFIG_ENV_EXT4_FILE
  env: ext4: set gd->env_valid
  env: sf: avoid space in backend name
  env: correctly handle env_load_prio
  env: nowhere: add .load ops
  env: the ops driver load becomes mandatory in struct env_driver
  cmd: env: add env load command
  cmd: env: add env select command
  configs: sandbox: activate env in ext4 support
  configs: sandbox: activate command env select and env load
  test: environment in ext4
  env: ext4: introduce new function env_ext4_save_buffer
  env: ext4: add support of command env erase
  test: sandbox: add test for erase command

 board/sandbox/sandbox.c            |  15 ++++
 cmd/Kconfig                        |  11 +++
 cmd/nvedit.c                       |  29 ++++++++
 configs/sandbox64_defconfig        |   7 ++
 configs/sandbox_defconfig          |   7 ++
 configs/sandbox_flattree_defconfig |   7 ++
 configs/sandbox_spl_defconfig      |   7 ++
 env/Kconfig                        |   2 +-
 env/env.c                          |  80 ++++++++++++++++++--
 env/ext4.c                         |  54 ++++++++++++--
 env/nowhere.c                      |  17 +++++
 env/sf.c                           |   2 +-
 include/env.h                      |  15 +++-
 include/env_internal.h             |   3 +-
 test/py/tests/test_env.py          | 113 ++++++++++++++++++++++++++++-
 15 files changed, 349 insertions(+), 20 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 01/14] env: add absolute path at CONFIG_ENV_EXT4_FILE
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:40   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 02/14] env: ext4: set gd->env_valid Patrick Delaunay
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Add the absolute path to the default value of
CONFIG_ENV_EXT4_FILE = "/uboot.env".

This patch avoid the error :
  Saving Environment to EXT4... File System is consistent
  Please supply Absolute path

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

For information, it is the value used today by all the boards:

dragonboard820c_defconfig:29:CONFIG_ENV_EXT4_FILE="/uboot.env"
hikey960_defconfig:25:CONFIG_ENV_EXT4_FILE="/uboot.env"
stm32mp15_basic_defconfig:64:CONFIG_ENV_EXT4_FILE="/uboot.env"
stm32mp15_trusted_defconfig:50:CONFIG_ENV_EXT4_FILE="/uboot.env"


(no changes since v1)

 env/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/env/Kconfig b/env/Kconfig
index 5784136674..445e1ad341 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -473,7 +473,7 @@ config ENV_EXT4_DEVICE_AND_PART
 config ENV_EXT4_FILE
 	string "Name of the EXT4 file to use for the environment"
 	depends on ENV_IS_IN_EXT4
-	default "uboot.env"
+	default "/uboot.env"
 	help
 	  It's a string of the EXT4 file name. This file use to store the
 	  environment (explicit path to the file)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 02/14] env: ext4: set gd->env_valid
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
  2020-07-28  9:51 ` [PATCH v4 01/14] env: add absolute path at CONFIG_ENV_EXT4_FILE Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:40   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 03/14] env: sf: avoid space in backend name Patrick Delaunay
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Add a missing initialization of gd->env_valid in env_ext4_load
as it is already done in some other env device.

Set gd->env_valid = ENV_VALID in env_ext4_save() and env_ext4_load().

This patch allows to have a correct information in 'env info' command.

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

(no changes since v1)

 env/ext4.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/env/ext4.c b/env/ext4.c
index 8e90bb71b7..ac9f126bec 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -32,6 +32,8 @@
 #include <ext4fs.h>
 #include <mmc.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 __weak const char *env_ext4_get_intf(void)
 {
 	return (const char *)CONFIG_ENV_EXT4_INTERFACE;
@@ -79,6 +81,7 @@ static int env_ext4_save(void)
 			CONFIG_ENV_EXT4_FILE, ifname, dev, part);
 		return 1;
 	}
+	gd->env_valid = ENV_VALID;
 
 	puts("done\n");
 	return 0;
@@ -124,7 +127,11 @@ static int env_ext4_load(void)
 		goto err_env_relocate;
 	}
 
-	return env_import(buf, 1);
+	err = env_import(buf, 1);
+	if (!err)
+		gd->env_valid = ENV_VALID;
+
+	return err;
 
 err_env_relocate:
 	env_set_default(NULL, 0);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 03/14] env: sf: avoid space in backend name
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
  2020-07-28  9:51 ` [PATCH v4 01/14] env: add absolute path at CONFIG_ENV_EXT4_FILE Patrick Delaunay
  2020-07-28  9:51 ` [PATCH v4 02/14] env: ext4: set gd->env_valid Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:40   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 04/14] env: correctly handle env_load_prio Patrick Delaunay
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Remove space in ENV backend name for SPI Flash (SF)
to avoid issue with env select command.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

(no changes since v3)

Changes in v3:
- new

 env/sf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/env/sf.c b/env/sf.c
index 3e524f2947..a059561cb0 100644
--- a/env/sf.c
+++ b/env/sf.c
@@ -305,7 +305,7 @@ static int env_sf_init(void)
 
 U_BOOT_ENV_LOCATION(sf) = {
 	.location	= ENVL_SPI_FLASH,
-	ENV_NAME("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)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 04/14] env: correctly handle env_load_prio
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
                   ` (2 preceding siblings ...)
  2020-07-28  9:51 ` [PATCH v4 03/14] env: sf: avoid space in backend name Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:40   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 05/14] env: nowhere: add .load ops Patrick Delaunay
                   ` (9 subsequent siblings)
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Only update gd->env_load_prio in generic function env_load()
and no more in the weak function env_get_location() which is
called in many place (for example in env_driver_lookup, even
for ENVOP_SAVE operation).

This patch is a preliminary step to use env_driver_lookup()/
env_get_location() in new function env_select() without
updating gd->env_load_prio.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

(no changes since v3)

Changes in v3:
- new

 env/env.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/env/env.c b/env/env.c
index 2e64346438..bcc68c6bce 100644
--- a/env/env.c
+++ b/env/env.c
@@ -131,8 +131,6 @@ __weak enum env_location env_get_location(enum env_operation op, int prio)
 	if (prio >= ARRAY_SIZE(env_locations))
 		return ENVL_UNKNOWN;
 
-	gd->env_load_prio = prio;
-
 	return env_locations[prio];
 }
 
@@ -204,6 +202,8 @@ int env_load(void)
 		ret = drv->load();
 		if (!ret) {
 			printf("OK\n");
+			gd->env_load_prio = prio;
+
 			return 0;
 		} else if (ret == -ENOMSG) {
 			/* Handle "bad CRC" case */
@@ -227,7 +227,8 @@ int env_load(void)
 		debug("Selecting environment with bad CRC\n");
 	else
 		best_prio = 0;
-	env_get_location(ENVOP_LOAD, best_prio);
+
+	gd->env_load_prio = best_prio;
 
 	return -ENODEV;
 }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 05/14] env: nowhere: add .load ops
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
                   ` (3 preceding siblings ...)
  2020-07-28  9:51 ` [PATCH v4 04/14] env: correctly handle env_load_prio Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:41   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 06/14] env: the ops driver load becomes mandatory in struct env_driver Patrick Delaunay
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Add the ops .load for nowhere ENV backend to load the
default environment.

This ops is needed for the command 'env load'

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v4:
- don't use env_import in SPL to avoid to increase its size
  as it is only required for 'env load' command

Changes in v3:
- new: add load ops in nowhere

 env/nowhere.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/env/nowhere.c b/env/nowhere.c
index f5b0a17652..d33fdf27d0 100644
--- a/env/nowhere.c
+++ b/env/nowhere.c
@@ -27,8 +27,25 @@ static int env_nowhere_init(void)
 	return 0;
 }
 
+static int env_nowhere_load(void)
+{
+	/*
+	 * for SPL, set env_valid = ENV_INVALID is enougth as env_get_char()
+	 * return the default env if env_get is used
+	 * and SPL don't used env_import to reduce its size
+	 * For U-Boot proper, import the default environment to allow reload.
+	 */
+	if (!IS_ENABLED(CONFIG_SPL_BUILD))
+		env_set_default(NULL, 0);
+
+	gd->env_valid	= ENV_INVALID;
+
+	return 0;
+}
+
 U_BOOT_ENV_LOCATION(nowhere) = {
 	.location	= ENVL_NOWHERE,
 	.init		= env_nowhere_init,
+	.load		= env_nowhere_load,
 	ENV_NAME("nowhere")
 };
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 06/14] env: the ops driver load becomes mandatory in struct env_driver
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
                   ` (4 preceding siblings ...)
  2020-07-28  9:51 ` [PATCH v4 05/14] env: nowhere: add .load ops Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:41   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 07/14] cmd: env: add env load command Patrick Delaunay
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

The ops driver load becomes mandatory in struct env_drive,
change the comment for this ops and remove unnecessary test.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

(no changes since v3)

Changes in v3:
- new: load operation becomes mandatory

 env/env.c              | 3 ---
 include/env_internal.h | 3 +--
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/env/env.c b/env/env.c
index bcc68c6bce..5cf5bd238f 100644
--- a/env/env.c
+++ b/env/env.c
@@ -187,9 +187,6 @@ int env_load(void)
 	for (prio = 0; (drv = env_driver_lookup(ENVOP_LOAD, prio)); prio++) {
 		int ret;
 
-		if (!drv->load)
-			continue;
-
 		if (!env_has_inited(drv->location))
 			continue;
 
diff --git a/include/env_internal.h b/include/env_internal.h
index 66550434c3..795941daee 100644
--- a/include/env_internal.h
+++ b/include/env_internal.h
@@ -154,8 +154,7 @@ struct env_driver {
 	/**
 	 * load() - Load the environment from storage
 	 *
-	 * This method is optional. If not provided, no environment will be
-	 * loaded.
+	 * This method is required for loading environment
 	 *
 	 * @return 0 if OK, -ve on error
 	 */
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 07/14] cmd: env: add env load command
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
                   ` (5 preceding siblings ...)
  2020-07-28  9:51 ` [PATCH v4 06/14] env: the ops driver load becomes mandatory in struct env_driver Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:41   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 08/14] cmd: env: add env select command Patrick Delaunay
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

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

(no changes since v3)

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 e2b0a4fbc0..4aec6fe844 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -604,6 +604,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 acd9f82667..f730e2e754 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 5cf5bd238f..785a2b8552 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

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 08/14] cmd: env: add env select command
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
                   ` (6 preceding siblings ...)
  2020-07-28  9:51 ` [PATCH v4 07/14] cmd: env: add env load command Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:41   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 09/14] configs: sandbox: activate env in ext4 support Patrick Delaunay
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Add the new command 'env select' to force the persistent storage
of environment, saved in gd->env_load_prio.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

(no changes since v3)

Changes in v3:
- new: add 'env select' command

 cmd/Kconfig   |  5 +++++
 cmd/nvedit.c  | 15 +++++++++++++++
 env/env.c     | 42 ++++++++++++++++++++++++++++++++++++++++++
 include/env.h |  8 +++++++-
 4 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 4aec6fe844..5208687df4 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -610,6 +610,11 @@ config CMD_NVEDIT_LOAD
 	  Load all environment variables from the compiled-in persistent
 	  storage.
 
+config CMD_NVEDIT_SELECT
+	bool "env select"
+	help
+	  Select the compiled-in persistent storage of environment variables.
+
 endmenu
 
 menu "Memory commands"
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index f730e2e754..d188c6aa6b 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -802,6 +802,15 @@ static int do_env_load(struct cmd_tbl *cmdtp, int flag, int argc,
 	return env_reload() ? 1 : 0;
 }
 #endif
+
+#if defined(CONFIG_CMD_NVEDIT_SELECT)
+static int do_env_select(struct cmd_tbl *cmdtp, int flag, int argc,
+			 char *const argv[])
+{
+	return env_select(argv[1]) ? 1 : 0;
+}
+#endif
+
 #endif /* CONFIG_SPL_BUILD */
 
 int env_match(uchar *s1, int i2)
@@ -1367,6 +1376,9 @@ static struct cmd_tbl cmd_env_sub[] = {
 #if defined(CONFIG_CMD_ERASEENV)
 	U_BOOT_CMD_MKENT(erase, 1, 0, do_env_erase, "", ""),
 #endif
+#endif
+#if defined(CONFIG_CMD_NVEDIT_SELECT)
+	U_BOOT_CMD_MKENT(select, 2, 0, do_env_select, "", ""),
 #endif
 	U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
 #if defined(CONFIG_CMD_ENV_EXISTS)
@@ -1456,6 +1468,9 @@ static char env_help_text[] =
 #if defined(CONFIG_CMD_NVEDIT_LOAD)
 	"env load - load environment\n"
 #endif
+#if defined(CONFIG_CMD_NVEDIT_SELECT)
+	"env select [target] - select environment target\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 785a2b8552..2af2fae23c 100644
--- a/env/env.c
+++ b/env/env.c
@@ -344,3 +344,45 @@ int env_init(void)
 
 	return ret;
 }
+
+int env_select(const char *name)
+{
+	struct env_driver *drv;
+	const int n_ents = ll_entry_count(struct env_driver, env_driver);
+	struct env_driver *entry;
+	int prio;
+	bool found = false;
+
+	printf("Select Environment on %s: ", name);
+
+	/* search ENV driver by name */
+	drv = ll_entry_start(struct env_driver, env_driver);
+	for (entry = drv; entry != drv + n_ents; entry++) {
+		if (!strcmp(entry->name, name)) {
+			found = true;
+			break;
+		}
+	}
+
+	if (!found) {
+		printf("driver not found\n");
+		return -ENODEV;
+	}
+
+	/* search priority by driver */
+	for (prio = 0; (drv = env_driver_lookup(ENVOP_INIT, prio)); prio++) {
+		if (entry->location == env_get_location(ENVOP_LOAD, prio)) {
+			/* when priority change, reset the ENV flags */
+			if (gd->env_load_prio != prio) {
+				gd->env_load_prio = prio;
+				gd->env_valid = ENV_INVALID;
+				gd->flags &= ~GD_FLG_ENV_DEFAULT;
+			}
+			printf("OK\n");
+			return 0;
+		}
+	}
+	printf("priority not found\n");
+
+	return -ENODEV;
+}
diff --git a/include/env.h b/include/env.h
index 68e0f4fa56..665857f032 100644
--- a/include/env.h
+++ b/include/env.h
@@ -286,6 +286,13 @@ int env_save(void);
  */
 int env_erase(void);
 
+/**
+ * env_select() - Select the environment storage
+ *
+ * @return 0 if OK, -ve on error
+ */
+int env_select(const char *name);
+
 /**
  * env_import() - Import from a binary representation into hash table
  *
@@ -349,5 +356,4 @@ int env_get_char(int index);
  * This is used for those unfortunate archs with crappy toolchains
  */
 void env_reloc(void);
-
 #endif
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 09/14] configs: sandbox: activate env in ext4 support
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
                   ` (7 preceding siblings ...)
  2020-07-28  9:51 ` [PATCH v4 08/14] cmd: env: add env select command Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:41   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 10/14] configs: sandbox: activate command env select and env load Patrick Delaunay
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Activate ENV in EXT4 support in sandbox.

The sandbox behavior don't change; the default environment with
the nowhere backend (CONFIG_ENV_IS_NOWHERE)is still used:
the weak function env_get_location() return ENVL_NOWHERE for priority 0.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

(no changes since v3)

Changes in v3:
- change env_get_location to avoid gd->env_load_prio modification

 board/sandbox/sandbox.c            | 15 +++++++++++++++
 configs/sandbox64_defconfig        |  4 ++++
 configs/sandbox_defconfig          |  4 ++++
 configs/sandbox_flattree_defconfig |  4 ++++
 configs/sandbox_spl_defconfig      |  4 ++++
 5 files changed, 31 insertions(+)

diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index c1317a8ca3..937ce28411 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -7,6 +7,7 @@
 #include <cpu_func.h>
 #include <cros_ec.h>
 #include <dm.h>
+#include <env_internal.h>
 #include <init.h>
 #include <led.h>
 #include <os.h>
@@ -44,6 +45,20 @@ unsigned long timer_read_counter(void)
 }
 #endif
 
+/* specific order for sandbox: nowhere is the first value, used by default */
+static enum env_location env_locations[] = {
+	ENVL_NOWHERE,
+	ENVL_EXT4,
+};
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+	if (prio >= ARRAY_SIZE(env_locations))
+		return ENVL_UNKNOWN;
+
+	return env_locations[prio];
+}
+
 int dram_init(void)
 {
 	gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index 5794d1d159..66bf794f7f 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -83,6 +83,10 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_LIVE=y
 CONFIG_OF_HOSTFILE=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox64"
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="host"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
 CONFIG_NETCONSOLE=y
 CONFIG_IP_DEFRAG=y
 CONFIG_REGMAP=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 4110497841..a01711cbaf 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -93,6 +93,10 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_LIVE=y
 CONFIG_OF_HOSTFILE=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="host"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
 CONFIG_NETCONSOLE=y
 CONFIG_IP_DEFRAG=y
 CONFIG_REGMAP=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index bea27f68bb..eef7e182f1 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -66,6 +66,10 @@ CONFIG_AMIGA_PARTITION=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_HOSTFILE=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="host"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
 CONFIG_NETCONSOLE=y
 CONFIG_IP_DEFRAG=y
 CONFIG_REGMAP=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index ffb6a6f710..1c3d9a1eae 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -81,6 +81,10 @@ CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_HOSTFILE=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
 CONFIG_SPL_OF_PLATDATA=y
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="host"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
 CONFIG_NETCONSOLE=y
 CONFIG_IP_DEFRAG=y
 CONFIG_SPL_DM=y
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 10/14] configs: sandbox: activate command env select and env load
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
                   ` (8 preceding siblings ...)
  2020-07-28  9:51 ` [PATCH v4 09/14] configs: sandbox: activate env in ext4 support Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:41   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 11/14] test: environment in ext4 Patrick Delaunay
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Add support of environment location with the new env command:
'env select' and 'env load'

The ENV backend is selected by priority order
- 0 = "nowhere" (default at boot)
- 1 = "EXT4"

To test EXT4 env support, this backend is selected by name:
> env select EXT4

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

(no changes since v3)

Changes in v3:
- replace specific sandbox command by generic command
  'env select' and 'env load'
- change title "sandbox: support the change of env location"

Changes in v2:
- change cmd_tbl_t to struct cmd_tbl

 configs/sandbox64_defconfig        | 2 ++
 configs/sandbox_defconfig          | 2 ++
 configs/sandbox_flattree_defconfig | 2 ++
 configs/sandbox_spl_defconfig      | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index 66bf794f7f..d19c6dfba9 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -31,6 +31,8 @@ CONFIG_CMD_ENV_CALLBACK=y
 CONFIG_CMD_ENV_FLAGS=y
 CONFIG_CMD_NVEDIT_EFI=y
 CONFIG_CMD_NVEDIT_INFO=y
+CONFIG_CMD_NVEDIT_LOAD=y
+CONFIG_CMD_NVEDIT_SELECT=y
 CONFIG_LOOPW=y
 CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_MEMINFO=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index a01711cbaf..04efc9b50b 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -35,6 +35,8 @@ CONFIG_CMD_ENV_CALLBACK=y
 CONFIG_CMD_ENV_FLAGS=y
 CONFIG_CMD_NVEDIT_EFI=y
 CONFIG_CMD_NVEDIT_INFO=y
+CONFIG_CMD_NVEDIT_LOAD=y
+CONFIG_CMD_NVEDIT_SELECT=y
 CONFIG_LOOPW=y
 CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_MEMINFO=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index eef7e182f1..60d065b8c5 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -25,6 +25,8 @@ CONFIG_CMD_BOOTEFI_HELLO=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 CONFIG_CMD_NVEDIT_INFO=y
+CONFIG_CMD_NVEDIT_LOAD=y
+CONFIG_CMD_NVEDIT_SELECT=y
 CONFIG_LOOPW=y
 CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_MEMINFO=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 1c3d9a1eae..40605626e5 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -35,6 +35,8 @@ CONFIG_CMD_GREPENV=y
 CONFIG_CMD_ENV_CALLBACK=y
 CONFIG_CMD_ENV_FLAGS=y
 CONFIG_CMD_NVEDIT_INFO=y
+CONFIG_CMD_NVEDIT_LOAD=y
+CONFIG_CMD_NVEDIT_SELECT=y
 CONFIG_LOOPW=y
 CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_MEMINFO=y
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 11/14] test: environment in ext4
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
                   ` (9 preceding siblings ...)
  2020-07-28  9:51 ` [PATCH v4 10/14] configs: sandbox: activate command env select and env load Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:41   ` Tom Rini
  2020-08-03 15:43   ` Stephen Warren
  2020-07-28  9:51 ` [PATCH v4 12/14] env: ext4: introduce new function env_ext4_save_buffer Patrick Delaunay
                   ` (2 subsequent siblings)
  13 siblings, 2 replies; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Add basic test to persistent environment in ext4:
save and load in host ext4 file 'uboot.env'.

On first execution an empty EXT4 file system is created in
persistent data dir: env.ext4.img.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

(no changes since v3)

Changes in v3:
- replace specific sandbox command by generic command
  'env select' and 'env load'
- update after Stephen Warren comments

 test/py/tests/test_env.py | 97 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 96 insertions(+), 1 deletion(-)

diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index a64aaa9bc5..70913c8d9a 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -4,6 +4,10 @@
 
 # Test operation of shell commands relating to environment variables.
 
+import os
+import os.path
+from subprocess import call, check_call, CalledProcessError
+
 import pytest
 import u_boot_utils
 
@@ -374,7 +378,6 @@ def test_env_info(state_test_env):
 @pytest.mark.buildconfigspec('cmd_nvedit_info')
 @pytest.mark.buildconfigspec('cmd_echo')
 def test_env_info_sandbox(state_test_env):
-
     """Test 'env info' command result with several options on sandbox
        with a known ENV configuration: ready & default & persistent
     """
@@ -399,3 +402,95 @@ def test_env_info_sandbox(state_test_env):
     response = c.run_command('env info -d -p -q')
     response = c.run_command('echo $?')
     assert response == "1"
+
+def mk_env_ext4(state_test_env):
+
+    """Create a empty ext4 file system volume."""
+    c = state_test_env.u_boot_console
+    filename = 'env.ext4.img'
+    persistent = c.config.persistent_data_dir + '/' + filename
+    fs_img = c.config.result_dir  + '/' + filename
+
+    if os.path.exists(persistent):
+        c.log.action('Disk image file ' + persistent + ' already exists')
+    else:
+        try:
+            u_boot_utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent)
+            u_boot_utils.run_and_log(c, 'mkfs.ext4 -O ^metadata_csum %s' % persistent)
+        except CalledProcessError:
+            call('rm -f %s' % persistent, shell=True)
+            raise
+
+    u_boot_utils.run_and_log(c, ['cp',  '-f', persistent, fs_img])
+    return fs_img
+
+ at pytest.mark.boardspec('sandbox')
+ at pytest.mark.buildconfigspec('cmd_echo')
+ at pytest.mark.buildconfigspec('cmd_nvedit_info')
+ at pytest.mark.buildconfigspec('cmd_nvedit_load')
+ at pytest.mark.buildconfigspec('cmd_nvedit_select')
+ at pytest.mark.buildconfigspec('env_is_in_ext4')
+def test_env_ext4(state_test_env):
+
+    """Test ENV in EXT4 on sandbox."""
+    c = state_test_env.u_boot_console
+    fs_img = ''
+    try:
+        fs_img = mk_env_ext4(state_test_env)
+
+        c.run_command('host bind 0  %s' % fs_img)
+
+        response = c.run_command('ext4ls host 0:0')
+        assert 'uboot.env' not in response
+
+        # force env location: EXT4 (prio 1 in sandbox)
+        response = c.run_command('env select EXT4')
+        assert 'Select Environment on EXT4: OK' in response
+
+        response = c.run_command('env save')
+        assert 'Saving Environment to EXT4' in response
+
+        response = c.run_command('env load')
+        assert 'Loading Environment from EXT4... OK' in response
+
+        response = c.run_command('ext4ls host 0:0')
+        assert '8192 uboot.env' in response
+
+        response = c.run_command('env info')
+        assert 'env_valid = valid' in response
+        assert 'env_ready = true' in response
+        assert 'env_use_default = false' in response
+
+        response = c.run_command('env info -p -d')
+        assert 'Environment was loaded from persistent storage' in response
+        assert 'Environment can be persisted' in response
+
+        response = c.run_command('env info -d -q')
+        assert response == ""
+        response = c.run_command('echo $?')
+        assert response == "1"
+
+        response = c.run_command('env info -p -q')
+        assert response == ""
+        response = c.run_command('echo $?')
+        assert response == "0"
+
+        # restore env location: NOWHERE (prio 0 in sandbox)
+        response = c.run_command('env select nowhere')
+        assert 'Select Environment on nowhere: OK' in response
+
+        response = c.run_command('env load')
+        assert 'Loading Environment from nowhere... OK' in response
+
+        response = c.run_command('env info')
+        assert 'env_valid = invalid' in response
+        assert 'env_ready = true' in response
+        assert 'env_use_default = true' in response
+
+        response = c.run_command('env info -p -d')
+        assert 'Default environment is used' in response
+        assert 'Environment cannot be persisted' in response
+
+    finally:
+        if fs_img:
+            call('rm -f %s' % fs_img, shell=True)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 12/14] env: ext4: introduce new function env_ext4_save_buffer
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
                   ` (10 preceding siblings ...)
  2020-07-28  9:51 ` [PATCH v4 11/14] test: environment in ext4 Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:41   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 13/14] env: ext4: add support of command env erase Patrick Delaunay
  2020-07-28  9:51 ` [PATCH v4 14/14] test: sandbox: add test for erase command Patrick Delaunay
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Split the function env_ext4_save to prepare the erase support.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

(no changes since v1)

 env/ext4.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/env/ext4.c b/env/ext4.c
index ac9f126bec..0a10a5e050 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -44,9 +44,8 @@ __weak const char *env_ext4_get_dev_part(void)
 	return (const char *)CONFIG_ENV_EXT4_DEVICE_AND_PART;
 }
 
-static int env_ext4_save(void)
+static int env_ext4_save_buffer(env_t *env_new)
 {
-	env_t	env_new;
 	struct blk_desc *dev_desc = NULL;
 	struct disk_partition info;
 	int dev, part;
@@ -54,10 +53,6 @@ static int env_ext4_save(void)
 	const char *ifname = env_ext4_get_intf();
 	const char *dev_and_part = env_ext4_get_dev_part();
 
-	err = env_export(&env_new);
-	if (err)
-		return err;
-
 	part = blk_get_device_part_str(ifname, dev_and_part,
 				       &dev_desc, &info, 1);
 	if (part < 0)
@@ -72,7 +67,7 @@ static int env_ext4_save(void)
 		return 1;
 	}
 
-	err = ext4fs_write(CONFIG_ENV_EXT4_FILE, (void *)&env_new,
+	err = ext4fs_write(CONFIG_ENV_EXT4_FILE, (void *)env_new,
 			   sizeof(env_t), FILETYPE_REG);
 	ext4fs_close();
 
@@ -81,9 +76,26 @@ static int env_ext4_save(void)
 			CONFIG_ENV_EXT4_FILE, ifname, dev, part);
 		return 1;
 	}
-	gd->env_valid = ENV_VALID;
 
+	return 0;
+}
+
+static int env_ext4_save(void)
+{
+	env_t env_new;
+	int err;
+
+	err = env_export(&env_new);
+	if (err)
+		return err;
+
+	err = env_ext4_save_buffer(&env_new);
+	if (err)
+		return err;
+
+	gd->env_valid = ENV_VALID;
 	puts("done\n");
+
 	return 0;
 }
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 13/14] env: ext4: add support of command env erase
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
                   ` (11 preceding siblings ...)
  2020-07-28  9:51 ` [PATCH v4 12/14] env: ext4: introduce new function env_ext4_save_buffer Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:41   ` Tom Rini
  2020-07-28  9:51 ` [PATCH v4 14/14] test: sandbox: add test for erase command Patrick Delaunay
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Add support of opts erase for env in ext4,
this opts is used by command 'env erase'.

This command only fill the env file (CONFIG_ENV_EXT4_FILE)
with 0, the CRC and the saved environment becomes invalid.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

(no changes since v2)

Changes in v2:
- use CONFIG_IS_ENABLED to set .erase (same as .save)

 env/ext4.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/env/ext4.c b/env/ext4.c
index 0a10a5e050..cc36504154 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -99,6 +99,23 @@ static int env_ext4_save(void)
 	return 0;
 }
 
+static int env_ext4_erase(void)
+{
+	env_t env_new;
+	int err;
+
+	memset(&env_new, 0, sizeof(env_t));
+
+	err = env_ext4_save_buffer(&env_new);
+	if (err)
+		return err;
+
+	gd->env_valid = ENV_INVALID;
+	puts("done\n");
+
+	return 0;
+}
+
 static int env_ext4_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -156,4 +173,6 @@ U_BOOT_ENV_LOCATION(ext4) = {
 	ENV_NAME("EXT4")
 	.load		= env_ext4_load,
 	.save		= ENV_SAVE_PTR(env_ext4_save),
+	.erase		= CONFIG_IS_ENABLED(CMD_ERASEENV) ? env_ext4_erase :
+							    NULL,
 };
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 14/14] test: sandbox: add test for erase command
  2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
                   ` (12 preceding siblings ...)
  2020-07-28  9:51 ` [PATCH v4 13/14] env: ext4: add support of command env erase Patrick Delaunay
@ 2020-07-28  9:51 ` Patrick Delaunay
  2020-07-31 21:42   ` Tom Rini
  13 siblings, 1 reply; 33+ messages in thread
From: Patrick Delaunay @ 2020-07-28  9:51 UTC (permalink / raw)
  To: u-boot

Add test for the erase command tested on ENV in EXT4.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

---

(no changes since v3)

Changes in v3:
- replace sandbox command by generic command 'env load' in test_env

 configs/sandbox64_defconfig        |  1 +
 configs/sandbox_defconfig          |  1 +
 configs/sandbox_flattree_defconfig |  1 +
 configs/sandbox_spl_defconfig      |  1 +
 test/py/tests/test_env.py          | 16 ++++++++++++++++
 5 files changed, 20 insertions(+)

diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index d19c6dfba9..d4cef46e13 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -27,6 +27,7 @@ CONFIG_CMD_BOOTEFI_HELLO=y
 # CONFIG_CMD_ELF is not set
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_ERASEENV=y
 CONFIG_CMD_ENV_CALLBACK=y
 CONFIG_CMD_ENV_FLAGS=y
 CONFIG_CMD_NVEDIT_EFI=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 04efc9b50b..90aac2d69b 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -31,6 +31,7 @@ CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_ELF is not set
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_ERASEENV=y
 CONFIG_CMD_ENV_CALLBACK=y
 CONFIG_CMD_ENV_FLAGS=y
 CONFIG_CMD_NVEDIT_EFI=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index 60d065b8c5..195ce57d81 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -24,6 +24,7 @@ CONFIG_CMD_BOOTEFI_HELLO=y
 # CONFIG_CMD_ELF is not set
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_ERASEENV=y
 CONFIG_CMD_NVEDIT_INFO=y
 CONFIG_CMD_NVEDIT_LOAD=y
 CONFIG_CMD_NVEDIT_SELECT=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 40605626e5..fe7b182b89 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -32,6 +32,7 @@ CONFIG_CMD_BOOTEFI_HELLO=y
 # CONFIG_CMD_ELF is not set
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_ERASEENV=y
 CONFIG_CMD_ENV_CALLBACK=y
 CONFIG_CMD_ENV_FLAGS=y
 CONFIG_CMD_NVEDIT_INFO=y
diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index 70913c8d9a..86ec1b36d3 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -475,6 +475,22 @@ def test_env_ext4(state_test_env):
         response = c.run_command('echo $?')
         assert response == "0"
 
+        response = c.run_command('env erase')
+        assert 'OK' in response
+
+        response = c.run_command('env load')
+        assert 'Loading Environment from EXT4... ' in response
+        assert 'bad CRC, using default environment' in response
+
+        response = c.run_command('env info')
+        assert 'env_valid = invalid' in response
+        assert 'env_ready = true' in response
+        assert 'env_use_default = true' in response
+
+        response = c.run_command('env info -p -d')
+        assert 'Default environment is used' in response
+        assert 'Environment can be persisted' in response
+
         # restore env location: NOWHERE (prio 0 in sandbox)
         response = c.run_command('env select nowhere')
         assert 'Select Environment on nowhere: OK' in response
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v4 01/14] env: add absolute path at CONFIG_ENV_EXT4_FILE
  2020-07-28  9:51 ` [PATCH v4 01/14] env: add absolute path at CONFIG_ENV_EXT4_FILE Patrick Delaunay
@ 2020-07-31 21:40   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:40 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:14AM +0200, Patrick Delaunay wrote:

> Add the absolute path to the default value of
> CONFIG_ENV_EXT4_FILE = "/uboot.env".
> 
> This patch avoid the error :
>   Saving Environment to EXT4... File System is consistent
>   Please supply Absolute path
> 
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/3bb7bf7a/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 02/14] env: ext4: set gd->env_valid
  2020-07-28  9:51 ` [PATCH v4 02/14] env: ext4: set gd->env_valid Patrick Delaunay
@ 2020-07-31 21:40   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:40 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:15AM +0200, Patrick Delaunay wrote:

> Add a missing initialization of gd->env_valid in env_ext4_load
> as it is already done in some other env device.
> 
> Set gd->env_valid = ENV_VALID in env_ext4_save() and env_ext4_load().
> 
> This patch allows to have a correct information in 'env info' command.
> 
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/b6dfc186/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 03/14] env: sf: avoid space in backend name
  2020-07-28  9:51 ` [PATCH v4 03/14] env: sf: avoid space in backend name Patrick Delaunay
@ 2020-07-31 21:40   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:40 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:16AM +0200, Patrick Delaunay wrote:

> Remove space in ENV backend name for SPI Flash (SF)
> to avoid issue with env select command.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/d1626722/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 04/14] env: correctly handle env_load_prio
  2020-07-28  9:51 ` [PATCH v4 04/14] env: correctly handle env_load_prio Patrick Delaunay
@ 2020-07-31 21:40   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:40 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:17AM +0200, Patrick Delaunay wrote:

> Only update gd->env_load_prio in generic function env_load()
> and no more in the weak function env_get_location() which is
> called in many place (for example in env_driver_lookup, even
> for ENVOP_SAVE operation).
> 
> This patch is a preliminary step to use env_driver_lookup()/
> env_get_location() in new function env_select() without
> updating gd->env_load_prio.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/aa1b25c5/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 05/14] env: nowhere: add .load ops
  2020-07-28  9:51 ` [PATCH v4 05/14] env: nowhere: add .load ops Patrick Delaunay
@ 2020-07-31 21:41   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:41 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:18AM +0200, Patrick Delaunay wrote:

> Add the ops .load for nowhere ENV backend to load the
> default environment.
> 
> This ops is needed for the command 'env load'
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/d532b4d4/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 06/14] env: the ops driver load becomes mandatory in struct env_driver
  2020-07-28  9:51 ` [PATCH v4 06/14] env: the ops driver load becomes mandatory in struct env_driver Patrick Delaunay
@ 2020-07-31 21:41   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:41 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:19AM +0200, Patrick Delaunay wrote:

> The ops driver load becomes mandatory in struct env_drive,
> change the comment for this ops and remove unnecessary test.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/6f06791b/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 07/14] cmd: env: add env load command
  2020-07-28  9:51 ` [PATCH v4 07/14] cmd: env: add env load command Patrick Delaunay
@ 2020-07-31 21:41   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:41 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:20AM +0200, Patrick Delaunay wrote:

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

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/918f5de9/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 08/14] cmd: env: add env select command
  2020-07-28  9:51 ` [PATCH v4 08/14] cmd: env: add env select command Patrick Delaunay
@ 2020-07-31 21:41   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:41 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:21AM +0200, Patrick Delaunay wrote:

> Add the new command 'env select' to force the persistent storage
> of environment, saved in gd->env_load_prio.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/1620a06d/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 09/14] configs: sandbox: activate env in ext4 support
  2020-07-28  9:51 ` [PATCH v4 09/14] configs: sandbox: activate env in ext4 support Patrick Delaunay
@ 2020-07-31 21:41   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:41 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:22AM +0200, Patrick Delaunay wrote:

> Activate ENV in EXT4 support in sandbox.
> 
> The sandbox behavior don't change; the default environment with
> the nowhere backend (CONFIG_ENV_IS_NOWHERE)is still used:
> the weak function env_get_location() return ENVL_NOWHERE for priority 0.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/e59caf7c/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 10/14] configs: sandbox: activate command env select and env load
  2020-07-28  9:51 ` [PATCH v4 10/14] configs: sandbox: activate command env select and env load Patrick Delaunay
@ 2020-07-31 21:41   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:41 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:23AM +0200, Patrick Delaunay wrote:

> Add support of environment location with the new env command:
> 'env select' and 'env load'
> 
> The ENV backend is selected by priority order
> - 0 = "nowhere" (default at boot)
> - 1 = "EXT4"
> 
> To test EXT4 env support, this backend is selected by name:
> > env select EXT4
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/46a45561/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 11/14] test: environment in ext4
  2020-07-28  9:51 ` [PATCH v4 11/14] test: environment in ext4 Patrick Delaunay
@ 2020-07-31 21:41   ` Tom Rini
  2020-08-03 15:43   ` Stephen Warren
  1 sibling, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:41 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:24AM +0200, Patrick Delaunay wrote:

> Add basic test to persistent environment in ext4:
> save and load in host ext4 file 'uboot.env'.
> 
> On first execution an empty EXT4 file system is created in
> persistent data dir: env.ext4.img.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/73ea437d/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 12/14] env: ext4: introduce new function env_ext4_save_buffer
  2020-07-28  9:51 ` [PATCH v4 12/14] env: ext4: introduce new function env_ext4_save_buffer Patrick Delaunay
@ 2020-07-31 21:41   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:41 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:25AM +0200, Patrick Delaunay wrote:

> Split the function env_ext4_save to prepare the erase support.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/24fa2465/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 13/14] env: ext4: add support of command env erase
  2020-07-28  9:51 ` [PATCH v4 13/14] env: ext4: add support of command env erase Patrick Delaunay
@ 2020-07-31 21:41   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:41 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:26AM +0200, Patrick Delaunay wrote:

> Add support of opts erase for env in ext4,
> this opts is used by command 'env erase'.
> 
> This command only fill the env file (CONFIG_ENV_EXT4_FILE)
> with 0, the CRC and the saved environment becomes invalid.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/7facd073/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 14/14] test: sandbox: add test for erase command
  2020-07-28  9:51 ` [PATCH v4 14/14] test: sandbox: add test for erase command Patrick Delaunay
@ 2020-07-31 21:42   ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-07-31 21:42 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 28, 2020 at 11:51:27AM +0200, Patrick Delaunay wrote:

> Add test for the erase command tested on ENV in EXT4.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200731/b516ca0c/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 11/14] test: environment in ext4
  2020-07-28  9:51 ` [PATCH v4 11/14] test: environment in ext4 Patrick Delaunay
  2020-07-31 21:41   ` Tom Rini
@ 2020-08-03 15:43   ` Stephen Warren
  2020-08-03 15:51     ` Tom Rini
  1 sibling, 1 reply; 33+ messages in thread
From: Stephen Warren @ 2020-08-03 15:43 UTC (permalink / raw)
  To: u-boot

On 7/28/20 3:51 AM, Patrick Delaunay wrote:
> Add basic test to persistent environment in ext4:
> save and load in host ext4 file 'uboot.env'.
> 
> On first execution an empty EXT4 file system is created in
> persistent data dir: env.ext4.img.

> diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py

> +def mk_env_ext4(state_test_env):

> +            u_boot_utils.run_and_log(c, 'mkfs.ext4 -O ^metadata_csum %s' % persistent)

Is "-O ^metadata_csum" necessary? The mkfs.ext4 in Ubuntu 16.04 doesn't
support that option, which causes this command to fail.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 11/14] test: environment in ext4
  2020-08-03 15:43   ` Stephen Warren
@ 2020-08-03 15:51     ` Tom Rini
  2020-08-03 16:57       ` Stephen Warren
  0 siblings, 1 reply; 33+ messages in thread
From: Tom Rini @ 2020-08-03 15:51 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 03, 2020 at 09:43:18AM -0600, Stephen Warren wrote:
> On 7/28/20 3:51 AM, Patrick Delaunay wrote:
> > Add basic test to persistent environment in ext4:
> > save and load in host ext4 file 'uboot.env'.
> > 
> > On first execution an empty EXT4 file system is created in
> > persistent data dir: env.ext4.img.
> 
> > diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
> 
> > +def mk_env_ext4(state_test_env):
> 
> > +            u_boot_utils.run_and_log(c, 'mkfs.ext4 -O ^metadata_csum %s' % persistent)
> 
> Is "-O ^metadata_csum" necessary? The mkfs.ext4 in Ubuntu 16.04 doesn't
> support that option, which causes this command to fail.

Yes, it's required because we don't support that feature in our ext4
codebase and newer tools default to enabling that.  Supporting that flag
is on my wishlist of items.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200803/d77f7714/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 11/14] test: environment in ext4
  2020-08-03 15:51     ` Tom Rini
@ 2020-08-03 16:57       ` Stephen Warren
  2020-08-03 17:11         ` Tom Rini
  0 siblings, 1 reply; 33+ messages in thread
From: Stephen Warren @ 2020-08-03 16:57 UTC (permalink / raw)
  To: u-boot

On 8/3/20 9:51 AM, Tom Rini wrote:
> On Mon, Aug 03, 2020 at 09:43:18AM -0600, Stephen Warren wrote:
>> On 7/28/20 3:51 AM, Patrick Delaunay wrote:
>>> Add basic test to persistent environment in ext4:
>>> save and load in host ext4 file 'uboot.env'.
>>>
>>> On first execution an empty EXT4 file system is created in
>>> persistent data dir: env.ext4.img.
>>
>>> diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
>>
>>> +def mk_env_ext4(state_test_env):
>>
>>> +            u_boot_utils.run_and_log(c, 'mkfs.ext4 -O ^metadata_csum %s' % persistent)
>>
>> Is "-O ^metadata_csum" necessary? The mkfs.ext4 in Ubuntu 16.04 doesn't
>> support that option, which causes this command to fail.
> 
> Yes, it's required because we don't support that feature in our ext4
> codebase and newer tools default to enabling that.  Supporting that flag
> is on my wishlist of items.

Hmm. Is there a way to detect that, and only use the flag when necessary?

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v4 11/14] test: environment in ext4
  2020-08-03 16:57       ` Stephen Warren
@ 2020-08-03 17:11         ` Tom Rini
  0 siblings, 0 replies; 33+ messages in thread
From: Tom Rini @ 2020-08-03 17:11 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 03, 2020 at 10:57:21AM -0600, Stephen Warren wrote:
> On 8/3/20 9:51 AM, Tom Rini wrote:
> > On Mon, Aug 03, 2020 at 09:43:18AM -0600, Stephen Warren wrote:
> >> On 7/28/20 3:51 AM, Patrick Delaunay wrote:
> >>> Add basic test to persistent environment in ext4:
> >>> save and load in host ext4 file 'uboot.env'.
> >>>
> >>> On first execution an empty EXT4 file system is created in
> >>> persistent data dir: env.ext4.img.
> >>
> >>> diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
> >>
> >>> +def mk_env_ext4(state_test_env):
> >>
> >>> +            u_boot_utils.run_and_log(c, 'mkfs.ext4 -O ^metadata_csum %s' % persistent)
> >>
> >> Is "-O ^metadata_csum" necessary? The mkfs.ext4 in Ubuntu 16.04 doesn't
> >> support that option, which causes this command to fail.
> > 
> > Yes, it's required because we don't support that feature in our ext4
> > codebase and newer tools default to enabling that.  Supporting that flag
> > is on my wishlist of items.
> 
> Hmm. Is there a way to detect that, and only use the flag when necessary?

I'm not sure.  I mean, we could put the above in a try/except?

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200803/8f77b990/attachment.sig>

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2020-08-03 17:11 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28  9:51 [PATCH v4 00/14] env: ext4: corrections and add test for env in ext4 Patrick Delaunay
2020-07-28  9:51 ` [PATCH v4 01/14] env: add absolute path at CONFIG_ENV_EXT4_FILE Patrick Delaunay
2020-07-31 21:40   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 02/14] env: ext4: set gd->env_valid Patrick Delaunay
2020-07-31 21:40   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 03/14] env: sf: avoid space in backend name Patrick Delaunay
2020-07-31 21:40   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 04/14] env: correctly handle env_load_prio Patrick Delaunay
2020-07-31 21:40   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 05/14] env: nowhere: add .load ops Patrick Delaunay
2020-07-31 21:41   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 06/14] env: the ops driver load becomes mandatory in struct env_driver Patrick Delaunay
2020-07-31 21:41   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 07/14] cmd: env: add env load command Patrick Delaunay
2020-07-31 21:41   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 08/14] cmd: env: add env select command Patrick Delaunay
2020-07-31 21:41   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 09/14] configs: sandbox: activate env in ext4 support Patrick Delaunay
2020-07-31 21:41   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 10/14] configs: sandbox: activate command env select and env load Patrick Delaunay
2020-07-31 21:41   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 11/14] test: environment in ext4 Patrick Delaunay
2020-07-31 21:41   ` Tom Rini
2020-08-03 15:43   ` Stephen Warren
2020-08-03 15:51     ` Tom Rini
2020-08-03 16:57       ` Stephen Warren
2020-08-03 17:11         ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 12/14] env: ext4: introduce new function env_ext4_save_buffer Patrick Delaunay
2020-07-31 21:41   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 13/14] env: ext4: add support of command env erase Patrick Delaunay
2020-07-31 21:41   ` Tom Rini
2020-07-28  9:51 ` [PATCH v4 14/14] test: sandbox: add test for erase command Patrick Delaunay
2020-07-31 21:42   ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.