Build Device Tree Overlays from my layer

Step by step:

  1. I copy existing file from device-tree-overlays and don’t change any line
    cp colibri-imx8x_dsihdmi_overlay.dts colibri-imx8x_dsiedp_overlay.dts

  2. Add in my layer recipes-kernel/linux/device-tree-overlays_git.bbappend

it copy colibri-imx8x_dsiedp_overlay.dts to build folder and add to Makefile

TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT_apalis-imx8 = "colibri-imx8x_panel-res-touch-7inch_overlay.dtbo colibri-imx8x_dsiedp_overlay.dtbo"

FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://colibri-imx8x_dsiedp_overlay.dts"

do_configure:prepend () {
    cp ${WORKDIR}/colibri-imx8x_dsiedp_overlay.dts ${S}

    sed -i -e 's,colibri-imx8x_vga-640x480_overlay.dtbo,colibri-imx8x_vga-640x480_overlay.dtbo\ndtb-y += colibri-imx8x_dsiedp_overlay.dtbo,g'  ${S}/Makefile
}
  1. bitbake device-tree-overlays -c do_compile

  2. got to work directory
    cd oe-core/build/tmp/work/colibri_imx8x-tdx-linux/device-tree-overlays/toradex_5.15-2.2.x-imx+gitAUTOINC+053445557b-r0/git

  3. I found colibri-imx8x_dsiedp_overlay.dts and found my changes in Makefile
    but do_compile don’t build my file

What is wrong ? What build dtbo files and where add my custom file ?

Hi @MariusM !

I created a layer just to test adding custom Device Tree Overlay to a Yocto build.

I just tested the same layer on BSP 6 (branch kirkstone-6.x.y of manifest tdxref/default.xml, specifically at commit b85f89d19dbf6e0c503caee6415cb11c507d77dd) and it worked. Here is how I did it:

First I created the layer and the bbappend inside it. You can use tools like bitbake-layers to create the layer and recipetool to create the bbappend targeting the specific original recipe you need. In your case (Verdin iMX8MP), the original recipe will be device-tree-overlays_git.bb, as you already correctly did and is also pointed out in our documentation Device Tree Overlays (Linux) | Toradex Developer Center.

meta-xablau
β”œβ”€β”€ conf
β”‚   └── layer.conf
β”œβ”€β”€ COPYING.MIT
β”œβ”€β”€ README
└── recipes-kernel
    └── linux
        β”œβ”€β”€ device-tree-overlays
        β”‚   └── xablau_overlay.dts
        └── device-tree-overlays_git.bbappend

Here is the content of device-tree-overlays_git.bbappend:

FILESEXTRAPATHS:prepend := "${THISDIR}/device-tree-overlays:"

CUSTOM_OVERLAYS_SOURCE = " \
    xablau_overlay.dts \
"
CUSTOM_OVERLAYS_BINARY = " \
    xablau_overlay.dtbo \
"

SRC_URI += " \
    file://xablau_overlay.dts \
"

#TEZI_EXTERNAL_KERNEL_DEVICETREE += " \
#    ${CUSTOM_OVERLAYS_BINARY} \
#"

TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT = " \
    ${CUSTOM_OVERLAYS_BINARY} \
"

do_collect_overlays:prepend() {
    for DTS in ${CUSTOM_OVERLAYS_SOURCE}; do
        cp ${WORKDIR}/${DTS} ${S}
    done
}

Then, after executing bitbake -c compile device-tree-overlays, I can see the resulting xablau_overlay.dtbo in build/tmp/work/<machine>-tdx-linux/device-tree-overlays/toradex_5.15-2.2.x-imx+gitAUTOINC+85e4729bdd-r0/build/xablau_overlay.dtbo.

As stated in the Developer article referenced above, please check the meta-toradex-bsp-common/classes/toradex-devicetree.bbclass for more information about TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT and TEZI_EXTERNAL_KERNEL_DEVICETREE.

Let us know if this helps you.

Best regards,

1 Like

It works !

Hi @MariusM !

Nice!

Thanks for the feedback :slight_smile:

Have a nice day!

Best regards,