Yocto how to build mender with external device tree

I am trying to setup mender for xilinx zynq device. Officially XIlinx provides meta-xilinx and meta-xilinx-tools these layers are intend for creation HW specific artifacts. One of these - device tree blob. It means that xilinx meta layers are generating dts files in build time and these are not included in kernel source tree. Therefore I am not defining KERNEL_DEVICETREE in my machine config file.

Problem:
mender meta layer checks KERNEL_DEVICETREE variable and triggers the error:
ERROR: u-boot-xlnx-v2018.01-xilinx-v2018.3+gitAUTOINC+d8fc4b3b70-r0 do_provide_mender_defines: Did not find a dtb specified in KERNEL_DEVICETREE

What could be the solution in this case ? How to setup mender to use dts files which are not in kernel source tree ?

If the integration you are trying to perform relies on “full automatic patching of U-Boot”, then this variable matters.

If you are trying to integrated with

 MENDER_UBOOT_AUTO_CONFIGURE = "0"

Then you can set anything you like here as it will not be used, and just needs to be defined to satisfy the defines.

Otherwise this line probably needs to be patched,

To provide a MENDER_DTB_NAME which takes precedence of KERNEL_DEVICETREE if already defined.

There is already similar code for the Linux kernel image type,

It does not help. Check for KERNEL_DEVICETREE in task do_provide_mender_defines and this triggered by

do_provide_mender_defines starts even if i set MENDER_UBOOT_AUTO_CONFIGURE = “0”

Yes but in the case of

MENDER_UBOOT_AUTO_CONFIGURE = “0”

you it does not really matter what KERNEL_DEVICETREE is set to as it will not be used later. Meaning you can set it to

  KERNEL_DEVICETREE = "whatever"

This will silence u-boot-mender-common.inc error, but could potentially trigger an error elsewhere.

But the proper solution is to provide a patch that implements

" To provide a MENDER_DTB_NAME which takes precedence of KERNEL_DEVICETREE if already defined."

Something like,

    if [ -n "${MENDER_MENDER_DTB_NAME_FORCE}" ]; then
        MENDER_DTB_NAME="${MENDER_MENDER_DTB_NAME_FORCE}"
    else
        MENDER_DTB_NAME=$(mender_get_clean_kernel_devicetree)
    fi

In my case i dont use separate DTB, but it included into FIT image within kernel. But seems mender always require that DTB should be set.
I will try to patch the code for my needs…

But seems mender always require that DTB should be set.

Yes, and actually this should not be the case when MENDER_UBOOT_AUTO_CONFIGURE = "0" is used because in this case one could just write a dummy value to it to not bother users.

Feel free to create a PR if you figure out something.

I have moved this topic to

https://hub.mender.io/c/general-discussions

which is more appropriate.

@Yury

Did you make further progress on this? I have managed to get u-boot and u-boot-fw-utils building however Yocto can not build the rootfs. I get the following error:

Error:
Problem: conflicting requests

  • nothing provides kernel-devicetree needed by packagegroup-core-boot=1.0-r17.plnx_zynq7

I assume Mender is pulling in this requirement?

Cheers,
Bryan

Hey Bryan,

I had a similar issue and solved it by adding

  • unset KERNEL_DEVICETREE to my recipes-kernel/linux/linux-xlnx_%.bbappend to stop the kernel trying to build my dtb file.

  • PROVIDES_${PN} = "kernel-devicetree" to my recipes-bsp/device-tree/device-tree.bbappend to tell Mender that the external device tree can come from the external device-tree recipe.

  • Adding device-tree to IMAGE_INSTALL

This would be much easier (and a bit more elegant) if Mender supported a way of adding a dtb file that isn’t generated from the kernel (the suggestion of MENDER_MENDER_DTB_NAME_FORCE seems good to me!).

1 Like

Thanks for the reply Sam. Unfortunately those steps didn’t quite work for me. I admit I am pretty new at using Yocto though and may not have made the changes in the right location. Here are the files I modified (Note that I am using the Petalinux 2018.3 tools provided by Xilinx):

  • project-spec/meta-user/conf/petalinuxbsp.conf:

IMAGE_INSTALL_append = " device-tree"

  • project-spec/meta-user/recipes-bsp/device-tree/device-tree.bbappend:

PROVIDES_${PN} = “kernel-devicetree”

  • project-spec/meta-user/recipes-kernel/linux/linux-xlnx_%.bbappend :

unset KERNEL_DEVICETREE

I have already made (I believe) the suggested patch from mirzak to MENDER_MENDER_DTB_NAME_FORCE.

What did work for me was patching meta-mender-core/classes/mender-setup-image.inc to remove the dependency on kernel-image and kernel-devicetree. I realize this isn’t a solution moving forward but I am trying to evaluate whether mender will work for my application or not.

@samlewis

I found the issue on my side.

PROVIDES_${PN} = “kernel-devicetree”

should be:

RPROVIDES_${PN} = “kernel-devicetree”

Thanks again for the suggestions.

Ah yes, sorry about that. It should indeed be RPROVIDES, not PROVIDES… copy and paste error on my part!