[U-Boot] U-Boot 2010.12 Cannot Successfully Save Variables with Redundant NAND Environment

Grant Erickson gerickson at nuovations.com
Sun Feb 6 22:33:48 CET 2011


On 2/6/11 12:41 PM, Grant Erickson wrote:
> I recently updated my TI AM37x EVM from U-Boot 2010.09 to 2010.12 and noticed
> that, in doing so, saveenv / env save no longer seems to work. The following
> example demonstrates [ELIDED]:

I subsequently found the following patch and commit:

    http://www.mail-archive.com/u-boot@lists.denx.de/msg46834.html
    
http://git.denx.de/?p=u-boot.git;a=commitdiff;h=920a5dd2325438a82b6ac8102c5a
5e0c43276fd;hp=42d44f631c4e8e5359775bdc098f2fffde4e5c05

However, it's not clear how this patch can reasonably work outside of random
chance:

    // Allocate a new environment on the stack. The environment structure is
    // whatever random data is already on the stack.

    env_t    env_new;

    ...
    
    // At this point, the data field will be initialized; however, crc and
    // flags are still random data.

    res = (char *)&env_new.data;
    len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);

    // The crc field is now set.

    env_new.crc   = crc32(0, env_new.data, ENV_SIZE);

    // Preincrement random data.

    ++env_new.flags; /* increase the serial */

Unfortunately, preincrementing random data won't replicate the behavior of
2010.09, where the flags field was referenced through a global env_ptr such
that flag manipulation was handled (more) coherently as the environment was
read and written.

Best,

Grant




More information about the U-Boot mailing list