Re: [U-Boot] [PATCH v4 2/4] env: mmc: add erase-function
Frank Wunderlich schrieb am Mo., 24. Juni 2019, 22:09: > You mean passing the offset (normal/redundant) instead of a bool? > Would you mind keeping the mail style of this list and stop top-responses please? I don't care where you make the difference between bool and actual offset, but you should keep all this as a changeset to env/mmc.c only to keep it consistent to existing redundant env code. Don't expose the bool to the env driver interface or the command file. Regards, Simon > Am 24. Juni 2019 21:40:36 MESZ schrieb Simon Goldschmidt < > simon.k.r.goldschm...@gmail.com>: > >Am 28.04.2019 um 10:51 schrieb Frank Wunderlich: > >> this adds erase environment for mmc storage > >> > >> Signed-off-by: Frank Wunderlich > > > >I think this is still too complex. > > > >I'd drop patches 3/4 and 4/4 and just erase both redundant storages > >here > >in env/mmc.c by calling the actual erase function twice. > > > >To do that, it would help to do as I suggested in response to v3: copy > >the 2-function style used by the save env code, then you can just call > >that 2nd function twice with a different offset (all in env/mmc.c). > > > >Regards, > >Simon > > > >> > >> squashed fixes: > >> - fix bogus indent > >> - add CONFIG_CMD_ERASEENV > >> > >> Suggested-by: Simon Goldschmidt > >> =2D-- > >> env/mmc.c | 31 +++ > >> 1 file changed, 31 insertions(+) > >> > >> diff --git a/env/mmc.c b/env/mmc.c > >> index c3cf35d01b..9ae9b1a66a 100644 > >> =2D-- a/env/mmc.c > >> +++ b/env/mmc.c > >> @@ -242,6 +242,34 @@ fini: > >> fini_mmc_for_env(mmc); > >> return ret; > >> } > >> + > >> +#if defined(CONFIG_CMD_ERASEENV) > >> +static int env_mmc_erase(void) > >> +{ > >> +int dev =3D mmc_get_env_dev(); > >> +struct mmc *mmc =3D find_mmc_device(dev); > >> +int n, blk, cnt; > >> + > >> +if (!mmc) > >> +return CMD_RET_FAILURE; > >> + > >> +blk =3D CONFIG_ENV_OFFSET / mmc->read_bl_len; > >> +cnt =3D CONFIG_ENV_SIZE / mmc->read_bl_len; > >> + > >> +printf("\nMMC erase env: dev # %d, block # %d (0x%x), count %d > >(0x%x)\n"= > >> , > >> + dev, blk, blk * mmc->read_bl_len, > >> + cnt, cnt * mmc->read_bl_len); > >> + > >> +if (mmc_getwp(mmc) =3D=3D 1) { > >> +printf("Error: card is write protected!\n"); > >> +return CMD_RET_FAILURE; > >> +} > >> +n =3D blk_derase(mmc_get_blk_desc(mmc), blk, cnt); > >> +printf("%d blocks erased: %s\n", n, (n =3D=3D cnt) ? "OK" : > >"ERROR"); > >> + > >> +return (n =3D=3D cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; > >> +} > >> +#endif /* CONFIG_CMD_ERASEENV */ > >> #endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */ > >> > >> static inline int read_env(struct mmc *mmc, unsigned long size, > >> @@ -351,5 +379,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 > >> > ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v4 2/4] env: mmc: add erase-function
You mean passing the offset (normal/redundant) instead of a bool? Am 24. Juni 2019 21:40:36 MESZ schrieb Simon Goldschmidt : >Am 28.04.2019 um 10:51 schrieb Frank Wunderlich: >> this adds erase environment for mmc storage >> >> Signed-off-by: Frank Wunderlich > >I think this is still too complex. > >I'd drop patches 3/4 and 4/4 and just erase both redundant storages >here >in env/mmc.c by calling the actual erase function twice. > >To do that, it would help to do as I suggested in response to v3: copy >the 2-function style used by the save env code, then you can just call >that 2nd function twice with a different offset (all in env/mmc.c). > >Regards, >Simon > >> >> squashed fixes: >> - fix bogus indent >> - add CONFIG_CMD_ERASEENV >> >> Suggested-by: Simon Goldschmidt >> =2D-- >> env/mmc.c | 31 +++ >> 1 file changed, 31 insertions(+) >> >> diff --git a/env/mmc.c b/env/mmc.c >> index c3cf35d01b..9ae9b1a66a 100644 >> =2D-- a/env/mmc.c >> +++ b/env/mmc.c >> @@ -242,6 +242,34 @@ fini: >> fini_mmc_for_env(mmc); >> return ret; >> } >> + >> +#if defined(CONFIG_CMD_ERASEENV) >> +static int env_mmc_erase(void) >> +{ >> +int dev =3D mmc_get_env_dev(); >> +struct mmc *mmc =3D find_mmc_device(dev); >> +int n, blk, cnt; >> + >> +if (!mmc) >> +return CMD_RET_FAILURE; >> + >> +blk =3D CONFIG_ENV_OFFSET / mmc->read_bl_len; >> +cnt =3D CONFIG_ENV_SIZE / mmc->read_bl_len; >> + >> +printf("\nMMC erase env: dev # %d, block # %d (0x%x), count %d >(0x%x)\n"= >> , >> + dev, blk, blk * mmc->read_bl_len, >> + cnt, cnt * mmc->read_bl_len); >> + >> +if (mmc_getwp(mmc) =3D=3D 1) { >> +printf("Error: card is write protected!\n"); >> +return CMD_RET_FAILURE; >> +} >> +n =3D blk_derase(mmc_get_blk_desc(mmc), blk, cnt); >> +printf("%d blocks erased: %s\n", n, (n =3D=3D cnt) ? "OK" : >"ERROR"); >> + >> +return (n =3D=3D cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; >> +} >> +#endif /* CONFIG_CMD_ERASEENV */ >> #endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */ >> >> static inline int read_env(struct mmc *mmc, unsigned long size, >> @@ -351,5 +379,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 >> ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v4 2/4] env: mmc: add erase-function
Am 28.04.2019 um 10:51 schrieb Frank Wunderlich: this adds erase environment for mmc storage Signed-off-by: Frank Wunderlich I think this is still too complex. I'd drop patches 3/4 and 4/4 and just erase both redundant storages here in env/mmc.c by calling the actual erase function twice. To do that, it would help to do as I suggested in response to v3: copy the 2-function style used by the save env code, then you can just call that 2nd function twice with a different offset (all in env/mmc.c). Regards, Simon squashed fixes: - fix bogus indent - add CONFIG_CMD_ERASEENV Suggested-by: Simon Goldschmidt =2D-- env/mmc.c | 31 +++ 1 file changed, 31 insertions(+) diff --git a/env/mmc.c b/env/mmc.c index c3cf35d01b..9ae9b1a66a 100644 =2D-- a/env/mmc.c +++ b/env/mmc.c @@ -242,6 +242,34 @@ fini: fini_mmc_for_env(mmc); return ret; } + +#if defined(CONFIG_CMD_ERASEENV) +static int env_mmc_erase(void) +{ + int dev =3D mmc_get_env_dev(); + struct mmc *mmc =3D find_mmc_device(dev); + int n, blk, cnt; + + if (!mmc) + return CMD_RET_FAILURE; + + blk =3D CONFIG_ENV_OFFSET / mmc->read_bl_len; + cnt =3D CONFIG_ENV_SIZE / mmc->read_bl_len; + + printf("\nMMC erase env: dev # %d, block # %d (0x%x), count %d (0x%x)\n"= , + dev, blk, blk * mmc->read_bl_len, + cnt, cnt * mmc->read_bl_len); + + if (mmc_getwp(mmc) =3D=3D 1) { + printf("Error: card is write protected!\n"); + return CMD_RET_FAILURE; + } + n =3D blk_derase(mmc_get_blk_desc(mmc), blk, cnt); + printf("%d blocks erased: %s\n", n, (n =3D=3D cnt) ? "OK" : "ERROR"); + + return (n =3D=3D cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; +} +#endif /* CONFIG_CMD_ERASEENV */ #endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */ static inline int read_env(struct mmc *mmc, unsigned long size, @@ -351,5 +379,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 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v4 2/4] env: mmc: add erase-function
this adds erase environment for mmc storage Signed-off-by: Frank Wunderlich squashed fixes: - fix bogus indent - add CONFIG_CMD_ERASEENV Suggested-by: Simon Goldschmidt --- env/mmc.c | 31 +++ 1 file changed, 31 insertions(+) diff --git a/env/mmc.c b/env/mmc.c index c3cf35d01b..9ae9b1a66a 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -242,6 +242,34 @@ fini: fini_mmc_for_env(mmc); return ret; } + +#if defined(CONFIG_CMD_ERASEENV) +static int env_mmc_erase(void) +{ + int dev = mmc_get_env_dev(); + struct mmc *mmc = find_mmc_device(dev); + int n, blk, cnt; + + if (!mmc) + return CMD_RET_FAILURE; + + blk = CONFIG_ENV_OFFSET / mmc->read_bl_len; + cnt = CONFIG_ENV_SIZE / mmc->read_bl_len; + + printf("\nMMC erase env: dev # %d, block # %d (0x%x), count %d (0x%x)\n", + dev, blk, blk * mmc->read_bl_len, + cnt, cnt * mmc->read_bl_len); + + if (mmc_getwp(mmc) == 1) { + printf("Error: card is write protected!\n"); + return CMD_RET_FAILURE; + } + n = blk_derase(mmc_get_blk_desc(mmc), blk, cnt); + printf("%d blocks erased: %s\n", n, (n == cnt) ? "OK" : "ERROR"); + + return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; +} +#endif /* CONFIG_CMD_ERASEENV */ #endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */ static inline int read_env(struct mmc *mmc, unsigned long size, @@ -351,5 +379,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 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot