Beaglebone Black libraries for GPIO access in C/C++?

Sorry if this is a common question, but I’ve searched around the web and the forum here and am curious are there any somewhat mature or popular libraries for simple digital GPIO access on the Beaglebone Black in C/C++? I’m curious if there’s anything like wiringPi or similar for the BBB yet. If not, are folks just rolling their own thing with access to sysfs or mmap?

<shameless plug>
https://github.com/piranha32/IOoo
</shameless plug>

j.

sysfs, and mmap. I’ve seen mention of both on the web ( including for the BB white ).

There is also libsoc [1]

[1] https://github.com/jackmitch/libsoc

There is also libsoc [1]

[1] https://github.com/jackmitch/libsoc

Arduino like librarys.

http://beagleboard.org/project/userspace-arduino/

Arduino like libraries.

http://beagleboard.org/project/userspace-arduino/

Jack, so low level how does your library access GPIO ? Isthis just a wrapper for mmap or sysfs ?

Same question to you cody.

Userspace-arduino is a wrapper for sysfs, so not low level, but it does provide the abstraction and familiarity for those comfortable with the arduino way of doing things.

Ah ok, so in my own case it’s something I’d just rather skip. Being that I’m not much for arduino, and even less for processing, and the arduino library abstraction. These things are good I suppose for people who just want to get something done and dont care how it is achieved. But also is less for teaching people about the hardware at hand( because IMHO it makes people lazy ).

Hi Tony,

there`s also libpruio. It supports configuring and controling (input / output) of any GPIOs in an easy and fast manner (by using driver software running on a PRUSS). Additionally it contains some ADC features.

William Hermans, how did you controlled the GPIO ?

The only way that I know is with :

/sys/class/gpio/gpio%d/value

but you talk about mmap ? How did you use it with this /sys/class/gpio/gpio%d/value ?

Thx you,

Micka,

Thanks for the replies everyone–looks like some nice libraries to check out.

Regarding memory mapped GPIO, check out this nice blog post for more info: http://vabi-robotics.blogspot.com/2013/10/register-access-to-gpios-of-beaglebone.html You can effectively map the GPIO registers to a process’ memory space and directly access them so there’s no overhead of making the system calls to read, write, etc. the sysfs-based GPIO.

I actually just tried out a couple quick tests and saw toggling a pin high and low in a tight loop with sysfs is pretty slow, only a few hunded khz. However using memory mapped GPIO registers it’s much, much faster. I’m seeing around 2.8 mhz toggling a pin with this approach. Now neither approach is technically going to ever give you a real time guarantee of course, but it’s nice to have the ability to read and write GPIO fairly quickly in some cases with memory mapped GPIO.

Thanks for the replies everyone–looks like some nice libraries to check out.

Regarding memory mapped GPIO, check out this nice blog post for more info: http://vabi-robotics.blogspot.com/2013/10/register-access-to-gpios-of-beaglebone.html You can effectively map the GPIO registers to a process’ memory space and directly access them so there’s no overhead of making the system calls to read, write, etc. the sysfs-based GPIO.

I actually just tried out a couple quick tests and saw toggling a pin high and low in a tight loop with sysfs is pretty slow, only a few hunded khz. However using memory mapped GPIO registers it’s much, much faster. I’m seeing around 2.8 mhz toggling a pin with this approach. Now neither approach is technically going to ever give you a real time guarantee of course, but it’s nice to have the ability to read and write GPIO fairly quickly in some cases with memory mapped GPIO.

The downside is you cannot support GPIO interrupts.

Regards,
John

Two other features of going low level with mmap:

Open drain output: By controlling the output enable registers, you can do open drain by setting the output to drive 0, then enable output to pull low, disable output to for high (with external pullup or internal through pin muxing).

Simultaneous toggling: You can set the pin states of a whole gpio bank at once. This is nice if you’re bit banging.

2.8MHz seems slow. I was at 4MHz through an mmap in Python. Make sure you’re using the set registers rather than doing a read-modify-write and only opening the mmap once…and I suppose your clock scaling will matter too, so maybe it’s the same.

–Brandon

what is the process to access gpio for Jetson nano using qt creator

Perhaps use the NVIDIA Jetson Nano forum for questions regarding this board.
https://forums.developer.nvidia.com/c/agx-autonomous-machines/jetson-embedded-systems/jetson-nano/76

That board is not Beaglebone compatible, so this is not an appropriate
forum for questions on that board.

  That said, the first hit on Google for "jetson nano gpio" is
https://maker.pro/nvidia-jetson/tutorial/how-to-use-gpio-pins-on-jetson-nano-developer-kit

  As for QT Creator -- if you can't figure out how to link the above
access methods to QT Creator, you'll have to ask the maintainers of QT
Creator... https://forum.qt.io/topic/93213/accessing-gpio-s (most are
Raspberry Pi related, but reading enough of them might show what needs to
be changed for the Nano).
https://www.google.com/search?q=qt+creator+gpio+jetson+nano&ei=inLKYNqjNtK3tAb7sr-YBA&oq=qt+creator+gpio+jetson+nano&gs_lcp=Cgdnd3Mtd2l6EAMyBQgAEM0COgcIABBHELADOgYIABAWEB46BQghEKABOgcIIRAKEKABOgUIIRCrAlCpOljCSGCkS2gBcAJ4AIABgAGIAdYJkgEEMTEuMpgBAKABAaoBB2d3cy13aXrIAQjAAQE&sclient=gws-wiz&ved=0ahUKEwjakJ_SkZ3xAhXSG80KHXvZD0MQ4dUDCA0&uact=5