diff options
author | Tom Rini <trini@konsulko.com> | 2018-07-02 05:10:33 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-07-02 05:10:33 +0300 |
commit | 168de20f3b6ccefef0ff5757fa5310f47a95c2f0 (patch) | |
tree | 5cebfe4064a7da19ebad8fbfee5eb6df1660c863 /tools/env | |
parent | 3fcb00be25b0a810c76dac4ed368a57b5c8e75b2 (diff) | |
download | u-boot-168de20f3b6ccefef0ff5757fa5310f47a95c2f0.tar.xz |
Revert "fw_printenv: Don't bail out directly after one env read error"
As pointed out by Wolfgang Denk, the problem with this fix is that while
interactive users will see that we have found one part of the
environment failed and are using the other, progmatic use will not see
this and can lead to problems.
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'tools/env')
-rw-r--r-- | tools/env/fw_env.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 3a5ad026f0..a5d75958e1 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -1427,21 +1427,14 @@ int fw_env_open(struct env_opts *opts) } dev_current = 0; - - if (!flash_io(O_RDONLY)) { - crc0 = crc32(0, (uint8_t *)environment.data, ENV_SIZE); - crc0_ok = (crc0 == *environment.crc); - } else if (have_redund_env) { - /* - * to give the redundant env a chance, maybe it's good: - * mark env crc0 invalid then test below if crc1 is ok - */ - crc0_ok = 0; - } else { + if (flash_io(O_RDONLY)) { ret = -EIO; goto open_cleanup; } + crc0 = crc32(0, (uint8_t *)environment.data, ENV_SIZE); + + crc0_ok = (crc0 == *environment.crc); if (!have_redund_env) { if (!crc0_ok) { fprintf(stderr, @@ -1469,10 +1462,8 @@ int fw_env_open(struct env_opts *opts) */ environment.image = addr1; if (flash_io(O_RDONLY)) { - crc1_ok = 0; - } else { - crc1 = crc32(0, (uint8_t *)redundant->data, ENV_SIZE); - crc1_ok = (crc1 == redundant->crc); + ret = -EIO; + goto open_cleanup; } /* Check flag scheme compatibility */ @@ -1498,6 +1489,9 @@ int fw_env_open(struct env_opts *opts) goto open_cleanup; } + crc1 = crc32(0, (uint8_t *)redundant->data, ENV_SIZE); + + crc1_ok = (crc1 == redundant->crc); flag1 = redundant->flags; if (crc0_ok && !crc1_ok) { |