# Yocto how to build mender with external device tree

**URL:** <https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423>\
**Category:** General Discussions\
**Tags:** yocto\
**Created:** [March 27, 2019, 8:31pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423 "2019-03-27T20:31:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yury](https://avatars.discourse-cdn.com/v4/letter/y/f19dbf/32.png) [@Yury](https://hub.mender.io/u/Yury)\
**Post date:** [March 27, 2019, 8:31pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/1 "2019-03-27T20:31:19Z")

</div>

I am trying to setup mender for xilinx zynq device. Officially XIlinx provides [meta-xilinx](https://github.com/Xilinx/meta-xilinx/tree/rel-v2018.3) and [meta-xilinx-tools](https://github.com/Xilinx/meta-xilinx-tools/tree/rel-v2018.3) 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 ?

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [March 27, 2019, 8:43pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/2 "2019-03-27T20:43:26Z")

</div>

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,

> <https://github.com/mendersoftware/meta-mender/blob/master/meta-mender-core/recipes-bsp/u-boot/u-boot-mender-common.inc#L109>

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,

> <https://github.com/mendersoftware/meta-mender/blob/master/meta-mender-core/recipes-bsp/u-boot/u-boot-mender-common.inc#L86-L92>

---

<div class="post-metadata">

**Author:** ![Yury](https://avatars.discourse-cdn.com/v4/letter/y/f19dbf/32.png) [@Yury](https://hub.mender.io/u/Yury)\
**Post date:** [March 27, 2019, 9:30pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/3 "2019-03-27T21:30:29Z")

</div>

It does not help. Check for KERNEL\_DEVICETREE in task do\_provide\_mender\_defines and this triggered by

> <https://github.com/mendersoftware/meta-mender/blob/rocko-v2018.03/meta-mender-core/recipes-bsp/u-boot/u-boot-mender-common.inc#L133>

do\_provide\_mender\_defines starts even if i set MENDER\_UBOOT\_AUTO\_CONFIGURE = “0”

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [March 27, 2019, 9:38pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/4 "2019-03-27T21:38:31Z")

</div>

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,

```auto
    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

```

---

<div class="post-metadata">

**Author:** ![Yury](https://avatars.discourse-cdn.com/v4/letter/y/f19dbf/32.png) [@Yury](https://hub.mender.io/u/Yury)\
**Post date:** [March 27, 2019, 9:50pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/5 "2019-03-27T21:50:02Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [March 27, 2019, 10:18pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/6 "2019-03-27T22:18:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [March 27, 2019, 10:30pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/7 "2019-03-27T22:30:36Z")

</div>

I have moved this topic to

[https://hub.mender.io/c/general-discussions](https://hub.mender.io/c/general-discussions)

which is more appropriate.

---

<div class="post-metadata">

**Author:** ![brymat](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/brymat/32/271_2.png) [@brymat](https://hub.mender.io/u/brymat)\
**Post date:** [May 29, 2019, 9:39pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/8 "2019-05-29T21:39:19Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![samlewis](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/samlewis/32/393_2.png) [@samlewis](https://hub.mender.io/u/samlewis)\
**Post date:** [May 30, 2019, 6:11am UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/9 "2019-05-30T06:11:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![brymat](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/brymat/32/271_2.png) [@brymat](https://hub.mender.io/u/brymat)\
**Post date:** [June 3, 2019, 3:34pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/10 "2019-06-03T15:34:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brymat](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/brymat/32/271_2.png) [@brymat](https://hub.mender.io/u/brymat)\
**Post date:** [June 3, 2019, 11:18pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/11 "2019-06-03T23:18:59Z")

</div>

@samlewis

I found the issue on my side.

> PROVIDES\_${PN} = “kernel-devicetree”

should be:

> RPROVIDES\_${PN} = “kernel-devicetree”

Thanks again for the suggestions.

---

<div class="post-metadata">

**Author:** ![samlewis](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/samlewis/32/393_2.png) [@samlewis](https://hub.mender.io/u/samlewis)\
**Post date:** [June 3, 2019, 11:40pm UTC](https://hub.mender.io/t/yocto-how-to-build-mender-with-external-device-tree/423/12 "2019-06-03T23:40:40Z")

</div>

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