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

Xavier Drudis Ferran xdrudis at tinet.cat
Sat Jun 11 21:35:29 CEST 2022


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... 


More information about the U-Boot mailing list