Setting u-boot env variables from Linux

I saw the u-boot-utils programs fw_printenv and fw_setenv. This is exactly what I'm looking for, but I am having trouble getting it running on my stamp9g20. I set the following in the /etc/fw_env.config file:

# MTD device name Device offset Env. size Flash sector size
/dev/mtd2 0x60000 0x20000 0x20000
/dev/mtd3 0x80000 0x20000 0x20000

Is there something wrong with this? When I try the fw_printenv command, I get:
# fw_printenv
seek error on /dev/mtd2: Invalid argument

Also, once I get this working, I don't understand why there are 2 env partitions. Do I need to write my desired settings to both partitions?

Thanks in advance!

(By the way, this is u-boot-utils 1.2.0. U-boot is 2009.08)
U-Boot> version
U-Boot 2009.08 (Jan 12 2010 - 16:15:57)

Re: Setting u-boot env variables from Linux

In your config, there is an error. The device offset is the offset in the chosen device not of the device. So it should run like:

# MTD device name Device offset Env. size Flash sector size
/dev/mtd2 0x00000 0x20000 0x20000
/dev/mtd3 0x00000 0x20000 0x20000

Nonetheless the tools delivered seem to have a problem with redundant environment. You can use fw_printenv and it kind of works, but not fw_setenv. Redundant environment makes sense on nand flash, as nand flash may get bad blocks. Normally both u-boot and fw_printenv/ fw_setenv should deal with this and apart of the configuration file this doesn't need to be your concern. Download the working binary from here:
http://www.armbedded.eu/download/software/fw_printenv
Just rename it to fw_setenv to have the counterpart, it's one binary for both commands.

Re: Setting u-boot env variables from Linux

Thanks, this was helpful. Just as you predicted, my fw_setenv binary did not work for me... but your binary did work. Is there a bug in the particular version of u-boot-utils? What is the secret to that binary / how did you build it? I would prefer to build my own images with bitbake.

Re: Setting u-boot env variables from Linux

Actually I did built this binary in my current u-boot git tree. We have now updated the OpenEmbedded overlay for our boards to a newer version of u-boot-utils. You can update your git tree and a bitbake u-boot-utils or building your image new should give you the working version.

Re: Setting u-boot env variables from Linux

I need the sources of the updated u-boot-utils and not just the binaries, that were provided in an earlier posting. So I thought to "git pull" the OE taskit-overlay and do a bitbake u-boot-utils. However the bitbake build fails:

ERROR: u-boot-utils-2009.08: ftp://ftp.denx.de/pub/u-boot/u-boot-2009.08.tar.bz2 has no entry in conf/checksums.ini, not checking URI
ERROR: Error in executing: /home/ce/taskit/develop/oe/taskit-overlay/recipes/u-boot/u-boot-utils_2009.08.bb
ERROR: Exception: Message:1
ERROR: Printing the environment of the function
ERROR: Error in executing: /home/ce/taskit/develop/oe/taskit-overlay/recipes/u-boot/u-boot-utils_2009.08.bb
ERROR: Exception: Message:1
ERROR: Printing the environment of the function
ERROR: Build of /home/ce/taskit/develop/oe/taskit-overlay/recipes/u-boot/u-boot-utils_2009.08.bb do_fetch failed
ERROR: Task 2 (/home/ce/taskit/develop/oe/taskit-overlay/recipes/u-boot/u-boot-utils_2009.08.bb, do_fetch) failed
NOTE: Tasks Summary: Attempted 380 tasks of which 380 didn't need to be rerun and 1 failed.
ERROR: '/home/ce/taskit/develop/oe/taskit-overlay/recipes/u-boot/u-boot-utils_2009.08.bb' failed

Anything wrong with the taskit overlay or something wrong on my side?

Thanks!

Re: Setting u-boot env variables from Linux

Can pull and try again? The checksums were just missing.

Re: Setting u-boot env variables from Linux

Doing git pull gave changes, but still the error messages remain:

From http://git.armbedded.eu/taskit-overlay
b8f5899..ab54a4a master -> origin/master
Updating b8f5899..ab54a4a
Fast-forward
recipes/base-passwd/base-passwd_3.5.20.bb | 3 +++
recipes/linux/linux_2.6.29.bb | 2 ++
recipes/linux/linux_2.6.31.bb | 2 ++
recipes/linux/linux_2.6.32.bb | 2 ++
recipes/u-boot/u-boot-utils_2009.08.bb | 2 ++
5 files changed, 11 insertions(+), 0 deletions(-)
ce@L1549:~/taskit/develop/oe/taskit-overlay$ bitbake u-boot-utils
NOTE: Handling BitBake files: - (6785/6785) [100 %]
NOTE: Parsing finished. 6478 cached, 5 parsed, 302 skipped, 0 masked.
NOTE: Resolving any missing task queue dependencies
NOTE: Preparing runqueue
NOTE: Executing runqueue
NOTE: Running task 381 of 565 (ID: 2, /home/ce/taskit/develop/oe/taskit-overlay/recipes/u-boot/u-boot-utils_2009.08.bb, do_fetch)
NOTE: Missing checksum
ERROR: u-boot-utils-2009.08: ftp://ftp.denx.de/pub/u-boot/u-boot-2009.08.tar.bz2 has no entry in conf/checksums.ini, not checking URI
ERROR: Error in executing: /home/ce/taskit/develop/oe/taskit-overlay/recipes/u-boot/u-boot-utils_2009.08.bb
ERROR: Exception: Message:1
ERROR: Printing the environment of the function
ERROR: Error in executing: /home/ce/taskit/develop/oe/taskit-overlay/recipes/u-boot/u-boot-utils_2009.08.bb
ERROR: Exception: Message:1
ERROR: Printing the environment of the function
ERROR: Build of /home/ce/taskit/develop/oe/taskit-overlay/recipes/u-boot/u-boot-utils_2009.08.bb do_fetch failed
ERROR: Task 2 (/home/ce/taskit/develop/oe/taskit-overlay/recipes/u-boot/u-boot-utils_2009.08.bb, do_fetch) failed
NOTE: Tasks Summary: Attempted 380 tasks of which 380 didn't need to be rerun and 1 failed.
ERROR: '/home/ce/taskit/develop/oe/taskit-overlay/recipes/u-boot/u-boot-utils_2009.08.bb' failed

Thanks!

Re: Setting u-boot env variables from Linux

Ah, it seems that the stable branch of OpenEmbedded does not use checksums provided in the recipes. Then you have two options:
1. Add the checksums from the u-boot tarball to the file conf/checksums.ini in the main OE directory
or
2. Disable strict checksum checking. Do this by adding

OE_STRICT_CHECKSUMS = ""

to your local.conf

Re: Setting u-boot env variables from Linux

I did option 2 and it works.

Thanks again.

Re: Setting u-boot env variables from Linux

Hi,

I tried your binary but it doesn't work for me.

./fw_setenv bootdelay 4
Can't open /dev/mtd2: Permission denied
Error: can't write fw_env to flash

I tried also with chmod 777 /dev/mtd2

I am using a stamp9g20evb.

Thank you for your help.

Regards.

Re: Setting u-boot env variables from Linux

I think your problem is, that the environment partitions are labelled as read only, when you submit the mtdparts variable to the linux kernel. Edit the mtdparts variable in u-boot according to your needs.
You can access information on your mtd partitions by typing

cat /proc/mtd
Syndicate content