Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


What is causing this error?


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"
share|improve this question

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.

share|improve this answer
Is the procedure what I am following is correct..?? fw_env.config is a file which we will creat on target /etc am I correct...?? IN my case what are value will become for offset,env.size and flash sectort size with considering my proc/mtd out...?? – amar Apr 23 '13 at 5:13
Yes, fw_env.config should be placed in /etc on target. It seems your fw_env.config is missing the column nbr. sectors, but apart from that it looks OK. Please try strace on the fw_printenv, this is really useful to narrow the error down. It could be that you are missing some libraries or something like that. – Kotte Apr 23 '13 at 8:35
thanks for your quick reply... I have using the nbr. sectors as 1 even though its giving the same error SEGV. what will be the other possibility since I am new to this please help me – amar Apr 23 '13 at 10:59
should I need to change anything in the files fw_env.h and fw_env.c and fw_evn_main.c files please suggest me. I used those file as it is in u boot.in u boot I executed make env command and obtained the fw_printenv file that i copied.please help me – amar Apr 23 '13 at 11:02
Thanks for giving suggestion my problem solved bye compiling with respect to processor architecture. and using correct env_size flash sector. # MTD device name Device offset Env. size Flash sector size /dev/mtd0 0x00000 (4*1024) 0x20000 – amar Apr 24 '13 at 9:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.