In recent months, some I.MX customers hope to compile u-boot-fw-utils in yocto and get fw_printenv & fw_setenv tools.
Although there are u-boot-fw-utils bblayers in Yocto recipes, by default, u-boot-fw-utils is not based on u-boot-imx, but downloaded from the u-boot source website, when using bitbake When u-boot-fw-utils compiles it, it will fail to compile.
For example:
# cd ~/imx-yocto-bsp-5.4.3_1.0.0
# DISTRO=fsl-imx-fb MACHINE=imx6sxsabresd source imx-setup-release.sh -b build_sabresd
# bitbake u-boot-fw-utils -c compile
If changing .config to be mx6sxsabresd_optee_defconfig in the top directory of u-boot source code, new errors will occur, like descriptions in the link:
https://community.nxp.com/message/1318081?commentID=1318081#comment-1318081
The root cause is that the u-boot is not u-boot-imx.
If we did the test below, it is easy to validate it.
# bitbake u-boot-imx -c compile
After compilation is done, u-boot-imx source code will be released .
Replace u-boot source code in u-boot-fw-utils directory with u-boot-imx source code. Then continue to compile u-boot-fw-utils
# bitbake u-boot-fw-utils -c compile
We will find it can be compiled successfully.
This shows that when u-boot-fw-utils is compiled, the downloaded u-boot source code must be u-boot-imx.
In order to achieve this, we need to add recipes to yocto's u-boot-imx, and we can successfully compile fw_printevn and fw_setenv through the bitbake command.
Please follow these steps to add u-boot-fw-utils for i.mx to yocto!
# DISTRO=fsl-imx-fb MACHINE=imx6sxsabresd source imx-setup-release.sh -b build_sabresd
# bitbake u-boot-imx-fw-utils -c compile
# bitbake u-boot-imx-fw-utils -c install
Then you will get fw_printenv & fw_setenv
[Comment]
If i.MX users are using other version of linux BSP, she only need to modify the following content of u-boot-imx-common_2019.04.inc to compile u-boot-fw-utils.
……
LIC_FILES_CHKSUM = "file://Licenses/gpl-2.0.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263"
UBOOT_SRC ?= "git://source.codeaurora.org/external/imx/uboot-imx.git;protocol=https"
SRCBRANCH = "lf-5.4.y_v2019.04"
SRC_URI = "${UBOOT_SRC};branch=${SRCBRANCH} \
"
SRCREV = "228843cdf5435d4bd69f42a6015f78761ff4cc0d"
……
Then compile it following above steps.
Example for L4.14.98_2.0.0:
1.Copy u-boot-imx-common_2019.04.inc & u-boot-imx-fw-utils_2019.04.bb to
~/imx-release-bsp-4.14.98-2.0.0/sources/meta-fsl-bsp-release/imx/meta-bsp/recipes-bsp/u-boot/
2.Rename files name according to u-boot version
u-boot-imx-common_2018.03.inc
u-boot-imx-fw-utils_2018.03.bb
3.Modifying u-boot-imx-common_2018.03.inc
In the directory, there is u-boot-imx_2018.03.bb file, open it, and find the link of u-boot and check sum, and use lines below to replace those lines in u-boot-imx-common_2018.03.inc
In u-boot-imx_2018.03.bb file:
……
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://Licenses/gpl-2.0.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263"
UBOOT_SRC ?= "git://source.codeaurora.org/external/imx/uboot-imx.git;protocol=https"
SRCBRANCH = "imx_v2018.03_4.14.98_2.0.0_ga"
SRC_URI = "${UBOOT_SRC};branch=${SRCBRANCH}"
SRCREV = "87a19df5e462f1f63e8a6d2973c7fb9e95284d04"
……
Then in u-boot-imx-common_2018.03.inc, there is the same contents as above:
Save it and exit. Go back to the top directory of yocto: ~/imx-release-bsp-4.14.98-2.0.0
# cd ~/imx-release-bsp-4.14.98-2.0.0
# DISTRO=fsl-imx-fb MACHINE=imx6sxsabresd source fsl-setup-release.sh -b build_sabresd
# bitbake u-boot-imx-fw-utils -c compile
# bitbake u-boot-imx-fw-utils -c install
The same method can be used for other Linux BSP versions.
NXP TIC Team
Weidong Sun
05/28/2020