Nano SPI Not Working

0, Problem

Spi Communtion not working.
No signal in MOSI for spi communication(GPIO Port no.19&21 ). I checked the voltage of pins 19 and 21 through an oscilloscope.

1,Back Ground

Jetson Nano Dev Kit 4Gb
B01 board
Flash jp461 file by balenaetcher
(Using SD card)

1, What I did

sudo apt-get update
sudo apt-get upgrade
sudo apt install python3-pip

pip3 install Jetson.GPIO
sudo groupadd -f -r gpio
sudo usermod -a -G gpio [my name]
sudo apt-get install nano

sudo /opt/nvidia/jetson-io/jetson-io.py

image

/boot/kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb.
saved to file and rebooted
kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.zip (43.1 KB)

2,System Info

and this is my extlinux.conf file.

$ sudo nano /boot/extlinux/extlinux.conf

Looking at the default and FDT items, it seems to have been applied well.

DEFAULT JetsonIO
FDT /boot/kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.$

The full text is below


TIMEOUT 30
DEFAULT JetsonIO

MENU TITLE L4T boot options

LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfsty$

# When testing a custom kernel, it is recommended that you create a back$
# the original kernel and add a new entry to this file so that the devic$
# fallback to the original kernel. To do this:
#
# 1, Make a backup of the original kernel
#      sudo cp /boot/Image /boot/Image.backup
#
# 2, Copy your custom kernel into /boot/Image
#
# 3, Uncomment below menu setting lines for the original kernel
#
# 4, Reboot

# LABEL backup
#    MENU LABEL backup kernel
#    LINUX /boot/Image.backup
#    INITRD /boot/initrd
#    APPEND ${cbootargs}

LABEL JetsonIO
        MENU LABEL Custom Header Config: <HDR40 User Custom [2024-01-17-$
        LINUX /boot/Image
        FDT /boot/kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.$
        INITRD /boot/initrd
        APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfs$

and this is my release version

$ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.6 LTS
Release:        18.04
Codename:       bionic

sudo cat /sys/kernel/debug/tegra_pinctrl_reg | grep -i spi

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: 0x00006046 -> spi2_mosi_pb4
Bank: 1 Reg: 0x70003068 Val: 0x00006046 -> spi2_miso_pb5
Bank: 1 Reg: 0x7000306c Val: 0x00006046 -> spi2_sck_pb6
Bank: 1 Reg: 0x70003070 Val: 0x00006046 -> spi2_cs0_pb7
Bank: 1 Reg: 0x70003074 Val: 0x00006045 -> 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
Bank: 1 Reg: 0x70003088 Val: 0x00002040 -> qspi_sck_pee0
Bank: 1 Reg: 0x7000308c Val: 0x00002000 -> qspi_cs_n_pee1
Bank: 1 Reg: 0x70003090 Val: 0x00002040 -> qspi_io0_pee2
Bank: 1 Reg: 0x70003094 Val: 0x00002040 -> qspi_io1_pee3
Bank: 1 Reg: 0x70003098 Val: 0x00002040 -> qspi_io2_pee4
Bank: 1 Reg: 0x7000309c Val: 0x00002040 -> qspi_io3_pee5
Bank: 0 Reg: 0x70000b70 Val: 0x00000001 -> drive_qspi_comp_control
Bank: 0 Reg: 0x70000b78 Val: 0x00000001 -> drive_qspi_lpbk_control
Bank: 0 Reg: 0x70000a78 Val: 0x00808000 -> drive_qspi_comp

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 04 00 00 000000
 B: 0:1 f0 00 00 20 00 00 000000
 C: 0:2 1f 00 00 1f 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 00 00 00 000000
 H: 1:3 fd 99 00 60 00 00 000000
 I: 2:0 07 07 03 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 01 00 00 00 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 01 00 00 000000
CC: 7:0 92 80 80 10 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

3,Loof Back Test

1, Hardware Setting

as you see, I connect MISO and MOSI pins(no.19&21)

2, Test Code

loop back test link

I copied and pasted that code exactly the same.
I made spidev_test.c file and run it.

$ sudo gcc spidev_test.c

after entering password

$ ./a.out

spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 

what should I do?

At first, SPI communication worked well. But after resetting and reinstalling the OS in SD card, SPI doesn’t work. Afterwards, I reset sd card several times and tried several times . I even used another Jetson Nano devices with numerous SD cards . But SPI never works. What did I miss? what should I do?

thanks for helping

Hi 201241,

What’s your Jetpack version in use?

Please refer to the following thread to enable SPI on Jetson Nano.
Jetson Nano SPI Bus Not Working - #10 by KevinFFF

Your issue might be related to GPIO usage for those pins. Please check the method to remove GPIO usage in the link I shared (2-2-2-3 Modify the following line)

Have you tried to use SDKM to flash your SD on your board?

Thanks for replying

0, Jetpack Version Issue

I checked the jetpack version in two ways

Method.1 $ dpkg -l | grep nvidia-jetpack

->but nothing happened

Method.2 -/usr/local$ cat nvidia/jetpack_version.txt

cacd /usr/local/
cat nvidia/jetpack_version.txt

but the result is

t: nvidia/jetpack_version.txt: No such file or directory

I can’t find the version of jetpack.
The image file written to the sd card is jp461

1, What does Flash means?

In item 2-2-2-5, what is the meaning of flash in Flash the board?
Does this mean that I have to flash it using the SDK manager?

2-2-2. Method 2 - Remove from decompiled dtb
2-2-2-1 Find you dtb in Linux_for_Tegra/kernel/dtb/tegra210-p3448-0000-p3449-0000-b00.dtb

2-2-2-2 Dissemble the dtb to dts
dtc -I dtb -O dts -o temp.dts tegra210-p3448-0000-p3449-0000-b00.dtb

2-2-2-3 Modify the following line
-        gpio-input = <0xd8 0xc 0xd 0xe 0xf 0xe8 0x26 0x95 0x5 0xbc 0xbd 0xbe 0xc1 0xc2 0xa8 0xc8 0xca 0x4d 0x4e 0x4c 0x4f 0x32 0x33 0x10 0x11 0x12 0x13 0x14 0x3a 0x3d 0x3e 0x41 0xe4>;
+        gpio-input = <0xd8 0x26 0x95 0x5 0xbc 0xbd 0xbe 0xc1 0xc2 0xa8 0xc8 0xca 0x4d 0x4e 0x4c 0x4f 0x32 0x33 0x3a 0x3d 0x3e 0x41 0xe4>;

2-2-2-4 Assemble the dts back to dtb
dtc -I dts -O dtb -o tegra210-p3448-0000-p3449-0000-b00.dtb temp.dts

2-2-2-5 Flash the board

2, Do I have to use sdkm?

As far as I know, sdkm requires one more Linux host. Preparing a Linux host is difficult for me.
**Can’t the solution be solved by flashing the jetpack without using sdkm?

Have a nice day sir!!

Please share the result of the following command on your board.

$ cat /etc/nv_tegra_release

Please use flash command like the following to flash your board.

$ sudo ./flash.sh jetson-nano-devkit mmcblk0p1

You would still need to get a Ubuntu 16.04 or 18.04 as host PC to develop Jetson device.

Thank you for your detailed advice

Now Im trying to use virtual ubuntu env on my pc(window) to develope jetson device
I can’t proceed any further without an Ubuntu host, right?
After downloading, I will proceed with flashing.

by the way, the versions are as follows.

$ cat /etc/nv_tegra_release

#R32 (release), REVISION: 7.1, GCID: 29818004, BOARD: t210ref, EABI: aarch64, DATE: Sat Feb 19 17:05:08 UTC 2022

I think I definitely wrote the image to the SD card properly. There was no problem using the Jetson Nano by inserting an SD card. I can log in, and the LED blinking example using gpio runs normally, but why doesn’t spi communication work?

Please make sure the connection between your board and host is stable since you are using Ubuntu in VM.

SPI is not enabled by default so that you should enable it by those steps.

Maybe you could try just decompile the dtb into dts on your board and modify the contents as “2-2-2-3” in my link shared.
Please provide the /boot/dtb/kernel_XXX.dtb as file here for further check.

Thanks for helping me

This is my dtb file

This dtb was made by using

sudo /opt/nvidia/jetson-io/jetson-io.py

It seems the SPI pins are removed in gpio-input.

Could you short MISO/MOSI of SPI1 and run the following command on your board to verify loopback test?

$ sudo modprobe spidev
$ wget https://raw.githubusercontent.com/torvalds/linux/v4.9/tools/spi/spidev_test.c
$ gcc -o spidev_test spidev_test.c
$ sudo ./spidev_test -D /dev/spidev0.0 -v -p "HelloWorld123456789abcdef"

this is loop back test result
I connected pin 19&21

:~$ sudo ./spidev_test -D /dev/spidev0.0 -v -p

“HelloWorld123456789abcdef”
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | 48 65 6C 6C 6F 57 6F 72 6C 64 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 __ __ __ __ __ __ __ | HelloWorld123456789abcdef
RX | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ | …

If so, can you provide the appropriate dtb file?

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

Could you run the following command on your board and provide extracted_proc.dts for further check?

$ sudo dtc -I fs -O dts -o extracted_proc.dts /proc/device-tree