* [U-Boot] [PATCH v7 0/2] add command env erase
@ 2019-06-29 9:36 Frank Wunderlich
2019-06-29 9:36 ` [U-Boot] [PATCH v7 1/2] env: register erase command Frank Wunderlich
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Frank Wunderlich @ 2019-06-29 9:36 UTC (permalink / raw
To: u-boot
sometimes it is needed to erase the non-volatile environment
e.g. for boot-up with builtin-environment or after resizing env
this series add basic functionality for erasing environment from
storage as a first storage-driver mmc is introduced, other needs to be added
later
changes since v6:
- fix whitespace around errmsg
changes since v5:
- don't use the CMD_RET_ macros in erase_env
- remove mmc-checks (!mmc + mmc_getwp) and add init_mmc_for_env
changes since v4:
- rebased to 2019.07-rc4
- changed handling with CONFIG_ENV_OFFSET_REDUND (more similar to saveenv)
- quashed last 2 commits to get 2-parts patchset
Frank Wunderlich (2):
env: register erase command
env: mmc: add erase-function
cmd/Kconfig | 8 +++++++
cmd/nvedit.c | 20 +++++++++++++++++
env/env.c | 30 +++++++++++++++++++++++++
env/mmc.c | 51 +++++++++++++++++++++++++++++++++++++++++++
include/environment.h | 17 +++++++++++++++
5 files changed, 126 insertions(+)
--
2.17.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH v7 1/2] env: register erase command
2019-06-29 9:36 [U-Boot] [PATCH v7 0/2] add command env erase Frank Wunderlich
@ 2019-06-29 9:36 ` Frank Wunderlich
2019-07-09 19:26 ` Simon Goldschmidt
2019-07-18 23:57 ` Tom Rini
2019-06-29 9:36 ` [U-Boot] [PATCH v7 2/2] env: mmc: add erase-function Frank Wunderlich
2019-07-07 18:40 ` [U-Boot] [PATCH v7 0/2] add command env erase Frank Wunderlich
2 siblings, 2 replies; 11+ messages in thread
From: Frank Wunderlich @ 2019-06-29 9:36 UTC (permalink / raw
To: u-boot
this patch adds basic changes for adding a erase-subcommand to env
with this command the environment stored on non-volatile storage written
by saveenv can be cleared.
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
squashed fixes
- start message with "Erasing"
- mark erase-function as optional
- env: separate eraseenv from saveenv
Suggested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
---
cmd/Kconfig | 8 ++++++++
cmd/nvedit.c | 20 ++++++++++++++++++++
env/env.c | 30 ++++++++++++++++++++++++++++++
include/environment.h | 17 +++++++++++++++++
4 files changed, 75 insertions(+)
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 0badcb3fe0..77e8a542d9 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -408,6 +408,14 @@ config CMD_SAVEENV
Save all environment variables into the compiled-in persistent
storage.
+config CMD_ERASEENV
+ bool "eraseenv"
+ default n
+ depends on CMD_SAVEENV
+ help
+ Erase environment variables from the compiled-in persistent
+ storage.
+
config CMD_ENV_EXISTS
bool "env exists"
default y
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 52c242b4f6..63de758534 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -761,6 +761,20 @@ U_BOOT_CMD(
"save environment variables to persistent storage",
""
);
+
+#if defined(CONFIG_CMD_ERASEENV)
+static int do_env_erase(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ return env_erase() ? 1 : 0;
+}
+
+U_BOOT_CMD(
+ eraseenv, 1, 0, do_env_erase,
+ "erase environment variables from persistent storage",
+ ""
+);
+#endif
#endif
#endif /* CONFIG_SPL_BUILD */
@@ -1207,6 +1221,9 @@ static cmd_tbl_t cmd_env_sub[] = {
#endif
#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
+#if defined(CONFIG_CMD_ERASEENV)
+ U_BOOT_CMD_MKENT(erase, 1, 0, do_env_erase, "", ""),
+#endif
#endif
U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
#if defined(CONFIG_CMD_ENV_EXISTS)
@@ -1282,6 +1299,9 @@ static char env_help_text[] =
#endif
#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
"env save - save environment\n"
+#if defined(CONFIG_CMD_ERASEENV)
+ "env erase - erase environment\n"
+#endif
#endif
#if defined(CONFIG_CMD_NVEDIT_EFI)
"env set -e name [arg ...] - set UEFI variable; unset if 'arg' not specified\n"
diff --git a/env/env.c b/env/env.c
index 4b417b90a2..d3cbe2f915 100644
--- a/env/env.c
+++ b/env/env.c
@@ -24,6 +24,8 @@ void env_fix_drivers(void)
entry->load += gd->reloc_off;
if (entry->save)
entry->save += gd->reloc_off;
+ if (entry->erase)
+ entry->erase += gd->reloc_off;
if (entry->init)
entry->init += gd->reloc_off;
}
@@ -254,6 +256,34 @@ int env_save(void)
return -ENODEV;
}
+int env_erase(void)
+{
+ struct env_driver *drv;
+
+ drv = env_driver_lookup(ENVOP_ERASE, gd->env_load_prio);
+ if (drv) {
+ int ret;
+
+ if (!drv->erase)
+ return -ENODEV;
+
+ if (!env_has_inited(drv->location))
+ return -ENODEV;
+
+ printf("Erasing Environment on %s... ", drv->name);
+ ret = drv->erase();
+ if (ret)
+ printf("Failed (%d)\n", ret);
+ else
+ printf("OK\n");
+
+ if (!ret)
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
int env_init(void)
{
struct env_driver *drv;
diff --git a/include/environment.h b/include/environment.h
index cd96676141..de67cf4f0e 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -200,6 +200,7 @@ enum env_operation {
ENVOP_INIT, /* we want to call the init function */
ENVOP_LOAD, /* we want to call the load function */
ENVOP_SAVE, /* we want to call the save function */
+ ENVOP_ERASE, /* we want to call the erase function */
};
struct env_driver {
@@ -225,6 +226,15 @@ struct env_driver {
*/
int (*save)(void);
+ /**
+ * erase() - Erase the environment on storage
+ *
+ * This method is optional and required for 'eraseenv' to work.
+ *
+ * @return 0 if OK, -ve on error
+ */
+ int (*erase)(void);
+
/**
* init() - Set up the initial pre-relocation environment
*
@@ -303,6 +313,13 @@ int env_load(void);
*/
int env_save(void);
+/**
+ * env_erase() - Erase the environment on storage
+ *
+ * @return 0 if OK, -ve on error
+ */
+int env_erase(void);
+
/**
* env_fix_drivers() - Updates envdriver as per relocation
*/
--
2.17.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH v7 2/2] env: mmc: add erase-function
2019-06-29 9:36 [U-Boot] [PATCH v7 0/2] add command env erase Frank Wunderlich
2019-06-29 9:36 ` [U-Boot] [PATCH v7 1/2] env: register erase command Frank Wunderlich
@ 2019-06-29 9:36 ` Frank Wunderlich
2019-07-09 19:26 ` Simon Goldschmidt
2019-07-18 23:57 ` Tom Rini
2019-07-07 18:40 ` [U-Boot] [PATCH v7 0/2] add command env erase Frank Wunderlich
2 siblings, 2 replies; 11+ messages in thread
From: Frank Wunderlich @ 2019-06-29 9:36 UTC (permalink / raw
To: u-boot
this adds erase environment for mmc storage
squashed fixes:
- add CONFIG_CMD_ERASEENV
- env: erase redundant offset if defined
- changes mentioned by Simon
- fix whitespaces around errmsg
Suggested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
---
env/mmc.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/env/mmc.c b/env/mmc.c
index c3cf35d01b..b7b833f423 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -242,6 +242,54 @@ fini:
fini_mmc_for_env(mmc);
return ret;
}
+
+#if defined(CONFIG_CMD_ERASEENV)
+static inline int erase_env(struct mmc *mmc, unsigned long size,
+ unsigned long offset)
+{
+ uint blk_start, blk_cnt, n;
+ struct blk_desc *desc = mmc_get_blk_desc(mmc);
+
+ blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len;
+ blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
+
+ n = blk_derase(desc, blk_start, blk_cnt);
+ printf("%d blocks erased: %s\n", n, (n == blk_cnt) ? "OK" : "ERROR");
+
+ return (n == blk_cnt) ? 0 : 1;
+}
+
+static int env_mmc_erase(void)
+{
+ int dev = mmc_get_env_dev();
+ struct mmc *mmc = find_mmc_device(dev);
+ int ret, copy = 0;
+ u32 offset;
+ const char *errmsg;
+
+ errmsg = init_mmc_for_env(mmc);
+ if (errmsg) {
+ printf("%s\n", errmsg);
+ return 1;
+ }
+
+ if (mmc_get_env_addr(mmc, copy, &offset))
+ return CMD_RET_FAILURE;
+
+ ret = erase_env(mmc, CONFIG_ENV_SIZE, offset);
+
+#ifdef CONFIG_ENV_OFFSET_REDUND
+ copy = 1;
+
+ if (mmc_get_env_addr(mmc, copy, &offset))
+ return CMD_RET_FAILURE;
+
+ ret |= erase_env(mmc, CONFIG_ENV_SIZE, offset);
+#endif
+
+ return ret;
+}
+#endif /* CONFIG_CMD_ERASEENV */
#endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */
static inline int read_env(struct mmc *mmc, unsigned long size,
@@ -351,5 +399,8 @@ U_BOOT_ENV_LOCATION(mmc) = {
.load = env_mmc_load,
#ifndef CONFIG_SPL_BUILD
.save = env_save_ptr(env_mmc_save),
+#if defined(CONFIG_CMD_ERASEENV)
+ .erase = env_mmc_erase,
+#endif
#endif
};
--
2.17.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH v7 0/2] add command env erase
2019-06-29 9:36 [U-Boot] [PATCH v7 0/2] add command env erase Frank Wunderlich
2019-06-29 9:36 ` [U-Boot] [PATCH v7 1/2] env: register erase command Frank Wunderlich
2019-06-29 9:36 ` [U-Boot] [PATCH v7 2/2] env: mmc: add erase-function Frank Wunderlich
@ 2019-07-07 18:40 ` Frank Wunderlich
2019-07-09 19:23 ` Simon Goldschmidt
2 siblings, 1 reply; 11+ messages in thread
From: Frank Wunderlich @ 2019-07-07 18:40 UTC (permalink / raw
To: u-boot
any new opinions about last version? can it be merged to next u-boot version?
regards Frank
> Gesendet: Samstag, 29. Juni 2019 um 11:36 Uhr
> Von: "Frank Wunderlich" <frank-w@public-files.de>
> An: "Simon Goldschmidt" <simon.k.r.goldschmidt@gmail.com>, u-boot at lists.denx.de
> Cc: "Frank Wunderlich" <frank-w@public-files.de>
> Betreff: [PATCH v7 0/2] add command env erase
>
> sometimes it is needed to erase the non-volatile environment
> e.g. for boot-up with builtin-environment or after resizing env
>
> this series add basic functionality for erasing environment from
> storage as a first storage-driver mmc is introduced, other needs to be added
> later
>
> changes since v6:
> - fix whitespace around errmsg
>
> changes since v5:
> - don't use the CMD_RET_ macros in erase_env
> - remove mmc-checks (!mmc + mmc_getwp) and add init_mmc_for_env
>
> changes since v4:
> - rebased to 2019.07-rc4
> - changed handling with CONFIG_ENV_OFFSET_REDUND (more similar to saveenv)
> - quashed last 2 commits to get 2-parts patchset
>
> Frank Wunderlich (2):
> env: register erase command
> env: mmc: add erase-function
>
> cmd/Kconfig | 8 +++++++
> cmd/nvedit.c | 20 +++++++++++++++++
> env/env.c | 30 +++++++++++++++++++++++++
> env/mmc.c | 51 +++++++++++++++++++++++++++++++++++++++++++
> include/environment.h | 17 +++++++++++++++
> 5 files changed, 126 insertions(+)
>
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH v7 0/2] add command env erase
2019-07-07 18:40 ` [U-Boot] [PATCH v7 0/2] add command env erase Frank Wunderlich
@ 2019-07-09 19:23 ` Simon Goldschmidt
2019-07-09 19:48 ` Frank Wunderlich
0 siblings, 1 reply; 11+ messages in thread
From: Simon Goldschmidt @ 2019-07-09 19:23 UTC (permalink / raw
To: u-boot
Am 07.07.2019 um 20:40 schrieb Frank Wunderlich:
> any new opinions about last version? can it be merged to next u-boot version?
I remember having answered to v5, then you sent v6 and without further
responses sent v7. I fail to read from the patches what actually changed
between the versions. You have written a changelog in the cover letter,
please do so for the different patches as well.
Further, you have not integrated by Reviewed-by tag to 1/2 I sent for v5...
I'll no go and manually diff v6 and v6, and then reply sigh...
But even then, keep in mind I'm not the one mergin this!
Regards,
Simon
>
> regards Frank
>
>
>> Gesendet: Samstag, 29. Juni 2019 um 11:36 Uhr
>> Von: "Frank Wunderlich" <frank-w@public-files.de>
>> An: "Simon Goldschmidt" <simon.k.r.goldschmidt@gmail.com>, u-boot at lists.denx.de
>> Cc: "Frank Wunderlich" <frank-w@public-files.de>
>> Betreff: [PATCH v7 0/2] add command env erase
>>
>> sometimes it is needed to erase the non-volatile environment
>> e.g. for boot-up with builtin-environment or after resizing env
>>
>> this series add basic functionality for erasing environment from
>> storage as a first storage-driver mmc is introduced, other needs to be added
>> later
>>
>> changes since v6:
>> - fix whitespace around errmsg
>>
>> changes since v5:
>> - don't use the CMD_RET_ macros in erase_env
>> - remove mmc-checks (!mmc + mmc_getwp) and add init_mmc_for_env
>>
>> changes since v4:
>> - rebased to 2019.07-rc4
>> - changed handling with CONFIG_ENV_OFFSET_REDUND (more similar to saveenv)
>> - quashed last 2 commits to get 2-parts patchset
>>
>> Frank Wunderlich (2):
>> env: register erase command
>> env: mmc: add erase-function
>>
>> cmd/Kconfig | 8 +++++++
>> cmd/nvedit.c | 20 +++++++++++++++++
>> env/env.c | 30 +++++++++++++++++++++++++
>> env/mmc.c | 51 +++++++++++++++++++++++++++++++++++++++++++
>> include/environment.h | 17 +++++++++++++++
>> 5 files changed, 126 insertions(+)
>>
>> --
>> 2.17.1
>>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH v7 1/2] env: register erase command
2019-06-29 9:36 ` [U-Boot] [PATCH v7 1/2] env: register erase command Frank Wunderlich
@ 2019-07-09 19:26 ` Simon Goldschmidt
2019-07-18 23:57 ` Tom Rini
1 sibling, 0 replies; 11+ messages in thread
From: Simon Goldschmidt @ 2019-07-09 19:26 UTC (permalink / raw
To: u-boot
Am 29.06.2019 um 11:36 schrieb Frank Wunderlich:
> this patch adds basic changes for adding a erase-subcommand to env
>
> with this command the environment stored on non-volatile storage written
> by saveenv can be cleared.
>
> Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
>
> squashed fixes
> - start message with "Erasing"
> - mark erase-function as optional
> - env: separate eraseenv from saveenv
>
> Suggested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> =2D--
> cmd/Kconfig | 8 ++++++++
> cmd/nvedit.c | 20 ++++++++++++++++++++
> env/env.c | 30 ++++++++++++++++++++++++++++++
> include/environment.h | 17 +++++++++++++++++
> 4 files changed, 75 insertions(+)
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 0badcb3fe0..77e8a542d9 100644
> =2D-- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -408,6 +408,14 @@ config CMD_SAVEENV
> Save all environment variables into the compiled-in persistent
> storage.
>
> +config CMD_ERASEENV
> + bool "eraseenv"
> + default n
> + depends on CMD_SAVEENV
> + help
> + Erase environment variables from the compiled-in persistent
> + storage.
> +
> config CMD_ENV_EXISTS
> bool "env exists"
> default y
> diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> index 52c242b4f6..63de758534 100644
> =2D-- a/cmd/nvedit.c
> +++ b/cmd/nvedit.c
> @@ -761,6 +761,20 @@ U_BOOT_CMD(
> "save environment variables to persistent storage",
> ""
> );
> +
> +#if defined(CONFIG_CMD_ERASEENV)
> +static int do_env_erase(cmd_tbl_t *cmdtp, int flag, int argc,
> + char * const argv[])
> +{
> + return env_erase() ? 1 : 0;
> +}
> +
> +U_BOOT_CMD(
> + eraseenv, 1, 0, do_env_erase,
> + "erase environment variables from persistent storage",
> + ""
> +);
> +#endif
> #endif
> #endif /* CONFIG_SPL_BUILD */
>
> @@ -1207,6 +1221,9 @@ static cmd_tbl_t cmd_env_sub[] =3D {
> #endif
> #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
> U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
> +#if defined(CONFIG_CMD_ERASEENV)
> + U_BOOT_CMD_MKENT(erase, 1, 0, do_env_erase, "", ""),
> +#endif
> #endif
> U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
> #if defined(CONFIG_CMD_ENV_EXISTS)
> @@ -1282,6 +1299,9 @@ static char env_help_text[] =3D
> #endif
> #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
> "env save - save environment\n"
> +#if defined(CONFIG_CMD_ERASEENV)
> + "env erase - erase environment\n"
> +#endif
> #endif
> #if defined(CONFIG_CMD_NVEDIT_EFI)
> "env set -e name [arg ...] - set UEFI variable; unset if 'arg' not speci=
> fied\n"
> diff --git a/env/env.c b/env/env.c
> index 4b417b90a2..d3cbe2f915 100644
> =2D-- a/env/env.c
> +++ b/env/env.c
> @@ -24,6 +24,8 @@ void env_fix_drivers(void)
> entry->load +=3D gd->reloc_off;
> if (entry->save)
> entry->save +=3D gd->reloc_off;
> + if (entry->erase)
> + entry->erase +=3D gd->reloc_off;
> if (entry->init)
> entry->init +=3D gd->reloc_off;
> }
> @@ -254,6 +256,34 @@ int env_save(void)
> return -ENODEV;
> }
>
> +int env_erase(void)
> +{
> + struct env_driver *drv;
> +
> + drv =3D env_driver_lookup(ENVOP_ERASE, gd->env_load_prio);
> + if (drv) {
> + int ret;
> +
> + if (!drv->erase)
> + return -ENODEV;
> +
> + if (!env_has_inited(drv->location))
> + return -ENODEV;
> +
> + printf("Erasing Environment on %s... ", drv->name);
> + ret =3D drv->erase();
> + if (ret)
> + printf("Failed (%d)\n", ret);
> + else
> + printf("OK\n");
> +
> + if (!ret)
> + return 0;
> + }
> +
> + return -ENODEV;
> +}
> +
> int env_init(void)
> {
> struct env_driver *drv;
> diff --git a/include/environment.h b/include/environment.h
> index cd96676141..de67cf4f0e 100644
> =2D-- a/include/environment.h
> +++ b/include/environment.h
> @@ -200,6 +200,7 @@ enum env_operation {
> ENVOP_INIT, /* we want to call the init function */
> ENVOP_LOAD, /* we want to call the load function */
> ENVOP_SAVE, /* we want to call the save function */
> + ENVOP_ERASE, /* we want to call the erase function */
> };
>
> struct env_driver {
> @@ -225,6 +226,15 @@ struct env_driver {
> */
> int (*save)(void);
>
> + /**
> + * erase() - Erase the environment on storage
> + *
> + * This method is optional and required for 'eraseenv' to work.
> + *
> + * @return 0 if OK, -ve on error
> + */
> + int (*erase)(void);
> +
> /**
> * init() - Set up the initial pre-relocation environment
> *
> @@ -303,6 +313,13 @@ int env_load(void);
> */
> int env_save(void);
>
> +/**
> + * env_erase() - Erase the environment on storage
> + *
> + * @return 0 if OK, -ve on error
> + */
> +int env_erase(void);
> +
> /**
> * env_fix_drivers() - Updates envdriver as per relocation
> */
> =2D-
> 2.17.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH v7 2/2] env: mmc: add erase-function
2019-06-29 9:36 ` [U-Boot] [PATCH v7 2/2] env: mmc: add erase-function Frank Wunderlich
@ 2019-07-09 19:26 ` Simon Goldschmidt
2019-07-18 23:57 ` Tom Rini
1 sibling, 0 replies; 11+ messages in thread
From: Simon Goldschmidt @ 2019-07-09 19:26 UTC (permalink / raw
To: u-boot
Am 29.06.2019 um 11:36 schrieb Frank Wunderlich:
> this adds erase environment for mmc storage
>
> squashed fixes:
> - add CONFIG_CMD_ERASEENV
> - env: erase redundant offset if defined
> - changes mentioned by Simon
> - fix whitespaces around errmsg
>
> Suggested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> =2D--
> env/mmc.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
>
> diff --git a/env/mmc.c b/env/mmc.c
> index c3cf35d01b..b7b833f423 100644
> =2D-- a/env/mmc.c
> +++ b/env/mmc.c
> @@ -242,6 +242,54 @@ fini:
> fini_mmc_for_env(mmc);
> return ret;
> }
> +
> +#if defined(CONFIG_CMD_ERASEENV)
> +static inline int erase_env(struct mmc *mmc, unsigned long size,
> + unsigned long offset)
> +{
> + uint blk_start, blk_cnt, n;
> + struct blk_desc *desc =3D mmc_get_blk_desc(mmc);
> +
> + blk_start =3D ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len;
> + blk_cnt =3D ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
> +
> + n =3D blk_derase(desc, blk_start, blk_cnt);
> + printf("%d blocks erased: %s\n", n, (n =3D=3D blk_cnt) ? "OK" : "ERROR")=
> ;
> +
> + return (n =3D=3D blk_cnt) ? 0 : 1;
> +}
> +
> +static int env_mmc_erase(void)
> +{
> + int dev =3D mmc_get_env_dev();
> + struct mmc *mmc =3D find_mmc_device(dev);
> + int ret, copy =3D 0;
> + u32 offset;
> + const char *errmsg;
> +
> + errmsg =3D init_mmc_for_env(mmc);
> + if (errmsg) {
> + printf("%s\n", errmsg);
> + return 1;
> + }
> +
> + if (mmc_get_env_addr(mmc, copy, &offset))
> + return CMD_RET_FAILURE;
> +
> + ret =3D erase_env(mmc, CONFIG_ENV_SIZE, offset);
> +
> +#ifdef CONFIG_ENV_OFFSET_REDUND
> + copy =3D 1;
> +
> + if (mmc_get_env_addr(mmc, copy, &offset))
> + return CMD_RET_FAILURE;
> +
> + ret |=3D erase_env(mmc, CONFIG_ENV_SIZE, offset);
> +#endif
> +
> + return ret;
> +}
> +#endif /* CONFIG_CMD_ERASEENV */
> #endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */
>
> static inline int read_env(struct mmc *mmc, unsigned long size,
> @@ -351,5 +399,8 @@ U_BOOT_ENV_LOCATION(mmc) =3D {
> .load =3D env_mmc_load,
> #ifndef CONFIG_SPL_BUILD
> .save =3D env_save_ptr(env_mmc_save),
> +#if defined(CONFIG_CMD_ERASEENV)
> + .erase =3D env_mmc_erase,
> +#endif
> #endif
> };
> =2D-
> 2.17.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH v7 0/2] add command env erase
2019-07-09 19:23 ` Simon Goldschmidt
@ 2019-07-09 19:48 ` Frank Wunderlich
2019-07-09 19:52 ` Simon Goldschmidt
0 siblings, 1 reply; 11+ messages in thread
From: Frank Wunderlich @ 2019-07-09 19:48 UTC (permalink / raw
To: u-boot
Hi Simon
Am 9. Juli 2019 21:23:45 MESZ schrieb Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>:
>I remember having answered to v5, then you sent v6 and without further
>responses sent v7. I fail to read from the patches what actually
>changed
>between the versions. You have written a changelog in the cover letter,
>
>please do so for the different patches as well.
Only change between v6 and v7 is in 2/2 (mentioned in cover letter and 2/2 but there not as version history):
- fix whitespaces around errmsg
There are spaces instead of tabs i've seen after send v6. So i fixed that without waiting for responses.
V6 has changed to be closer to saveenv like you suggested.
>Further, you have not integrated by Reviewed-by tag to 1/2 I sent for
>v5...
Sorry i missed that,1/2 afair has not changed since v5
>I'll no go and manually diff v6 and v6, and then reply sigh...
>
>But even then, keep in mind I'm not the one mergin this!
Regards Frank
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH v7 0/2] add command env erase
2019-07-09 19:48 ` Frank Wunderlich
@ 2019-07-09 19:52 ` Simon Goldschmidt
0 siblings, 0 replies; 11+ messages in thread
From: Simon Goldschmidt @ 2019-07-09 19:52 UTC (permalink / raw
To: u-boot
Am 09.07.2019 um 21:48 schrieb Frank Wunderlich:
> Hi Simon
>
> Am 9. Juli 2019 21:23:45 MESZ schrieb Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>:
>> I remember having answered to v5, then you sent v6 and without further
>> responses sent v7. I fail to read from the patches what actually
>> changed
>> between the versions. You have written a changelog in the cover letter,
>>
>> please do so for the different patches as well.
>
> Only change between v6 and v7 is in 2/2 (mentioned in cover letter and 2/2 but there not as version history):
>
> - fix whitespaces around errmsg
That's not the point. The point is it should be in the patch so I can
jsut see it when finding the time to look at it.
I encourage you to rely on patman creating the cover letter and
changelog for you (see 'tools/patman/README').
>
> There are spaces instead of tabs i've seen after send v6. So i fixed that without waiting for responses.
That wouldn't have been a problem if the patches contained a changelog.
And for patches without changes from one version to the next, include
"-no changes" or something like that to let everyone know you did not
forget the changelog (or just use patman :)
>
> V6 has changed to be closer to saveenv like you suggested.
Yes, I've just sent by rb.
>
>> Further, you have not integrated by Reviewed-by tag to 1/2 I sent for
>> v5...
> Sorry i missed that,1/2 afair has not changed since v5
No problem, I keep forgetting that too, just wanted to let you know.
Regards,
Simon
>
>> I'll no go and manually diff v6 and v6, and then reply sigh...
>>
>> But even then, keep in mind I'm not the one mergin this!
>
> Regards Frank
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH v7 1/2] env: register erase command
2019-06-29 9:36 ` [U-Boot] [PATCH v7 1/2] env: register erase command Frank Wunderlich
2019-07-09 19:26 ` Simon Goldschmidt
@ 2019-07-18 23:57 ` Tom Rini
1 sibling, 0 replies; 11+ messages in thread
From: Tom Rini @ 2019-07-18 23:57 UTC (permalink / raw
To: u-boot
On Sat, Jun 29, 2019 at 11:36:19AM +0200, Frank Wunderlich wrote:
> this patch adds basic changes for adding a erase-subcommand to env
>
> with this command the environment stored on non-volatile storage written
> by saveenv can be cleared.
>
> Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
>
> squashed fixes
> - start message with "Erasing"
> - mark erase-function as optional
> - env: separate eraseenv from saveenv
>
> Suggested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190718/d60feab4/attachment.sig>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH v7 2/2] env: mmc: add erase-function
2019-06-29 9:36 ` [U-Boot] [PATCH v7 2/2] env: mmc: add erase-function Frank Wunderlich
2019-07-09 19:26 ` Simon Goldschmidt
@ 2019-07-18 23:57 ` Tom Rini
1 sibling, 0 replies; 11+ messages in thread
From: Tom Rini @ 2019-07-18 23:57 UTC (permalink / raw
To: u-boot
On Sat, Jun 29, 2019 at 11:36:20AM +0200, Frank Wunderlich wrote:
> this adds erase environment for mmc storage
>
> squashed fixes:
> - add CONFIG_CMD_ERASEENV
> - env: erase redundant offset if defined
> - changes mentioned by Simon
> - fix whitespaces around errmsg
>
> Suggested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190718/6d1c0a96/attachment.sig>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-07-18 23:57 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-29 9:36 [U-Boot] [PATCH v7 0/2] add command env erase Frank Wunderlich
2019-06-29 9:36 ` [U-Boot] [PATCH v7 1/2] env: register erase command Frank Wunderlich
2019-07-09 19:26 ` Simon Goldschmidt
2019-07-18 23:57 ` Tom Rini
2019-06-29 9:36 ` [U-Boot] [PATCH v7 2/2] env: mmc: add erase-function Frank Wunderlich
2019-07-09 19:26 ` Simon Goldschmidt
2019-07-18 23:57 ` Tom Rini
2019-07-07 18:40 ` [U-Boot] [PATCH v7 0/2] add command env erase Frank Wunderlich
2019-07-09 19:23 ` Simon Goldschmidt
2019-07-09 19:48 ` Frank Wunderlich
2019-07-09 19:52 ` Simon Goldschmidt
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.