This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

uboot 2010.03 doesn't use ECC to protect environment

Other Parts Discussed in Thread: OMAP3503

Running an Omap3503 uboot gives me "bad CRC" error while booting, although there is just one bit toggled. There should be ECC running to prevent this.

I have configured the hole system running SW-ECC (which seems to work). I never ever had a failure (for instance while unpacking the kernel), but several CRC problems in environment. So for some reasons, this is not protected! How can this be fixed? This is a serious problem here.

best regards
Arno

  • I found the reason for this "Bad NAND, wrong CRC" message.

    I assumed that ECC correction is not working, but this was not the reason. Correction works, but the return value of nand_read() is not "0" in case, errors have been corrected.

    env_relocate_spec() calls readenv(), which returns with 1 (instead of 0). Then use_default() is called, instead of using the corrected environment.

    My soution/patch is the following: env_nand.c - readenv()

        while (amount_loaded < CONFIG_ENV_SIZE && offset < end) {
            if (nand_block_isbad(&nand_info[0], offset)) {
                offset += blocksize;
            } else {
                char_ptr = &buf[amount_loaded];
     -           if (nand_read(&nand_info[0], offset, &len, char_ptr))
     +          err = nand_read(&nand_info[0], offset, &len, char_ptr);
     +          if ( err && (err != -EUCLEAN) ) {
     +                   return 1;     // EUCLEAN is not an Error, shows that bits have been corrected bits
      -                  return 1;
                offset += blocksize;
                amount_loaded += len;
            }
        }
        if (amount_loaded != CONFIG_ENV_SIZE)
            return 1;

        return 0;
    }

     

    Also

    + #include <linux/err.h>                // to check for EUCLEAN error from nand_read()

     

    Would be nice is someone could confirm this. Here it works.

  • Can you please note which PSP version you're using?  Thanks.

  • Now I am using the latest TI uboot (2010.06). It is based onhttp://arago-project.org/git/projects/?p=u-boot-omap3.git;a=commit;h=ae5aaebb687e4810ed1ea6961cbbd0fbd31f2c35and has some patches TI releases in Juli with PSP 4.02.00.07.

    diff -rupN u-boot/common/env_nand.c u-boot_patched/common/env_nand.c
    --- u-boot/common/env_nand.c    2011-04-08 22:30:40.000000000 +0200
    +++ u-boot_patched/common/env_nand.c    2011-10-25 13:48:52.000000000 +0200
    @@ -34,6 +34,7 @@
     
     #include <common.h>
     #include <command.h>
    +#include <linux/err.h>                //  to check for EUCLEAN error from nand_read()
     #include <environment.h>
     #include <linux/stddef.h>
     #include <malloc.h>
    @@ -265,7 +266,7 @@ int readenv (size_t offset, u_char * buf
         size_t end = offset + CONFIG_ENV_RANGE;
         size_t amount_loaded = 0;
         size_t blocksize, len;
    -
    +    int err;
         u_char *char_ptr;
     
         /* fail if no nand detected */
    @@ -282,8 +283,9 @@ int readenv (size_t offset, u_char * buf
                 offset += blocksize;
             } else {
                 char_ptr = &buf[amount_loaded];
    -            if (nand_read(&nand_info[0], offset, &len, char_ptr))
    -                return 1;
    +            err = nand_read(&nand_info[0], offset, &len, char_ptr);
    +            if ( err && (err != -EUCLEAN) )
    +                    return 1;     // EUCLEAN is not an Error, shows that bits have been corrected bits
                 offset += blocksize;
                 amount_loaded += len;
             }

    ----------------------

    What is strange to me: Looking at this it seems that all uboots (not just OMAPs) have a problem with Error correction in uboot environment.

    Best regards

    Arno

  • Arno Steffens said:

    What is strange to me: Looking at this it seems that all uboots (not just OMAPs) have a problem with Error correction in uboot environment.

    This appears to be a problem that the community has fixed in later versions, based on what Scott Wood has said to you on the U-Boot ML.