cancel
Showing results for 
Search instead for 
Did you mean: 

I found the env problem when EMMC started

User.44
Associate II

I found that the UBoot env stored at the same address as the bootfs, which caused emMC to fail to start the kernel

0693W000003RkDMQA0.png0693W000003RkD2QAK.png

Env and Uboot are both at 0x280000 addresses,

1 ACCEPTED SOLUTION

Accepted Solutions
PatrickD
ST Employee

Hi,

in OpenSTLinux v1.1, for eMMC the enviromnent in saved in ext4 file in bootfs... (CONFIG_ENV_EXT4_FILE = "/uboot.env")

But the U-Boot ext4 suport cause issue as some EXT4 option are not supported in U-Boot to allow write.

in OpenSTLinux v2.0, the eMMC now environment is saved at the END of the U-Boot partition in RAW (CONFIG_ENV_MMC)

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

And normally CONFIG_ENV_OFFSET is not used for env/mmc.c if "u-boot,mmc-env-partition" is defined in config node of DT

but it can be used as fallback when the partition name is not present in the device tree.

in ST boards, CONFIG_ENV_OFFSET=0X2800000 is used ony for NOR

So I assumed that "u-boot,mmc-env-partition" is missing in your device tree (it is an addition between V1.1 and V2.0)

see ST boards device tree for example

arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi:19:

arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi:20:

/ {

......

config {

.....

u-boot,mmc-env-partition = "ssbl"; <<<<< NEW in v2.0

.....

};

regards

Patrick

View solution in original post

3 REPLIES 3
PatrickD
ST Employee

Hi,

in OpenSTLinux v1.1, for eMMC the enviromnent in saved in ext4 file in bootfs... (CONFIG_ENV_EXT4_FILE = "/uboot.env")

But the U-Boot ext4 suport cause issue as some EXT4 option are not supported in U-Boot to allow write.

in OpenSTLinux v2.0, the eMMC now environment is saved at the END of the U-Boot partition in RAW (CONFIG_ENV_MMC)

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

And normally CONFIG_ENV_OFFSET is not used for env/mmc.c if "u-boot,mmc-env-partition" is defined in config node of DT

but it can be used as fallback when the partition name is not present in the device tree.

in ST boards, CONFIG_ENV_OFFSET=0X2800000 is used ony for NOR

So I assumed that "u-boot,mmc-env-partition" is missing in your device tree (it is an addition between V1.1 and V2.0)

see ST boards device tree for example

arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi:19:

arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi:20:

/ {

......

config {

.....

u-boot,mmc-env-partition = "ssbl"; <<<<< NEW in v2.0

.....

};

regards

Patrick

Hi Patrick,

I trying to change some u-boot variables from user space, and I using u-boot-fw-utils in my Yocto build (2.1 release). I changed the /etc/fw_env.config.mmc to /etc/fw_env.config because I using eMMC ( I did what you mentioned before - u-boot,mmc-env-partition = "ssbl"; )

When I run the program in user space :

root@stm32mp1-ground4-mx:/etc# fw_printenv
Cannot read environment, using default
Cannot read default environment from file

I tried to change the address in /etc/fw_env.config :

/dev/disk/by-partlabel/ssbl       -0x2000     0x2000

to address that I think it was with hexdump -C /dev/disk/by-partlabel/ssbl

but nothing changed I still cannot change the env variables.

can you help ?

Hi,

​Tested on OpenSTLinux v2.1, with alligned  U-Boot provided in V2.1  for the ST EV1 board

(v2020.01 => stm32mp15_trusted_defconfig with ENV configuration: CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET_REDUND)

root@stm32mp1:~# fw_printenv -c /etc/fw_env.config.mmc

altbootcmd=run bootcmd

android_mmc_boot=mmc dev ${devnum};run android_mmc_splash;run android_mmc_fdt;run andr;

android_mmc_fdt=if part start mmc ${devnum} dt_${suffix} dt_start &&part size mmc ${dei

android_mmc_kernel=if part start mmc ${devnum} boot_${suffix} boot_start && part size i

android_mmc_splash=if part start mmc ${devnum} splash splash_start && part size mmc ${i

arch=arm

autoload=no

baudrate=115200

board=stm32mp1

board_id=0x1272

board_name=stm32mp157f-dk2

board_rev=0x000c

boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${sc}

boot_device=mmc

boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else booi

boot_extlinux=run scan_m4fw;sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scri}

boot_instance=0

boot_m4fw=rproc init; rproc load 0 ${m4fw_addr} ${filesize}; rproc start 0

boot_net_usb_start=true

boot_prefixes=/mmc0_

boot_script_dhcp=boot.scr.uimg

boot_scripts=boot.scr.uimg boot.scr

boot_syslinux_conf=extlinux/stm32mp157f-dk2_extlinux.conf

boot_targets=mmc0

bootcmd=run bootcmd_stm32mp

bootcmd_android=env set mmc_boot run android_mmc_boot;run bootcmd_stm32mp

bootcmd_mmc0=devnum=0; run mmc_boot

bootcmd_mmc1=devnum=1; run mmc_boot

bootcmd_mmc2=devnum=2; run mmc_boot

bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi

bootcmd_stm32mp=echo "Boot over ${boot_device}${boot_instance}!";if test ${boot_device;

bootcmd_ubifs0=devnum=0; run ubifs_boot

bootcount=3

bootdelay=1

bootfstype=ext4

cpu=armv7

devplist=4

distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done

dtimg_addr=0xc44FFF80

efi_dtb_prefixes=/ /dtb/ /dtb/current/

env_check=env exists env_ver || env set env_ver ${ver};if env info -p -d -q; then env ;

env_ver=U-Boot 2020.01-stm32mp-r2.1 (Jan 06 2020 - 20:56:31 +0000)

ethaddr=00:80:e1:42:7c:ce

fastboot.boot_instance=0

fastboot.boot_mode=trusted

fdt_addr_r=0xc4000000

fdtcontroladdr=d7aec640

fdtfile=stm32mp157f-dk2.dtb

fileaddr=c4100000

filesize=b7f

kernel_addr_r=0xc2000000

load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi}

loadaddr=0xc2000000

m4fw_addr=0xc2000000

m4fw_name=rproc-m4-fw.elf

mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi

partitions=name=ssbl,size=2M;name=bootfs,size=64MB,bootable;name=vendorfs,size=16M;nam-

pxefile_addr_r=0xc4200000

ramdisk_addr_r=0xc4400000

scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix;

scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists dt

scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n "${soc}"e

scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boi

scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}e

scan_m4fw=if test -e ${devtype} ${devnum}:${distro_bootpart} ${m4fw_name};then echo Fo;

scriptaddr=0xc4100000

serial#=0049002C3438511836383238

serverip=192.168.1.1

soc=stm32mp

splashimage=0xc4300000

suffix=a

ubifs_boot=env exists bootubipart || env set bootubipart UBI; env exists bootubivol ||i

usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_parti

vendor=st

ver=U-Boot 2020.01-stm32mp-r2.1 (Jan 06 2020 - 20:56:31 +0000)

root@stm32mp1:~#

You can add trace in u-boot/env/mmc.c to display the address in eMMC of the expected ENV offset when U-Boot is starting....

Then you can cross check this address used in fw_printenv....

Patrick