Regarding using multiple spi on colibri imx7 with torizon OS?

Hi,
I want to use more than one spi on colibri imx7 board with Torizon OS. But i can see only one spi aka spi2 in sys/class/spi_master directory.
Can you help, how can i enable multiple spi on same board?

Greetings @ansh,

By default we only have the 1 SPI interface enabled in order to maintain pin compatibility with our other Colibri products. This means that adding and enabling more SPI interfaces will require changes to the device tree used on your device.

As for what changes need to be made, you’ll need to add additional SPI interfaces to the device tree. An example of an SPI interface being defined can be found in the i.MX7 device tree here: imx7-colibri.dtsi « dts « boot « arm « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

Do note that you’ll need to reallocate pins for further SPI interfaces, this means you’ll need to disable/remove interfaces that already use these pins as to avoid conflict. Pin assignments can be found at the bottom of the above device tree file under the iomuxc node. You can check the i.MX7 datasheet on our developer site to fine what other pins can serve as SPI pins.

Next you’ll need to then expose this interface in user space so it can be used. We use the spidev interface to do this. Here’s an example of adding spidev to an already established SPI node in the device tree: imx7-colibri-eval-v3.dtsi « dts « boot « arm « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

Now that I’ve covered what changes need to be done, I’ll quickly go over how you can then deploy these changes to a Torizon device.

One option is to use device tree overlays for which we already provide a utility container: Device Tree Overlays on Torizon | Toradex Developer Center

With this option you won’t need to recompile and redeploy a fresh device tree binary, though it requires knowledge of the device tree you’re appending onto and the syntax can be a little tricky.

Finally the standard way would be to pull down our kernel source, make changes, and recompile a new device tree. You can then copy the new binary to this location on the device: /boot/ostree/torizon-{random checksum}/. In this directory you’ll find the current running device tree that is loaded on boot. You just need replace it with your new device tree (make sure to match the filename) then just a reboot to reload the new device tree.

Generally this is what you’ll need to do in order to enable another SPI interface. Please let me know if there are any further clarifications I can provide.

Best Regards,
Jeremias

Hi,
From where i can download the kernel source for torizon OS. So that i can recompile the new device tree with the changes for enabling other spi interface.

If you want just the kernel source from Torizon you can clone the sources from here: linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

You’ll want either the toradex_5.3.y or toradex_5.4.y branch depending on your version of Torizon you can confirm this by running uname -a on your Torizon device.

You can follow this guide for compiling/building our kernel: Build U-Boot and Linux Kernel from Source Code | Toradex Developer Center

The content of the article isn’t exactly Torizon specific but much of the prerequisites and build steps still apply to Torizon.

One small change you’ll need is that the Torizon kernel config isn’t part of the kernel source so you’ll need to get a copy of the kernel source from the device, found here /proc/config.gz.

Best Regards,
Jeremias

Hi,

I did as you said
I downloaded the toradex_5.4.2 kernel source form git.
then I made the changes in the imx7-colibri.dtsi and imx7-colibri-emmc-eval.dtsi file to enable spi1 and spi2 in the files.
After these changes I copied the config file that i got from the imx7 module with Torizon OS from /proc/config.gz directory and copied it to linux-toradex/arch/arm/configs. I renamed the config file to colibri_imx7_defconfig in the same directory.
Then i did $make colibri_imx7_defconfig followed by $make imx7d-colibri-emmc-eval-v3.dtb
After this i renamed the generated file to devicetree-imx7d-colibri-emmc-eval-v3.dtb and copied the same to the /boot/ostree/torizon-{some number} directory and did a rebboot.
Now the Torizon is not booting and gets struck after following

Kernel image @ 0x81000000 [ 0x000000 - 0x7a5200 ]

Flattened Device Tree blob at 82000000

Booting using the fdt blob at 0x82000000
Using Device Tree in place at 82000000, end 8200cbd4

Starting kernel …

[ 0.038920] imx7d-pinctrl 30330000.iomuxc: Invalid fsl,pins or pins property in node /soc/aips-bus@30000000/iomuxc@30330000/gpio2-grp

[ 0.038982] imx7d-pinctrl 30330000.iomuxc: Invalid fsl,pins or pins property in node /soc/aips-bus@30000000/iomuxc@30330000/ecspi3-cs-grp

[ 0.038998] imx7d-pinctrl 30330000.iomuxc: Invalid fsl,pins or pins property in node /soc/aips-bus@30000000/iomuxc@30330000/ecspi3-grp

[ 0.039051] imx7d-pinctrl 30330000.iomuxc: Invalid fsl,pins or pins property in node /soc/aips-bus@30000000/iomuxc@30330000/pwm1-grp

[ 0.039066] imx7d-pinctrl 30330000.iomuxc: Invalid fsl,pins or pins property in node /soc/aips-bus@30000000/iomuxc@30330000/pwm2-grp

[ 0.039081] imx7d-pinctrl 30330000.iomuxc: Invalid fsl,pins or pins property in node /soc/aips-bus@30000000/iomuxc@30330000/pwm3-grp

[ 0.039096] imx7d-pinctrl 30330000.iomuxc: Invalid fsl,pins or pins property in node /soc/aips-bus@30000000/iomuxc@30330000/pwm4-grp
[ 1.333749] caam_jr 30901000.jr0: failed to flush job ring 0

[ 1.339573] caam_jr 30902000.jr1: failed to flush job ring 1

[ 1.345366] caam_jr 30903000.jr1: failed to flush job ring 2

Starting version 243+
root ‘/dev/disk/by-label/otaroot’ doesn’t exist or does not contain a /dev.

Now I am also unable to load easy installer from pendrive to give a fresh start.
I am getting following after running distro_bootcmd

Colibri iMX7 # run distro_bootcmd
switch to partitions #0, OK

mmc0(part 0) is current device
Scanning mmc 0:1…

Found U-Boot script /boot.scr
2427 bytes read in 8 ms (295.9 KiB/s)

Executing script at 87000000
445 bytes read in 10 ms (43 KiB/s)

8016384 bytes read in 108 ms (70.8 MiB/s)

3255644 bytes read in 52 ms (59.7 MiB/s)

Kernel image @ 0x81000000 [ 0x000000 - 0x7a5200 ]

ERROR: Did not find a cmdline Flattened Device Tree
FDT and ATAGS support not compiled in - hanging

ERROR ### Please RESET the board

Hi,

First of all to get the device back to Easy Installer you’ll need to put the device into recovery mode and load Easy Installer over USB OTG as described here.

As for the device tree it seems like from the boot logs that some pins were defined incorrectly in the iomuxc node of the device tree, if you could provide a diff of your changes I could comment further on what might be wrong.

Best Regards,
Jeremias