do_configure:append() {
# Remove existing fdtfile, it there is one
sed -i '/"fdtfile=.*\\0" \\/d' ${S}/include/configs/apalis-imx8.h
# Add new fdtfile
sed -i 's/\("fdt_board=.*\\0" \\\)/\0\n "fdtfile=imx8qm-apalis-v1.1-cust.dtb\\0" \\/' ${S}/include/configs/apalis-imx8.h
}
Please note that device tree is not a kernel module or application. It’s a blob located in separate (boot) partition and that blob should be loaded to certain memory location by U-Boot before starting kernel.
Please double check if your imx8qm-apalis-v1.1-cust.dtb was included in deployable tarball. Than you need to check image json file. For example:
In that case your custom dtb file should be included in the Reference-Minimal-Image-apalis-imx8.bootfs.tar.xz
Then you need to verify if U_Boot environment set properly . Check fdtfile value in u-boot-initial-env-sd file.
Ifimx8qm-apalis-v1.1-cust.dtb got built but not included in the tarball or U_boot environment you can manually edit that files to test your new device tree.
However, I cannot find imx8qm-apalis-v1.1-emli-4.dtb anywhere in my build folder.
Other dtb files , e.g. imx8qm-apalis-eval-apalis-imx8.dtb , are in /tmp/work/apalis_imx8-tdx-linux/linux-toradex/5.4.193+gitAUTOINC+cf62fa8fd9_f782992971-r0/deploy-linux-toradex
Does that mean it wasn’t built properly?
I managed to include my custom device tree .dtb manually by setting the preboot and fdtfile as described above.
I have also managed to include in using Yocto, but I had to change the line in conf/layer.conf from as described in the article
include conf/machine/verdin-imx8mp-extra.conf
to
include machine/verdin-imx8mp-extra.conf
to get the relative search path correct.
In my case it’s not verdin-imx8mp, so my include is
include machine/apalis-imx8-extra.conf
I alos needed to change the sed commands so that fdt_board is replaced as well.
# Replace existing fdtfile with a new one
sed -i 's/\("fdtfile=.*\\0" \\\)/"fdtfile=imx8qm-apalis-v1.1-custom.dtb\\0" \\/' ${S}/include/configs/apalis-imx8.h
# Replace existing fdt_board with a new one. Not sure why needed, but probably since preboot in u-boot uses fdt_board to set fdtfile.
sed -i 's/\("fdt_board=.*\\0" \\\)/"fdt_board=custom\\0" \\/' ${S}/include/configs/apalis-imx8.h
After this my custom device tree is included in the yocto build, and I can flash the image with my custom device tree included.