Hello team,
We are doing yocto project, for that we have to interface DAC with SPI, buit we are not seeing any spi driver under /dev tree, could please provide me steps to add nodes in dtsi and configure the spi driver in SBC.
Hello team,
We are doing yocto project, for that we have to interface DAC with SPI, buit we are not seeing any spi driver under /dev tree, could please provide me steps to add nodes in dtsi and configure the spi driver in SBC.
Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!
Did you like my answer?
To enable the SPI driver on an Apalis iMX8QM module and ensure that the SPI device appears under the /dev
tree, you need to follow these steps:
You need to add the SPI node in the device tree source (DTS) file. Here is an example of how you can modify the device tree to enable SPI and bind it to the spidev driver.
Create a device tree overlay file, for example, apalis-imx8qm-spi-overlay.dts
:
/dts-v1/;
/plugin/;
/ {
compatible = "toradex,apalis-imx8qm";
fragment@0 {
target = <&ecspi1>;
__overlay__ {
status = "okay";
spidev@0 {
compatible = "spidev";
reg = <0>;
spi-max-frequency = <10000000>;
status = "okay";
};
};
};
};
In this example:
&ecspi1
refers to the SPI1 controller. You may need to adjust this based on the specific SPI controller you are using.spidev@0
is the SPI device node with a chip select of 0.spi-max-frequency
sets the maximum SPI clock frequency.Compile the device tree overlay to generate the .dtbo
file:
dtc -I dts -O dtb -o apalis-imx8qm-spi-overlay.dtbo apalis-imx8qm-spi-overlay.dts
Copy the compiled .dtbo
file to the boot partition of your Apalis iMX8QM module. You can use scp or any other method to transfer the file.
scp apalis-imx8qm-spi-overlay.dtbo root@<your_board_ip>:/boot/overlays/
Edit the overlays.txt
file located in the /boot
directory on your Apalis iMX8QM module to include your new overlay:
vi /boot/overlays.txt
Add the following line to the fdt_overlays
variable:
fdt_overlays=apalis-imx8qm-spi-overlay.dtbo
Please, also check if these links can help you solve your problem:
Maximum transfer size 4096 bytes with spidev driver for SPI on Colibri imx6.
How to add device tree overlay
Hi, @karthikgowda6!
I’ve tried to find a driver for this IC, but, apparently, there is no driver for this specific model. So, it won’t be possible to add an SPI node or driver to our device tree.
I saw that you asked another question, so I’ll keep the answers here since the topic is related.
Another option in your case is using SPIDEV to communicate with the DAC from user space. Please, refer to this article to find out how it is done, and feel free to ask if you have any doubts.
Best regards.
Lucas Azeituno
Hi @lucas_az.tx
Tried this method, we are able see the spi under /dev but the problem is once we reboot it will disappear from that, can you give a solution to reflect it at /dev automatically once we update the dtsi.
Hi, @karthikgowda6!
As you are using Apalis iMX8QM, you can enable the SPIDEV overlay (if it isn’t already enabled) and it should be enough to automatically start SPIDEV.
Here you can find out how to enable a device tree overlay, and here you can find the name of the pre-built SPIDEV overlay to enable it.
As you can see in this article, you may have to use an external code (like the sample code used) to do some tests with SPIDEV.
Please, let me know if you face any doubts.
Best regards.
Lucas Azeituno