I am trying to interface a FLIR Lepton 2.5 thermal imaging camera with Jetson-nano B01 using SPI.
However, I was not able to work with the SPI, even I tried to read and apply some other posts in the forum.
Below are the steps I did:
-
In Windows PC, I followed the steps in here, downloaded jetson-nano-jp461-sd-card-image.zip, and wrote image to the SD card.
-
In Jetson Nano, I can see the versions: nvidia-l4t-core 32.7.1, and Jetpack 4.6.4-b39.
tareq@tareq-nano3:~$ dpkg-query --show nvidia-l4t-core
nvidia-l4t-core 32.7.1-20220219090432
tareq@tareq-nano3:~$ sudo apt-cache show nvidia-jetpack
Package: nvidia-jetpack
Version: 4.6.4-b39
Architecture: arm64
Maintainer: NVIDIA Corporation
Installed-Size: 194
...
- Then I ran JetsonIO, configured 40 pin header, selected spi1 pins (19,21,23,24,26), saved and rebooted.
tareq@tareq-nano3:~$ sudo /opt/nvidia/jetson-io/jetson-io.py
It created /boot/kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb file and updated /boot/extlinux/extlinux.conf file. The contents of the /boot/extlinux/extlinux.conf file are shown 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 rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
# When testing a custom kernel, it is recommended that you create a backup of
# the original kernel and add a new entry to this file so that the device can
# 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 [2023-06-26-122936]>
LINUX /boot/Image
FDT /boot/kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb
INITRD /boot/initrd
APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb (232.4 KB)
extlinux.conf (1.2 KB)
- Then I used DTC compiler to create the kt.dts from the dtb file.
tareq@tareq-nano3:~$ dtc -I dtb -O dts -o kt.dts /boot/kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb
kt.dts (319.8 KB)
- Then I opened kt.dts using text editor.
tareq@tareq-nano3:~$ sudo gedit kt.dts
I modified spi1 and spi2 related texts as below:
spi2_miso_pb5 {
nvidia,pins = "spi2_miso_pb5";
nvidia,function = "spi2";
nvidia,pull = <0x1>;
nvidia,tristate = <0x0>;
nvidia,enable-input = <0x1>;
};
spi2_sck_pb6 {
nvidia,pins = "spi2_sck_pb6";
nvidia,function = "spi2";
nvidia,pull = <0x1>;
nvidia,tristate = <0x0>;
nvidia,enable-input = <0x1>;
};
spi2_cs0_pb7 {
nvidia,pins = "spi2_cs0_pb7";
nvidia,function = "spi2";
nvidia,pull = <0x1>;
nvidia,tristate = <0x0>;
nvidia,enable-input = <0x1>;
};
spi2_cs1_pdd0 {
nvidia,pins = "spi2_cs1_pdd0";
nvidia,function = "spi2";
nvidia,pull = <0x1>;
nvidia,tristate = <0x0>;
nvidia,enable-input = <0x1>;
spi1_mosi_pc0 {
nvidia,pins = "spi1_mosi_pc0";
nvidia,function = "spi1";
nvidia,pull = <0x1>;
nvidia,tristate = <0x0>;
nvidia,enable-input = <0x1>;
};
spi1_miso_pc1 {
nvidia,pins = "spi1_miso_pc1";
nvidia,function = "spi1";
nvidia,pull = <0x1>;
nvidia,tristate = <0x0>;
nvidia,enable-input = <0x1>;
};
spi1_sck_pc2 {
nvidia,pins = "spi1_sck_pc2";
nvidia,function = "spi1";
nvidia,pull = <0x1>;
nvidia,tristate = <0x10>;
nvidia,enable-input = <0x1>;
};
spi1_cs0_pc3 {
nvidia,pins = "spi1_cs0_pc3";
nvidia,function = "spi1";
nvidia,pull = <0x1>;
nvidia,tristate = <0x0>;
nvidia,enable-input = <0x1>;
};
spi1_cs1_pc4 {
nvidia,pins = "spi1_cs1_pc4";
nvidia,function = "spi1";
nvidia,pull = <0x1>;
nvidia,tristate = <0x0>;
nvidia,enable-input = <0x1>;
};
The the modified file is attached.
kt_modified.dts (319.8 KB)
- Then generated the kt.dtb file from the modified dts file.
tareq@tareq-nano3:~$ dtc -I dts -O dtb -o kt.dtb kt_modified.dts
- Then copied the dtb file to the boot directory as /boot/kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb
tareq@tareq-nano3:~$ sudo rm /boot/kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb
tareq@tareq-nano3:~$ sudo cp kt.dtb /boot/kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb
kernel_tegra210-p3448-0000-p3449-0000-b00-user-custom.dtb (232.4 KB)
Then I restarted the Jetson-nano.
- Turned on spidev and check the registers.
tareq@tareq-nano3:~$ sudo modprobe spidev
[sudo] password for tareq:
tareq@tareq-nano3:~$ ls /dev/spidev*
/dev/spidev0.0 /dev/spidev0.1 /dev/spidev1.0 /dev/spidev1.1
tareq@tareq-nano3:~$ sudo cat /sys/kernel/debug/tegra_pinctrl_reg | grep -i spiBank: 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
tareq@tareq-nano3:~$ 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 80 00 00 000000
C: 0:2 1f 00 00 18 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 02 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 00 00 00 000000
CC: 7:0 92 80 80 10 00 12 121200
DD: 7:1 01 00 00 01 00 00 000000
EE: 7:2 00 00 00 00 00 00 000000
FF: 7:3 00 00 00 00 00 00 000000
- Then used spidev-test to test SPI. I connected pin 19 and 21; and pin 22 and 37.
tareq@tareq-nano3:~$ git clone https://github.com/rm-hull/spidev-test
Cloning into 'spidev-test'...
remote: Enumerating objects: 26, done.
remote: Counting objects: 100% (26/26), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 26 (delta 10), reused 24 (delta 9), pack-reused 0
Unpacking objects: 100% (26/26), done.
tareq@tareq-nano3:~$ cd spidev-test
tareq@tareq-nano3:~/spidev-test$ gcc spidev_test.c -o spidev_test
tareq@tareq-nano3:~/spidev-test$ ./spidev_test -v -D /dev/spidev0.0
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | 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 | ......@....ļæ½..................ļæ½.
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 00 00 00 00 00 00 00 | ................................
tareq@tareq-nano3:~/spidev-test$ ./spidev_test -v -D /dev/spidev1.0
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | 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 | ......@....ļæ½..................ļæ½.
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 00 00 00 00 00 00 00 | ................................
tareq@tareq-nano3:~/spidev-test$ ./spidev_test -v -D /dev/spidev0.1
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | 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 | ......@....ļæ½..................ļæ½.
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 00 00 00 00 00 00 00 | ................................
tareq@tareq-nano3:~/spidev-test$ ./spidev_test -v -D /dev/spidev1.1
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | 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 | ......@....ļæ½..................ļæ½.
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 00 00 00 00 00 00 00 | ................................
Can you please help? If you can share the dts and dtb file for nvidia-l4t-core 32.7.1, and Jetpack 4.6.4-b39 for Jetson-nano that works, that might help.