I connected the SPI interface sensor module (MPU9250) to the Expansion Header (SPI1_MOSI(19), SPI1_MISO(21), SPI1_SCK(23) and SP1_CS0(24)), but the SPI device was not recognized.
I tried sudo modprobe spidev command on the assumption that device file (e.g. /dev/spidev.0.0) will be created, but it was not created.
In dmesg, the error spidev: no symbol version for module_layout is output.
How can I use the SPI device?
The SPI device voltage level is 3.3V and I selected 3.3V voltage level by J514 on Xavier.
I used JetPack 4.1.
I attempted to rebuild the module from the latest source (L4T 31.0.2: https://developer.nvidia.com/embedded/dlc/l4t-sources-31-0-2 ), but the same error occurred when doing insmod.
And I tried modprobe command with f option, I got a different error message.
$ sudo modprobe -f spidev
modprobe: ERROR: could not insert 'spidev': Exec format error
Although this error seems to occur when the version is different, I think that it is the same version in my environment.
What are other possible causes?
I tried this myself, and it does, indeed, seem to not work:
nvidia@xavier:~$ sudo depmod
nvidia@xavier:~$ sudo modprobe -v -f -s spidev
insmod /lib/modules/4.9.108-tegra/kernel/drivers/spi/spidev.ko
modprobe: ERROR: could not insert 'spidev': Exec format error
nvidia@xavier:~$ file /lib/modules/4.9.108-tegra/kernel/drivers/spi/spidev.ko
/lib/modules/4.9.108-tegra/kernel/drivers/spi/spidev.ko: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), BuildID[sha1]=8c99ab33dc53f43d804b41bdeafa456f8489735f, not stripped
So, perhaps the module has some other dependency, thatās not fulfilled?
Kernel module dependency errors are notoriously hard to debug, because the interface back is just āerrnoā which isnāt particularly rich.
There isnāt any extra output in dmesg or journalctl after using the -s flag, either.
I built the kernel and drivers from the source and changed the device tree with reference to the information of Jetson TX2, the device file (eg /etc/spidev.0.0) was created.
The changes of the device tree are as follows.
However, Jetson Xavier can not communicate with the sensor connected to the Expansion Header. It seems that the state of the pin does not change even if the file is opened with spidev.
import spidev
spi = spidev.SpiDev()
spi.open(0, 0) // select device number in 0, 1, 2, 6, 7
spi.xfer2([1, 2])
spi.close()
I think you also need to change the pinmux to set the appropriate pins to SPI function rather than GPIO function.
This is where the large, hard-to-understand, chase-documentation-through-four-separate-documents spreadsheet of pin configurations comes in.
That, and a custom device tree.
I used spidev_test (/usr/src/linux-headers-4.9.108-tegra/tools/spi/spidev_test.c) to check spi communication.
device name: /dev/spidev0.0
pin name: SPI1_MOSI(19), SPI1_MISO(21), SPI1_SCLK(23) and SPI1_CS0(24) in Expansion header.
in the device tree, I want to know SPI1 detail adress, in my system, is spi@c260000, but when I want to change it, I found there is an imx204 exist already, when I add spi@0 block here,the dtc report a duplicate error, so I choice spi@321000,the SPI0 address, but my finally purpose is to enable SPI1.
sudo dd if=tegra194-p2888-0001-p2822-0000-base.dtb of=/dev/mmcblk0p31
when I use this command, I want to know the meaning of mmcblk0p31, in the TX2SPI official guide, is mmcblk0p1, I first use mmcblk0p31 and the spidev does not work. so I change to mmclbk0p1, my Xavier canāt boot at all, I post a topic at: xavier boot fail after change mmcblk0p1 for SPI - Jetson AGX Xavier - NVIDIA Developer Forums
I want to know if the mmcblk0p31 relate to the device(Xavier or tx2) or SPI(SPI0 or SPI1)