SPI and Thermal Lepton

I’m trying to connect a Lepton 3.5 w/ Breakout Board v2.0 to the Jetson Orin Nano.

I went through the Jetson I/O Config and enabled SPI.

I checked in /dev/spi* and have the following:

crw-rw---- 1 root gpio 153, 0 Sep  8  2022 /dev/spidev0.0
crw-rw---- 1 root gpio 153, 1 Sep  8  2022 /dev/spidev0.1
crw-rw---- 1 root gpio 153, 2 Sep  8  2022 /dev/spidev2.0
crw-rw---- 1 root gpio 153, 3 Sep  8  2022 /dev/spidev2.1

When I put a jumper on the MISO and MOSI (19/21), and run this quick Python check, I get SPI loopback test passed:

import spidev
import time
spi = spidev.SpiDev()
spi.open(0, 1)  # bus 0, device 0
spi.max_speed_hz = 500000
spi.mode = 0
msg = [0xFF, 0xAA, 0x55, 0x00]
while True:
    resp = spi.xfer2(msg)
    if resp == msg:
        print("SPI loopback test passed")
    else:
        print("SPI loopback test failed")
    # Sleep for a bit
    time.sleep(1)

However, when I got to read data from the camera, this is nothing coming in on these pins but garbage.

I then went on and tested out using this Medium article and repo: Thermal Images on Jetson™ Nano with FLIR Lepton3 - Myzhar's MyzharBot and more...

When I run the code, it tells me *** Forcing RESYNC *** and that’s it.

I checked the I2C, and it is working on I2C-1, pins 27/28.

I set the bufsize to 65565 also, and tried as little as 20484.

I’m running out of options, and I’m not sure what’s happening here. I re-checked the cables a bunch, and they all seem to match where they’re supposed to be on the SPI and I2C connections.

Hi rich25,

It seems you are using the custom board for Orin Nano.

What’s your Jetpack version in use?

It seems you could run loopback test successfully but failed with communication with your camera.
Do you use CS pin for camera?

Please also share the full serial console log for further check.

Jetpack 35.3.1
We use CS0 for the SPI on pin 24.

I’m going to have to buy a serial USB adapter for the minicom to get the full console log, unless there is another kind of log you mean.

Yes, you would need a serial console cable to capture the logs.

Please also refer the following thread to check if it could help. That is to fix the issue about CS.
SPI TPM module support fail on jetpack 5.0.2/5.1 on jetson xavier agx - #25 by DaneLLL

1 Like

Attached is the serial console.log:
serial_console.txt (122.6 KB)

I installed a specific code base and settings on a Pi, and the device works perfect. I connected all the same cables to the Orin Nano, and attempted both I2C buses (this sends commands to the sensor), and none of them work. It’s definitely an issue with the Jetson config.

I looked over the CS issue, but I have no idea how to apply that change. Do I just copy and paste that code as is into the terminal? i.e.

diff --git...

What do you mean about “specific code” here? What is Pi?
Are you using L4T release for Jetson device?

You should download the kernel source, apply that patch and rebuild the kernel image. You could refer to the following instruction to build kernel image…
Kernel Customization — Jetson Linux Developer Guide documentation (nvidia.com)

Specific code is this:

Pi is the Raspberry Pi, which apparently is far easier to run SPI and I2C from since it requires a simple button push to activate those 2 protocols, versus here, where I’m being asked to recompile an entire Linux kernel to activate SPI and I2C properly. We used it to verify there is nothing wrong with the external board and its connections.

I thought nVidia finally got this fixed right and we use the sudo /opt/nvidia/jetson-io/jetson-io.py to activate SPI?

Do I do this all on my Jetson Orin Nano device?

I’m keeping running notes here so I can make sure I can get this answered. Thank you!

There is no: ./source_sync.sh on the Jetson Orin Nano Dev Kit

Jetson-IO is a tool used for the devkit to configure the pinmux for 40-pins header easily.
If your custom board has the similar design, you may also could use that tool.
If not, you should configure the pinmux through spreadsheet or modifying device tree directly.

This should be used under the BSP package directory (Linux_for_Tegra/) on your host PC.

Hey all,

So I figured this out somewhat and am going to leave the answer here.

There is nothing wrong with the SPI setup, or any other needs to reconfigured the kernel. The challenge is that PyLepton doesn’t work anymore with the Jetson configs, and it’s not clear why. I also tried some of the latest Python forks of the PyLepton others, and didn’t work on the Jetson. So here is how I got it to work.

Download this library:

Follow his article on setup instructions.

You have to make changes in 2 files:
Lepton3_Jetson/grabber_lib/src/Lepton3.cpp file
– Line 48: mSpiMode = SPI_MODE_1;
++ Line 48: mSpiMode = SPI_MODE_3;

opencv_demo/opencv_demo.cpp
– Line 47: lepton3 = new Lepton3( “/dev/spidev0.0”, “/dev/i2c-0”, deb_lvl ); // use SPI1 and I2C-1 ports
++ Line 47: lepton3 = new Lepton3( “/dev/spidev0.0”, “/dev/i2c-1”, deb_lvl ); // use SPI1 and I2C-1 ports

I’m still isolating the other settings in this C++ codebase to see if I can port it to Python. However, for now, it does work and you can pull in images. Be sure to use pins 27/28 for your I2C connections.

1 Like

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