SPI setup issues with Jetson Nano B01 DevKit

My actual SPI HW is working now as well. Thanks, Linuxdev, Kevin, and Shane, for your extended efforts in getting this resolved. Here’s a summary of what finally ended up working for me. I can’t be sure that all of these steps are necessary but I’m out of time to go back and strip it down to the minimum. Note that I did NOT end up doing any custom kernel building - I simply decompiled the dtb on the host PC, edited it to enable SPI, recompiled it and flashed it to the Jetson using SDKManager.

Overall setup:
Host PC: Ubuntu18.04.6 LTS on an Intel based PC
SDKManager: version 2.0.0-11402
Jetson Nano: B01 standard 4GB DevKit with SD card and stock NVIDIA carrier board
Jetpack 4.6.4

Steps I used:

  1. Download SDKManager onto host PC
  2. Using disk utility on the host PC, hard erase (write zeros) to the flash card intended for use on the Jetson, formatting with EXT4
  3. Connect micro-usb between host PC and Jetson Nano
  4. Boot Jetson Nano in Force Recovery mode
  5. Flash Jetpack4.6.4 (standard downloaded version) onto Jetson Nano using SDKManager
  6. Copy the original dtb file from Jetpack4.6.4 from the Linux_for_Tegra/kernel/dtb directory on your host PC to your home directory on your host PC so you have a backup (For reference, my original file was in $HOME/nvidia/nvidia_sdk/JetPack_4.6.4_Linux_JETSON_NANO_TARGETS/Linux_for_Tegra/kernel/dtb/tegra210-p3448-0000-p3449-0000-b00.dtb)
  7. cd ~
  8. In your home directory on your host PC, decompile the original dtb file into editable form:
    dtc -I dtb -O dts -o ~/extracted.dts ~/tegra210-p3448-0000-p3449-0000-b00.dtb
  9. Confirm that ‘extracted.dts’ exists, then rename the original dtb file to back it up:
    mv tegra210-p3448-0000-p3449-0000-b00.dtb tegra210-p3448-0000-p3449-0000-b00_JP464Original.dtb
  10. Edit ‘extracted.dts’ with a text editor of your choice and modify the gpio-input line found below (‘-’ means remove a line, ‘+’ means add a 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>;

In the same file, find the ‘rsvd*’ with ‘spi*’ in the 10 lines noted below for spi1 and spi2 only:

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

			spi1_miso_pc1 {
				nvidia,pins = "spi1_miso_pc1";
-				nvidia,function = "rsvd1";
+				nvidia,function = "spi1";
				nvidia,pull = <0x1>;
				nvidia,tristate = <0x0>;
				nvidia,enable-input = <0x1>;
			};

			spi1_sck_pc2 {
				nvidia,pins = "spi1_sck_pc2";
-				nvidia,function = "rsvd1";
+				nvidia,function = "spi1";
				nvidia,pull = <0x1>;
				nvidia,tristate = <0x0>;
				nvidia,enable-input = <0x1>;
			};

			spi1_cs0_pc3 {
				nvidia,pins = "spi1_cs0_pc3";
-				nvidia,function = "rsvd1";
+				nvidia,function = "spi1";
				nvidia,pull = <0x2>;
				nvidia,tristate = <0x0>;
				nvidia,enable-input = <0x1>;
			};

			spi1_cs1_pc4 {
				nvidia,pins = "spi1_cs1_pc4";
-				nvidia,function = "rsvd1";
+				nvidia,function = "spi1";
				nvidia,pull = <0x2>;
				nvidia,tristate = <0x0>;
				nvidia,enable-input = <0x1>;
			};
			spi2_mosi_pb4 {
				nvidia,pins = "spi2_mosi_pb4";
-				nvidia,function = "rsvd2";
+				nvidia,function = "spi2";
				nvidia,pull = <0x1>;
				nvidia,tristate = <0x0>;
				nvidia,enable-input = <0x1>;
			};

			spi2_miso_pb5 {
				nvidia,pins = "spi2_miso_pb5";
-				nvidia,function = "rsvd2";
+				nvidia,function = "spi2";
				nvidia,pull = <0x1>;
				nvidia,tristate = <0x0>;
				nvidia,enable-input = <0x1>;
			};

			spi2_sck_pb6 {
				nvidia,pins = "spi2_sck_pb6";
-				nvidia,function = "rsvd2";
+				nvidia,function = "spi2";
				nvidia,pull = <0x1>;
				nvidia,tristate = <0x0>;
				nvidia,enable-input = <0x1>;
			};

			spi2_cs0_pb7 {
				nvidia,pins = "spi2_cs0_pb7";
-				nvidia,function = "rsvd2";
+				nvidia,function = "spi2";
				nvidia,pull = <0x1>;
				nvidia,tristate = <0x0>;
				nvidia,enable-input = <0x1>;
			};

			spi2_cs1_pdd0 {
				nvidia,pins = "spi2_cs1_pdd0";
-				nvidia,function = "rsvd1";
+				nvidia,function = "spi2";
				nvidia,pull = <0x1>;
				nvidia,tristate = <0x0>;
				nvidia,enable-input = <0x1>;
			};
  1. Save the modified file under the same name (extracted.dts)
  2. Recompile to dtb using the following command:
    dtc -I dts -O dtb -o ~/tegra210-p3448-0000-p3449-0000-b00.dtb ~/extracted.dts
  3. Copy the modified dtb file back to the Jetpack kernel/dtb directory (still on your host PC):
    sudo cp ~/tegra210-p3448-0000-p3449-0000-b00.dtb $HOME/nvidia/nvidia_sdk/JetPack_4.6.4_Linux_JETSON_NANO_TARGETS/Linux_for_Tegra/kernel/dtb/tegra210-p3448-0000-p3449-0000-b00.dtb
  4. cd to the Linux_for_Tegra directory on your host PC:
    cd $HOME/nvidia/nvidia_sdk/JetPack_4.6.4_Linux_JETSON_NANO_TARGETS/Linux_for_Tegra/
  5. Restart the Jetson Nano in Force Recovery mode and confirm that the micro-USB is connected to the host PC
  6. Open a terminal on your host PC and re-flash from the command line:
    sudo ./flash.sh jetson-nano-devkit mmcblk0p1 2>&1 | tee log_flash.txt
  7. Assuming the flash completes successfully, move over to your Jetson Nano, ensure the Force Recovery jumper has been removed if you haven’t already, then reboot and go through the standard OEM config setup (username, password, timezone, network, etc.).
  8. Enable SPI with:
    sudo modprobe spidev
  9. download spidev_test and compile:
$ cd ${HOME}
$ wget https://raw.githubusercontent.com/torvalds/linux/v4.9/tools/spi/spidev_test.c
$ gcc -o spidev_test spidev_test.c
  1. Place a jumper to short pins 19 & 21 on the Jetson Nano 40 pin header (for SPI1), then run spidev_test with the following command:
sudo ./spidev_test -D /dev/spidev0.0 -v -p "HelloWorld123456789abcdef"

If your TX and RX still don’t match after this, I wish you the best of luck and sincerely hope that your adventure in finding a solution is less epic than mine was.

5 Likes