Hi
Iβm using IMX7D emmc and i have built my custom Device tree and i have tested it .i want to replace it by main Toradex device tree .
i wonder how i could set my custom device tree in yocot image (tdx-reference-minimal-image) .
and how to patch uboot to run my custom device tree instead of the default toradex on .
thanks in advance.
Device tree blob located at the boot partition and U_boot environment variables βfdt_fileβ defines which file will be loaded. So you can manually replace dtb file there. Please check this post if you want to include new DT to your Yocto build.
Thanks For your Response.
i have followed This Instruction link
but there is some parts that i donβt understand.
for example the part that say :
conf/machine/colibri-imx6-extra.conf
KERNEL_DEVICETREE_append = " my-custom-devicetree-file.dtb"
i dont have any directory name machine .
and i as i checked the deploy directory the device tree has been compiled but hasnβt been added in boot patrion.
and for the second question i have :
do_configure_append() {
sed -i 's/#define FDT_FILE.*/#define FDT_FILE "my-custom-devicetree-file.dtb"/' ${S}/include/configs/colibri_imx6.h
}
in this part we are telling the u-boot to boot our device tree.
but i think for IMX7 itβs different .
it would be nice if you guide me more .
cheers joe
Hi @joe.hiko,
This is just a folder used as an example, you will need to create it.
For Colibri iMX7, you will use colibri_imx7.h file. This file comes from u-boot, you can clone the u-boot repo on your computer and search for these files inside include/configs/. This is the folder where Yocto will get these files. You can see how you can clone the u-boot here. This is only for you to search the files, but you donβt need to do this to build your custom layer because Yocto will download u-boot and Linux kernel automatically.
Sure! I made an example here, where Iβm going to build a custom layer to add my own device tree file. The structure of your meta-customer should be something as follows:
yocto@984338ceadd3:~/oe-core/layers/meta-customer$ tree
.
βββ conf
β βββ layer.conf
β βββ machine
β βββ colibri-imx7d-emmc-extra.conf
βββ COPYING.MIT
βββ README
βββ recipes-bsp
β βββ u-boot
β βββ u-boot-toradex_%.bbappend
βββ recipes-kernel
βββ linux
βββ linux-toradex
β βββ my-custom-devicetree-file.dts
βββ linux-toradex%.bbappend
Where the files are defined as:
yocto@984338ceadd3:~/oe-core/layers/meta-customer/recipes-bsp/u-boot$ cat u-boot-toradex_%.bbappend
do_configure_append() {
sed -i 's/#define FDT_FILE.*/#define FDT_FILE "my-custom-devicetree-file.dtb"/' ${S}/include/configs/colibri_imx7.h
}
yocto@984338ceadd3:~/oe-core/layers/meta-customer/recipes-kernel/linux$ cat linux-toradex%.bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}/linux-toradex:"
# Prevent the use of in-tree defconfig
unset KBUILD_DEFCONFIG
CUSTOM_DEVICETREE = "my-custom-devicetree-file.dts"
SRC_URI += "\
file://${CUSTOM_DEVICETREE} \
"
do_configure_append() {
cp ${WORKDIR}/${CUSTOM_DEVICETREE} ${S}/arch/arm/boot/dts
}
yocto@984338ceadd3:~/oe-core/layers/meta-customer/conf$ cat layer.conf
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"
# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "meta-customer"
BBFILE_PATTERN_meta-customer = "^${LAYERDIR}/"
BBFILE_PRIORITY_meta-customer = "6"
LAYERDEPENDS_meta-customer = "core"
LAYERSERIES_COMPAT_meta-customer = "dunfell"
include conf/machine/colibri-imx7d-emmc-extra.conf
yocto@984338ceadd3:~/oe-core/layers/meta-customer/conf/machine$ cat colibri-imx7d-emmc-extra.conf
KERNEL_DEVICETREE_append = " my-custom-devicetree-file.dtb"
Please, donβt forget to add this layer to your bblayers.conf file.
I hope this will help you. Please, feel free to ask any questions you might have.
Best regards,
Hiago.
Thank you Hiago!!
This is Exactly what i needed. ill give it a try and i lll let you know about the result. thanks
kind regards.
joe.
Hi Hiago
I have Tried What you said and i was able to successfully Set My custom Device Tree To The bootfs .
but as i searched in toradex-uboot specially this file:
/include/configs/colibri_imx7.h
I couldnt Find The macro that Sets :
#define FDT_FILE
and i maked menuconfig for the imx7_emmc i found that toradex use diffrent method for setting the fdtfile .
and as you can see there is a preboot value that sets the fdtfile .
and i wanna know to set my own device tree with this structure.
Best Regards.
Joe
Hi @joe.hiko,
yes, you are right, Toradex u-boot sets the device tree file based on these two variables: $soc and $fdt_board.
For example, if you are using a custom device tree named βimx7-colibri-emmc-custom.dtbβ, you can enter in the u-boot terminal and run:
setenv fdt_board custom
saveenv
reset
The $soc value is set automatically by u-boot, it will be βimx7β in your case.
With this command, u-boot will set automatically the device tree file called βimx7-colibri-emmc-custom.dtbβ, which has to be inside the /boot/ folder for u-boot to find it.
Therefore, if you donβt want to set your device tree in Yocto, you can remove the part where we set the custom device tree in your meta layer and set it inside u-boot as I mentioned above.
For production though, we recommend setting the device tree file with Yocto, because it will be easier to manage your custom image and set the device tree for all your modules.
Best regards,
Hiago.