SPI access in Torizon

I’m trying to access the SPI port of a Colibri iMX7 module while running Torizon, but I’m struggling to get started. I just need to be able to open the port, set the chip select then clock a few bytes in and out.

Inside the container running on Torizon I can see a device called spi2 in /sys/class/spi_master, but I don’t know how to access this device. There are no SPI devices visible in the /dev folder.

Is one SPI port enabled by default in the device tree? Do I need to create a driver for my SPI device or can I just read and write bytes directly to it from C code, like I could in Windows CE?

Would libsoc be the easiest way to get low-level access to an SPI port? Do you have any example code to show using libsoc to send a few bytes over SPI?

@MikeS

I’ve confirmed on my end as well that no spi devices are being created in /dev. Also it seems like there aren’t even any spidev nodes in the device tree. This seems to be unintended, I’ll bring awareness to the Torizon team and will return with an update on this issue.

Thanks for checking this for me @jeremias.tx, I’ll wait to hear what you and the team find.

@MikeS, just to give you a quick update, the Torizon team has been notified and are planning on adding proper user space functionality for accessing SPI in Torizon.

@jeremias.tx @MikeS is there any update of SPI on torizon because i am also facing the same problem,@jeremias.tx is there any update because i facing the same problem

Hi @rajat7693,

This should now be resolved with Torizon now having a /dev/spidev entry. Do note to access the version of Torizon with this fix you’ll need to use the Toradex Easy Installer to install a more recent Torizon from our CI feeds.

If you’re unfamiliar with how to access the CI builds of Torizon refer to the initial part of this video: https://www.youtube.com/watch?v=hwCXSckISXM