[U-Boot] when does default env get written to flash on a new system?

i'm sure i'll figure this out if i keep reading the code, but if i have a new board where the env will be stored in flash, and i flash a fresh build of u-boot with a default environment, at what point will that default environment be written to persistent storage (as defined by CONFIG_ENV_ADDR)?
is this done automatically at some point when u-boot runs for the first time? or does it require me to, at some point, do an "env save"? thanks.
rday

On Thu, 1 Sep 2016, Robert P. J. Day wrote:
i'm sure i'll figure this out if i keep reading the code, but if i have a new board where the env will be stored in flash, and i flash a fresh build of u-boot with a default environment, at what point will that default environment be written to persistent storage (as defined by CONFIG_ENV_ADDR)?
is this done automatically at some point when u-boot runs for the first time? or does it require me to, at some point, do an "env save"? thanks.
just to follow up on my own question, i can see the first part of what i'm after, in that common/board_f.c will, early on, invoke:
env_init, /* initialize environment */
where that routine is:
int env_init(void) { if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) { gd->env_addr = (ulong)&(env_ptr->data); gd->env_valid = 1; return 0; }
gd->env_addr = (ulong)&default_environment[0]; gd->env_valid = 0; return 0; }
so assuming there is no valid env in flash, i'll now have the global data structure referring to the default environment, and indicating there is no valid environment in persistent storage. so far, so good, now i'm just tracing along, looking for the next step ...
rday
participants (1)
-
Robert P. J. Day