How to access u boot environment from linux?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to access u boot environment from linux?

4,886 Views
akomarov80
Contributor I

Hello

I try to make firmware update tool for imx35. But i have one problem (

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 0x80000 

target#./fw_printenv

What is causing this error?

Warning: Bad CRC, using default environment

bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm

bootdelay=5

baudrate=115200

target# cat /proc/mtd

dev:    size   erasesize  name

mtd0: 00080000 00020000 "Bootloader"

mtd1: 00300000 00020000 "nor.Kernel.1"

mtd2: 00300000 00020000 "nor.Kernel.2"

mtd3: 01c00000 00020000 "nor.rootfs.1"

mtd4: 01c00000 00020000 "nor.rootfs.2"

mtd5: 00003000 00020000 "FIS directory"

mtd6: 02001000 00020000 "Redboot config"

mtd7: 00300000 00080000 "nand.bootloader"

mtd8: 00500000 00080000 "nand.kernel"

mtd9: 10000000 00080000 "nand.rootfs"

mtd10: 00800000 00080000 "nand.configure"

mtd11: 6f000000 00080000 "nand.userfs"

(((

1 Reply

1,236 Views
Yuri
NXP Employee
NXP Employee

Basically it is possible to build U-boot tools (particularly -

fw_printenw) under LTIB using U-boot package :

$ ./ltib -m prep -p u-boot

$ ./ltib -m scbuild -p u-boot

$ ./ltib -m shell

LTIB> cd rpm/BUILD/u-boot-2009.08

LTIB> make env

After that directory rpm/BUILD/u-boot-2009.08 /tools/env contains the needed files.

To configure correctly fw_env.config, please use section FLASH and environment

organization in board header file (say, mx35_3stack.h or mx35_3stack_mmc.h)
in U-boot directory

include/configs/mx35_<reference board name>.h

There environment parameters are as following :

CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, CONFIG_ENV_SIZE.

Linux fw_env.config may be as following :

# MTD device name    Device offset      Env. size    Flash sector size Number of sectors

/dev/mtd0                 0xC0000            0x2000              0x2000        1

Device offset = CONFIG_ENV_OFFSET in mx35_3stack.h (768 * 1024)

  1. Env. size = CONFIG_ENV_SIZE in mx35_3stack.h (128 * 1024)

Flash sector size = CONFIG_ENV_SIZE.