Page 1 of 2

Accessing u-boot variables from linux

Posted: 20 Nov 2010, 20:03
by madx
I'm trying to access the u-boot variables of my B3 from linux with fw_printenv
(http://www.denx.de/wiki/DULG/HowCanIAcc ... lesInLinux)
But it needs /etc/fw_env.config to be configured with the correct values for the board ... which I couldn't find anywhere.

I tried to guess them from

Code: Select all

# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 000c0000 00010000 "u-boot"
mtd1: 00020000 00010000 "env"
mtd2: 00120000 00010000 "data"
But I always get

Code: Select all

# fw_printenv
Warning: Bad CRC, using default environment
...
Note: I can see the variables if I read /dev/mtd1 directly

Supposedly the values are available from the u-boot command line but I would need to solder a rs232 cable, which I would really like to avoid.

So, would it be possible to have the values and/or the fw_env.config of the B3 ?

Re: Accessing u-boot variables from linux

Posted: 23 Nov 2010, 07:49
by tor
Hi,

You could try this one. I used it briefly while working with this a while ago. No guarantees of any kind of course :)

/Tor

Re: Accessing u-boot variables from linux

Posted: 09 Nov 2011, 14:57
by MouettE
Does anyone know how to get this to work on the bubba two ? I just managed to make my bubba boot on a raid-1 device, and I would like to write an howto about it ; However it requires a change in the u-boot environment, and it would be nice to avoid the serial cable prerequisite :wink: .

So far I installed the uboot-envtools with apt-get and tried to tune the fw_env.config file, with no success (bad CRC error).

Re: Accessing u-boot variables from linux

Posted: 10 Nov 2011, 11:07
by johannes
Oh, nice work! I will try to dig out some information on this and get back.

Re: Accessing u-boot variables from linux

Posted: 11 Nov 2011, 03:21
by johannes
Not sure if this is what you need, but on B2 there is only one flash partition (mtd0). In there, the environment begins at 0x50000. Sector size and env size should be the same.

Re: Accessing u-boot variables from linux

Posted: 11 Nov 2011, 09:19
by MouettE
I did notice the 0x50000 area in the flash content and tried to write the fw_env.config this way :

Code: Select all

# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
/dev/mtd0               0x050000        0x010000        0x010000
However it doesn't work. I think that either the configuration is incorrect or the setenv tool needs to be modified...

Re: Accessing u-boot variables from linux

Posted: 11 Nov 2011, 09:36
by johannes
So you get bad crc with this config file as well?

Re: Accessing u-boot variables from linux

Posted: 11 Nov 2011, 10:20
by MouettE
Yes I did indeed :

Code: Select all

root@bubba:~# fw_printenv 
Warning: Bad CRC, using default environment
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ipm
bootdelay=5
baudrate=115200

Re: Accessing u-boot variables from linux

Posted: 11 Nov 2011, 10:27
by johannes
Bummer. Then I really can't help, Tor who was the expert here doesn't work here anymore, and I can't really understand why it wouldn't work.. :(

Re: Accessing u-boot variables from linux

Posted: 11 Nov 2011, 14:27
by MouettE
Well I'm making progress ; after carefully looking into flash, and reading the u-boot docs, I managed to get fw_printenv working with this configuration :

Code: Select all

# MTD device name       Device offset   Env. size       Flash sector size
/dev/mtd0               0x050000        0x002000        0x002000
/dev/mtd0               0x060000        0x002000        0x002000
But fw_setenv doesn't work :

Code: Select all

root@bubba:~# fw_setenv bootdelay 2
MTD erase error on /dev/mtd0: Invalid argument
Error: can't write fw_env to flash
I'm looking into it now.

Re: Accessing u-boot variables from linux

Posted: 11 Nov 2011, 15:17
by 6feet5
Your flash sector size is incorrect.

It should be:

Code: Select all

/dev/mtd0     0x50000       0x002000    0x10000
/dev/mtd0     0x60000       0x002000    0x10000
/Johan

Re: Accessing u-boot variables from linux

Posted: 11 Nov 2011, 15:41
by MouettE
It works, wooo ! Thanks a lot I was nowhere near that. Now I can start writing the howto.

Re: Accessing u-boot variables from linux

Posted: 14 Dec 2012, 04:04
by pompopom
MouettE wrote:It works, wooo ! Thanks a lot I was nowhere near that. Now I can start writing the howto.
Hi MouettE,

Are you the one that wrote the Wiki "Install_Bubba_on_RAID-1_volumes"?

First of all: great job you've done, really helpfull and clear from start to bottom!

I received my B3 last week, and wanted to set it to full raid, just like you did with your B2. However, as you predicted, at the u-boot part I'm stuck with bad CRC. The cat /proc/mtd outputs just like in the starting post from madx. However I have no clue in how to correlate this towards the config file.

Can you point in the right direction?

Madx, did you had any results since your starting post?

EDIT:
Been reading some more info today on the net. And I'm getting somewhere but not completely (yet)
The line in the /etc/fw_env.config should read something like:

Code: Select all

#MTD device name       Device offset   Env. size      Flash sector size
/dev/mtd0              0x0c0000        0x002000       0x010000
Came to this conclusion by:

Code: Select all

root@b3:/mnt/b3# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 000c0000 00010000 "u-boot"
mtd1: 00020000 00010000 "env"
mtd2: 00120000 00010000 "data"
Since then:

Code: Select all

root@b3:/# fw_printenv 
Read error on /dev/mtd0: Success
Not completely what the result should be, but no longer the bad CRC.

I'm aware that the env.size and Flash sector size have wrong values. Now the env. size is a value that I should find somewhere in a header file, if I follow Google. Now on the git repository I found b2.h which indead had these parameters, but it's for B2 board obviously. I can't seem to find the same file for b3... Does anyone know where to find that one?

Re: Accessing u-boot variables from linux

Posted: 17 Dec 2012, 07:29
by pompopom
Can someone post the output from cat /proc/mtd from a B2?

thx.

Re: Accessing u-boot variables from linux

Posted: 18 Dec 2012, 14:06
by 6feet5
Can someone post the output from cat /proc/mtd from a B2?
Here it is

Code: Select all

dev:    size   erasesize  name
mtd0: 00080000 00010000 "physmap-flash.0"
/Johan