Python GPIO support?

Hi, it seems pretty clear that the Jetson Nano’s GPIO is trying to be pin-compatible with the Raspberri Pi header. I was wondering, can code designed to interface with the RPi’s GPIO run on the Jetson? Specifically, I’m trying to run some Python 3 packages that use the RPi.GPIO package, and getting the following error:

File “/home/maximecb/pypot/build/lib/pypot/sensor/contact/contact.py”, line 1, in
import RPi.GPIO as GPIO
File “/usr/lib/python3/dist-packages/RPi/GPIO/init.py”, line 23, in
from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!

The error seems to be coming from some precompiled library:
_GPIO.cpython-36m-aarch64-linux-gnu.so

Is there an equivalent Python GPIO library for the Jetson Nano? If not, could we expect the RPi GPIO library to work on the Jetson if we just remove the assertion producing the error message above?

hello maximechevalierb,

apparently, this kernel module don’t support Jetson-Nano.

RuntimeError: This module can only be run on a Raspberry Pi!

suggest you refer to the kernel sources, and have using the APIs to perform GPIO controls.
for example,

static inline int gpio_get_value(unsigned gpio)
{
	return __gpio_get_value(gpio);
}
 
static inline void gpio_set_value(unsigned gpio, int value)
{
 	__gpio_set_value(gpio, value);
}

Ok, but is there an Nano-specific API for GPIO? If so, is this documented anywhere? Is there example usage code available?

In case anyone is wondering. I got some help from the Jetbot people. There is in fact a Jetson Nano library that masquerades as RPi.GPIO: GPIO & Adafruit MotorHat · Issue #18 · NVIDIA-AI-IOT/jetbot · GitHub

There is a Jetson.GPIO library just released.
[url]https://pypi.org/project/Jetson.GPIO/[/url]

The github repository is not yet available though.

1 Like