Hi,
I am new to iMX7 and I want to use SPI from the A7 microprocessor present in iMX7. I just followed this link and altered the device tree tree as shown and compiled the OS. But when i try to communicate, I could not initialize the SPI as libsoc_spi_init() returns failure saying
libsoc-spi-debug: /dev/spidev3.0 not a vaild device (spidev3.0, libsoc_spi_init)
I have also attached the device tree file after editing. I also tried with spidev 2.0 but the same error exists. So is there any other step to enable spi for iMX7?
Thanks for your time
Regards, Nishanth
HI @nishanth1829
Thanks for writing to the Toradex Community!
According to the Documentation at the Link you provided, you should get a device spidev2.1. Could you check this (ls /dev | grep spi
) and change you code according to this?
Thanks and best regards,
Jaski
Hi @jaski.tx ,
Thank you for your quick reply.
I checked with spidev2.1 in my code, still the same problem exists.
Could you check this (ls /dev | grep spi
)?
I tried with this command but i could not see any of the spidev. Did you check with the device tree file? Is there anything to change?
Thanks and regards,
Nishanth
HI Nishant
I tried with this command but i could not see any of the spidev.
Then something went wrong with the compilation or deploying the devicetree file to the module. The devicetree file is OK.
Could you share the dmesg log in a text file?
Thanks.
Hi @jaski.tx
Here is the dmesg log. I didn’t find any errors while compiling the OS also the build time was too quick.
Thanks and regards,
Nishanth
Hi
I asked for the dmesg.log when you boot up the module and not build log. Especially I would first try to the regular kernel build then doing this directly in OE-Build.
Best regards,
Jaski
Hi @jaski.tx ,
Here is the dmesg log. Let me check with original kernel version and let you know.
Thanks and regards,
Nishanth
Thanks for the dmesg.log. According to this log, you did not disable the spi can and hence also not enable spidev.
[ 6.589344] mcp251x spi2.0 can0: MCP2515 successfully initialized.
Best regards,
Jaski
Hi @jaski.tx ,
But I have altered the device tree and compiled the OS but as I mentioned in this question, the new image is not generated. But adding or removing any layers did that. So in my understanding, the new image will be generated only if we alter the layers. Is my understanding correct?
Regards,
Nishanth
I don’t know what you did to change the devicetree files in OE Build. But usually adding and removing layer is not needed to generate a new image.
Best regards,
Jaski
Hi,
I opened the device tree file with gedit and made the changes and then compiled using bitbake. Is this right or should i edit the dts file only using terminal?
Regards,
Nishanth
That’s OK. You can edit the file using whatever you like. You just need to save your changes.
Best regards,
Jaski
That’s OK, but after changing the device tree and after a successful build, the new OS is not generated in the deploy folder. So I just tried with altering the device tree and also by adding an extra layer. This time the OS is generated in the deploy folder but SPI is not enabled. I could find the below line in the dmesg log.
[ 1.029695] spi_imx 30840000.ecspi: dma setup error -19, use pio [
1.038316] spi_imx 30840000.ecspi: probed
Also, I am going to use SPI with the M4 microcontroller only. So,altering device tree is for A7 processor, then how can i enable the SPI for the M4 microcontroller?
Regards,Nishanth
Hi Nishant
If spidev is still not enabled, there is an issue in changing and deploying the device-tree.
If you want to use spi with M4, then you need to disable the specific SPI Bus completely in the device-tree.
Best regards,
Jaski
Hi @jaski.tx ,
The problem is, when altering the device tree and then compiling, the compilation was successful in a flash but the image is not getting generated in my deploy folder. I tried with colleague PC also, we are facing the same problem but if we alter the layers, the image is getting generated. I don’t no why the image is not getting generated and how to solve this.
Thanks for your time.
Regards,
Nishanth
Hi Nishant
I would suggest you create the custom device-tree as explained here rather than trying to do this with OpenEmbedded Build.
By the way which file exactly did you change on the OE-Build. Could you share the complete path to this file?
Thanks.
Thank you for the quick response and the path of the device tree file that I altered is
/home/nishanth/build/webinar/yocto/build/tmp-glibc/work-shared/colibri-imx7-emmc/kernel-source/arch/arm/boot/dts/imx7-colibri-eval-v3.
Regards,Nishanth
You should not change the files in the temp or build folder but the source folder.
Best regards,
Jaski
Ok but where can I found the exact device tree file? Can you help me with the folder path?
/home/nishanth/build/webinar/yocto/build/tmp-glibc/work-shared/colibri-imx7-emmc/kernel-build-artifacts/source/arch/arm/boot/dts
Is this the correct path for the device tree file?
Regards,
Nishanth
Hi Jaski,
Will try with what you suggested and let you know. But as a workaround, I just tried with .dtb file in the BOOT folder while ums 0 mmc 0. I converted .dtb to .dts using device tree compiler and then made spi status enabled and converted the .dts file back to .dtb and replaced it in the BOOT folder. Now I can see that the spidev2.0 is enabled for Linux. But as far as for M4, I disabled the whole SPI bus in the device tree and I could see that both SPI and Can is disabled for Linux. But while using SPI from M4, the application gets struck in a infinite while loop when Linux Kernel starts which I asked in this question . Thanks for your time.
Regards,
NIshanth
Regards,
Nishanth.