Linux – How to access u boot environment from linux

arch linuxbootboot-loadercommand linelinux

How can I access and change the u-Boot env variables in linux. Using the u-boot/tools/env directory in u boot directory:

u-boot$ make env 

Which created the executable file fw_printenv. I copied this to /usr/sbin and on target etc/fw_env.config file:


# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundand
# environment sector is assumed present.
# MTD device name     Device offset    Env. size    Flash sector size
/dev/mtd0          0x00000                0x20000         0x20000

target#./fw_printenv
SEGV

What is causing this error?

/proc/mtd

dev:    size   erasesize  name                                                  
mtd0: 00020000 00020000 "flash_uboot_env"                                       
mtd1: 002e0000 00020000 "flash_linux_image"                                     
mtd2: 00900000 00020000 "flash_jffs2"                                           
mtd3: 00900000 00020000 "flash_data"

Best Answer

Your fw_env.config differs from mine. I have the u-boot env on the range 0x00260000-0x00280000. As I recall, the fw_env file is pretty sensitive, and if you forget some column fw_setenv will fall back to some default value which can cause all sorts of weird errors.

Just for reference, here is my fw_env.config

root@linux:~# cat /etc/fw_env.config 
# Dev. name    offset    env. size     flash sector size    nbr. sectors
  /dev/mtd1    0x00      0x2000        0x20000              1

You could cross compile straceand use that for troubleshooting.

Related Question