2011-03-16 10:05:46     Unable to update u-boot using fw_setenv after extended testing

Document created by Aaronwu Employee on Aug 26, 2013
Version 1Show Document
  • View in full screen mode

2011-03-16 10:05:46     Unable to update u-boot using fw_setenv after extended testing

Reggy Perrin (UNITED STATES)

Message: 98968   

 

Hi folks,

 

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=1

Jan  1 15:03:06 root: flag0=125,flag1=124,dev_current=0

Jan  1 15:03:52 root: flag0=125,flag1=126,dev_current=1

Jan  1 15:04:39 root: flag0=127,flag1=126,dev_current=0

Jan  1 15:04:39 root: flag0=127,flag1=-128,dev_current=0

Jan  1 15:05:26 root: flag0=127,flag1=-128,dev_current=0

Jan  1 15:05:26 root: flag0=127,flag1=-128,dev_current=0

 

Is this a sign issue?  Instead of "char flag0" should these be "unsigned char flag0"?

 

Thanks

 

RP

QuoteReplyEditDelete

 

 

2011-03-16 11:08:20     Re: Unable to update u-boot using fw_setenv after extended testing

Mike Frysinger (UNITED STATES)

Message: 98969   

 

you probably want this:

  thread.gmane.org/gmane.comp.boot-loaders.u-boot/95657

QuoteReplyEditDelete

 

 

2011-03-16 11:36:52     Re: Unable to update u-boot using fw_setenv after extended testing

Reggy Perrin (UNITED STATES)

Message: 98970   

 

Yep, totally.

 

Just changing to unsigned char fixed my problem, but I will incorporate those changes to.

 

Do I need to enter a tracker to get this into the distro?  The current fw_env.c will only support updating the environment 254 times.

QuoteReplyEditDelete

 

 

2011-03-16 14:18:58     Re: Unable to update u-boot using fw_setenv after extended testing

Mike Frysinger (UNITED STATES)

Message: 98973   

 

upstream will eventually merge and we'll eventually upgrade to upstream, so no need to file a tracker item

Attachments

    Outcomes