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.

PROCESSOR-SDK-AM62A: Changing u-boot environment variable from user space

Part Number: PROCESSOR-SDK-AM62A

Tool/software:

Hi,

Yocto SDK: 09_01_00

EVM: AM62A SK EVM

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1127618/faq-sk-am62-how-to-flash-emmc-using-usb-dfu-on-am62x-sk-e2

I have followed the above link to boot the board from the emmc flash and able to boot the device from emmc as well.

Now, We have requirement of accessing and modification of the u-boot environment variable at user space.

=> printenv dfu_alt_info_emmc
dfu_alt_info_emmc=rawemmc raw 0 0x800000 mmcpart 1; rootfs part 0 1; tiboot3.bin.raw raw 0x0 0x400 mmcpart 1; tispl.bin.raw raw 0x400 0x1000 mmcpart 1; u-boot.img.raw raw 0x1400 0x2000 mmcpart 1; u-env.raw raw 0x3400 0x100 mmcpart 1; sysfw.itb.raw raw 0x3600 0x800 mmcpart 1

As per above command we should be able flash the u-env.raw file at  certain offset in either boot0 or boot1 partition. I have below query for this.

1) How can we generate u-env.raw file in yocto to flash in emmc?

2) If we want to change the offset of the u-env.raw, where to change the same in the u-boot?

3) How can we access the same u-env.raw at user space to modify the few u-boot environment variable?

4) Will u-boot use the same environment variable written in the u-env.raw? Or do we need to change u-boot code to read environment from u-env.raw?

Let me know any clarification required in above query.

Regards,

Jay

  • Hello Jay,

    The support for modifying U-boot env variables using saveenv command has been removed from the SDK. You can modify U-boot env variables from the source code, or use the uEnv.txt file present in boot partition of SD card.

    I will check internally if a patch is available for getting back the saveenv command, to be able to save the changes.

    Regards,
    Aparna

  • Hi Aparna, 

    Sure, Let us know the patch to update the environment variable from u-boot prompt. If you also can provide the detail about location or offset address of where environment variable are stored than that will useful for us.

    Regards,

    Jay

  • For modifying the U-boot env variables, you can modify it from source code as follows:

    • Modify ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07/board-support/ti-u-boot-2023.04+gitAUTOINC+b0d717b732-gb0d717b732/board/ti/am62ax/am62ax.env
    • Build U-boot on top level using the command make u-boot.
    • Copy tiboot3.bin, tispl.bin, u-boot.img files and flash these into eMMC.

    Regards,
    Aparna

  • Hi Aparna, 

    Thank you for your reply. 

    We are aware about changing the environment variables from u-boot source.

    If having this file and modifying env variables from U-boot prompt is a necessity, do let me know.

    I will check internally if a patch is available for the same.

    We want know the process to change the env variables from u-boot prompt. 

    Regards,

    Jay

  • Hello Jay,

    I will update the thread soon with how to enable the uEnv.txt.

    Meanwhile, please refer to the following:
    e2e.ti.com/.../4965575

    You can add the env variables into the uEnv.txt file and modify them from the U-boot prompt like mentioned above. 

    Regards,
    Aparna

  • Hello Jay,

    You can either save the variables in the uEnv.txt file present in boot partition of SD card.
    But please note that saveenv command has been removed after 8.6 SDK, hence the changes done in U-boot prompt will not be saved, i.e. a POR will reset the changes.

    If you want to restore the saveenv command please refer to the patch here:
    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1215936/tda4al-q1-there-is-no-saveenv-boot-cmd/4591095#4591095

    Regards,
    Aparna

  • Hi Aparna, 

    Thank you for pointing out the solution. 

    I understand the we can add or change the env variable in uEnv.txt file in mmcblk1p1 partition and will come into effect in next boot. 

    Now we will be using the eMMC for boot and not SD card. And we are flashing the eMMC as mentioned in below this link.

    So, we are using the boot0 or boot1 raw partition for u-boot. There is no step to flash the uEnv.txt but as i see the dfu_alt_info_emmc variable, we can flash the uEnv.txt as well. But I have question for that. 

    1) Does raw uEnv.txt is required to flash it in raw partition (boot0 or boot1)? If yes that raw uEnv.txt is required then how can I generate the raw uEnv.txt?

    2) If I flash uEnv.txt in raw partition, will u-boot use it in every boot?

    Let me know if there is any other method to change env variable when u-boot is flashed in raw partition.

    Regards,

    Jay

  • Hello Jay,

    1) Does raw uEnv.txt is required to flash it in raw partition (boot0 or boot1)? If yes that raw uEnv.txt is required then how can I generate the raw uEnv.txt?

    You dont need to generate the uEnv.txt file. In the dfu-util command, -a u-env.raw is the name given to uEnv.txt file. dfu_alt_info_emmc will take care of the address to which the files need to be flashed. You can check the address values, please refer below:

    dfu_alt_info_emmc=
    	rawemmc raw 0 0x800000 mmcpart 1;
    	rootfs part 0 1;
    	tiboot3.bin.raw raw 0x0 0x400 mmcpart 1;
    	tispl.bin.raw raw 0x400 0x1000 mmcpart 1;
    	u-boot.img.raw raw 0x1400 0x2000 mmcpart 1;
    	u-env.raw raw 0x3400 0x100 mmcpart 1;
    	sysfw.itb.raw raw 0x3600 0x800 mmcpart 1

    If I flash uEnv.txt in raw partition, will u-boot use it in every boot?

    I have not verified this at my end, but this should work. Please use the following command to flash the env file:

    sudo dfu-util -a u-env.raw -D <your_uEnv.txt>

    The uEnv.txt is a text file present in the boot partition of your SD card, when you flash the wic image. The format of this file is: variable=value

    Regards,
    Aparna

    27362.uEnv.txt
    # This uEnv.txt file can contain additional environment settings that you
    # want to set in U-Boot at boot time.  This can be simple variables such
    # as the serverip or custom variables.  The format of this file is:
    #    variable=value
    # NOTE: This file will be evaluated after the bootcmd is run and the
    #       bootcmd must be set to load this file if it exists (this is the
    #       default on all newer U-Boot images.  This also means that some
    #       variables such as bootdelay cannot be changed by this file since
    #       it is not evaluated until the bootcmd is run.