pySX127x on Jetson Nano 4gb

Hi,

Could you help me to run pySX127x at the Jetson Nano.
After start I give a problem

nvidia@nvidia-desktop:~/pySX127x$ sudo python3 test_lora.py
/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.17-py3.6.egg/Jetson/GPIO/gpio.py:386: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings
Traceback (most recent call last):
  File "test_lora.py", line 129, in <module>
    BOARD.setup()
  File "/home/nvidia/pySX127x/SX127x/board_config.py", line 58, in setup
    GPIO.setup(BOARD.LED, GPIO.OUT)
  File "/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.17-py3.6.egg/Jetson/GPIO/gpio.py", line 393, in setup
  File "/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.17-py3.6.egg/Jetson/GPIO/gpio.py", line 187, in _setup_single_out
OSError: [Errno 5] Input/output error
nvidia@nvidia-desktop:~/pySX127x$ sudo python3 lora_util.py
/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.17-py3.6.egg/Jetson/GPIO/gpio.py:386: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings
Traceback (most recent call last):
  File "lora_util.py", line 29, in <module>
    BOARD.setup()
  File "/home/nvidia/pySX127x/SX127x/board_config.py", line 58, in setup
    GPIO.setup(BOARD.LED, GPIO.OUT)
  File "/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.17-py3.6.egg/Jetson/GPIO/gpio.py", line 393, in setup
  File "/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.17-py3.6.egg/Jetson/GPIO/gpio.py", line 187, in _setup_single_out
OSError: [Errno 5] Input/output error

Before start I configured the nano to work with SPI througt jetson-io.py and modprobe -s -v spidev, after the nano has /dev/spidev0.0 , spidev0.1, spidev1.0, spidev1.1

We’ve made an application with pySX127x to Xavier and it works well, with out any problem.

I run spidev-test and have this log

nvidia@nvidia-desktop:~/spidev-test$ sudo ./spidev_test
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
RX | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  | ................................

What’s the gpio.py do? It control the Jetson GPIO or GPIO pin on pySx127x?

Yes.

How I said erlyier, we made the app to Xavier based on pySX127x and it works well with SX127x module, but after we copied it to Jetson Nano connect module to NANOs GPIO and it isn’t work.

Is Jetson.GPIO same on Nano & Xavier?

I’ve tested with spidev-test and SPI dev worked properly.

With connect mosi <-> miso by single wire

nvidia@nvidia-desktop:~/spidev-test$ ./spidev_test -v
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D  | ......@....▒..................▒.
RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D  | ......@....▒..................▒.

Without connect miso <-> mosi by single wire

nvidia@nvidia-desktop:~/spidev-test$ ./spidev_test -v
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D  | ......@....▒..................▒.
RX | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  | ................................

I think the GPIO on Nano is different with Xavier.

Hm, ok, we will try to check it.
We use BCM names, is it different on both devices?

Different chip will map to different pin.

I can’t found Xavier PIN out BCM, is it like TX2?

Does this link help on it.

HI,
I’ve checked Pinouts, there is some GPIO different, but I can’t understand why it isn’t work. I use Python library “Jetson.GPIO” which have to use gpio and control PINs by BCOM numbering.

import Jetson.GPIO as GPIO
import spidev
import time

class BOARD:
    """ Board initialisation/teardown and pin configuration is kept here.
        Also, information about the RF module is kept here.
        This is the Raspberry Pi board with one LED and a Ra-02 Lora.
    """
    # Note that the BCOM numbering for the GPIOs is used.
    DIO0 = 4   # RaspPi GPIO 4
    DIO1 = 17   # RaspPi GPIO 17
    DIO2 = 18   # RaspPi GPIO 18
    DIO3 = 27   # RaspPi GPIO 27
    RST  = 22   # RaspPi GPIO 22
    # LED  = 13   # RaspPi GPIO 13 connects to the LED and a resistor (1kohm or 330ohm)

Did you check those GPIO number transfer to right GPIO number for Xavier?

yes, I double checked it. Installed LEDs at the pins 7, 11, 12, 13, 15, configured at OUTPUT and found that PINs have low voltage, only 1.8v instead 3.3v. I think it’s problem. How to change voltage to 3.3v?

Could you try if can control the manually by /sys/class/gpio

https://www.kernel.org/doc/Documentation/gpio/sysfs.txt

I tryed use sysfs, it has same voltage level is 1.8V

All of those GPIO pins are 1.8v ?

yes.

nvidia@nvidia-desktop:~$ sudo nvpmodel -q
NVPM WARN: fan mode is not set!
NV Power Mode: MAXN
0

Did you configure those GPIO in device tree? Like add them to below scope.

	gpio: gpio@6000d000 {
		gpio-init-names = "default";
		gpio-init-0 = <&gpio_default>;

		gpio_default: default {
			gpio-input = <
				TEGRA_GPIO(BB, 0)
				TEGRA_GPIO(B, 4)
				TEGRA_GPIO(B, 5)
				TEGRA_GPIO(B, 6)
				TEGRA_GPIO(B, 7)
				TEGRA_GPIO(DD, 0)
				TEGRA_GPIO(E, 6)
				TEGRA_GPIO(S, 5)

where is I can found it? I didn’t do

Check this document to get the source and build the device tree for it.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/kernel_custom.html#

I dissamble the current DTC

dtc -I dtb -O dts -o output.txt tegra210-p3448-0000-p3449-0000-a02-user-custom.dtb

I atached the output file.
output.txt (309.1 KB)

Add those pins in below scope.

		default {
			gpio-input = <0x5 0xbc 0xbd 0xbe 0xc1 0xa9 0xca 0x3a 0x3d 0x3e 0x41 0xe4>;
			gpio-output-low = <0x97 0x98 0xcb 0x38 0x3b 0x3c 0x3f 0x40 0x42>;
			gpio-output-high = <0x6 0xbb 0xe7>;
			linux,phandle = <0x41>;
			phandle = <0x41>;
		};