Yocto customize device tree FlexCAN

I’m using yocto to generate a very simple custom image, which in this case is just modifying the device tree from using the external CANbus controller (MCP2515) to the internal IMX6 FlexCAN.

Following the information from here and from here, I have added a custom recipe to modify the device tree.

I run bitbake to generate the image, and it creates the image.

After flashing the new image to the Colibri IMX6 module, I run the command dmesg | grep can and I get this output:

[    2.351188] imx_epdc_fb 20f4000.epdc: can't get/select pinctrl

[    7.201194] caam-snvs 20cc000.caam-snvs: can't get snvs clock

[    9.364700] mcp251x spi3.0 can0: MCP2515 successfully initialized.

By looking at it, it looks like my device tree modification is not working as expected.

Any pointers where should I start looking to fix this?

Thanks.

Can you share what you changed at Device Tree?

Hi @alex.tx ,

Thanks for the reply.

Following the instructions on here, I have changed the following:

Disabled MCP251x0 settings status to disabled, commented out gpio2, and added can1.

I have attached my custom device tree file
link text

Thanks

Could you explain in details how exactly you have added a custom recipe? Looks like something wrong here.
From other hand you can try to build a device tree separately and manually replace it on module without creating full OS image and module re-flashing. Please check this article.

Have you done this?

We also need to add the device tree file to the variable KERNEL_DEVICETREE which defines which devicetrees are built and included into the final image.
conf/machine/colibri-imx6-extra.conf
KERNEL_DEVICETREE_append = " my-custom-devicetree-file.dtb"
By default this file is not included anywhere. Therefore, we must make sure that it is included by another conf file (e.g. layer.conf). We can do that by adding the following line to conf/layer.conf:
include conf/machine/colibri-imx6-extra.conf
In a last step we need to tell U-Boot to load my-custom-devicetree-file.dtb instead of the standard one. For this we need to replace the original name with the new name by adding a bbappend file again. Create a directory recipes-bsp/u-boot:
$ cd layers/meta-customer/
$ mkdir -p recipes-bsp/u-boot
recipes-bsp/u-boot/u-boot-toradex_2019.%.bbappend
do_configure_append() {
sed -i 's/#define FDT_FILE.
/#define FDT_FILE “my-custom-devicetree-file.dtb”/’ ${S}/include/configs/colibri_imx6.h
}*

@alex.tx ,

Thanks for reply.

As I have other changes to the image already made, it makes sense that I use yocto to modify the device tree.

Here is what I have done, however please keep in mind that this is my first time building an image with yocto, therefore I expect to have done something wrong.

In my custom layer, I have created a recipes-kernel folder.

Here is the structure of the recipes-kernel folder:

- linux
  |---linux-toradex
  |   |--- defconfig
  |   |--- my-custom-devicetree-file.dts
  |---linux-toradex_%.bbappend

I have attached the following files : my-custom-devicetree-file.dts, defconfig and linux-toradex_%.bbappend

I’m not sure if all the information provided will sufice, if not, please let me know what else would be required.

Thank you

@alex.tx ,

Yes, I have done what you have described.

I have followed the instructions from here.

Thanks

If you done everything as described you should have your new DT be in use.
I still recommend to compile your DT separately and when everything works OK add a new metalayer to youcto build

ok. thanks.

You are welcome.