This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] TDA4VM: How to use uEnv.txt to configure u-boot env when using OSPI as boot media.

Part Number: TDA4VM

Tool/software:

When using OSPI as a boot media, I cannot use the uEnv.txt loaded in OSPI. It always uses the default  what should I do to use the uEnv.txt loaded in OSPI?

  • Hi,

    By default from the environment variables, the uEnv.txt is picked up from the MMCSD. And on SDK 9.0 onwards, its not possible to update these environment variables from u-boot prompt. hence to change the sourcing of uEnv.txt from OSPI flash memory, we would have to make changes in the u-boot source code and recompile the u-boot.

    At the source code at "[PSDK-Linux-Install-Directory]/board-support/ti-u-boot-[commit-hash]/", apply the following patch:

    diff --git a/include/environment/ti/mmc.env b/include/environment/ti/mmc.env
    index 1e62bf85..b16e9bc9 100644
    --- a/include/environment/ti/mmc.env
    +++ b/include/environment/ti/mmc.env
    @@ -9,27 +9,23 @@ loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr
     bootscript=echo Running bootscript from mmc${mmcdev} ...;
     	source ${loadaddr}
     bootenvfile=uEnv.txt
    -importbootenv=echo Importing environment from mmc${mmcdev} ...;
    -	env import -t ${loadaddr} ${filesize}
    -loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}
    +importbootenv=echo Importing environment from ospi ...;
    +	env import -t ${loadaddr} 0x20000
    +loadbootenv=
    +	if sf probe; then
    +		sf read ${loadaddr} 0x680000 0x20000;
    +	fi
     loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
     loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/dtb/${fdtfile}
     get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} ${bootdir}/dtb/${name_fdt}
    -envboot=mmc dev ${mmcdev};
    -	if mmc rescan; then
    -		echo SD/MMC found on device ${mmcdev};
    -		if run loadbootscript; then
    -			run bootscript;
    -		else
    -			if run loadbootenv; then
    -				echo Loaded env from ${bootenvfile};
    -				run importbootenv;
    -			fi;
    -			if test -n $uenvcmd; then
    -				echo Running uenvcmd ...;
    -				run uenvcmd;
    -			fi;
    -		fi;
    +envboot=
    +	if run loadbootenv; then
    +		echo Loaded env from ${bootenvfile};
    +		run importbootenv;
    +	fi;
    +	if test -n $uenvcmd; then
    +		echo Running uenvcmd ...;
    +		run uenvcmd;
     	fi;
     mmcloados=
     	if test ${boot_fdt} = yes || test ${boot_fdt} = try; then
    

    The go to "[PSDK-Linux-Install-Directory]" and run "make u-boot" to build the u-boot binary.

    You will find the built u-boot binary at : "[PSDK-Linux-Install-Directory]/board-support/ti-u-boot-[commit-hash]/build/a72/u-boot.img". Copy  this binary to OSPI at u-boot's offset.

    Next, you will have to flash the uEnv.txt file in OSPI at 0x680000 offset. For this, you can get file from either an alternate boot media (like SD Card or eMMC) or using TFTP over network. In this example I am showing using SD Card, boot partition. For TFTP, make sure that you have a TFTP server available on your host and that the uEnv.txt is present in the appropriate folder.

    Boot to the u-boot prompt, and run the following commands on it.

    • fatload mmc 1 $loadaddr uEnv.txt
    • sf probe
    • sf erase 0x680000 0x20000
    • sf update $loadaddr 0x680000 $filesize

    You will have the uEnv.txt in your OSPI now and it will be executed on the next boot.

    You can update the uEnv.txt to vary your environment now. in uEnv.txt, you can assign addition environment variables or update existing environment variables. for example to apply an device-tree overlay, you can just mention the following line in your uEnv.txt:

    • name_overlays=k3-j721e-evm-virt-mac-client.dtbo

    To execute some script at boot, you can append it at the end of "uenvcmd" variable. This will execute it at every boot. for example to print "Hello World!!" while booting, you can add following command to uEnv.txt

    • uenvcmd=echo "hello World!!"

    Just be careful as the many times the "uenvcmd" is already loaded with some scripts for some checks. Be sure to add this command at the end and not overwrite it.

    Once you have updated your uEnv.txt, flash it once more to OSPI using the steps given above for the changes to take affect.

    Regards,
    Tanmay