Xilinx Zynq-7000 : Help petalinux patch u-boot env vars

Hello,
I'm trying to update some of the u-boot environment variables when I build my linux Image using petalinux for the zynq 7000 (zedboard).
Looking at the configs folder I found the "xilinx_zynq_virt_defconfig". So my first question is the following. Does this file contain the environment variables I see when I boot u-boot? I want to add some environment variables for u-boot.
For example, ipaddr = <my_ipaddr> serverip = <tftp_server_ip> etc....
If this file is not the file one would modify could someone point me to the correct place?
My ultimate goal is to use petalinux-devtool (which is yocto devtool - https://docs.yoctoproject.org/ref-manual/devtool-reference.html) to update u-boot so it contains my added environment variables. This tool basically downloads the xilinx u-boot repo and allows changes to be made via the yocto devtool. So that is a little background on why I'm trying to do this modification this way. The recommended approach from my silicon vendor (Xilins) is to use this devtool to "patch" the u-boot source.
So long story short, I have the source ready to be patched and built but I don't know exactly what to patch (which source file) so when I boot into u-boot I have the newly added environment variables loaded.
Thanks for any help!
Robbie Valentine Electrical Engineer RisingEdgeIndustries

El Fri, Jun 10, 2022 at 11:32:59PM -0700, RisingEdgeIndustries deia:
Hello,
I'm trying to update some of the u-boot environment variables when I build my linux Image using petalinux for the zynq 7000 (zedboard).
Hello, not an expert, but I hope I can help and that people correct me i fI was to mislead you.
Looking at the configs folder I found the "xilinx_zynq_virt_defconfig". So my first question is the following. Does this file contain the environment variables I see when I boot u-boot? I want to add some environment variables for u-boot.
No. You mean configs/xilinx_zynq_virt_defconfig, right ?
This file is a summary of the .config file that the U-Boot project proposes to configure the build for the board.
When you do
make xilinx_zynq_virt_defconfig
the file is copied to .config with the rest of options that are logical consequences of those in the file according to the rules in diverse Kconfig files. The make/autoconf/whatnot machinery gets them in .h files, link files... Makefiles recognize some, etc.
So these are build time options. You can change them interactively (and break things) with make nconfig for example, and if you want to create a summary of .config like those in configs/ do make savedefconfig and you could cp the generated defconfig into configs with the proper name if that was needed.
Environment variables are runtime options.
For example, ipaddr = <my_ipaddr> serverip = <tftp_server_ip> etc....
Yes those look like environment variables, for runtime. Those can be embedded inside the U-Boot binary, and/or U-Boot can read them from different places. That's decided through build time options like those in configs/xilinx_zynq_virt_defconfig.
You may want to read doc/usage/environment.rst
If this file is not the file one would modify could someone point me to the correct place?
I'd say this is not the one or only one, but you might get away by adding some CONFIG_ENV_SOURCE_FILE=x here and then create a new file board/xilinx/zynq/x.env
Or if you just want to change those variables you listed, you may set CONFIG_IPADDR, CONFIG_SERVERIP, CONFIG_BAUDRATE, in the file you said. But only those that include/env_default.h considers.
My ultimate goal is to use petalinux-devtool (which is yocto devtool - https://docs.yoctoproject.org/ref-manual/devtool-reference.html) to update u-boot so it contains my added environment variables. This tool basically downloads the xilinx u-boot repo and allows changes to be made via the yocto devtool. So that is a little background on why I'm trying to do this modification this way. The recommended approach from my silicon vendor (Xilins) is to use this devtool to "patch" the u-boot source.
Maybe you want to patch include/env_default.h or (too complex?) build an external environment file to load at runtime (if you don't need trust verification) with mkenvimage -r ... and have it put in offset 0xE00000 in your boot media. But then you should add a copy somewhere (at 0?). Curious that your board has CONFIG_SYS_REDUNDAND_ENVIRONMENT=y but no CONFIG_ENV_OFFSET_REDUND.
So long story short, I have the source ready to be patched and built but I don't know exactly what to patch (which source file) so when I boot into u-boot I have the newly added environment variables loaded.
U-Boot is not Perl, but there's more than one way to do it...

Thank you very much Xavier! This reply was very helpful. Yes, you are correct regarding <configs/xilinx_zynq_virt_defconfig>.
What did you mean by the below statement?
*Or if you just want to change those variables you listed, you may setCONFIG_IPADDR, CONFIG_SERVERIP, CONFIG_BAUDRATE, in the file you said.But only those that include/env_default.h considers.*
Specifically, what did you mean by "only those that include/env_default.h"? Looking at env_default.h I don't see much. Are you saying if I add my own CONFIG_xxx environment vars they also have to be in the env_default.h file?
I think patching a source file might be the easiest for me because I'm booting a ramdisk image so I'm not storing any data outside of my image binary so building these variables into the binary boot image seems ideal for me. Also, Xilinx provides a linux image build tool that builds linux images for their parts and this tool allows you to script in software patches to source files for u-boot and linux/kernel during the build process. This seems to fit into their expectations so I am trying to figure out how to "patch" (modify) the u-boot source to have to include some extra environment variables.
So (I think) what I really need to know is what the proper source file to patch and add these environment variables to would be. It's a little weird because there are quite a few environment variables there already I don't want to erase, I just want to append a couple new ones.
So if I add, for example, CONFIG_IPADDR to my configs/xilinx_zynq_virt_defconfig is there anything else I would need to check or do to ensure this flows through the build properly?
I also couldn't find the environment.rst in my docs - took a screenshot below. As an aside I'm using a Xilinx version of u-boot from the following repo.
https://github.com/Xilinx/u-boot-xlnx
[image: image.png]
Thank you again so much for helping me!
Robbie Valentine Electrical Engineer RisingEdgeIndustries (256) 244-4091
On Sat, Jun 11, 2022 at 12:35 PM Xavier Drudis Ferran xdrudis@tinet.cat wrote:
El Fri, Jun 10, 2022 at 11:32:59PM -0700, RisingEdgeIndustries deia:
Hello,
I'm trying to update some of the u-boot environment variables when I
build
my linux Image using petalinux for the zynq 7000 (zedboard).
Hello, not an expert, but I hope I can help and that people correct me i fI was to mislead you.
Looking at the configs folder I found the "xilinx_zynq_virt_defconfig".
So
my first question is the following. Does this file contain the
environment
variables I see when I boot u-boot? I want to add some environment variables for u-boot.
No. You mean configs/xilinx_zynq_virt_defconfig, right ?
This file is a summary of the .config file that the U-Boot project proposes to configure the build for the board.
When you do
make xilinx_zynq_virt_defconfig
the file is copied to .config with the rest of options that are logical consequences of those in the file according to the rules in diverse Kconfig files. The make/autoconf/whatnot machinery gets them in .h files, link files... Makefiles recognize some, etc.
So these are build time options. You can change them interactively (and break things) with make nconfig for example, and if you want to create a summary of .config like those in configs/ do make savedefconfig and you could cp the generated defconfig into configs with the proper name if that was needed.
Environment variables are runtime options.
For example, ipaddr = <my_ipaddr> serverip = <tftp_server_ip> etc....
Yes those look like environment variables, for runtime. Those can be embedded inside the U-Boot binary, and/or U-Boot can read them from different places. That's decided through build time options like those in configs/xilinx_zynq_virt_defconfig.
You may want to read doc/usage/environment.rst
If this file is not the file one would modify could someone point me to
the
correct place?
I'd say this is not the one or only one, but you might get away by adding some CONFIG_ENV_SOURCE_FILE=x here and then create a new file board/xilinx/zynq/x.env
Or if you just want to change those variables you listed, you may set CONFIG_IPADDR, CONFIG_SERVERIP, CONFIG_BAUDRATE, in the file you said. But only those that include/env_default.h considers.
My ultimate goal is to use petalinux-devtool (which is yocto devtool - https://docs.yoctoproject.org/ref-manual/devtool-reference.html) to
update
u-boot so it contains my added environment variables. This tool
basically
downloads the xilinx u-boot repo and allows changes to be made via the yocto devtool. So that is a little background on why I'm trying to do
this
modification this way. The recommended approach from my silicon vendor (Xilins) is to use this devtool to "patch" the u-boot source.
Maybe you want to patch include/env_default.h or (too complex?) build an external environment file to load at runtime (if you don't need trust verification) with mkenvimage -r ... and have it put in offset 0xE00000 in your boot media. But then you should add a copy somewhere (at 0?). Curious that your board has CONFIG_SYS_REDUNDAND_ENVIRONMENT=y but no CONFIG_ENV_OFFSET_REDUND.
So long story short, I have the source ready to be patched and built but
I
don't know exactly what to patch (which source file) so when I boot into u-boot I have the newly added environment variables loaded.
U-Boot is not Perl, but there's more than one way to do it...
participants (2)
-
RisingEdgeIndustries
-
Xavier Drudis Ferran