I have an application that requires a trigger signal (Just one pin going from low to high and back to low). There are several options for GPIO control in Julia but the PI 5 adds a new twist as outlined here and here.
The options in Julia seem to be:
BaremetalPi.jl /dev/gpiomem no PI5 support
PiGPIO.jl pigpio daemon No PI5 support
PiGPIOMEM.jl /dev/gpiomem No PI5 support
PiGPIOC.jl wrappers for gpio C-interface No PI5 support
Gpiod.jl wraps libgpiod with PI5 Support
One possibility is to try using Clang to wrap WiringPi as it supports the PI 5 and see if that works. With some more reading it seems that it just calls libgpiod under the hood so we might as well use Gpiod.jl.
And some more trial and error and I find that the examples in Gpiod.jl error after I find the libgpiod.so file on my system. My version of libgpiod is 1.6.3, so I suspect that I will have to build version 2.2 as version 2 does not come as an apt package. I guess ideally Gpiod.jl would ship with a working libgpiod.so file?
Usually the most portable option is to directly use the sysfs interface. Using this interface requires reading and writing special files, is well documented, and works across many different systems.
Indeed, I used directly gpiod 2.2 rather than the version 1.6 (unlikely compatible with the current version). Compiling gpiod was rather straight forward, if I remember correctly .
If somebody has time to investigate whether we can use BinaryBuilder to create the C library, that would be great.
Unfortunately, gpiod has a very minimal interface (no PWM, I2C, SPI support). Implementing these in Julia would be challenging since the garbage collector can pause a thread any time. I am still hoping that the upstream PiGPIOD will support the Raspberry Pi 5 at one point. Maybe wrapping wiringPi might actually be a better approach.
Thanks, I also opened an issue for Gpiod.jl. In there I reported on how to compile version 2.2.1. It successfully compiled but now the write function is giving me an error. From the comment above I recompiled libgpiod from version 2.2 and now all is well. Thanks for the information on the minimal interface. This is not a problem with my application but is good to know.
Since it seems that Gpiod.jl is specific to the PI and that it is specific to libgpiod version 2.2, I am wondering if we can bypass binary builder and just put the libgpiod.so file in the src directory of Gpiod. That is easy to do and will make Gpiod.jl just work.