About using spi on Jetson NANO

  1. Using jetson-io to configure it.
  2. After reboot have below command to generate the spidev*.*
sudo modprobe spidev
2 Likes

Hello,

Can I choose 1 or 2?

Thank you.

Default device tree enable both of them. If you just want to see one spidev*.* you need to modify the device tree for it.

1 Like

Hello,

Thank you.

Hello,

As soon as /opt/nvidia/jetson-io/jetson-io.py is executed, the execution of jetson-io.py is immediately terminated.

The l4t version is # R32 (release), REVISION: 6.1 .
Can you guess the cause?

Thank you.

Hello,

I can see the spi node.

Codes that open and access spi are also executed normally.

However, I can’t check the waveform change with the oscilloscope.
What’s the problem?

Thank you.

Modify those pins spi1__ to spi1 in “nvidia,function” like below.

                         spi1_mosi_pc0 {
                                nvidia,enable-input = <0x1>;
                                nvidia,pins = "spi1_mosi_pc0";
                                nvidia,tristate = <0x0>;
                                nvidia,function = "spi1";
                                nvidia,pull = <0x1>;
                        };
1 Like

Hello,

I did a search and found the following files:
I don’t know which file to edit.
I was told to check something with dmesg, how do I check it?
What file do I have to modify?

jetsonhostpc@jetsonhostpc-Vostro-470:/media/jetsonhostpc/841a9ca5-d24b-49de-8e73-d245a962e433/home/nanohostpc/coding/spi_jetson/Linux_for_Tegra$ grep -r "spi1_mosi_pc0" *
source/public/kernel/kernel-4.9/drivers/pinctrl/tegra/pinctrl-tegra210.c:static const unsigned spi1_mosi_pc0_pins[] = {
source/public/kernel/kernel-4.9/drivers/pinctrl/tegra/pinctrl-tegra210.c:       PINGROUP(spi1_mosi_pc0,        SPI1,       RSVD1,  RSVD2, RSVD3, 0x3050, Y,   Y,       N,       N,       0xae0, -1,      -1,      -1,      -1,      28,     2,      30,     2, -1),
source/public/kernel/kernel-4.9/arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi:                 spi1_mosi_pc0 {
source/public/kernel/kernel-4.9/arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi:                 nvidia,pins = "spi1_mosi_pc0";
source/public/kernel/kernel-4.9/arch/arm64/boot/dts/nvidia/tegra210-p2595.dtsi:                 spi1_mosi_pc0 {
source/public/kernel/kernel-4.9/arch/arm64/boot/dts/nvidia/tegra210-p2595.dtsi:                 nvidia,pins = "spi1_mosi_pc0";
source/public/kernel/kernel-4.9/arch/arm64/boot/dts/nvidia/tegra210-p2571.dts:                  spi1_mosi_pc0 {
source/public/kernel/kernel-4.9/arch/arm64/boot/dts/nvidia/tegra210-p2571.dts:                  nvidia,pins = "spi1_mosi_pc0";
source/public/kernel/kernel-4.9/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts:                  spi1_mosi_pc0 {
source/public/kernel/kernel-4.9/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts:                  nvidia,pins = "spi1_mosi_pc0";
source/public/kernel/kernel-4.9/Documentation/devicetree/bindings/pinctrl/nvidia,tegra210-pinmux.txt:    spi1_cs1_pc4, spi1_miso_pc1, spi1_mosi_pc0, spi1_sck_pc2, spi2_cs0_pb7,
source/public/hardware/nvidia/soc/tegra/kernel-include/dt-common/jetson/tegra210-jetson-tx1-p2597-2180-a01-devkit.h:#define HDR40_PIN19  "spi1_mosi_pc0"
source/public/hardware/nvidia/soc/tegra/kernel-include/dt-common/jetson/tegra210-p3448-0000-p3449-0000-a01.h:#define HDR40_PIN19 "spi1_mosi_pc0"
source/public/hardware/nvidia/soc/tegra/kernel-include/dt-common/jetson/tegra210-p3448-0000-p3449-0000-a02.h:#define HDR40_PIN19 "spi1_mosi_pc0"
source/public/hardware/nvidia/soc/tegra/kernel-include/dt-common/jetson/tegra210-p3448-0003-p3542-0000.h:#define HDR40_PIN19     "spi1_mosi_pc0"

Thank you.

Check which dtb was applied by dmesg | grep -i kernel
Then check this dts include which dts file or you can modify all of them to make sure of it.

1 Like

Hello,

If it is confirmed as below, is it tegra210-p3448-0002-p3449-0000-b00.dts file?

tegra210-p3448-0002-p3449-0000-b00.dts

When you say edit all files, do you mean edit all files with the following content?

manager@manager-desktop:~$ dmesg | grep -i kernel
[    0.000000] Kernel command line: tegraid=21.1.2.0.0 ddr_die=4096M@2048M section=512M memtype=0 vpr_resize usb_port_owner_info=0 lane_owner_info=0 emc_max_dvfs=0 touch_id=0@63 video=tegrafb no_console_suspend=1 console=ttyS0,115200n8 debug_uartport=lsport,4 earlyprintk=uart8250-32bit,0x70006000 maxcpus=4 usbcore.old_scheme_first=1 lp0_vec=0x1000@0xff780000 core_edp_mv=1125 core_edp_ma=4000 gpt  earlycon=uart8250,mmio32,0x70006000  root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 sdhci_tegra.en_boot_part_access=1 quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 sdhci_tegra.en_boot_part_access=1 
[    0.000000] Memory: 3568412K/4159488K available (15358K kernel code, 2956K rwdata, 6692K rodata, 8640K init, 612K bss, 115940K reserved, 475136K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.001846] kmemleak: Kernel memory leak detector disabled
[    0.207972] DTS File Name: /home/test/Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t210/porg/kernel-dts/**tegra210-p3448-0002-p3449-0000-b00.dts**
[    0.321306] alternatives: patching kernel code
[    0.416526] DTS File Name: /home/test/Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t210/porg/kernel-dts/**tegra210-p3448-0002-p3449-0000-b00.dts**
[    0.550046] eventlib_kernel: keventlib is initialized, test id: 0
[    1.678895] sysfs: cannot create duplicate filename '/kernel/rt8168_power'
[    1.678975] WARNING: CPU: 0 PID: 1 at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/fs/sysfs/dir.c:31 sysfs_warn_dup+0x68/0x88
[    1.679299] [<ffffff8009610d20>] kernel_init_freeable+0x1a0/0x244
[    1.679311] [<ffffff8008f63dc0>] kernel_init+0x18/0x108
[    1.692071] unable to create rt8168_power_saver kernel object!
[    2.036254] KERNEL: PMC reset status reg: 0x0
[    2.082548] Freeing unused kernel memory: 8640K
[    4.708048] WARNING: CPU: 0 PID: 2798 at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/drivers/spi/spidev.c:767 0xffffff8000f892a8
[    4.835568] WARNING: CPU: 3 PID: 2798 at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/drivers/spi/spidev.c:767 0xffffff8000f892a8
[    4.863734] WARNING: CPU: 3 PID: 2798 at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/drivers/spi/spidev.c:767 0xffffff8000f892a8
[    4.888018] WARNING: CPU: 3 PID: 2798 at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/drivers/spi/spidev.c:767 0xffffff8000f892a8
 spi1_mosi_pc0 {
                                nvidia,enable-input = <0x1>;
                                nvidia,pins = "spi1_mosi_pc0";
                                nvidia,tristate = <0x0>;
                                nvidia,function = "spi1";
                                nvidia,pull = <0x1>;
                        };

Thank you.

Hello,
extracted_proc.dts (330.0 KB)

Attach the dts generated by the following command.
sudo dtc -I fs -O dts -o extracted_proc.dts /proc/device-tree

Thank you.

Hello,

Edit spi1_mosi_pc0 in tegra210-porg-pinmux-p3448-0002-b00.dtsi as follows and compile dtb

I flashed dtb with the following command.

sudo ./flash.sh -k DTB jetson-nano-devkit-emmc mmcblk0p1

But still there is no change in the oscilloscope’s waveform.
Attach dmesg.txt.
What more can we do?

Thank you.

Hello, @ShaneCCC

Can you please reply after checking the message?

Thank you.

Have a dump the REG by below command to check.

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

Did you short pin 22 and 37 for loopback test to check the waveform?

1 Like
manager@manager-desktop:~$ sudo cat /sys/kernel/debug/tegra_pinctrl_reg | grep -i spi
[sudo] password for manager: 
Bank: 1 Reg: 0x70003050 Val: 0x0000e045 -> spi1_mosi_pc0
Bank: 1 Reg: 0x70003054 Val: 0x0000e045 -> spi1_miso_pc1
Bank: 1 Reg: 0x70003058 Val: 0x0000e045 -> spi1_sck_pc2
Bank: 1 Reg: 0x7000305c Val: 0x0000e049 -> spi1_cs0_pc3
Bank: 1 Reg: 0x70003060 Val: 0x0000e049 -> 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: 0x00002015 -> qspi_sck_pee0
Bank: 1 Reg: 0x7000308c Val: 0x00002015 -> qspi_cs_n_pee1
Bank: 1 Reg: 0x70003090 Val: 0x00002015 -> qspi_io0_pee2
Bank: 1 Reg: 0x70003094 Val: 0x00002015 -> qspi_io1_pee3
Bank: 1 Reg: 0x70003098 Val: 0x00002015 -> qspi_io2_pee4
Bank: 1 Reg: 0x7000309c Val: 0x00002015 -> 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

Thank you.

Hello,

Once the clock doesn’t come out.
When the clock is confirmed, I will also do a loopback test.

Thank you.

Hello, @ShaneCCC

Do you have any advice for me?

Thank you.

Looks like your device didn’t apply well.
The REG dump should be like below. Check by dmesg | grep -i kernel if apply correct dtb build from your host. Or dump by dtc to confirm it. Also check if the /boot/extlinux/extlinux.conf have define the FDT to load dtb from rootfs.

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

1 Like

Hello,

dmesg | grep -i kernel

manager@manager-desktop:~$ dmesg | grep -i kernel
[    0.000000] Kernel command line: tegraid=21.1.2.0.0 ddr_die=4096M@2048M section=512M memtype=0 vpr_resize usb_port_owner_info=0 lane_owner_info=0 emc_max_dvfs=0 touch_id=0@63 video=tegrafb no_console_suspend=1 console=ttyS0,115200n8 debug_uartport=lsport,4 earlyprintk=uart8250-32bit,0x70006000 maxcpus=4 usbcore.old_scheme_first=1 lp0_vec=0x1000@0xff780000 core_edp_mv=1125 core_edp_ma=4000 gpt  earlycon=uart8250,mmio32,0x70006000  root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 sdhci_tegra.en_boot_part_access=1 quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 sdhci_tegra.en_boot_part_access=1 
[    0.000000] Memory: 3568412K/4159488K available (15358K kernel code, 2956K rwdata, 6692K rodata, 8640K init, 612K bss, 115940K reserved, 475136K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.001814] kmemleak: Kernel memory leak detector disabled
[    0.208256] DTS File Name: /home/test/Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-p3448-0002-p3449-0000-b00.dts
[    0.321315] alternatives: patching kernel code
[    0.416542] DTS File Name: /home/test/Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-p3448-0002-p3449-0000-b00.dts
[    0.554319] eventlib_kernel: keventlib is initialized, test id: 0
[    1.763794] sysfs: cannot create duplicate filename '/kernel/rt8168_power'
[    1.763877] WARNING: CPU: 1 PID: 1 at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/fs/sysfs/dir.c:31 sysfs_warn_dup+0x68/0x88
[    1.764194] [<ffffff8009610d20>] kernel_init_freeable+0x1a0/0x244
[    1.764206] [<ffffff8008f63dc0>] kernel_init+0x18/0x108
[    1.777002] unable to create rt8168_power_saver kernel object!
[    2.124485] KERNEL: PMC reset status reg: 0x0
[    2.170869] Freeing unused kernel memory: 8640K
[    4.569343] WARNING: CPU: 2 PID: 2864 at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/drivers/spi/spidev.c:767 0xffffff8000f892a8
[    4.591301] WARNING: CPU: 2 PID: 2864 at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/drivers/spi/spidev.c:767 0xffffff8000f892a8
[    4.637157] WARNING: CPU: 2 PID: 2864 at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/drivers/spi/spidev.c:767 0xffffff8000f892a8
[    4.693160] WARNING: CPU: 2 PID: 2864 at /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/drivers/spi/spidev.c:767 0xffffff8000f892a8

/boot/extlinux/extlinux.conf

manager@manager-desktop:~$ cat /boot/extlinux/extlinux.conf
TIMEOUT 30
DEFAULT primary

MENU TITLE L4T boot options

LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      FDT /boot/tegra210-p3448-0002-p3449-0000-b00.dtb
      APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 sdhci_tegra.en_boot_part_access=1 

# 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}```

Thank you.

Using dtc to un-compile below file to check the modification.

1 Like