I want to be able to set U-boot environment variables to their desired values once, incorporate them into the image(s) built with Yocto, and then flash them from an SD card when installing Boot2Qt without the need to manually modify values on every device with setenv/saveenv during manufacturing. We use Toradex Easy Installer to flash Boot2Qt images modified with Yocto tools to Colibri-imx8x.
When we install a new image, and boot to the U-boot prompt, U-boot uses environment variables, which are NOT the same as the ones used after the “env default -a” command.
- Do the values used after the “env default -a” command come from the U-boot executable itself, and therefore can not be modified unless U-boot is rebuilt from source?
- Is it possible to modify the environment variables used right after a new image is flashed (and WITHOUT the “env default -a” command) without rebuilding U-boot from source? If it is possible, what is the sequence of steps needed to do this?
- If U-boot needs to be rebuilt from source to accomplish what I want, which files need to be modified for #1 and #2 above?
Thanks.
Hi @rubi0030 ,
There is a file on the images called uEnv.txt
or u-boot-initial-env
depending on the version of your image, you can make the changes on these files and then execute the env default -a
to reset the variables. You also can execute the erase flash function on Easy Installer before installing the image in order to don’t need to execute the env default -a.
Can you please try it and check if it is enough for you?
Best regards,
Daniel Morais
Thanks for the reply. I have tried it, but it does not seem to work the way you described it.
The SD card I use with the Easy Installer contains a file named “u-boot-initial-env-sd”, and this file is referenced in image.json as follows: “u_boot_env”: “u-boot-initial-env-sd”
If I manually modify the “u-boot-initial-env-sd” file on the SD card by adding a new environment variable (e.g. fruit=apple) or modifying an existing one (e.g. netmask), and then use the Easy Installer to install images from the SD card, I see that environment variables displayed by the printenv command are updated. However, this happens even when I don’t erase flash during the Easy Installer installation, and I see updated variables as soon as power up the board (i.e. no need for “env default -a”). Moreover, if I then decide to execute the “env default -a” command, the new variables I added to “u-boot-initial-env-sd” disappear, the changes I made to the existing variables in “u-boot-initial-env-sd” go away, and some variables (e.g. fdtcontroladdr) disappear from the list shown by printenv. Note that the fdtcontroladdr variable does not appear in “u-boot-initial-env-sd” at all, but it is in the list shown by printenv immediately after a new image installation.
Please explain. It would be nice to get an understanding of how various pieces fit together, so that we don’t have to guess at how things are supposed to work.
Thank you.
Hi @rubi0030 ,
Sorry for the misunderstood.
Yes, you are correct, the variables on u-boot-initial-env
are directly flashed into the u-boot, does this solve your issue?
The env default
command takes values from the U-Boot source, you can change the values on this file.
Best regards,
Daniel Morais
So, if the “env default” command takes values from the colibri-imx8x.h source file, and environment variables such as fdtcontroladdr are neither in colibri-imx8x.h nor in u-boot-initial-env-sd, how do they end up being part of the U-boot environment when a new image is installed?
Thanks.
Hi @rubi0030 ,
The env default
command takes values from the U-Boot source, the colibri-imx8.h
is a file designed to set specific variables for the module.
The fdtcontroladdr
variable in specific is configured on this file on the U-Boot source.
Please let me know if you have any more doubts.
Best regards,
Daniel Morais