cancel
Showing results for 
Search instead for 
Did you mean: 

U-BOOT environment variables not stored in u-boot-env partition

GLaure
Senior

Hi,

I am confused how to correctly set u-boot environment variables in a system based on OpenST Linux 4.1 and follows DK2 settings.

The partition layout looks like this:

#Opt	    Id	    	Name	    Type	    IP	    Offset	    Binary
-	    0x01	fsbl1-boot	Binary	    none	0x0	        arm-trusted-firmware/tf-a-stm32mp157f-nexio-usb.stm32
-	    0x03	fip-boot	Binary	    none	0x0	        fip/fip-stm32mp157f-nexio-trusted.bin
P	    0x04	fsbl1	    Binary	    mmc0	0x00004400	arm-trusted-firmware/tf-a-stm32mp157f-nexio-sdcard.stm32
P	    0x05	fsbl2	    Binary	    mmc0	0x00044400	arm-trusted-firmware/tf-a-stm32mp157f-nexio-sdcard.stm32
P	    0x06	metadata1	Binary	    mmc0	0x00084400	arm-trusted-firmware/metadata.bin
P	    0x07	metadata2	Binary	    mmc0	0x000C4400	arm-trusted-firmware/metadata.bin
P	    0x08	fip-a	    FIP	        mmc0	0x00104400	fip/fip-stm32mp157f-nexio-trusted.bin
PED	    0x09	fip-b	    FIP	        mmc0	0x00504400	none
PED	    0x0A	u-boot-env	Binary	    mmc0	0x00904400	none
P	    0x10	bootfs	    System	    mmc0	0x00984400	st-image-bootfs-openstlinux-weston-stm32mp1-nexio.ext4
P	    0x11	vendorfs    FileSystem	    mmc0	0x04984400	st-image-vendorfs-openstlinux-weston-stm32mp1-nexio.ext4
P	    0x12	rootfs	    FileSystem	    mmc0	0x05984400	st-image-core-openstlinux-weston-stm32mp1-nexio.ext4
P	    0x13	rootfs	    FileSystem	    mmc0	0x45984400	st-image-core-openstlinux-weston-stm32mp1-nexio.ext4
E	    0x14	writeable	FileSystem	    mmc0	0x85984400	none	# 256kB persistent memory    
E	    0x15	dummy	    FileSystem	    mmc0	0x859C4400	none	# unused

​My idea is to use u-boot boot.scr.cmd to be able to switch between the two root filesystems.

fw_env.config looks like this:

# Block device example
/dev/disk/by-partlabel/u-boot-env		0x3bc00		0x2000
/dev/disk/by-partlabel/u-boot-env		0x3bc00		0x2000

I got the start offset by looking into u-boot-env by using hexdump.

After boot I am able to use fw_printenv and fw_setenv and I see the changes made to u-boot-env.

​But I have a number of issues with this approach:

  1. boot.scr.img is not always executed. It seems only to get executed at the first boot.
  2. u-boot prompt: env set var 123; env save; does not seem to save the variable to the u-boot-env partition. In fact after using hexdump I found out the value is stored to the fip-b partition. Why doesnt it use u-boot-dev?
  3. Using fw_setenv does change the value in u-boot-dev, but on the u-boot prompt I see the previous value. The one from the fip-b partition.

How can I configure the system so that u-boot and the rootfs use the same device for storing the FW environment variables?

Thank you 1000 times!

bye Gunther

1 ACCEPTED SOLUTION

Accepted Solutions
GLaure
Senior

I believe I found the culprit;

Somehow our u-boot device tree set:

u-boot,mmc-env-partition = "fip";

I am changing it to:

u-boot,mmc-env-partition = "u-boot-env";

and expecting consistent behavior.

Bye Gunther

View solution in original post

2 REPLIES 2
GLaure
Senior

I believe I found the culprit;

Somehow our u-boot device tree set:

u-boot,mmc-env-partition = "fip";

I am changing it to:

u-boot,mmc-env-partition = "u-boot-env";

and expecting consistent behavior.

Bye Gunther

Hi,

I confirm, that is a modification in U-Boot device tree on ST boards for OpenSTLinux migration V3.X => V4.X to respect the new flashlayout = https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer_flashlayout#SD_card

A new partition is created for save the U-Boot environment, it is no more saved at the end of the FIP partition.

If you can adopt the new SD-Card partitioning (the new tsv files) you must update this part in your U-Boot device tree:
https://wiki.st.com/stm32mpu/wiki/U-Boot_overview#U-Boot_environment_variables

sorry if it was clear enough.

Patrick