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

2184 views
Skip to first unread message

Tony DiCola

unread,
Jun 3, 2014, 5:42:59 PM6/3/14
to beagl...@googlegroups.com
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?

Jacek Radzikowski

unread,
Jun 3, 2014, 5:46:15 PM6/3/14
to beagleboard
<shameless plug>
https://github.com/piranha32/IOoo
</shameless plug>

j.
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to beagleboard...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Given a choice between two theories, take the one which is funnier

William Hermans

unread,
Jun 3, 2014, 5:57:37 PM6/3/14
to beagl...@googlegroups.com
sysfs, and mmap. I've seen mention of both on the web ( including for the BB white ).

wiringPi

Whats this ? The Arduino IDE for the rPI ? Nothing like this exists for the BBB that I am aware of.

Jack Mitchell

unread,
Jun 3, 2014, 6:08:44 PM6/3/14
to beagl...@googlegroups.com
There is also libsoc [1]

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

Cody Lacey

unread,
Jun 3, 2014, 6:24:23 PM6/3/14
to beagl...@googlegroups.com



For more options, visit https://groups.google.com/d/optout.
--
For more options, visit http://beagleboard.org/discuss
--- You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.

Cody Lacey

unread,
Jun 3, 2014, 6:26:04 PM6/3/14
to beagl...@googlegroups.com


On Tue, Jun 3, 2014 at 5:08 PM, Jack Mitchell <m...@communistcode.co.uk> wrote:

For more options, visit https://groups.google.com/d/optout.
--
For more options, visit http://beagleboard.org/discuss
--- You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.

William Hermans

unread,
Jun 3, 2014, 6:50:18 PM6/3/14
to beagl...@googlegroups.com
Jack, so low level how does your library access GPIO ?  Isthis just a wrapper for mmap or sysfs ?

Same question to you cody.


To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

Cody Lacey

unread,
Jun 3, 2014, 7:39:20 PM6/3/14
to beagl...@googlegroups.com
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.

William Hermans

unread,
Jun 3, 2014, 8:53:26 PM6/3/14
to beagl...@googlegroups.com
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 ).

TJF

unread,
Jun 4, 2014, 7:43:00 AM6/4/14
to beagl...@googlegroups.com
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.

Micka

unread,
Jun 4, 2014, 8:00:27 AM6/4/14
to beagl...@googlegroups.com
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,


Jack Mitchell

unread,
Jun 4, 2014, 8:14:19 AM6/4/14
to beagl...@googlegroups.com
There is also libsoc [1]

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

On 03/06/2014 22:45, Jacek Radzikowski wrote:

Tony DiCola

unread,
Jun 4, 2014, 11:29:31 AM6/4/14
to beagl...@googlegroups.com
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.


You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Mef65w6PZ7s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

John Syn

unread,
Jun 4, 2014, 5:26:32 PM6/4/14
to beagl...@googlegroups.com

From: Tony DiCola <to...@tonydicola.com>
Reply-To: <beagl...@googlegroups.com>
Date: Wednesday, June 4, 2014 at 8:29 AM
To: <beagl...@googlegroups.com>
Subject: Re: [beagleboard] Beaglebone Black libraries for GPIO access in C/C++?

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

Brandon I

unread,
Jun 4, 2014, 6:20:43 PM6/4/14
to beagl...@googlegroups.com
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

Mohammad Walihullah

unread,
Jun 16, 2021, 12:59:09 PMJun 16
to BeagleBoard
what is the process to access gpio for Jetson nano using qt creator

jonnymo

unread,
Jun 16, 2021, 1:08:33 PMJun 16
to Beagle Board

Dennis Lee Bieber

unread,
Jun 16, 2021, 5:55:31 PMJun 16
to Beagleboard
On Wed, 16 Jun 2021 09:58:08 -0700 (PDT), in
gmane.comp.hardware.beagleboard.user Mohammad Walihullah
<walihullah-Re5JQ...@public.gmane.org> wrote:

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

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



--
Dennis L Bieber

Reply all
Reply to author
Forward
0 new messages