-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hal_pi_gpio
doesn't work on Raspberry Pi 4 on Debian Bookworm
#2371
Comments
There seems to have been a great deal of divergence: Maybe we need to consider why the driver cares? I think it is just so it knows which of the (currently two?) GPIO connectors we are dealing with? The RPi docs specifically warn against doing what we are doing: And provide sample code of a better way to do it. |
And we should maybe switch to libgpiod, which is a standard way for the kernel to expose gpios on all kinds of platforms. Don't know if it's fast enough to do realtime type stuff with...? |
I have a PR pending for the getting Linuxcnc doc page which has a proven and tested method to install Linuxcnc on the Raspberry Pi and the Bookworm repos. I think it should be tagged 2.9-must-fix. Seb asked for it. |
Having addressed the cpuinfo issue, I have now found that the hal_pi_gpio relied on /dev/gpiomem, and that isn't present with a bookworm installation. It does seem to work on Raspbian Buster, though. Which gives more weight to the suggestion to use libgpiod |
I've only used the Pi with Mesa and EtherCAT devices. |
[Andy Pugh]
Having addressed the cpuinfo issue, I have now found that the
hal_pi_gpio relied on /dev/gpiomem, and that isn't present with a
bookworm installation. It does seem to work on Raspbian Buster,
though.
I do not know the inner working of this, but was able to trace
/dev/gpiomem to the kernel driver implemented in
<URL: https://github.com/eq-3/RaspberryMatic/blob/master/linux-4.1/drivers/char/broadcom/bcm2835-gpiomem.c >.
No idea if it is implemented in the default Linux kernel. :)
…--
Happy hacking
Petter Reinholdtsen
|
Following @SebKuzminsky 's suggestion, I have written a new driver called hal_gpio which should work on all of these SBCs that support gpiod https://github.com/LinuxCNC/linuxcnc/blob/andypugh/hal_gpio/src/hal/drivers/hal_gpio.c Issues: |
Most of these issues are now addressed. It currently reads 8 GPIO lines in 16µs and writes 8 gpio lines in 8µs. sample HAL file:
Given that I think that I have fixed the original issue, and that there is a new driver on the way. should I close this issue? |
The configure script checks for libgpiod-dev and if it's missing it says: configure: WARNING: Could not find libgpiod, not building hal_gpio But it's "built" anyway and later on it fails at the linking stage. |
I don't think it makes much sense for libgpiod-dev to be mandatory, it isn't any use on most PCs, for example. What OS are you building on? I am currently puzzled by the behaviour on Bookworm. It was developed and tested on a Pi400 under Buster, and works fine. But on Bookworm it builds but then fails at load-time with "unknown symbol" for gpio_line_find() |
A fresh install of Debian 12. If it's not mandatory something needs to be set so it wont actually build. For example, if there is no po4a the environment variable BUILD_DOCS_TRANSLATED is set to no which later on is checked in the submakefile for docs. Something like this needs to be done for hal_gpio if it shouldn't be built if the library is not available. |
I was planning on building a linuxcnc PI image using the upstream repo https://github.com/pyavitz/rpi-img-builder It might be worth considering some sort of switch to determine which docs should be included given the number that now exist. My 2 Gb ISO became 3.0 Gb once I forked the Linuxcnc-live-build repo... |
Andys' fixes to GPIO and his new driver in master branch have been tested by a few users now. |
hal_gpio went into 2.9 last night. |
On a Raspberry Pi 4B, running a recent Debian Bookworm image from https://github.com/SebKuzminsky/image-specs:
This seems to be due to an out of date version of the
cpuinfo.c
file we got from MachineKit, who got it from raspberry-gpio-python.We should probably fetch the new file from upstream and integrate it with our code.
We should maybe also consider writing a generic gpio driver for HAL using libgpiod for the back end.
The text was updated successfully, but these errors were encountered: