About using spi on Jetson NANO

Hello, @ShaneCCC

I have used jp4.6.1.
cat /etc/nv_tegra_release

R32 (release), REVISION: 7.1, GCID: 29818004, BOARD: t210ref, EABI: aarch64, D

sudo cat /sys/kernel/debug/tegra_pinctrl_reg | grep -i spi
[sudo] password for manager: 
Bank: 1 Reg: 0x70003050 Val: 0x0000e015 -> spi1_mosi_pc0
Bank: 1 Reg: 0x70003054 Val: 0x0000e015 -> spi1_miso_pc1
Bank: 1 Reg: 0x70003058 Val: 0x0000e015 -> spi1_sck_pc2
Bank: 1 Reg: 0x7000305c Val: 0x0000e015 -> spi1_cs0_pc3
Bank: 1 Reg: 0x70003060 Val: 0x0000e015 -> spi1_cs1_pc4
Bank: 1 Reg: 0x70003064 Val: 0x00006016 -> spi2_mosi_pb4
Bank: 1 Reg: 0x70003068 Val: 0x00006016 -> spi2_miso_pb5
Bank: 1 Reg: 0x7000306c Val: 0x00006016 -> spi2_sck_pb6
Bank: 1 Reg: 0x70003070 Val: 0x00006016 -> spi2_cs0_pb7
Bank: 1 Reg: 0x70003074 Val: 0x00006015 -> 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
sudo dtc -I fs -O dts -o extracted_proc_emmc_new.dts /proc/device-tree

extracted_proc_emmc_new.dts (321.5 KB)

and
apply nvidia,function = “spi1”.

and compile dtb from extracted_proc_emmc_new.dts

dtc -I dts extracted_proc_emmc_new.dts -O dtb -o spi-emmc.dtb

and execute below command

sudo cp spi-emmc.dtb /boot/
sudo vi /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/spi_emmc.dtb or /boot/tegra210-p3448-0002-p3449-0000-b00.dtb

At this time,

Is it something wrong with my work?

Thank you.

Hello, @ShaneCCC

I have used R32.7.1.

I can’t find TEGRA_GPIO B an B.

Where can I find this?
extracted_proc_emmc_new.dts (321.5 KB)

Thank you.

The “nvidia,enable-input” and “nvidia,tristate” should be like below for all spi1_xxx pins
You need find the TEGRA_GPIO(B, *) in kernel source instead of device tree dump.

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

Hello, @ShaneCCC

  1. Shouldn’t dtb compiled with dtc be applied using dts created from /proc/device-tree? Is this the wrong way?

  2. Check the /boot directory in jp4.6.1 (l4t R32.7.1)
    kernel_tegra210-p3448-0002-p3449-0000-b00.dtb
    tegra210-p3448-0002-p3449-0000-b00.dtb

There are two, which of the two applies? Please confirm.

Thank you.

Use the dts source codes to check what ShaneCCC is asking.

Otherwise it is just hex value which is not human readable.

1 Like

Hello, @ShaneCCC

Thank you for your support.

Should I change not only 1 but also 2 or 3?
The kernel source contains nvidia, enable-input = <TEGRA_PIN_DISABLE>
is set to 0.

Thank you.

Yes, need modify like below.

				nvidia,pins = "spi1_mosi_pc0";
79 					nvidia,function = "spi1";
80 					nvidia,pin-label = "spi1_dout";
81 					nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
82 					nvidia,tristate = <TEGRA_PIN_DISABLE>;
83 					nvidia,enable-input = <TEGRA_PIN_ENABLE>;
1 Like

Hello, @ShaneCCC

Do I need to add a pin label?

Thank you.

Thanks for the explain from @WayneWWW
If able know the hex value you can use dtc instead of touch the source.

1 Like

Hello, @ShaneCCC

There is no pin label in the original kernel source. should i add it?

Thank you.

No need to add the pin label.

1 Like

Hello,

I’m in a bit of a hurry, can you watch with me for a moment?

tegra210-porg-pinmux-p3448-0002-b00.dtsi (38.1 KB)
I changed everything as instructed and applied dtb as FDT in extlinux.conf.

Thank you.

Hello, @ShaneCCC

Help me. please.
I am using the kernel source equivalent to jp4.6.1

Thank you.

Any problem after apply your modification?

1 Like

Hello, @ShaneCCC

Any problem after apply your modification?
=> YES

dtb built from the kernel source corresponding to jp4.6.1 does not work properly even if applied through FDT.

When dtb built from the kernel source corresponding to jp4.6 is applied through FDT, you can see that the pin address has changed as follows.

manager@manager-desktop:~/repos/spi_adc/spi_adc$ !221
sudo cat /sys/kernel/debug/tegra_pinctrl_reg | grep -i spi
[sudo] password for manager:
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
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

May I ask you to check nvidia internally?

Thank you.

I have verify it without problem before.
Do you confirm system apply your dtb by dmesg | grep -i kernel?

Attached my dtb for reference.
nano-spi.dtb (233.6 KB)

1 Like

Hello, @ShaneCCC

dmesg | grep -i kernel

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 tegra_fbmem=0x800000@0x92cb4000 is_hdmi_initialised=1  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: 3560284K/4159488K available (15358K kernel code, 2956K rwdata, 6696K rodata, 8640K init, 612K bss, 124068K reserved, 475136K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.001768] kmemleak: Kernel memory leak detector disabled
[    0.212561] DTS File Name: /media/jetsonhostpc/841a9ca5-d24b-49de-8e73-d245a962e433/home/nanohostpc/coding/spi_jetson2/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.325382] alternatives: patching kernel code
[    0.420645] DTS File Name: /media/jetsonhostpc/841a9ca5-d24b-49de-8e73-d245a962e433/home/nanohostpc/coding/spi_jetson2/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.566716] eventlib_kernel: keventlib is initialized, test id: 0
[    1.199487] sysfs: cannot create duplicate filename '/kernel/rt8168_power'
[    1.199565] 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.199886] [<ffffff8009610d20>] kernel_init_freeable+0x1a0/0x244
[    1.199899] [<ffffff8008f658a0>] kernel_init+0x18/0x108
[    1.212628] unable to create rt8168_power_saver kernel object!
[    1.527687] KERNEL: PMC reset status reg: 0x0
[    1.574253] Freeing unused kernel memory: 8640K

Thank you.

Hello, @ShaneCCC

Can I designate nano-spi.dtb that you attached as FDT in extlinux.conf?

like below.
FDT /boot/nano-spi.dtb

Thank you.

Yes, you can.
Also check the dmesg | grep -i kernel to make sure applied correct dtb.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.