We are using u-boot to store some key environment variables that are needed (mainly the active partition/kernel to boot from). Changing this one variable alternates between each partition.
We are storing our u-boot environment in NAND, using a redundant environment, and have 4 flash blocks allocated for each environment.
We have a loop test which verifies operation of this feature repeatedly, and runs in a continuous loop. After several hundred successful operations (I got > 300 last night), the fw_setenv command fails without giving me an error code. I'm detecting it by issuing a fw_printenv after the command, and validating that the new environment is correct.
In fw_env.c, I've added the following line to get some additional information:
case FLAG_INCREMENTAL: if ((flag0 == 255 && flag1 == 0) || flag1 > flag0) dev_current = 1; else if ((flag1 == 255 && flag0 == 0) || flag0 > flag1) dev_current = 0; else /* flags are equal - almost impossible */ dev_current = 0; fprintf(stderr,"flag0=%d,flag1=%d,dev_current=%d\n",flag0,flag1,dev_current); break;
The last 5 updates look like this:
Jan 1 15:02:19 root: flag0=123,flag1=124,dev_current=1Jan 1 15:03:06 root: flag0=125,flag1=124,dev_current=0Jan 1 15:03:52 root: flag0=125,flag1=126,dev_current=1Jan 1 15:04:39 root: flag0=127,flag1=126,dev_current=0Jan 1 15:04:39 root: flag0=127,flag1=-128,dev_current=0Jan 1 15:05:26 root: flag0=127,flag1=-128,dev_current=0Jan 1 15:05:26 root: flag0=127,flag1=-128,dev_current=0
you probably want this:http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/95657