]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
Merge branch 'master' of git://git.denx.de/u-boot-ubi
authorTom Rini <trini@konsulko.com>
Mon, 13 Jun 2016 12:51:21 +0000 (08:51 -0400)
committerTom Rini <trini@konsulko.com>
Mon, 13 Jun 2016 12:51:21 +0000 (08:51 -0400)
common/env_ubi.c

index e611199a58d6d30a69e72dc5c95fa39e9577dff8..0ac2f65f0b24be57a7b2c123d3ef7a1faa8f0c6e 100644 (file)
@@ -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);