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 strace
and use that for troubleshooting.
Related videos on Youtube
Author by
amar
Updated on September 18, 2022Comments
-
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 about 11 yearsIs 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 about 11 yearsYes,
fw_env.config
should be placed in/etc
on target. It seems yourfw_env.config
is missing the columnnbr. sectors
, but apart from that it looks OK. Please trystrace
on thefw_printenv
, this is really useful to narrow the error down. It could be that you are missing some libraries or something like that. -
amar about 11 yearsthanks 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 about 11 yearsshould 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 about 11 yearsI don't think that you need to change the
fw_env.*
. I think should try thestrace
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 about 11 yearsThanks 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