where is uboot environment variables stored in emmc?

3.4k views Asked by At

I'm trying to understand where uboot stores the environment variables in emmc. I have the following set in the uboot config file -

CONFIG_ENV_IS_NOWHERE=y
CONFIG_ENV_IS_IN_MMC=y
CONFIG_SYS_MMC_ENV_DEV=2
CONFIG_SYS_MMC_ENV_PART=0
CONFIG_ENV_SIZE=0x4000
CONFIG_ENV_OFFSET=0x400000
CONFIG_ENV_SECT_SIZE=0x10000

uboot is able to save the env variables in emmc and I can read them from Linux. Variables set from Linux are also readable in uboot. I fail to understand which partition has the environment variables?

Output lsblk from Linux -

NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mtdblock0     31:0    0   16M  0 disk 
mmcblk2      179:0    0  7.3G  0 disk 
|-mmcblk2p1  179:1    0 83.2M  0 part /run/media/mmcblk2p1
|-mmcblk2p2  179:2    0  1.7G  0 part /
|-mmcblk2p3  179:3    0 83.2M  0 part /run/media/mmcblk2p3
|-mmcblk2p4  179:4    0    1K  0 part 
|-mmcblk2p5  179:5    0  1.7G  0 part /run/media/mmcblk2p5
`-mmcblk2p6  179:6    0    1G  0 part /run/media/mmcblk2p6
mmcblk2boot0 179:32   0    4M  1 disk 
mmcblk2boot1 179:64   0    4M  1 disk 

mmcblk2boot0 is where uboot is located which is 4MB in size, considering the environment is saved at an offset of 0x400000 in mmcblk2 device, it should be located just after mmcblk2boot0 which points to the parition mmcblk2boot1, but if I dump the strings "strings /dev/mmcblk2boot1", I get nothing.

I have provided a file /etc/fw_config which is used by fw_printenv and fw_saveenv, this file contains "/dev/mmcblk2 0x400000 0x10000". All the settings point to the fact that uboot environment is located at an offset of 0x400000 in mmcblk2 device. Any pointers on which partition listed in output of lsblk holds the uboot environment variables..?

Thanks, Vinay

1

There are 1 answers

0
Tom Rini On

The confusing thing here is that CONFIG_SYS_MMC_ENV_PART does not refer to sofware partitions, such as /dev/mmcblk2p1 that you see under Linux, but rather hardware partitions such as /dev/mmcblk2 (partition 0) or /dev/mmcblk2boot0 (partition 1).