How to access u boot environment from linux?

5,240

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:
5,240

Related videos on Youtube

amar
Author by

amar

Updated on September 18, 2022

Comments

  • amar
    amar over 1 year

    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"
    
  • amar
    amar about 11 years
    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...??
  • Kotte
    Kotte about 11 years
    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.
  • amar
    amar about 11 years
    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
    amar about 11 years
    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
  • Kotte
    Kotte about 11 years
    I don't think that you need to change the fw_env.*. I think should try the strace approach, this usually give a good indication on what is causing the problem. I've created a gist that shortly describes how to build strace on gist.github.com/ElektroKotte/5450136.
  • amar
    amar about 11 years
    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