Hi,
I’ve seen some other posts on the forum regarding my issue but failed to get it working.
I have an STM32 device, working in SPI master with CS, SCK, MOSI pins. STM device only works as transmit device.
I’ve connected Jetson Xavier’s SPI1_SCK to STM_SCK, SPI1_MOSI to STM_MOSI, and SPI1_CS0 to STM_CS
Next, I’ve configured the dts file
spi@3210000 {
compatible = "nvidia,tegra186-spi-slave";
reg = <0x0 0x3210000 0x0 0x10000>;
interrupts = <0x0 0x24 0x4>;
#address-cells = <0x1>;
#size-cells = <0x0>;
iommus = <0x2 0x20>;
dma-coherent;
dmas = <0x22 0xf 0x22 0xf>;
dma-names = "rx", "tx";
spi-max-frequency = <0x3dfd240>;
nvidia,clk-parents = "pll_p", "clk_m";
clocks = <0x4 0x87 0x4 0x66 0x4 0xe>;
clock-names = "spi", "pll_p", "clk_m";
resets = <0x5 0x5b>;
reset-names = "spi";
status = "okay";
linux,phandle = <0x16d>;
phandle = <0x16d>;
spi@0 {
compatible = "tegra-spidev";
reg = <0x0>;
spi-max-frequency = <0x1f78a40>;
controller-data {
nvidia,enable-hw-based-cs;
nvidia,rx-clk-tap-delay = <0x11>;
};
};
spi@1 {
compatible = "tegra-spidev";
reg = <0x1>;
spi-max-frequency = <0x1f78a40>;
controller-data {
nvidia,enable-hw-based-cs;
nvidia,rx-clk-tap-delay = <0x11>;
};
};
};
Also for the pinmux I’ve tried bunch of settings I’ve seen on the forum
such as :
Reg: 0x0243d010 Val: 0x00000448 -> spi1_cs0_pz6
Reg: 0x0243d020 Val: 0x00000440 -> spi1_miso_pz4
Reg: 0x0243d040 Val: 0x00000444 -> spi1_sck_pz3
Reg: 0x0243d050 Val: 0x00000448 -> spi1_cs1_pz7
Reg: 0x0243d058 Val: 0x00000440 -> spi1_mosi_pz5
But with spidev_test
file I always get
sudo ./spidev_test -D /dev/spidev0.0 -s 3000000 -r -n10 -g32 -p0 -b32 -zzz
using device: /dev/spidev0.0
setting spi mode for read,write
setting spi bpw
setting max speed for rd/wr
spi mode: 0
bits per word: 32 bytes per word: 4
max speed: 3000000 Hz (3000 KHz)
no. runs: 10
Using seed:0x61d2582e
loop count = 0
transfer ioctl error: -1
loop count = 1
transfer ioctl error: -1
loop count = 2
transfer ioctl error: -1
loop count = 3
transfer ioctl error: -1
loop count = 4
transfer ioctl error: -1
loop count = 5
transfer ioctl error: -1
loop count = 6
transfer ioctl error: -1
loop count = 7
transfer ioctl error: -1
loop count = 8
transfer ioctl error: -1
loop count = 9
transfer ioctl error: -1
/dev/spidev0.0: TEST FAILED !!!!! (status:-1)
====== Transfer stats ====
Receive:
total: 0B (0KiB 0MiB)
total: 0P
good: 0B (0KiB 0MiB)
good: 0P
ioerr: 10P
dataerr: 0P
Rate:
good: -1B/s (0KB/s)
good: -1P/s
packet drop: -1/10000
Total time: 0.471914s
Also, I’ve noticed even though Jetson is configured as slave mode, I’ve observed that CS0 pin gets high (when driven to low by stm) during above test. When the test has stopped working, the CS line is pulled to low as expected by the stm32
Please advice on how to configure pinmux (assuming everything else is correct)
Here are my SPI Connection Spesifications:
Master: STM32 Device
CLK: 1.5625MHz
MOSI: Driven by STM32
CS: Driven by STM32
Bits / transfer: 32-bit
CPOL: LOW
CPHA: 1 Edge
Slave: Jetson AGX Xavier
SPI1_CLK, SPI1_CS0, SPI1_MOSI connected appropriately.
STM device will be transferring on a scheduled timing. Jetson will transmit nothing, stm will receive nothing.
Here is the screenshot of observed CS (NSS) behavior.