cancel
Showing results for 
Search instead for 
Did you mean: 

STM32mp135f-dk custom uboot environment not saving properly

robo1340
Associate II

I have an STM32mp135f-dk board that I have been using openstlinux-6.1 to develop images on.

For my board, I made a custom device tree "iris.dtb" which I intend to use instead of the default "stm32mp135f-dk.dtb".

I ran into an interesting issue where u-boot on my board would not load the my modified uboot environment variables.

For context, the following is my flash layout file with the u-boot-env at address 0x00904400

 

 

#Opt    Id      Name    Type    IP      Offset  Binary
-       0x01    fsbl-boot       Binary  none    0x0     arm-trusted-firmware/tf-a-stm32mp135f-dk-usb.stm32
-       0x03    fip-boot        FIP     none    0x0     fip/fip-stm32mp135f-dk-optee.bin
P       0x04    fsbl1   Binary  mmc0    0x00004400      arm-trusted-firmware/tf-a-stm32mp135f-dk-sdcard.stm32
P       0x05    fsbl2   Binary  mmc0    0x00044400      arm-trusted-firmware/tf-a-stm32mp135f-dk-sdcard.stm32
P       0x06    metadata1       FWU_MDATA       mmc0    0x00084400      arm-trusted-firmware/metadata.bin
P       0x07    metadata2       FWU_MDATA       mmc0    0x000C4400      arm-trusted-firmware/metadata.bin
P       0x08    fip-a   FIP     mmc0    0x00104400      fip/fip-stm32mp135f-dk-optee.bin
PED     0x09    fip-b   FIP     mmc0    0x00504400      none
PED     0x0A    u-boot-env      ENV     mmc0    0x00904400      none
P       0x10    bootfs  System  mmc0    0x00984400      st-image-bootfs-openstlinux-weston-iris-machine.ext4
P       0x11    vendorfs        FileSystem      mmc0    0x04984400      st-image-vendorfs-openstlinux-weston-iris-machine.ext4
P       0x12    rootfs  FileSystem      mmc0    0x05984400      st-image-weston-openstlinux-weston-iris-machine.ext4
P       0x13    userfs  FileSystem      mmc0    0x105984400     st-image-userfs-openstlinux-weston-iris-machine.ext4

 

 

On my target development board I created a symlink for the fw-util config so that fw_printenv and fw_setenv would work. I intend to ad this to a bbappend for u-boot-stm32mp.bb later on.

 

 

ln -s /etc/fw_env.config.mmc /etc/fw_env.config

 

 

I also had to modify the contents of fw_env.config.mmc as follows, otherwise fw_printenv prints the error "Cannot read environment, using default
Cannot read default environment from file". I'm not sure why this works but it does.

 

 

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

 

 Then I set my fdtfile as shown.

 

root@iris-machine:~# fw_setenv fdtfile=iris.dtb
root@iris-machine:~# fw_printenv fdtfile
fdtfile=iris.dtb

 

This configuration persists after rebooting so I know fw-util is working correctly and there is a persistent u-boot environment image somewhere.

Yet, when I reboot and get a uboot shell via serial port fdtfile has the following value.

 

U-Boot 2022.10-stm32mp-r1 (Oct 03 2022 - 19:25:32 +0000)

CPU: STM32MP135F Rev.Y
Model: STMicroelectronics STM32MP135F-DK Discovery Board
Board: stm32mp1 in trusted mode (st,stm32mp135f-dk)
Board: MB1635 Var1.0 Rev.E-02
DRAM:  512 MiB
optee optee: OP-TEE: revision 3.19 (afacf356)
Clocks:
- MPU : 1000 MHz
- AXI : 266.500 MHz
- PER : 24 MHz
- DDR : 533 MHz
Core:  260 devices, 40 uclasses, devicetree: board
WDT:   Started watchdog with servicing (32s timeout)
NAND:  0 MiB
MMC:   STM32 SD/MMC: 0, STM32 SD/MMC: 1
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Previous ADC measurements was not the one expected, retry in 20ms
****************************************************
*        WARNING 500mA power supply detected       *
*     Current too low, use a 3A power supply!      *
****************************************************

Net:   eth0: eth1@5800a000, eth1: eth2@5800e000
Hit any key to stop autoboot:  0
STM32MP>
STM32MP>
STM32MP>
STM32MP> print fdtfile
fdtfile=stm32mp135f-dk.dtb

 

So it seems u-boot itself is not loading its own environment correctly and is returning to defaults after every boot. This forces me to change fdtfile manually after every boot, or rename my device tree blob in the /boot directory. 

I also tried the following, which appears to work at first glance.

 

STM32MP> setenv fdtfile iris.dtb
STM32MP> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
STM32MP> env save
Saving Environment to MMC... Writing to redundant MMC(0)... OK

 

But after a reboot, fdtfile returns to the default value.

So I created a development workspace for u-boot-stm32mp using dev tool as it generally described in this article.

https://wiki.koansoftware.com/index.php/Using_devtool_to_modify_recipes_in_Yocto

And I started looking at the stm32mp13_defconfig described int his article.

https://wiki.st.com/stm32mpu/wiki/U-Boot_overview#U-Boot_environment_variables

And in the first 10 lines I see this.

 

robo1340@yocto-build-machine:~/stm32mp1/build-openstlinuxweston-stm32mp13-disco/workspace/sources/u-boot-stm32mp$ head -10 configs/stm32mp13_defconfig
CONFIG_ARM=y
CONFIG_ARCH_STM32MP=y
CONFIG_TFABOOT=y
CONFIG_SYS_MALLOC_F_LEN=0x180000
CONFIG_ENV_OFFSET=0x900000
CONFIG_ENV_SECT_SIZE=0x40000
CONFIG_DEFAULT_DEVICE_TREE="stm32mp135f-dk"
CONFIG_SYS_PROMPT="STM32MP> "
CONFIG_STM32MP13X=y
CONFIG_DDR_CACHEABLE_SIZE=0x8000000

 

I fiddled around with these settings for a while and built a few images from them but none worked.

I also dd'd the block device where the uboot env should be and can see that there are uboot environment variables present. I searched though it and found the following lines.

 

fdtfile=stm32mp135f-dk.dtb
...
fdtfile=iris.dtb

 

Since the one set to iris.dtb is coming second, I assume the redundant uboot env is getting set but not the primary one.

I can see that I could just change CONFIG_DEFAULT_DEVICE_TREE to "iris.dtb" then rebuild my image and that would fix the immediate issue, but it wouldn't fix the more general issue of my not being able to save uboot environment variables as I expect I should.

I feel I have all the moving pieces in front of me but just can't figure out how to make them align now. Thank you for any additional guidance that can be given.

 

0 REPLIES 0