July 2020 GPIO Best Practices

It appears that libgpiod is the best way to access GPIO from C/C++/Python these days. I have a simple C++ program working, but I can’t figure out how to free up more GPIOs for use. I disabled video, audio, wireless and ADC in uEnv.txt, but gpioinfo shows about the same number of lines “used” as before. (In fact, a couple of GPIOs that I had been using, went from unused to used when I disabled those things!)

A lot of the lines are marked used by “P[89]_[0-9]+”, but I don’t see a corresponding process that looks like it would be using them.

Is there a way to figure out which process (if any) is using a particular line?

Is there a FAQ or compendium of current best practices? What about PRU – I found some stuff about libpruio that looked promising, but it seems to be out of date? Is libgpiod preferable, if I don’t need the extra speed PRU appears to provide?

Thanks!

Hi Dave!

Is there a FAQ or compendium of current best practices?

There has been good documentations for Kernel 3.8. But the kernel changed and the docs got out of date.

What about PRU – I found some stuff about libpruio that looked promising, but it seems to be out of date? Is libgpiod preferable, if I don’t need the extra speed PRU appears to provide?

libpruio is not out of date. It builds and runs on each kernel since 3.8. And so does the users code compiled against libpruio.

The current BB repos don’t contain the libpruio packages. They never contained libpruio packages (exept the LKM). So if you don’t want to build from source, ask RCN or Jason Kridner. (Or switch back to Jessie for a comfortable binary installation by the package manager.)

libpruio provides extra execution speed. But the main advantage is the steep learning curve. It does all kind of pin-muxing. And if a pin is claimed by an other process it shows the process name in the error message. And if the user cannot (or temprary will not) resolve the conflict, libpruio can override the claim (admin privilegues).

Hardware configuration gets as easy as on the Arduino, but with the power of a full featured LINUX system.

Regards

Thanks for the info! I tried to build libpruio, but it needed FreeBasicCompiler and some other stuff, which was harder to organize than I had patience for at the time. I’ll give it another try, and revert to Jessie if I can’t get things working on Buster.