summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2016-06-13 08:51:21 -0400
committerTom Rini <trini@konsulko.com>2016-06-13 08:51:21 -0400
commitf4abfed1de34e3fa18be4a8a156416cd6ed21f4a (patch)
treef65c099f92ff6fe56989ac2773504cb2a4f497fd
parentfd9102dafea5c6959401d0dbc5293a56d2261878 (diff)
parentc1f51e0f3edca57273ff524714b69345ce627996 (diff)
downloadu-boot-imx-f4abfed1de34e3fa18be4a8a156416cd6ed21f4a.zip
u-boot-imx-f4abfed1de34e3fa18be4a8a156416cd6ed21f4a.tar.gz
u-boot-imx-f4abfed1de34e3fa18be4a8a156416cd6ed21f4a.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-ubi
-rw-r--r--common/env_ubi.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/common/env_ubi.c b/common/env_ubi.c
index e611199..0ac2f65 100644
--- a/common/env_ubi.c
+++ b/common/env_ubi.c
@@ -115,6 +115,17 @@ void env_relocate_spec(void)
int crc1_ok = 0, crc2_ok = 0;
env_t *ep, *tmp_env1, *tmp_env2;
+ /*
+ * In case we have restarted u-boot there is a chance that buffer
+ * contains old environment (from the previous boot).
+ * If UBI volume is zero size, ubi_volume_read() doesn't modify the
+ * buffer.
+ * We need to clear buffer manually here, so the invalid CRC will
+ * cause setting default environment as expected.
+ */
+ memset(env1_buf, 0x0, CONFIG_ENV_SIZE);
+ memset(env2_buf, 0x0, CONFIG_ENV_SIZE);
+
tmp_env1 = (env_t *)env1_buf;
tmp_env2 = (env_t *)env2_buf;
@@ -174,6 +185,16 @@ void env_relocate_spec(void)
{
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
+ /*
+ * In case we have restarted u-boot there is a chance that buffer
+ * contains old environment (from the previous boot).
+ * If UBI volume is zero size, ubi_volume_read() doesn't modify the
+ * buffer.
+ * We need to clear buffer manually here, so the invalid CRC will
+ * cause setting default environment as expected.
+ */
+ memset(buf, 0x0, CONFIG_ENV_SIZE);
+
if (ubi_part(CONFIG_ENV_UBI_PART, NULL)) {
printf("\n** Cannot find mtd partition \"%s\"\n",
CONFIG_ENV_UBI_PART);