SPI on the viola carrier board with colibri-imx6ull

I need to enable SPI on my setup, and I see many references on this forum to SPI (Linux) that’s an archived page.

In this page I see a reference to an overlay, colibri-imx6-eval_spidev_overlay.dtbo, that I cannot find in my sources tree.

I have already setup the SDK, built a minimal core image and burnt it into the module.

I would like to know if that overlay file should be somewhere on my source tree or if I need to set a dtsi file somewhere to be built with “bitbake virtual/kernell” and included in my image.

This part of the documentation is not that clear to me so any help would be really appreciated.

I have already built a dtsi file, “custom.dtsi” with contents:

&ecspi1 {
        status = "okay";

        mcp2515: can@0 {
                compatible = "microchip,mcp2515";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_can_int>;
                reg = <0>;
                clocks = <&clk16m>;
                interrupt-parent = <&gpio2>;
                interrupts = <4 IRQ_TYPE_EDGE_FALLING>;
                spi-max-frequency = <10000000>;
                vdd-supply = <&reg_3v3>;
                xceiver-supply = <&reg_5v0>;
                status = "disabled";
        };

        spidev0: spidev@0 {
                compatible = "toradex,evalspi";
                reg = <0>;
                spi-max-frequency = <23000000>;
                status = "okay";
        };
};

I hope someone more experienced than me, could help me get this file included in my image or is able to tell me where to find the spi overlay file metionen in the documentation.

Many thanks in advance for your help.

Hardware:
Viola Plus 1.28 Carrier Board
Colibri imx6ull 512MB IT C1.1A

Software:
Yocto BSP 5

Thanks Alex.

Before to post this question, I had already done the bit about editing overlays.txt and copying the dto fle to /boot.

In my build boot was not even populated.

Is there a previous step to enable device trees ?

Just in case.

Thanks.

Please check Enable/Disable a Device Tree Overlay chapter for details

Thanks again Alex.

Hi @iagorubio!

Was your issue solved?

If yes, please mark the related message as the solution :slight_smile:

If not, let us know how can we further help you.

Best regards,

No yet henrique.

I have to jump to another project, and I am getting back to this one, but what I have tried so far did not worked.

The SPI - or CAN because I tried both - devices did not show up on the board.

I will go for it again and will be back to you when I find what is the problem.

Thanks for your help.

Definitely not working sorry.

I am just trying to get CAN instead of SPI now but the problem is the same.

I have edited both dtsi files imx6ull-colibri-eval-v3.dtsi, I have edited both dtsi files imx6ull-colibri-eval-v3.dtsi, imx6ull-colibri-nonwifi.dtsi and imx6ull-colibri-wifi.dtsi to match CAN (Linux) | Toradex Developer Center but when i do bitbake virtual/kernel and/or bitmake image-name nothing changes and nothing gets built.

I know I am missing something obvious sorry.

I am wondering if using the core-image-minimal have something to do with this.

May be there are no recipes to build the overlays or something like that.

I see the build system notices my attempts to force rebuilds but the kernel and overlays don’t get rebuilt.

WARNING: /home/iago/files/packages/oe-core/build/../layers/meta-toradex-nxp/recipes-kernel/linux/linux-toradex_4.14-2.3.x.bb.do_compile is tainted from a forced run                                | ETA:  0:00:00
WARNING: /home/iago/files/packages/oe-core/build/../layers/meta-toradex-nxp/recipes-kernel/linux/linux-toradex_4.14-2.3.x.bb.do_build is tainted from a forced run

I am sure it should be something easy to handle, but ain’t getting any luck.

Thanks in advance for your help.

Hi @iagorubio ,

did you try to clean your working directory before rebuilding?
Maybe a fresh rebuild can resolve this without the need to force it.

Best Regards
Kevin

I did clean tmp, sstate directories and used bitbake clean, bitbacke cleanstate commands just to get plenty errors abut non deterministic hashing.

Then cleared all but downloads , including images and ipk folders, and switched to another image .

From core-image-minimal to core-image-base.

Now the build fails with: “The recipe base-files is trying to install files into a shared area when those files already exist.”

I have started over again. I seems the clean commands does not do a full clean, and this seems to require a delete/rename of the deploy directory.

I am sitll working through it.

Hi @iagorubio

If you need to rebuild an entire image you have to delete the tmp folder. The clean command does not work for that. Also please note it seems you are building an old version of the BSP. Please make sure you checked out the dunfell-5.x.y branch (For BSP 5 or kirkstone-6.x.y for BSP 6). See this article for more details:

Just for testing the device tree overlay, you don’t really need to build the image from scratch. You can first try to make it work without it. For that you have to checkout the device tree overlay repo.
For BSP5 (upstream):

git clone git://git.toradex.com/device-tree-overlays.git -b toradex_5.4.y

For BSP6 (upstream):

git clone git://git.toradex.com/device-tree-overlays.git -b master

Afterward, you can start by looking into this article:

You can transfer your own device tree overlay to the board with scp to the folder /boot/overlays/ and then just enable it in /boot/overlays.txt.

After you have a working overlay, you can integrate it into Yocto by adding your own meta layer:

An example for enabling spidev can be found here:
https://git.toradex.com/cgit/device-tree-overlays.git/tree/overlays/colibri-imx6ull_spidev_overlay.dts
However, if I’m not wrong it should already be enabled in BSP5. Check if there is any /dev/spidev on your target:

ls /dev/spidev*

If so you should be able to use it.

For can the overlay would probably look as follows (I didn’t test it, so it might need some adjustments):

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright 2022 Toradex
 */

// Colibri imx6ull can

#include <dt-bindings/gpio/gpio.h>

/dts-v1/;
/plugin/;

/ {
	compatible = "toradex,colibri-imx6ull",
		     "toradex,colibri-imx6ull-emmc";
};

/* Remove pinctrl_gpio7 for can1 and pinctrl_gpio3 for can2 */
&iomuxc {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_gpio1 &pinctrl_gpio2
		&pinctrl_gpio4 &pinctrl_gpio6
		&pinctrl_gpmi_gpio>;
};

&can1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_flexcan1>;
	status = "okay";
};

&can2 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_flexcan2>;
	status = "okay";
};

Regards,
Stefan

Thank you Stephan. Your help is really appreciated.

I have just dumped the development environment and started over again.

I have created a BSP5 tdx-reference-minimal-image and edited imx6ull-colibri-eval-v3.dtsi and imx6ull-colibri-wifi-eval-v3.dtsi following CAN (Linux) | Toradex Developer Center

Disabled MCP251x and freed pinctrl_gpio7 from iomuxc.

Enabled flexcan.

Re-built the image, and finally the dtb files on deploy/images/my-image changed, so now bitbake is atleast rebuilding the dtsi.

Created a usb to flash with easy installer the image.

On image.json I see on the dtb files referencing imx6ull-colibri-eval-v3.dtb for products 0036 and 044, and imx6ull-colibri-wifi-eval-v3.dtb for 0040 or 0045.

I don’t know if those products ids matrch my viola board so it may be wrong.

Flashed the board and the can devices are not shown.

The flexcan kernel modules exists.

The board tries to start the MCP251x via SPI with no luck, as the board have no MCP251x.

I also tried to load the dtb files via /boot/overlays.txt, after copying them to /boot on the board, with the same result.

So the dtb are not being loaded by the kernel.

I know I am an inch away from getting it working and my next step is to build a layer containing those changes, as in your example, instead of fiddling with the dtsi files as for the instructions in CAN (Linux) | Toradex Developer Center.

If you see something obviously wrong please let me know.

As I said, your support is really appreciated stefan.

Thank you.

I have just found the PN for my module Colibri iMX6ULL 512MB IT and is 044 so imx6ull-colibri-eval-v3.dtb should be copied.

I am trying to find information on the image.json format and how the dtb is copied: if it’s phisically copied to /boot - not working - ot it’s attached to the kernel image via sysfs.

[edit]
Answering to myself, it seems the default kernel configuration on this image - tdx-reference-minimal-image - have no support for device tree overlays ?

root@colibri-imx6ull-07327627:~# ls /sys/kernel/config/device-tree/overlays     
ls: /sys/kernel/config/device-tree/overlays: No such file or directory

Hi @iagorubio

You are right, for the iMX6ULL without eMMC overlays do not work so you have to modify the device tree directly. By default the “eval” devicetree for your module will be flashed on the ubi device tree partition. So you have to modify imx6ull-colibri-eval-v3.dts to make it work.

Regards,
Stefan

Hi stefan, thank you for your input.

I finally built the kernel from scratch and compiled on that kernel tree the edited dts and dtsi, with the same edits I was doing from the very start on the yocto project, and now both can0 and can1 shows up.

To try to load the dtbo overlays in /boot/overlays.txt was a big mistake as that was not supported by my board.

Editing the imx6ull-colibri-eval-v3.dts to enable flexcan and imx6ull-colibri-nonwifi.dtsi to free gpios 3 and 7 was the right think to do, with a fresh kernel.

I don’t know yet why editing the yocto provided dts and dtsi and compiling the kernel with bitbake did not work, but I finally have a working kernel with can enabled.

Thank you so much for the help Stefan.

I was pretty much about to give up and look for other solution.

Thanks again.

1 Like

Just a quick follow up.

We have just plug the board in our device’s can bus and everyhting works great :star_struck:

1 Like

Hi @iagorubio ,

Thanks for the update :+1:

If you have more questions feel free to attach them here.

Best Regards
Kevin