cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Visitor
Visitor
980 Views
Registered: ‎07-01-2020

Include U-Boot utils "fw_setenv, fw_printenv" in Petalinux 2020.1 rootfs

Dear all,

I was following the following threads and suggestions to include the U-Boot environmental variable utils into the created RootFS:

1)   https://forums.xilinx.com/t5/Embedded-Linux/How-to-include-U-Boot-s-quot-fw-printenv-quot-tool-in-Petalinux/m-p/732538#M17477

2)   https://forums.xilinx.com/t5/Embedded-Linux/How-to-include-U-Boot-s-quot-fw-printenv-quot-tool-in-Petalinux/td-p/770629

Unfortunately, these do not work (anymore?) with Petalinux 2020.1.

>> For 1), I get the following error:

ERROR: Task do_env_only does not exist for target virtual/bootloader (/home/sarah/petalinux_workspace/myZynq/components/yocto/layers/meta-xilinx/meta-xilinx-bsp/recipes-bsp/u-boot/u-boot-xlnx_2020.1.bb:do_env_only)

>> For 2), please see the log file attached.

I would very much appreciate some help. It would be mainly necessary, to be able to change the MAC-Address from an already running Linux environment. Thanks!

0 Kudos
Reply
11 Replies
702 Views
Registered: ‎02-24-2020

The second method is the the way you are supposed to do things. You can also invoke the recipe directly via:

petalinux-build -c u-boot-fw-utils

U-Boot fw-utils is actually really part of the U-Boot source, so it's going to want to use a U-boot config for your platform so it can have a reference to the default env in case one does not exist. In this case the u-boot-fw-utils is using a different version of U-boot. I'm looking in petalinux_install_dir/components/yocto/source/arm/layers/core/meta/recipes-bsp/u-boot/ and I see u-boot-fw-utils_2018.07.bb, meaning that recipe is based on U-Boot version 2018.07. 

Xilinx renamed some defconfigs in the most recent version of U-Boot.

https://github.com/Xilinx/u-boot-xlnx/commit/412e20a2c5f7a1cd288f62e139d888b78b6542a1

So when building this older version of fw-utils in U-boot, it's not going to find your config file. If you look at the "u-boot-common_" file include in the bb file you can see SRCREV is set (if yours matches mine):

SRCREV = "8c5d4fd0ec222701598a27b26ab7265d4cee45a

which matches the U-boot v2018.07 upstream tag. Since your current config name didn't exist in that version, the build will fail.

So the quick solution here is to make a bbappend for u-boot-fw-utils recipe and up the SRCREV to point to v2020.01 (U-Boot version used in PetaLinux 2020.1). You might also need to make other changes if any of the u-boot-fw-utils build methods in the recipe are not compatible with the newer version, but you'll need to change the version first to see.

This hasn't been updated probably because as Xilinx indicated in those other threads, it isn't officially supported by them. However, with a few tweaks there should be no issues in getting this to work, it's pretty standard.

Ken Sloat - Embedded Software Engineer
https://www.designlinxhs.com
Tags (3)
0 Kudos
Reply
717 Views
Registered: ‎02-24-2020

#2 is the the way you are supposed to do things. You can also invoke the recipe directly via:

 

petalinux-build -c u-boot-fw-utils

 

U-Boot fw-utils is actually really part of the U-Boot source, so it's going to want to use a U-boot config for your platform so it can have a reference to the default env in case one does not exist. In this case the u-boot-fw-utils is using a different version of U-boot. I'm looking in petalinux_installation_path/components/yocto/source/arm/layers/core/meta/recipes-bsp/u-boot/ and I see u-boot-fw-utils_2018.07.bb, meaning that recipe is based on U-Boot version 2018.07. 

Xilinx renamed some defconfigs in the most recent version of U-Boot.

https://github.com/Xilinx/u-boot-xlnx/commit/412e20a2c5f7a1cd288f62e139d888b78b6542a1

So when building this older version of fw-utils in U-boot, it's not going to find your config file. If you look at the "u-boot-common_" file include in the bb file you can see SRCREV is set (if yours matches mine):

 

SRCREV = "8c5d4fd0ec222701598a27b26ab7265d4cee45a

which matches the U-boot v2018.07 upstream tag. Since your current config name didn't exist in that version, the build will fail.

 

So the quick solution here is to make a bbappend for u-boot-fw-utils recipe and up the SRCREV to point to v2020.01 (U-Boot version used in PetaLinux 2020.1). You might also need to make other changes if any of the u-boot-fw-utils build methods in the recipe are not compatible with the newer version, but you'll need to change the version first to see.

This hasn't been updated probably because as Xilinx indicated in those other threads, it isn't officially supported by them. However, with a few tweaks there should be no issues in getting this to work, it's pretty standard.

Ken Sloat - Embedded Software Engineer
https://www.designlinxhs.com
0 Kudos
Reply
934 Views
Registered: ‎02-24-2020

Hi @istitaki 

I've tried to answer the question here in the post but the forum keeps flagging my message as spam and removing it. I do have the answer to your problem, so hopefully the mods can restore my post shortly so you can see the solution.

@shabbirk please take a look at this, I'm trying to answer the question here but the post keeps getting removed. The only external link I'm posting is to the Xilinx Github so not sure why it keeps autoremoving it. This isn't the first time I've seen that happen.

 

Ken Sloat - Embedded Software Engineer
https://www.designlinxhs.com
0 Kudos
Reply
Visitor
Visitor
916 Views
Registered: ‎07-01-2020

@ksloatdesignlinx  Thanks for the reply; this sounds very good. I will wait for the mods to "solve" the issue. Thanks!

0 Kudos
Reply
851 Views
Registered: ‎02-24-2020

Let's see if I can post this again without it getting flagged:

Your second method is the the way you are supposed to include it. You can also invoke the recipe directly via:

petalinux-build -c u-boot-fw-utils

U-Boot fw-utils is actually really part of the U-Boot source, so it's going to want to use a U-boot config for your platform so it can have a reference to the default env in case one does not exist. In this case the u-boot-fw-utils is using a different version of U-boot. I'm looking in petalinux_install_dir}components/yocto/source/arm/layers/core/meta/recipes-bsp/u-boot/ and I see u-boot-fw-utils_2018.07.bb, meaning that recipe is based on U-Boot version 2018.07. 

Xilinx renamed some defconfigs in the most recent version of U-Boot.

https://github.com/Xilinx/u-boot-xlnx/commit/412e20a2c5f7a1cd288f62e139d888b78b6542a1

So when building this older version of fw-utils in U-boot, it's not going to find your config file. If you look at the "u-boot-common_" file include in the bb file you can see SRCREV is set (if yours matches mine):

SRCREV = "8c5d4fd0ec222701598a27b26ab7265d4cee45a

which matches the U-boot v2018.07 upstream tag. Since your current config name didn't exist in that version, the build will fail.

So the quick solution here is to make a bbappend for u-boot-fw-utils recipe and up the SRCREV to point to v2020.01 (U-Boot version used in PetaLinux 2020.1). You might also need to make other changes if any of the u-boot-fw-utils build methods in the recipe are not compatible with the newer version, but you'll need to change the version first to see.

This hasn't been updated probably because as Xilinx indicated in those other threads, it isn't officially supported by them. However, with a few tweaks there should be no issues in getting this to work, it's pretty standard.

Ken Sloat - Embedded Software Engineer
https://www.designlinxhs.com
0 Kudos
Reply
Visitor
Visitor
839 Views
Registered: ‎07-01-2020

@ksloatdesignlinx  fortunately, I can see your feedback! Thanks!

I have checked the files as you suggested and as it seems in Petalinux 2020.1 "u-boot-fw-utils_2019.07", so recipes based on U-Boot version 2019.07 is present. I have also checked the "u-boot-common.inc" file, which contains the SRCREV definition. The values are different, but I assume this is because the version diff you-me have. I have attached my "u-boot-common.inc" file.

I have tried to build it as you suggested; the following error occurrs; I am using a Zynq based board, but not manufactured by Xilinx. According to UG1144, the default machine can be left as it is.

*** Can't find default configuration "arch/../configs/xilinx_zynq_virt_defconfig"!

Unfortunately, i have problems with the rest you suggested. I understand what to do, but not how to do it. I would appreciate your support.

Is it enough to create a .bbappend file simply with an adapted SRCREV value? Where to create this append file?

Is it somehow possible to include it directly into the RootFS, without building U-Boot? I remember that the "u-boot-utils" could be installed in an Ubuntu based FS simply by using its APT. This did not require any rebuild of U-Boot, just a .conf file to define the MTD partition(s) and properties.

Many thanks in advance!

0 Kudos
Reply
799 Views
Registered: ‎02-24-2020

It's not that the entire U-boot is build for fw utils, but rather that the source code for it lies in the source tree and it also relies on defconfigs and default environment to the U-Boot source is needed to build all this. As you mentioned, fw utils does also require a conf file to tell it where the env is, but this is for runtime use - what we are talking about is compile time to define the default environment and the source itself.

Changing SRC_URI along will be mandatory because the defconfig for your system was not shipped prior to U-Boot 2020.1. You could also append the U-boot recipe to include your specific defconfig file instead, but I think that changing the SRC_URI might be easier. It's possible there may be other build issues but you won't really know this until you solve the first issue - and if there were you could likewise use your append to modify them.

As far as creating a bbappend file, it's basically just creating a file with the same name as the recipe (or with a wildcard) in your petalinux meta-user directory except with the extension .bbappend and adding whatever statement you like (like SRC_URI = "xxxx") in it. This file will be automatically appended to the main recipe by the Yocto build system, which essentially allows you to override variables if they have already been set.

In this case, making a file called "u-boot-fw-utils_%.bbappend" within your PetaLinux project in "project-spect/meta-user/recipes-bsp/u-boot/" would be what you want to do.

Here's some extensive documentation on bbappend files:

https://www.yoctoproject.org/docs/latest/dev-manual/dev-manual.html#using-bbappend-files

Ken Sloat - Embedded Software Engineer
https://www.designlinxhs.com
0 Kudos
Reply
Visitor
Visitor
769 Views
Registered: ‎07-01-2020

@ksloatdesignlinx Thanks for your support.

I have created the .bbappend file and adapted the SRC_URI to the newest tag from Xilinx. This was not enough. I also played with the GIT link and pointed to the 2020.01 (and even Master branch) of the Xilinx U-Boot repository. Always some u-boot-fw-utils package is checked out (something is always downloaded), but the build fails always reporting, that "do_..." doesnt exist.

So to temporarily overcome this issue, I did the followings:

  • I have checked out the latest U-Boot 2020.01 maintained by Xilinx
  • used the latest OS arm-linux-gnueabihf- cross-compiler (7.5.0) to build the envtools, as documented on Denx website or even in the Readme file in the U-Boot source /tools/env/. Make configuration used xilinx_zynq_virt_defconfig, see Xilinx "Build U-Boot" confluence site.
  • I added the compiled binary and adapted fw_env.config, using simply the Petalinux function for adding precompiled apps. As the binary is already stripped, dont forget to add INSANE_SKIP_${PN} = "already-stripped" in the .bb script, before do_install {..}. Of course, the .bb file must be adapted to install the files.
  • => It is working

I know, that this temporary solution is not a clean one, because a binary is added to the RootFs, that was compiled with another compiler version. However, it is working, so as it seems compiling envtools with an arm cross-compiler with v7.5.0 and building the RootFs with Petalinux (gcc v9.2.0) seems to be OK.

I will work on fining out how to cleanly make this, but until then I stick to this workaround. Any opinions?

0 Kudos
Reply
745 Views
Registered: ‎02-24-2020

Hi @istitaki 

Could you upload or post the full error log? Note you will want to build u-boot-fw-utils using the #2 method you had in your original post (or even better for testing the direct petalinux command I mentioned) , not the #1 method. 

Ken Sloat - Embedded Software Engineer
https://www.designlinxhs.com
0 Kudos
Reply
743 Views
Registered: ‎02-24-2020

Oh and I just noticed this, u-boot-fw-utils is based on the upstream U-boot project, not the Xilinx repository, so if you are using tags from Xilinx they would fail:

In mine:

 

SRCREV = "8c5d4fd0ec:222701598a27b26ab7265d4cee45a3"

SRC_URI = "git://git.denx.de/u-boot.git \
           file://CVE-2018-1000205-1.patch \
           file://CVE-2018-1000205-2.patch \
"

S = "${WORKDIR}/git"

 

 

So you want the tag "v2020.01" or the sha "0b0c6af38738f2c132cfd41a240889acaa031c8f" - this corresponds to the same upstream U-boot version Xilinx released PetaLinux 2020.1 with.

It's possible those patches there may no longer apply either so you might need to remove them but first try the correct SRCREV for the upstream repo in your append and see what happens. Please post any error logs you see.

Ken Sloat - Embedded Software Engineer
https://www.designlinxhs.com
0 Kudos
Reply
Adventurer
Adventurer
606 Views
Registered: ‎05-30-2018

I ran into the exact same problem with this just recently of trying to enable uboot.env in Petalinux 2020.1. I did what was recommended by Ken's post and it seems to work.

In my scenario, Petalinux was trying to use U-boot 2019.07 instead of U-boot 2020.1 for my u-boot-fw-utils%.bbappend bit-bake recipe. I noticed that my u-boot-common.inc was including several patches to U-boot which were specific to 2019.07:

SRCREV = "e5aee22e4be75e75a854ab64503fc80598bc2004"

SRC_URI = "git://git.denx.de/u-boot.git \
file://0001-CVE-2019-13103.patch \
file://0002-CVE-2019-13104.patch \
file://0003-CVE-2019-13105.patch \
file://0004-CVE-2019-13106.patch \
file://0005-CVE-2019-14192-14193-14199.patch \
file://0006-CVE-2019-14197-14200-14201-14202-14203-14204.patch \
file://0007-CVE-2019-14194-14198.patch \
file://0008-CVE-2019-14195.patch \
file://0009-CVE-2019-14196.patch \
"

So what I did was modify my  u-boot-fw-utils%.bbappend  file to do two things:

a) use U-boot 2020.1 via specifying SRCREV

b) remove the effect of these patches

 

SRCREV = "0b0c6af38738f2c132cfd41a240889acaa031c8f"

SRC_URI += "git://git.denx.de/u-boot.git"
SRC_URI += " file://fw_env.config"

# remove patches introduced in older version
SRC_URI_remove = "file://0001-CVE-2019-13103.patch"
SRC_URI_remove = "file://0002-CVE-2019-13104.patch"
SRC_URI_remove = "file://0003-CVE-2019-13105.patch"
SRC_URI_remove = "file://0004-CVE-2019-13106.patch"
SRC_URI_remove = "file://0005-CVE-2019-14192-14193-14199.patch"
SRC_URI_remove = "file://0006-CVE-2019-14197-14200-14201-14202-14203-14204.patch"
SRC_URI_remove = "file://0007-CVE-2019-14194-14198.patch"
SRC_URI_remove = "file://0008-CVE-2019-14195.patch"
SRC_URI_remove = "file://0009-CVE-2019-14196.patch"


do_install_append() {
install -d ${D}${sysconfdir}
install -m 0644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config
}
PACKAGE_ARCH = "${MACHINE_ARCH}"

After doing this, I was able to build the fw_setenv and fw_getenv into my root file system. Note that if you don't remove these patches you'll most likely get into a build error which was what happened to me. I think one thing to consider here is to if there are any patches that need to be applied that are specific to U-boot 2020.1 but I'm not sure.

Hope this helps.