Commit b76a147b722565bde046f707a5cc92df8ea29738

Authored by Phil Sutter
Committed by Scott Wood
1 parent fcecb4a52c

env_nand.c: clarify log messages when env reading fails

The single message is misleading, since there is no equivalent success
note when reading the other copy succeeds. Instead, warn if one of the
redundant copies could not be loaded and emphasise on the error when
reading both fails.

Signed-off-by: Phil Sutter <phil.sutter@viprinet.com>

Showing 1 changed file with 8 additions and 4 deletions Side-by-side Diff

... ... @@ -331,6 +331,7 @@
331 331 void env_relocate_spec(void)
332 332 {
333 333 #if !defined(ENV_IS_EMBEDDED)
  334 + int read1_fail = 0, read2_fail = 0;
334 335 int crc1_ok = 0, crc2_ok = 0;
335 336 env_t *ep, *tmp_env1, *tmp_env2;
336 337  
337 338  
... ... @@ -342,11 +343,14 @@
342 343 goto done;
343 344 }
344 345  
345   - if (readenv(CONFIG_ENV_OFFSET, (u_char *) tmp_env1))
346   - puts("No Valid Environment Area found\n");
  346 + read1_fail = readenv(CONFIG_ENV_OFFSET, (u_char *) tmp_env1);
  347 + read2_fail = readenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) tmp_env2);
347 348  
348   - if (readenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) tmp_env2))
349   - puts("No Valid Redundant Environment Area found\n");
  349 + if (read1_fail && read2_fail)
  350 + puts("*** Error - No Valid Environment Area found\n");
  351 + else if (read1_fail || read2_fail)
  352 + puts("*** Warning - some problems detected "
  353 + "reading environment; recovered successfully\n");
350 354  
351 355 crc1_ok = crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc;
352 356 crc2_ok = crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc;