Use patched version of u-boot Ultrascale+

Dear Forum,

First of all this is my first topic, so excuse me in advance if I ask a simple question at the wrong place (the perfect fit for a forum :slight_smile: ).

I am trying to integrate Mender on a ZynqMP Ultrascale+. The module we use is produced by Enclustra (XU8+ CG4).
As some of you may know, the building process on the Ultrascale+ involves a special flavor of Yocto developed by Xilinx called Petalinux (it is in fact Yocto but with a supplementary layer that masks most of the bitbake operations).
(One of) the nice thing(s) of Petalinux is that it uses u-boot as a bootloader. As this is supported by Mender, it should work :partying_face: ! However, they created their own flavor of u-boot with a different name u-boot-xlnx.
As soon as I try to integrate mender, it complains that we do not provide u-boot but u-boot-xlnx.
Could someone point me towards the way to correct for this issue?

Thank you,

Pi-r

Hi @P3Pierre

This link should help you out.

Drew

Hi @drewmoseley ,

Thanks for the tip! I was able to move forward from there.
The next issue I have is related to the patching of u-boot (from what I got reading the forum posts, this had to be expected for forked version of u-boot :slight_smile: )

First of all, I want to boot from an SD attached to the device. When I configure a Petalinux without Mender, I set my rootfs to /dev/mmcblk1p1.
From what I read, I have to set a series of variables to ensure that the correct device block is targeted by Mender during the build process:
In my u-boot-xlnx_%.bbappend:

MENDER_UBOOT_AUTO_CONFIGURE=“0”
MENDER_DTB_NAME_FORCE=“image.ub”
MENDER_STORAGE_DEVICE_BASE=“/dev/mmcblk1”
MENDER_ROOTFS_PART_A_NUMBER=“p2”
MENDER_ROOTFS_PART_B_NUMBER=“p3”

BOOTENV_SIZE = “0x4000”

I had to set MENDER_ROOTFS_PART_A_NUMBER and MENDER_ROOTFS_PART_B_NUMBER because the build was complaining about finding the correct names.

However, even if it worked for one error, I got the exact same error later in another compilation.
‘MENDER_ROOTFS_PART_A_NUMBER=get_part_number_from_device /dev/mmcblk0_0’'

What do I do wrong?
Thank you in advance for any help!!

I think the MENDER_STORAGE_DEVICE_BASE, MENDER_ROOTFS_PART_A_NUMBER, and MENDER_ROOTFS_PART_B_NUMBER variables need to be global so should be in your local.conf or in a bbclass that is inherited by your local.conf. Putting it in the u-boot bbappend means that only the U-Boot recipe will see those values but they are needed by other recipes as well.

Drew

@drewmoseley Thanks again for the correction. As suggested elsewhere in the discussion, I put these parameters in my machine file.

With all the other modifications I made, I now have this part within my machine file:

INHERIT += “mender-full-ubi”

MENDER_FEATURES_ENABLE_append = " mender-uboot mender-image-sd"
MENDER_FEATURES_DISABLE_append = " mender-grub mender-image-uefi"

Memory card block device location

Memory card with 32GiB of storage.

MENDER_MTDIDS = “nand0=nand_mtd”
MENDER_IS_ON_MTDID = “nand_mtd”
MENDER_MTDPARTS = “mtdparts=nand_mtd:0x100000@0x000000(uboot),0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs),-(ubi)”
IMAGE_FSTYPES_remove = “mtdimg”

MENDER_STORAGE_DEVICE=“/dev/mmcblk1”
MENDER_STORAGE_DEVICE_BASE=“/dev/mmcblk1p”
MENDER_STOGE_TOTAL_SIZE_MB = “30436”
MENDER_ROOTFS_PART_A = “${MENDER_STORAGE_DEVICE_BASE}1”
MENDER_ROOTFS_PART_B = “${MENDER_STORAGE_DEVICE_BASE}2”
MENDER_DATA_PART = “${MENDER_STORAGE_DEVICE_BASE}3”

From my understanding of the log file (log.do_provide_mender_defines), it seems that now I do have an issue with a file that is not present (env/fw_env.c) from which I extracted these parts:

DEBUG: Executing shell function do_provide_mender_defines
+ echo p3-image-dev
+ fgrep mender-auto-provided
+ true
+ fgrep -A8 ‘skip_chars(char *s)’ /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/p3-image-dev/1.0-r0/p3-image-dev-1.0/tools/env/fw_env.c
+ fgrep -q ‘if (isblank(s))’
grep: /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/p3-image-dev/1.0-r0/p3-image-dev-1.0/tools/env/fw_env.c: No such file or directory
+ ‘[’ 0 -eq 0 ‘]’
++ expr 16769024 % ‘(’ 8384512 '
’ 2 ‘)’
+ ‘[’ 0 -ne 0 ‘]’
+ ‘[’ 16769024 -gt 16769024 ‘]’
+ ‘[’ -n ‘’ ‘]’
+ false
++ get_part_number_from_device /dev/mmcblk1p1
++ dev_base=unknown
++ case “$1” in
+++ echo /dev/mmcblk1p1
+++ cut -dk -f2
+++ cut -dp -f2
++ dev_base=1
+++ printf %d 1
++ part=1
++ ‘[’ 0 = 1 ‘]’
++ echo 1
+ MENDER_ROOTFS_PART_A_NUMBER=1
++ get_part_number_hex_from_device /dev/mmcblk1p1
+++ get_part_number_from_device /dev/mmcblk1p1
+++ dev_base=unknown
+++ case “$1” in
++++ echo /dev/mmcblk1p1
++++ cut -dk -f2
++++ cut -dp -f2
+++ dev_base=1
++++ printf %d 1
+++ part=1
+++ ‘[’ 0 = 1 ‘]’
+++ echo 1
++ part_dec=1
+++ printf %X 1
++ part_hex=1
++ ‘[’ 0 = 1 ‘]’
++ echo 1
+ MENDER_ROOTFS_PART_A_NUMBER_HEX=1

From what I read googling for an explanation, this is related to the environment configuration of u-boot. So I guess that I have something else to change but I am a bit lost (again, sorry :expressionless:) as I do not find a solution googling for it…

Thank you again for the time you’ll take to read this reply (and hopefully to provide a solution)

Pi-r

PS: It seems however that the names I provided in the machine file are correctly propagated in the future-but-not-working-yet defines file! :partying_face:

My guess is that is part of the U-Boot automatic patching. Presumably it relies on the contents of that file to determine the actual settings for your board. That may mean that your fork will need to use manual patching. @kacf any comments?

Drew

I already disabled the automatic patching as advised in the u-boot fork part of the documentation…
In fact enabling or disabling it doesn’t change the outcome…

Which version of U-Boot is this? Is there a public repository I could look at?

Hello @kacf,

This is the version make by Xilinx. GitHub - Xilinx/u-boot-xlnx at xilinx-v2020.2

Thank you for your help!

I assume you have followed Mender documentation and put this somewhere:

require recipes-bsp/u-boot/u-boot-mender.inc

But is it in the wrong file? It looks like it’s trying to apply U-Boot steps to an image recipe. In which files have you added this?

Hello @kacf,

I put it into my image definition file which is in a dedicated layer for our build… Grrrrr… I’ll move it into the forked bb recipe.

Pierre

Hello again @kacf,

It seems that the issue was exactly the one you suggested. The suspicious line was present in two files:

  1. In the image file (from a previous attempt and I forgot to remove it)
  2. In the recipe for the forked u-boot from xilinx.

Once I removed the faulty line, the compilation is starting (still waiting to check that I can reach the end of the process without any issue).

Yours,

Pierre

Great! Thanks @kacf, now I can start the compilation.
As prescribed in the documentation, I first tried with

MENDER_UBOOT_AUTO_CONFIGURE=“1”

But I had an error:

ERROR: u-boot-xlnx-v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0 do_configure: U-Boot configuration xilinx_zynqmp_virt_defconfig has setting:
CONFIG_MTDIDS_DEFAULT=“”
but Mender expects:
CONFIG_MTDIDS_DEFAULT=“nand0=nand_mtd”

However, when I looked in

u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/git/configs/xilinx_zynqmp_virt_defconfig

I can see that the patch has been applied:

CONFIG_ENV_SIZE=0x8000
CONFIG_MTDIDS_DEFAULT=“nand0=nand_mtd”
CONFIG_MTDPARTS_DEFAULT=“mtdparts=mtdparts=nand_mtd:0x100000@0x000000(uboot),0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs),-(ubi)”
CONFIG_ENV_IS_IN_UBI=y
CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
CONFIG_ENV_UBI_PART=“ubi”
CONFIG_ENV_UBI_VOLUME=“u-boot-env-1”
CONFIG_ENV_UBI_VOLUME_REDUND=“u-boot-env-2”
CONFIG_BOOTCOUNT_LIMIT=y
CONFIG_BOOTCOUNT_ENV=y

and the variable has been correctly set. Therefore, there is certainly something that I am missing.
I extracted the patch as explained in the documentation. I has no error doing so and the extracted patch is:

diff -r -u /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/old-src/configs/xilinx_zynqmp_virt_defconfig /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/git/configs/xilinx_zynqmp_virt_defconfig
— /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/old-src/configs/xilinx_zynqmp_virt_defconfig 2021-08-12 13:16:35.261127648 +0000
+++ /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/git/configs/xilinx_zynqmp_virt_defconfig 2021-08-12 13:17:02.182196631 +0000
@@ -138,3 +138,36 @@
CONFIG_SPL_GZIP=y
CONFIG_OF_LIBFDT_OVERLAY=y
CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_ENV_SIZE=0x8000
+CONFIG_MTDIDS_DEFAULT=“nand0=nand_mtd”
+CONFIG_MTDPARTS_DEFAULT=“mtdparts=mtdparts=nand_mtd:0x100000@0x000000(uboot),0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs),-(ubi)”
+# CONFIG_ENV_IS_NOWHERE is not set
+# CONFIG_ENV_IS_IN_EEPROM is not set
+# CONFIG_ENV_IS_IN_FAT is not set
+# CONFIG_ENV_IS_IN_EXT4 is not set
+# CONFIG_ENV_IS_IN_FLASH is not set
+# CONFIG_ENV_IS_IN_MMC is not set
+# CONFIG_ENV_IS_IN_NAND is not set
+# CONFIG_ENV_IS_IN_NVRAM is not set
+# CONFIG_ENV_IS_IN_ONENAND is not set
+# CONFIG_ENV_IS_IN_REMOTE is not set
+# CONFIG_ENV_IS_IN_SPI_FLASH is not set
+CONFIG_MTD_UBI=y
+CONFIG_ENV_IS_IN_UBI=y
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
+CONFIG_ENV_UBI_PART=“ubi”
+CONFIG_ENV_UBI_VOLUME=“u-boot-env-1”
+CONFIG_ENV_UBI_VOLUME_REDUND=“u-boot-env-2”
+CONFIG_CMD_UBIFS=y
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_BOOTCOUNT_GENERIC is not set
+# CONFIG_BOOTCOUNT_EXT is not set
+# CONFIG_BOOTCOUNT_AM33XX is not set
+# CONFIG_BOOTCOUNT_RAM is not set
+# CONFIG_BOOTCOUNT_I2C is not set
+# CONFIG_BOOTCOUNT_AT91 is not set
+# CONFIG_BOOTCOUNT_BOOTLIMIT is not set
+# CONFIG_BOOTCOUNT_ALEN is not set
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
+# CONFIG_BOOTCOMMAND is not set
Binary files /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/old-src/.git/index and /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/git/.git/index differ
diff -r -u /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/old-src/include/config_defaults.h /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/git/include/config_defaults.h
— /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/old-src/include/config_defaults.h 2021-08-12 13:16:35.362127907 +0000
+++ /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/git/include/config_defaults.h 2021-08-12 13:17:02.008196185 +0000
@@ -10,3 +10,5 @@
#define CONFIG_DEFAULTS_H

#endif
+#define MTDIDS_DEFAULT CONFIG_MTDIDS_DEFAULT
+#define MTDPARTS_DEFAULT CONFIG_MTDPARTS_DEFAULT
diff -r -u /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/old-src/include/config_distro_bootcmd.h /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/git/include/config_distro_bootcmd.h
— /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/old-src/include/config_distro_bootcmd.h 2021-08-12 13:16:35.362127907 +0000
+++ /home/pdaye/workspace/P3Lab/build/p3lab_builder/petalinux/projects/p3-uz4cg_kol_2020.2/build/tmp/work/uz4cg_kol-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/git/include/config_distro_bootcmd.h 2021-08-12 13:17:02.013196198 +0000
@@ -486,7 +486,6 @@
“done\0”

#ifndef CONFIG_BOOTCOMMAND
-#define CONFIG_BOOTCOMMAND “run distro_bootcmd”
#endif

#endif /* _CONFIG_CMD_DISTRO_BOOTCMD_H */

I hope that this will help someone finds the issue!
Thanks again for the very nice support!

Pierre

@kacf @drewmoseley no Idea on the reason why I have this issue?

No idea here. Sorry.

This is a long shot, but could you try removing this and this. I’m working on support for post-dunfell branches, and more recent versions of U-Boot do not work with this section. The reason I say it’s a long shot is that I would only expect this problem on v2020.10 and newer, but you never know.