Jetson Nano Fast GPIO C++ Example with Direct Memory Access (DMA)

Looking for a fast GPIO C++ example using the DMA approach (Direct Memory Access) instead of the slow “filesys” approach. Need very fast switching for stepper motor control and other high speed applications. GPIO via DMA has been implemented on the Raspberry Pi with the WiringPi library. Is there a similar DMA library for the Jetson Nano? DMA would be faster, simpler, and more robust over the slow filesys approach.

hello xplanescientist,

you may refer to standard APIs to access GPIOs from kernel side.
for example,

static inline int gpio_get_value(unsigned int gpio)
        return __gpio_get_value(gpio);

static inline void gpio_set_value(unsigned int gpio, int value)
        __gpio_set_value(gpio, value);

Hello JerryChang,

I recently upgraded to jetpack 4.4, R32.4.3 via a fresh new SD card image. Regarding the “gpio.h” file that you cited, I had trouble finding your “$L4T_Sources” path. But I believe I found it here:


But now what? Do you have C/C++ examples that demonstrate fast DMA GPIO on R32.4.3?

hello xplanescientist,

you may access L4T sources package via download center.
please also check Kernel Customization chapter for building the NVIDIA kernel.

you may also refer to kernel sources of the sensor driver to call these APIs for setting GPIO.
for example,

        if (pw->reset_gpio)
                gpio_set_value(pw->reset_gpio, 0);

hello Jerry,

I downloaded the “L4T sources” package dated 2020/07/07 and found your imx185.c example. But its not directly useful.

All I want to do is read whether a digital GPIO is high or low with via Direct Memory Access (DMA), and separately write high or low with DMA. The filesys approach is too slow and the latency is not consistent. I need fast GPIO switching for stepper motors and other high speed applications.

Not interested in kernel customization nor do I have the time for that. I’m surprised Nvidia does not have a simple library like RPi’s “WiringPi.h” - here’s a very simple blink program that works:

include <wiringPi.h>
int main (void)
  wiringPiSetup () ;
  pinMode (0, OUTPUT) ;
  for (;;)
    digitalWrite (0, HIGH) ; delay (500) ;
    digitalWrite (0,  LOW) ; delay (500) ;
  return 0 ;

My time is very limited - I’d rather spend it making projects with established GPIO functions and purchasing more Jetson Nanos rather than figuring out kernels. In just a few hours, I was able to buy a Raspberry Pi 4, format a microSD card, and program the DMA led example. Hopefully Nvidia will come up with a similar library. GPIO on/off with DMA is fundamental. I think you’ll find more customers. Isn’t that the point?

hello xplanescientist,

how about refer to Jetson GPIO, a Python library that enables the use of GPIOs.
please check the sample python scripts, i.e. for reference,

hello JerryChang,

The Python library looks neatly packaged, but my projects are coded in C/C++ to minimize latency - I need speed. My projects involve feedback control systems and object detection. Compiled C++ code is much faster than interpreted Python code - the difference is vast.

Are there any plans for a similar DMA GPIO library written in C/C++? DMA on/off IO is fundamental to any microcontroller board and single-board-computer . I think this is a major limitation of the Jetson Nano. Having it would simplify things and would certainly expand the user base.

1 Like

Hi xplane, did you find another solution?

I’m interested in using the nano for a robot car but it appears I will need to run a separate motor control board which is unfortunate.

Did you find the PI performed better for your application?

Check this out:
You can add your gpio here:
and take reference of this file to develop your usecase:
Here, you directly read/write through /dev/mem which is faster.


Hello lowellm,

I have not found a well packaged solution for DMA GPIO in C/C++ like the RPi “Wiring.h” library. It’s unfortunate. Digital I/O should be a fundamental capability in any SBC or microcontrooler.

For now, I have a Teensy 3.6 microcontroller connected to my Jetson Nano. The Teensy 3.6 does all the digital I/O operations and stepper motor control, and the Nano does the object detection.