Master-Slave Communication Between Two Jetson Nano over SPI

Hii, @ycaglar121 ,@ShaneCCC
Does your communication worked.

If run loopback test on two jetsons one as master another as slave without problem.

1 Like

Hii, @ShaneCCC
I want to interface jetson nano and BMP280 sensor via SPI, I have made changes on device tree and spi ports are visible on /dev / directory also added the driver for it and flshed it but I can’t find any compatible library, so can you help me how to proceed, means I don’t understand should I need library or not.

Sorry I don’t have experience for BMP280, Suppose you need driver and device tree configure.
Please consult with vendor to get support it.

1 Like

Hii, @ShaneCCC
I need to run spidev_test.c on jetson nano but don’t know the hardware setup can you please explain which pins should i connect and what to do for loopback mode and also where is spidev_test.c located.

Thank you.

Have reference to below link.

1 Like

Hii @ShaneCCC ,

Board used in above link is Jetson Xavier NX and I’m using Jetson nano after going through datasheet it seems all pins are same, so I want to ask that will it support for Jetson nano?
Also want to ask that does it work for 2 jetson nano connected via SPI?

Thank You.

Yes, just confirm the PINs connected for loopback test doesn’t matter NX or Nano

1 Like

Hii @ShaneCCC ,
Thank you!! Loopback test runs successfully, now I want to do SPI interface between 2 jetson nano, does loopback code supports for that or should I have to write the code if yes then please guide me with it. Hardware connections will not be tough but help me with software side like what steps should I follow, is there any library which I can use, do we need to add driver for it?

Thank you.

Suppose you can get the spidev_test source code from web.

Hii @ShaneCCC ,
Yes, I have the code will it work for 2 jetson nano, one as master and other is slave and for slave device should I follow this link: How to set to spi slave mode

Thank You.

Hii @ShaneCCC , Help me here.

Thank you.

Yes, follow the relative topic for it.

Thanks

1 Like

Hii @ShaneCCC ,
I set one Jetson nano as master and another as slave, could you please tell me
1.

Jetson nano 1 MISO → Jetson nano 2 MISO
Jetson nano 1 MOSI → Jetson nano 2 MOSI
Jetson nano 1 CLK → Jetson nano 2 CLK
Jetson nano 1 CS → Jetson nano 2 CS

is this hardware connection correct.

  1. should run spidev_test.c on master first and then on slave.
    Is there any changes should I make in spidev_test.c
    https://forums.developer.nvidia.com/t/master-slave-communication-between-two-jetson-nano-over-spi/221229/16?u=prasad.suralkar

Thank You.

Run the slave first. Also make sure your have modify the device tree as slave mode.

1 Like

Hii @ShaneCCC ,
Loopback test run fine on Jetson nano as master device
I have tried loopback test on Jetson nano as slave device

Command :

./spidev_test -D/dev/spidev1.0 -s18000000 -n100 -g30 -p4

Output :

[ 1108.050910] spi-tegra124-slave 7000d600.spi: pm runtime failed, e = -22
can’t set spi mode: Invalid argu[ 1108.057740] audit: type=1701 audit(1600599739.923:6): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=4733 comm="sp6
ment
Aborted

how to verify Jetson nano as slave device.

Thank You.

Hii @ShaneCCC
here I don’t understand what parameters are wrong, program returns 22 i.e. invalid arguments. can you please tell me where is the actual problem. I’m changing speed and other parameters but the result is always same

Thank You.

Did you modify the device tree for SPI slave mode?

Hii @ShaneCCC ,
Thank you for quick reply.
Yes, I have modified the device tree for slave mode.
I think device is set to slave mode so for loopback it didn’t get the clock frequency because on hardware I had short MISO & MOSI. & its only hardware connection i do.

Thank You.

Did you configure those PINs by jetson-io?

Confirm below command.
sudo cat /sys/kernel/debug/tegra_pinctrl_reg | grep -i spi

nvidia@nvidia-desktop:~$ sudo cat /sys/kernel/debug/tegra_pinctrl_reg | grep -i spi
[sudo] password for nvidia:
Bank: 1 Reg: 0x70003050 Val: 0x0000e044 -> spi1_mosi_pc0
Bank: 1 Reg: 0x70003054 Val: 0x0000e044 -> spi1_miso_pc1
Bank: 1 Reg: 0x70003058 Val: 0x0000e044 -> spi1_sck_pc2
Bank: 1 Reg: 0x7000305c Val: 0x0000e048 -> spi1_cs0_pc3
Bank: 1 Reg: 0x70003060 Val: 0x0000e048 -> spi1_cs1_pc4
Bank: 1 Reg: 0x70003064 Val: 0x00006044 -> spi2_mosi_pb4
Bank: 1 Reg: 0x70003068 Val: 0x00006044 -> spi2_miso_pb5
Bank: 1 Reg: 0x7000306c Val: 0x00006044 -> spi2_sck_pb6
Bank: 1 Reg: 0x70003070 Val: 0x00006044 -> spi2_cs0_pb7
Bank: 1 Reg: 0x70003074 Val: 0x00006044 -> spi2_cs1_pdd0
Bank: 1 Reg: 0x70003078 Val: 0x0000e015 -> spi4_mosi_pc7
Bank: 1 Reg: 0x7000307c Val: 0x0000e015 -> spi4_miso_pd0
Bank: 1 Reg: 0x70003080 Val: 0x0000e015 -> spi4_sck_pc5
Bank: 1 Reg: 0x70003084 Val: 0x0000e015 -> spi4_cs0_pc6