New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

Accessing u-boot variables from linux

Discuss development on Bubba
madx
Posts: 1
Joined: 20 Nov 2010, 19:30

Accessing u-boot variables from linux

Post 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 ?
tor
Posts: 703
Joined: 06 Dec 2006, 12:24
Contact:

Re: Accessing u-boot variables from linux

Post 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
Attachments
u-boot-fwenv.tar.gz
(23.04 KiB) Downloaded 1080 times
Co-founder OpenProducts and Ex Excito Developer
MouettE
Site admin
Posts: 341
Joined: 06 Oct 2011, 19:45

Re: Accessing u-boot variables from linux

Post 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).
johannes
Posts: 1470
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

Re: Accessing u-boot variables from linux

Post by johannes »

Oh, nice work! I will try to dig out some information on this and get back.
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)
johannes
Posts: 1470
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

Re: Accessing u-boot variables from linux

Post 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.
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)
MouettE
Site admin
Posts: 341
Joined: 06 Oct 2011, 19:45

Re: Accessing u-boot variables from linux

Post 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...
johannes
Posts: 1470
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

Re: Accessing u-boot variables from linux

Post by johannes »

So you get bad crc with this config file as well?
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)
MouettE
Site admin
Posts: 341
Joined: 06 Oct 2011, 19:45

Re: Accessing u-boot variables from linux

Post 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
johannes
Posts: 1470
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

Re: Accessing u-boot variables from linux

Post 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.. :(
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)
MouettE
Site admin
Posts: 341
Joined: 06 Oct 2011, 19:45

Re: Accessing u-boot variables from linux

Post 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.
6feet5
Posts: 269
Joined: 13 Apr 2007, 17:32
Location: Gnesta, Sweden
Contact:

Re: Accessing u-boot variables from linux

Post 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
MouettE
Site admin
Posts: 341
Joined: 06 Oct 2011, 19:45

Re: Accessing u-boot variables from linux

Post by MouettE »

It works, wooo ! Thanks a lot I was nowhere near that. Now I can start writing the howto.
pompopom
Posts: 50
Joined: 13 Dec 2012, 16:45

Re: Accessing u-boot variables from linux

Post 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?
pompopom
Posts: 50
Joined: 13 Dec 2012, 16:45

Re: Accessing u-boot variables from linux

Post by pompopom »

Can someone post the output from cat /proc/mtd from a B2?

thx.
6feet5
Posts: 269
Joined: 13 Apr 2007, 17:32
Location: Gnesta, Sweden
Contact:

Re: Accessing u-boot variables from linux

Post 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
Post Reply