Question

why fw_setenv tool set value of variable only for one environment?

I am using uboot with redundant env (#define CONFIG_ENV_OFFSET 0xc0000, #define CONFIG_ENV_OFFSET_REDUND 0x100000 ), and I am going to set value of uboot env variable from linux. There is fw_setenv/fw_printenv tool which can do this:

# fw_printenv rootfs
rootfs=mtd6
# fw_setenv rootfs mtd7

Check that it is realy was set:

# fw_printenv rootfs
rootfs=mtd7

Seems OK, but after reboot system and entering to u-boot console, the value of rootfs variable is former. uboot read former value:

=> printenv
rootfs=mtd6

Then I have looked at the hexdump output of mtd devices where uboot envs placed.

Before setting rootfs mtd7:

# hexdump -C /dev/mtd3 | head -n 200

. . . . .
000000a0  65 6c 61 79 3d 35 00 62  61 75 64 72 61 74 65 3d  |elay=5.baudrate=|
000000b0  31 31 35 32 30 30 00 72  6f 6f 74 66 73 3d 6d 74  |115200.rootfs=mt|
000000c0  64 36 00 00 ff ff ff ff  ff ff ff ff ff ff ff ff  |d6..............|
000000d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

Here rootfs=mtd6, seems OK.

# hexdump -C /dev/mtd4 | head -n 200

. . . . . 
00000090  6f 66 66 3b 20 62 6f 6f  74 6d 00 62 6f 6f 74 64  |off; bootm.bootd|
000000a0  65 6c 61 79 3d 35 00 62  61 75 64 72 61 74 65 3d  |elay=5.baudrate=|
000000b0  31 31 35 32 30 30 00 00  00 ff ff ff ff ff ff ff  |115200..........|
000000c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

There is no rootfs variable defined in env on redundant part. Why??

After using fw_setenv rootfs mtd7

# hexdump -C /dev/mtd3 | head -n 200

000000a0  65 6c 61 79 3d 35 00 62  61 75 64 72 61 74 65 3d  |elay=5.baudrate=|
000000b0  31 31 35 32 30 30 00 72  6f 6f 74 66 73 3d 6d 74  |115200.rootfs=mt|
000000c0  64 36 00 00 ff ff ff ff  ff ff ff ff ff ff ff ff  |d6..............|
000000d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

The environment on mtd3 stay unchanged (rootfs=mtd6).

# hexdump -C /dev/mtd4 | head -n 200

000000a0  65 6c 61 79 3d 35 00 62  61 75 64 72 61 74 65 3d  |elay=5.baudrate=|
000000b0  31 31 35 32 30 30 00 72  6f 6f 74 66 73 3d 6d 74  |115200.rootfs=mt|
000000c0  64 37 00 00 ff ff ff ff  ff ff ff ff ff ff ff ff  |d7..............|
000000d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

The new rootfs variable has been wrote on mtd4.

So the content in the uboot environments is not the same. How to properly set env from linux?

Was it helpful?

Solution

I believe you may have wrong info in "Device offset" column of fw_env.config file, you may try

/dev/mtd6    0x0c0000       0x10000     0x10000            0x1
/dev/mtd7    0x1c0000       0x10000     0x10000            0x1
#MTDdevname  Device offset  Env. size   Flash sector size  Number of sectors

The last three columns' info may be different for your platform.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top