Enabling spidev on the jetson nano is hanging when flashing

I can’t flash with your file too.
Did you use dtc to modify the dtb?
Could you modify dts and build the dtb by download the kernel source?

So, I managed to flash the device with a modified dtb using NVidia SDK Manager. I now have a /dev/spidev0.0 available on L4T. However, the loopback test fails. I just receive zeros while I send other values.

Here is a link to my custom dts: https://drive.google.com/open?id=156kr49s0odHsKLHuhuoUrWE-3PTljiOO
Basically, I just followed the guide here https://elinux.org/Jetson/TX1_SPI I modified the gpio@6000d000 to remap GPIO ports to SPI, and spi@7000d400 to enable SPIdev.

Any suggestions ?

Did you confirm the https://elinux.org/Jetson/TX1_SPI#Verifying_GPIO_PinMux

udo cat /sys/kernel/debug/tegra_gpio

The instructions in https://elinux.org/Jetson/TX1_SPI#Verifying_GPIO_PinMux didn’t work for me.
I modified the gpio@6000d000 entry to include gpio-to-sfio. However, it doesn’t change anything !

$ sudo cat /sys/kernel/debug/tegra_gpio

Name:Bank:Port CNF OE OUT IN INT_STA INT_ENB INT_LVL
 A  : 0  :0    64  40 40  24 00      00      000000
 B  : 0  :1    f0  00 00  00 00      00      000000
 C  : 0  :2    1f  00 00  00 00      00      000000
 D  : 0  :3    10  10 00  00 00      00      000000
 ...

Have you confirm your dtb have been updated correct.

i have got same problem. can you send me the SPI enabled modified version if dtb file. so that i can directly flash to Jetson nano

Finally seem to have spi configured correctly after jumping through many hoops.

spidev_test seems to be working in loopback:

spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D  | ......@....�..................�.

I’m going to test it with a real device and if that works I’ll get post a dtb.

I was able to make the thing work too. The Lepton Flair works pretty well on the Jetson through SPI.
Will post the dtb and a tutorial asap.
Thank’s for the support everyone

Here is a dtb with spi 2 enabled, pins SPI2_MOSI, SPI2_MISO, SPI2_CLK & SPI2_CSI0

tegra210-p3448-0000-p3449-a02.dtb

It will create /dev/spidev1.0

You can verify with spidev_test by connecting SPI2_MOSI to SPI2_MISO (pin 22 to pin 37)

sudo ./spidev_test -D /dev/spidev1.0

good to hear that your spi works.

kindly list the steps you have followed to flash the modified dtb file into jetson nano board.
i am getting struck here. your help will greatly admired.

After downloading the dtb copy it to sdk directory:

Linux_for_Tegra/kernel/dtb/

Next power down nano and enable recovery mode by:

  1. Connect the Force Recovery pins (3 and 4) on J40 button header
    2.Jumper the J48 Power Select Header pins and connect a power supply to J25 power jack. The developer kit automatically powers on in Force Recovery mode.
  2. Connect nano to PC via usb cable

Run flash command:

sudo ./flash.sh -r -k DTB jetson-nano-qspi-sd mmcblk0p1

Hello,

I have issues when trying to enable an SPI with the Jetson nano.
I started from scratch with a flashed nano through the SDKManager.
I then followed this tutorial taking all your comments into account
https://elinux.org/Jetson/TX1_SPI#Verifying_GPIO_PinMux

  1. Extract the dts
$ dtc -I dtb -O dts -o ~/spi_test/extracted.dts /boot/tegra210-p3448-0000-p3449-0000-a02.dtb
  1. Preparing the modified dts by adding to the gpio@6000d000 entry for SPI1:
gpio_default: default {
      gpio-to-sfio = <16 17 18 19 20>;
 };

and to the spi@7000d400 entry:

spi0_0 {
    #address-cells = <0x1>;
    #size-cells = <0x0>;
    compatible = "spidev";
    reg = <0x0>;
    spi-max-frequency = <20000000>;
    nvidia,enable-hw-based-cs;
    nvidia,cs-setup-clk-count = <0x1e>;
    nvidia,cs-hold-clk-count = <0x1e>;
    nvidia,rx-clk-tap-delay = <0x1f>;
    nvidia,tx-clk-tap-delay = <0x0>;
};
  1. I then recompiled the dtb:
$ dtc -I dts -O dtb -o ~/spi_test/modified-gpio-spi0.dtb ~/spi_test/modified-gpio-spi0.dts
  1. I replaced the dtb files in the /boot:
$ sudo cp ~/spi_test/modified-gpio-spi0.dtb /boot/tegra210-p3448-0000-p3449-0000-a02.dtb
$ sudo cp ~/spi_test/modified-gpio-spi0.dtb /boot/dtb/tegra210-p3448-0000-p3449-0000-a02.dtb

(I am not sure I should also change the one in /boot/dtb but OK)

  1. I put the nano in recovery mode

  2. I moved to the host and flash the modified-gpio-spi0.dtb:

$ sudo cp ~/spi_test/modified-gpio-spi0.dtb /Linux_for_Tegra/kernel/dtb/tegra210-p3448-0000-p3449-0000-a02.dtb
$ sudo ./flash.sh -r -k DTB jetson-nano-qspi-sd mmcblk0p1

The flashing process is sucessful and the nano boots up.

  1. On the nano I look at the tegra_gpio file but I see no modification. Even after reboot. For some reason, it is not the same as the one posted earlier by KmL_:
Name:Bank:Port CNF OE OUT IN INT_STA INT_ENB INT_LVL
 A: 0:0 64 40 40 24 00 00 000000
 B: 0:1 00 00 00 00 00 00 000000
 C: 0:2 1f 00 00 00 00 00 000000
 D: 0:3 00 00 00 00 00 00 000000
 E: 1:0 40 00 00 00 00 00 000000
 F: 1:1 00 00 00 00 00 00 000000
 G: 1:2 0c 00 00 04 00 00 000000
 H: 1:3 fd 99 00 60 00 00 000000
 I: 2:0 07 05 00 02 00 00 000000
 J: 2:1 f0 00 00 00 00 00 000000
 K: 2:2 00 00 00 00 00 00 000000
 L: 2:3 00 00 00 00 00 00 000000
 M: 3:0 00 00 00 00 00 00 000000
 N: 3:1 00 00 00 00 00 00 000000
 O: 3:2 00 00 00 00 00 00 000000
 P: 3:3 00 00 00 00 00 00 000000
 Q: 4:0 00 00 00 00 00 00 000000
 R: 4:1 00 00 00 00 00 00 000000
 S: 4:2 a0 80 00 00 00 00 000000
 T: 4:3 01 01 00 00 00 00 000000
 U: 5:0 00 00 00 00 00 00 000000
 V: 5:1 03 00 00 02 00 00 000000
 W: 5:2 00 00 00 00 00 00 000000
 X: 5:3 78 08 08 70 00 60 606000
 Y: 6:0 06 00 00 02 00 00 000000
 Z: 6:1 0f 08 08 04 00 06 020600
AA: 6:2 00 00 00 00 00 00 000000
BB: 6:3 01 00 00 00 00 00 000000
CC: 7:0 12 00 00 00 00 12 121200
DD: 7:1 01 00 00 00 00 00 000000
EE: 7:2 00 00 00 00 00 00 000000
FF: 7:3 00 00 00 00 00 00 000000
  1. I am pretty sure the dtb is correctly loaded as I can extract again the dts from the actual device tree, I see the two modifications inside:
$ dtc -I fs -O dts -o extracted_after_flash.dts /proc/device-tree
  1. The SPIdev is correctly loaded:
$ ls /dev/spi*
     /dev/spidev0.0
  1. the loopback test fails.

Does anyone have an idea of what I am doing wrong/not doing at all?

Thank you!

Hi All, I have read the whole message chain and it seems only way to enable SPI interface is by having a SDK manager on a Linux host machine. At my workplace, we dont have a linux PC. Is there any other way to enable the SPI interface?

I tried doing it by following a tutorial meant for Raspberry PI (As the interface seems to be the same). And the steps led me to follow what @guerric has done above in comment 32. But my Nano got bricked. I had to reflash the SD card and start all over again.

Omkar

@guerric
Cold you try below dtb from jas-mx

https://devtalk.nvidia.com/default/topic/1050427/jetson-nano/enabling-spidev-on-the-jetson-nano-is-hanging-when-flashing/post/5338252/#5338252

It seems that the gpio-to-sfio command is no longer supported. Instead, try:

default {
	gpio-hog;
	function;
 	gpios = <0x10 0x0 0x11 0x0 0x12 0x0 0x13 00 0x14 0x0>;
};

@ShaneCCC indeed I can achieve a functional loopback with this dtb. I will extract the dts and compare to mine. Thank you for the tip.

@KmL_ Thank you for this syntax, it is indeed the one used by jas-mx.

Hi. Thanks to @jas-mx’s information, I was able to enable SPI1.
@jas-mx, thank you very much for your information.
I published the .dts file and the flash script here: https://github.com/rt-net/JetsonNano_DT_SPI
I hope this helps.

Thanks Tiryoh

I have followed your prosedure to flash the #DTB file on my jetson nano board and now I am able to see SPIDEV1.0 module using #lsmod. but I am unable to use #spi.open(1,0) command from spidev library. it shows permission denied error message. can you please guide me, how can I use SPIDEV1.0 module to communicate with other device.

and how to run loopback test on jetson nano.

Run your program with supervisor mode (sudo)

Hi @manjeet.elect,

Add permission to access /dev/spi* for the current user or run the command by root user as @ShaneCCC said.

This topic seems to be similar.
https://www.raspberrypi.org/forums/viewtopic.php?t=106814