SPI on Colibri IMX6ULL

Hi support team,

I need help to enable SPI in my Colibrì IMX6ULL 256MB on Iris Carrier Board V 1.1.

I downloaded and compiled the last version of BSP:

cat /proc/version

Linux version 5.4.161-39930-gac75fc8160f2 (temalab@temalab-HD620-H81C) (gcc version 9.2.1 20191025 (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10))) #1 SMP Tue Feb 22 11:45:03 CET 2022

Then I followed the guide to customize the device tree:

  • copied imx6ull-colibri-eval-v3.dts (and .dtsi) in imx6ull-colibri-myconf.dts

  • insert reference in makefile

  • modified dtsi file to enable spi:

    &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";
      	};
    
      	/* To keep the CAN controller enabled by default,
      	 * disable conflicting spidev.
      	 */
      	spidev0: spidev@0 {
      		compatible = "toradex,evalspi";
      		reg = <0>;
      		spi-max-frequency = <23000000>;
      		status = "okay";
      	};
      };
      ....
    
  • compiled with “make dtbs”

  • copied generated dtb file in a new image, modified image.json file to use myconf

  • wrote new image with easy installer.

But in the /dev directory there is no spidev.

To ensure I’m using the right device tree genereted, I disabled a serial port and actually the serial port disabled disappeared in the dev directory…

Please tell me what I’m doing wrong!

Please, no one can help me? I still have the same problem…

Maurizio

Hi,

How did you check lack of spidev in /dev? There won’t be spidev device, but something like spidev1.0. Are you sure you checked with wildcard ?
ls /dev/spidev*
Try as well checking dmesg. It shoudl either confirm spi is present or tell something about what’s wrong:
dmesg | grep -i spi

You should never modify dtsi files. You always can override settings from dtsi in your dts, either with your new settings or deleting properties and nodes with /delete-property/ property or /delete-node/ node. Your custom dts could be like this:

#include "imx6ull-colibri-eval-v3.dts"

&ecspi1 {
    	status = "okay";
};

&mcp2515 {
    status = "disabled";
};

&spidev0 {
  		status = "okay";
};
2 Likes

Hi @temalab ,

Sorry for the delay to answer you and thanks @Edward for the additional input. Please test the suggestions from Edward and get back to us with the output from these commands. In addition, one nice thing the Device Tree Overlays article (Device Tree Overlays (Linux) | Toradex Developer Center). Maybe you could just add an overlay to enable the interface you want to use instead of modifying the main device tree.

In addition, one other thing that you should check is that if in any overlay or file included in the dtsi they’re not disabling this interface causing a conflict.

Best regards,
Guilherme

Thanks for the answer.
About the device: no, there is nothing similar to spi*.
For other suggestions, I’ll try as soon as possible.

Maurizio

1 Like

Hi Edward,
I followed you suggestion but still doesn’t work. I’m going crazy…

Nothing in the /dev directory. No message with dmesg.

Maybe could be something wrong in the image of kernel that I compiled? I run “make nconfig” and enabled spi master in the compile configuration. I compiled image without any error.
I compiled the dtsi files with “make dtbs” and then in the json file I entered the dtb file:

{
“filename”: “imx6ull-colibri-eval-v3.dtb”,
“product_ids”: “0040”
},

Please, have you an already dtb file with spi enabled for colibri/iris board?

Thanks
Maurizio Messa

Hi @temalab !

I just checked the configurations of the BSP5.5 upstream for Colibri iMX6ULL 256MB and the driver is compiled as a module (instead of builtin), so you need to probe it before starting to use.

I just did it on an unmodified reference minimal image.

TDX Wayland with XWayland Upstream 5.5.0+build.15 (dunfell) colibri-imx6ull-03007769 ttymxc0
Colibri-iMX6ULL_Reference-Minimal-Image-upstream

colibri-imx6ull-03007769 login: root
root@colibri-imx6ull-03007769:~# zcat /proc/config.gz | grep -i spi_spidev
CONFIG_SPI_SPIDEV=m
root@colibri-imx6ull-03007769:~# dmesg | grep -i spi
[   15.742350] spi_imx 2008000.spi: probed
root@colibri-imx6ull-03007769:~# ls /dev | grep -i spi
#no hit here
root@colibri-imx6ull-03007769:~# modprobe spidev
root@colibri-imx6ull-03007769:~# ls /dev | grep -i spi
colibri-spi-cs0
spidev0.0
root@colibri-imx6ull-03007769:~# 

Since you are building your kernel, you can set it as builtin. The symbol is CONFIG_SPI_SPIDEV.

Please, give it a try and let us know :slight_smile:

Best regards,

Just some side comments.

I agree with @Edward regarding not modifying dtsi. And, since you have your own dts:

Perform your modifications there :slight_smile:

Best regards²,

Thank you henrique,
With easy installer I download latest linux image upstream and of course the spidev is provided as a module. If modprobed it works.
But I can’t understand what was wrong in my image: I found
CONFIG_SPI_SPIDEV=y
so I think the spi is builtin, or not?
I would like to be able to compile my on image, maybe I need spidev as module too?

Maurizio

Dear @temalab,

How are you? As you can see in the menuconfig from the Kernel, the CONFIG_SPI_SPIDEV has a few dependencies. To use it as built-in, you should also ensure that SPI and SPI_MASTER are properly listed as built-in features.

On the Upstream Kernel of BSP 5.6.0, the .config looks like:

$ cat .config | grep CONFIG_SPI   
# CONFIG_SPI_CADENCE_QUADSPI is not set
# CONFIG_SPI_MTK_QUADSPI is not set
CONFIG_SPI=y
# CONFIG_SPI_DEBUG is not set
CONFIG_SPI_MASTER=y
CONFIG_SPI_MEM=y
# CONFIG_SPI_ALTERA is not set
# CONFIG_SPI_AXI_SPI_ENGINE is not set
CONFIG_SPI_BITBANG=y
# CONFIG_SPI_CADENCE is not set
# CONFIG_SPI_DESIGNWARE is not set
# CONFIG_SPI_FSL_LPSPI is not set
CONFIG_SPI_FSL_QUADSPI=y
# CONFIG_SPI_NXP_FLEXSPI is not set
CONFIG_SPI_GPIO=y
CONFIG_SPI_IMX=y
# CONFIG_SPI_FSL_SPI is not set
# CONFIG_SPI_OC_TINY is not set
# CONFIG_SPI_PL022 is not set
# CONFIG_SPI_PXA2XX is not set
# CONFIG_SPI_ROCKCHIP is not set
# CONFIG_SPI_SC18IS602 is not set
# CONFIG_SPI_SIFIVE is not set
# CONFIG_SPI_MXIC is not set
# CONFIG_SPI_XCOMM is not set
# CONFIG_SPI_XILINX is not set
# CONFIG_SPI_ZYNQMP_GQSPI is not set
CONFIG_SPI_SPIDEV=m
# CONFIG_SPI_LOOPBACK_TEST is not set
# CONFIG_SPI_TLE62X0 is not set
# CONFIG_SPI_SLAVE is not set

Did you check on your image if the requirements were also enabled? On the downstream kernel, the configuration is as follows:

$ cat .config | grep CONFIG_SPI       
# CONFIG_SPI_CADENCE_QUADSPI is not set
# CONFIG_SPI_MTK_QUADSPI is not set
CONFIG_SPI=y
# CONFIG_SPI_DEBUG is not set
CONFIG_SPI_MASTER=y
CONFIG_SPI_MEM=y
# CONFIG_SPI_ALTERA is not set
# CONFIG_SPI_AXI_SPI_ENGINE is not set
CONFIG_SPI_BITBANG=y
# CONFIG_SPI_CADENCE is not set
# CONFIG_SPI_DESIGNWARE is not set
CONFIG_SPI_FSL_LPSPI=y
CONFIG_SPI_FSL_QUADSPI=y
CONFIG_SPI_NXP_FLEXSPI=y
CONFIG_SPI_GPIO=y
CONFIG_SPI_IMX=y
CONFIG_SPI_FSL_LIB=y
CONFIG_SPI_FSL_SPI=y
# CONFIG_SPI_OC_TINY is not set
CONFIG_SPI_PL022=y
# CONFIG_SPI_PXA2XX is not set
# CONFIG_SPI_ROCKCHIP is not set
# CONFIG_SPI_SC18IS602 is not set
# CONFIG_SPI_SIFIVE is not set
# CONFIG_SPI_MXIC is not set
# CONFIG_SPI_THUNDERX is not set
# CONFIG_SPI_XCOMM is not set
# CONFIG_SPI_XILINX is not set
# CONFIG_SPI_ZYNQMP_GQSPI is not set
CONFIG_SPI_SPIDEV=y
# CONFIG_SPI_LOOPBACK_TEST is not set
# CONFIG_SPI_TLE62X0 is not set
CONFIG_SPI_SLAVE=y
CONFIG_SPI_SLAVE_TIME=y
CONFIG_SPI_SLAVE_SYSTEM_CONTROL=y
CONFIG_SPI_DYNAMIC=y

Does this help you?

Thank you gclaudino.tx
I checked my configuration and the only difference was in
CONFIG_SPI_MEM and CONFIG_SPI_FSL_QUADSPI (not set) and CONFIG_SPI_SPIDEV (set to Y). I changed them and recompiled but the spi still not appear.

I download and installed the minimal image upstream 5.6.0+build 18 (2022-30-03) and it works.

Probably there is an error in the device tree, but I can’t find it!. Please, have you a dts configuration sample?

Maurizio

Hi @temalab,

Our base device trees are publicly available as long as our pre-built overlays. You can have a check on our device tree GitHub device-trees/dts-arm32 at toradex_5.4-2.1.x-imx · toradex/device-trees · GitHub. There are a few device trees available.

To check what device tree the minimal image is using you can type:

$ cat /proc/device-tree/model

To check the overlays used it’s also very similar:

$ cat /boot/overlays.txt

Please tell me if this helps you figure it out. Otherwise you can keep in touch with us :smiley:

Hi gclaudino.tx

sorry but not working.
I downloaded all files dts-arm32 from link you gave me.
The model from /proc/device-tree is “Toradex Colibri iMX6ULL 256MB on Colibri Evaluation Board V3” so I modified imx6ull-colibri-eval-v3.dtsi, changing “disabled” in mcp2515 section and “ok” in spidev0.
Compiled with “make imx6ull-colibri-eval-v3.dtb” and compiled the kernel too.
I ensured the json file uses the correct dtb file. Copied zimage and .dtb file on the image setup and then installed with easy installer using a usb pendrive.

After boot dmesg doesn’t report any message about spi.

Maybe I skipped some passage?

Maurizio

Dear @temalab,

Thanks for the update. I’ve made a mistake. There correct github link was to be this one: device-trees/imx6ull-colibri-eval-v3.dtsi at toradex_5.4.y · toradex/device-trees · GitHub. I sent to you the Downstream Kernel where it’s not enabled by default. You should be on this branch: toradex_5.4.y.

By the way, did you have some time to check this thread? How to use SPI on Colibri IMX6ULL - #18 by jaski.tx

On it, there is a patch that helped a customer use the SPI Dev interface.

Can you please have a look at it?


Finally, just as an additional check, did you make any additional change to your image that doesn’t include the kernel modifications you already commented on?

I downloaded the .dtsi but it’s quite similar to mine. Anyway I compiled it and I tested with my zimage, but the result is the same.

About the kernel, no additional changes was made. I downloaded the source code and compiled it.

Thanks
Maurizio

Can you please share your full dts file?

Sorry, maybe I didn’t understand. The file is the one you linked me:

device-trees/imx6ull-colibri-eval-v3.dtsi at toradex_5.4.y · toradex/device-trees · GitHub”.
I overwrited all files with “device-trees/dts-arm32 at toradex_5.4-2.1.x-imx · toradex/device-trees · GitHub” and than no change was made.

Maurizio

Dear @temalab,

I wanted to see the resulting dts files from your changes. Where you did these changes:

By the way, did you have the time already to check the other thread I mentioned?

Hi gclaudino,
these are the files dts I used:
imx6ull-colibri-eval-v3.dts (356 Bytes)
imx6ull-colibri-eval-v3.dtsi (2.5 KB)
imx6ull-colibri-nonwifi.dtsi (2.6 KB)

I hope they could be useful to identify the issue.

About the link, is not useful for me. Is what I done so may time without success.

Thanks
Maurizio

Update: I find the solution. In the configuration we have to enable i.MX SDMA support

Thanks to all
Maurizio

1 Like