[U-Boot] where *precisely* is u-boot's environment stored?

Robert P. J. Day rpjday at crashcourse.ca
Wed Jul 6 11:49:28 CEST 2016


  oh, wait, i think i just answered some of my questions based on this
snippet from common/env_nvram.c:

/*
 * Initialize Environment use
 *
 * We are still running from ROM, so data use is limited
 */
int env_init(void)
{
#if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE)
        ulong crc;
        uchar data[ENV_SIZE];

        nvram_read(&crc, CONFIG_ENV_ADDR, sizeof(ulong));
        nvram_read(data, CONFIG_ENV_ADDR + sizeof(ulong), ENV_SIZE);

        if (crc32(0, data, ENV_SIZE) == crc) {
                gd->env_addr    = (ulong)CONFIG_ENV_ADDR + sizeof(long);
#else
        if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
                gd->env_addr    = (ulong)&env_ptr->data;
#endif
                gd->env_valid   = 1;
        } else {
                gd->env_addr    = (ulong)&default_environment[0];
                gd->env_valid   = 0;
        }

        return 0;
}


  so if there is a valid environment at the address specified by the
board header file, it's used, otherwise fall back to
default_environment[]. i had suspected it was something like that, i
just hadn't found the code yet.

  is this written up somewhere?

rday

p.s. how does the default environment get to the CONFIG_ENV_ADDR
defined in the board header file? is that done automatically when
u-boot starts to run and notices that there is no valid environment
info at that address, and therefore copies it for you?

  i will keep reading the source.

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================



More information about the U-Boot mailing list