Configuring SPI Speed for Jetson Orin Nano Developer Kit

Hello,

I am using the Jetson Orin Nano Developer Kit to communicate with the Pmod AD1 via SPI, but the communication speed is slow.

I tested it with Arduino and Raspberry Pi in the same environment, and they were 20 times faster.

I can’t understand why the Jetson Orin Nano, which has better performance, is slower.

I checked the spi-max-frequency and it is confirmed to be 65000000.

Below is the Python code.

Changing the sampling_rate value up or down doesn’t make a difference.

import spidev
import struct
import time

# Define constants
sample_queue_size = 2000
device = "/dev/spidev0.0"
sampling_rate = 65000000  # (SPI maximum speed)

# Set up SPI
spi = spidev.SpiDev()
spi.open(0, 0)  # Open SPI device
spi.max_speed_hz = sampling_rate

# Output file path
output_path = "output.out"

# Data collection
samples = [ ]

start_time = time.time()

for _ in range(sample_queue_size):
    # Read data via SPI
    response = spi.xfer2([0x00, 0x00])  # Read data via SPI (modify according to actual command)
    value = ((response[0] & 0x0F) << 8) | response[1]  # Convert to 12-bit data
    samples.append(value)

end_time = time.time()

# Measure and print time
elapsed_time = end_time - start_time
print(f"time elapsed: {elapsed_time:.6f} seconds")

# Save data to file
with open(output_path, "wb") as f:
    for value in samples:
        f.write(struct.pack('<H', value))  # Save 16-bit values in binary format (use lower 12 bits)

# Close SPI
spi.close()

Hi thirdxero1,

What’s your Jetpack version in use?

It is relating to the parent clock for SPI interface.
What’s your requirement for the SPI frequency?

Jetpack version is 5.1.3

and

PMOD AD1 uses an ADC chip called AD7476A

According to the AD7476A’s data sheet, the chip supports SPI radios up to 20MHz.

in the Python code

Changing the sampling_rate value 20000000 doesn’t make a difference.

I confirmed that the communication speed was fast and that the speed changed when

the sampling_rate (SPI speed) was adjusted during SPI testing on the Jetson Xavier NX.

However, on the Jetson Orin Nano Developer Kit, the speed does not change.

I upgraded the Jetpack version 6.0, but the speed remains the same.

Jetpack version is 5.1.3

and

PMOD AD1 uses an ADC chip called AD7476A

According to the AD7476A’s data sheet, the chip supports SPI radios up to 20MHz.

in the Python code

Changing the sampling_rate value 20000000 doesn’t make a difference.

I confirmed that the communication speed was fast and that the speed changed when

the sampling_rate (SPI speed) was adjusted during SPI testing on the Jetson Xavier NX.

However, on the Jetson Orin Nano Developer Kit, the speed does not change.

I upgraded the Jetpack version 6.0, but the speed remains the same.

Do you mean that the issue is specific to Orin Nano? (i.e. it is working on Xavier NX)

Please share your device tree and dmesg for further check.

yes the issue is specific to Orin Nano

share my device tree and dmesg
dmesg.txt (58.7 KB)
kernel_tegra234-p3768-0000+p3767-0005-nv.zip (36.7 KB)

Are you using Jetpack 5.1.3 for both Orin Nano and Xavier NX?

		spi@3210000 {
			compatible = "nvidia,tegra210-spi";
			..
			spi@0 {
				compatible = "tegra-spidev";
				reg = <0x00>;
				spi-max-frequency = <0x2faf080>;

Could you help to check if you have the same spi-max-frequency configuration as above for Xavier NX?

Orin Nano 5.1.3 and Xavier NX 4.4.1

Xavier NX also has the same spi-max-frequency

share my Xavier NX device tree

xavier_nx_device_tree.txt (1.1 KB)

From the device tree you shared, it seems using 65M as SPI max frequency on Xavier NX.
(it is 50M(0x2faf080) for Orin Nano)

spi@3210000 {
    compatible = "nvidia,tegra186-spi";
    reg = <0x0 0x3210000 0x0 0x10000>;
    ..
    spi-max-frequency = <0x3dfd240>;

Could you update Xavier NX to JP5.1.3 to clarify if it is relating to the Jetpack release or the module?

Jetpack of Xavier NX cannot be updated. I think it is a kernel driver or module issue that does not solve the problem even if you update Orin Nano’s Jetpack version.

Xavier NX should be available to be updated to JP5.1.3.

JP4.4.1 uses K4.9 and JP5.1.3 uses K5.10 so that the driver between them should be different.
We want to clarify if the issue is caused from the driver or the module.

I updated Xavier NX to JP5.1.3

The same symptoms as Jetson Orin Nano have been identified

Checked with the oscilloscope, the clock speed got faster

But the clock cycle has not accelerated

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

So, it seems the issue is relating to the kernel driver.

How did you check the clock cycle?