3
votes

I'm having problems trying to save environment variables in uBoot and have them persist across reboots, see trace below. This is with U-Boot 2009.08-00000-g19b0e8d-dirty (May 29 2012 - 16:09:40). Any ideas as to what could be wrong? Is the "Writing to Flash... Flash not Erased" message significant?

-> setenv ipaddr 10.1.10.28
-> saveenv
Saving Environment to Flash...
. done
Un-Protected 1 sectors
. done
Un-Protected 1 sectors
Erasing Flash...
. done
Erased 1 sectors
Writing to Flash... Flash not Erased
. done
Protected 1 sectors
. done
Protected 1 sectors
-> printenv
bootdelay=1
baudrate=115200
serverip=10.1.10.40
loadaddr=41000000
u-boot=q4/u-boot.bin
load=tftp ${loadaddr) ${u-boot}
upd=run load; run prog
bootargs=console=ttyMCF2,115200 panic=10
rootpath=/tftpboot/ltib
nfsargs=setenv bootargs ${bootargs} root=/dev/nfs rw nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off
nfs=run nfsargs; tftp q4/uImage-nfs; bootm
prog=prot off 0 3ffff;era 0 3ffff;cp.b ${loadaddr} 0 ${filesize};save
ext_wp_off=mw.b 10010020 e0 1
ethact=FEC0
ethaddr=3c:98:bf:00:00:14
eth1addr=3c:98:bf:00:00:15
nfsaddr=10.1.10.40
httpPort=81
hostname=
stdin=serial
stdout=serial
stderr=serial
mem=65024k
ipaddr=10.1.10.28

Environment size: 686/32763 bytes
-> reset


U-Boot 2009.08-00000-g19b0e8d-dirty (May 29 2012 - 16:09:40)
(c) 2012.

CPU:   Freescale MCF53013 (Mask:73 Version:1)
       CPU CLK 240 MHz BUS CLK 80 MHz
Board: RevB
I2C:   ready
DRAM:  64 MB
FLASH: 32 MB
In:    serial
Out:   serial
Err:   serial
Net:   FEC0, FEC1
-> printenv
bootdelay=1
baudrate=115200
serverip=10.1.10.40
loadaddr=41000000
u-boot=q4/u-boot.bin
load=tftp ${loadaddr) ${u-boot}
upd=run load; run prog
bootargs=console=ttyMCF2,115200 panic=10
rootpath=/tftpboot/ltib
nfsargs=setenv bootargs ${bootargs} root=/dev/nfs rw nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off
nfs=run nfsargs; tftp q4/uImage-nfs; bootm
prog=prot off 0 3ffff;era 0 3ffff;cp.b ${loadaddr} 0 ${filesize};save
ext_wp_off=mw.b 10010020 e0 1
ethact=FEC0
ethaddr=3c:98:bf:00:00:14
eth1addr=3c:98:bf:00:00:15
nfsaddr=10.1.10.40
httpPort=81
hostname=
stdin=serial
stdout=serial
stderr=serial
mem=65024k

Environment size: 668/32763 bytes
->

flinfo output is:

-> flinfo

Bank # 1: CFI conformant FLASH (16 x 16)  Size: 32 MB in 262 Sectors
  AMD Standard command set, Manufacturer ID: 0x01, Device ID: 0x227E
  Erase timeout: 8192 ms, write timeout: 1 ms
  Buffer write timeout: 5 ms, buffer size: 64 bytes

  Sector Start Addresses:
  00000000   RO   00008000   RO   00010000   RO   00018000   RO   00020000   RO 
  00040000        00060000        00080000        000A0000        000C0000      
  000E0000        00100000        00120000        00140000        00160000      
  00180000        001A0000        001C0000        001E0000        00200000      
  00220000        00240000        00260000        00280000        002A0000      
  002C0000        002E0000        00300000        00320000        00340000      
  00360000        00380000        003A0000        003C0000        003E0000      
  00400000        00420000        00440000        00460000        00480000      
  004A0000        004C0000        004E0000        00500000        00520000      
  00540000        00560000        00580000        005A0000        005C0000      
  005E0000        00600000        00620000        00640000        00660000      
  00680000        006A0000        006C0000        006E0000        00700000      
  00720000        00740000        00760000        00780000        007A0000      
  007C0000        007E0000        00800000        00820000        00840000      
  00860000        00880000        008A0000        008C0000        008E0000      
  00900000        00920000        00940000        00960000        00980000      
  009A0000        009C0000        009E0000        00A00000        00A20000      
  00A40000        00A60000        00A80000        00AA0000        00AC0000      
  00AE0000        00B00000        00B20000        00B40000        00B60000      
  00B80000        00BA0000        00BC0000        00BE0000        00C00000      
  00C20000        00C40000        00C60000        00C80000        00CA0000      
  00CC0000        00CE0000        00D00000        00D20000        00D40000      
  00D60000        00D80000        00DA0000        00DC0000        00DE0000      
  00E00000        00E20000        00E40000        00E60000        00E80000      
  00EA0000        00EC0000        00EE0000        00F00000        00F20000      
  00F40000        00F60000        00F80000        00FA0000        00FC0000      
  00FE0000        01000000        01020000        01040000        01060000      
  01080000        010A0000        010C0000        010E0000        01100000      
  01120000        01140000        01160000        01180000        011A0000      
  011C0000        011E0000        01200000        01220000        01240000      
  01260000        01280000        012A0000        012C0000        012E0000      
  01300000        01320000        01340000        01360000        01380000      
  013A0000        013C0000        013E0000        01400000        01420000      
  01440000        01460000        01480000        014A0000        014C0000      
  014E0000        01500000        01520000        01540000        01560000      
  01580000        015A0000        015C0000        015E0000        01600000      
  01620000        01640000        01660000        01680000        016A0000      
  016C0000        016E0000        01700000        01720000        01740000      
  01760000        01780000        017A0000        017C0000        017E0000      
  01800000        01820000        01840000        01860000        01880000      
  018A0000        018C0000        018E0000        01900000        01920000      
  01940000        01960000        01980000        019A0000        019C0000      
  019E0000        01A00000        01A20000        01A40000        01A60000      
  01A80000        01AA0000        01AC0000        01AE0000        01B00000      
  01B20000        01B40000        01B60000        01B80000        01BA0000      
  01BC0000        01BE0000        01C00000        01C20000        01C40000      
  01C60000        01C80000        01CA0000        01CC0000        01CE0000      
  01D00000        01D20000        01D40000        01D60000        01D80000      
  01DA0000        01DC0000        01DE0000        01E00000        01E20000      
  01E40000        01E60000        01E80000        01EA0000        01EC0000      
  01EE0000        01F00000        01F20000        01F40000        01F60000      
  01F80000        01FA0000        01FC0000        01FE0000   RO   01FE8000   RO 
  01FF0000        01FF8000
3
"Flash not Erased" - Yes this (error) message is significant, as it indicates that the write to flash has failed. Is this a pre-built version or custom-built version of U-Boot? What kind of flash memory does your board have, and is U-Boot configured to support it? What is the flash partition map?sawdust
Hey sawdust thanks for the message. This U-Boot is built from source (so not a pre-built one) and prob. has a few minor changes in it. The type of Flash used is definitely supported as this all used to work fine, this is the first failure I've seen. Let me know what command(s) to run to print the flash partition map and I'll include the results here.fred basset
Your U-Boot may have a regression. Looks like there are 2 sectors allocated to the env vars (i.e. 2 sectors are "unprotected" and later "protected" but only 1 sector is erased). Is the sector size 16KB? flinfo will display partition info. What kind of 32MB flash chip is on the board? If it's NAND, then instead of the "flash" routines, then "nand" routines should be used, e.g. nand info. Perhaps you need to re-config U-Boot with "debug" enabled, and re-build it.sawdust
I added the flinfo output, is that any help?fred basset
Not really. There is no list of partitions. The two sectors at 0x01fe0000 and 0x1fe8000 that are marked read-only look very suspicious, and are probably the clue to what is broken. Seems like your copy of U-Boot needs this patch: patchwork.ozlabs.org/patch/90591 If this used to work then, then you have to back track to find the cause of this regression.sawdust

3 Answers

1
votes

I had a similar issue after using "fw_setenv" to update my U-Boot environment.

What I found is that my U-Boot was unable to unlock the environment sector after fw_setenv locked it from Linux. Everything would look ok, but then the write would fail the same way yours did.

I was able to fix my problem by unlocking the env sector from Linux using flash_unlock.

1
votes

This occurs after using fw_setenv on occasion in Linux. If you can boot into your running Linux, the execute "mtd unlock /devX" where X is your partition in which your u-boot environment variables live, then boot back into u-boot. You should be able to execute a "Saveenv"

0
votes

I reflashed my Flash and can now save environment variables OK. Must have been some corruption?