unable to get gpio to work on Raspberry Pi 5 using latest image

More
05 Feb 2025 21:33 #320796 by galrub
Hello  I am using the latgest build, rpi-5-debian-bookworm-6.12.11-arm64-ext4-2025-01-27-0140.img, on a RP 5, logged in with user 'cnc'

runing:
uname -a
Linux raspberrypi 6.12.11 #1 SMP PREEMPT_RT Mon Jan 27 00:10:15 AEDT 2025 aarch64 GNU/Linux

halcmd -I
loadrt hal_gpio inputs=GPIO18,GPIO23,GPIO24,GPIO25,GPIO8 outputs=GPIO4,GPIO17,GPIO27,GPIO22,GPIO10,GPIO9,GPIO26
Note: Using POSIX realtime
hal_gpio: Failed to register input pin collection
hal_gpio: rtapi_app_main: Operation not permitted (-1)
<stdin>:1: waitpid failed /usr/bin/rtapi_app hal_gpio
<stdin>:1: /usr/bin/rtapi_app exited without becoming ready
<stdin>:1: insmod for hal_gpio failed, returned -1

loadrt hal_pi_gpio exclude=0xC3C03 dir=0x312839C
The Pi model 23 is not known to work with this driver but will be assumed to be be using the RPi2+ layout 40 pin connector
HAL_PI_GPIO: can't open /dev/gpiomem:  2 - No such file or directory
If the error is 'permission denied' then try adding the user who runs
LinuxCNC to the gpio group: sudo gpasswd -a username gpio
HAL_PI_GPIO: can't open /dev/mem:  13 - Permission denied
hal_pi_gpio: rtapi_app_main: Operation not permitted (-1)
<stdin>:2: waitpid failed /usr/bin/rtapi_app hal_pi_gpio
<stdin>:2: /usr/bin/rtapi_app exited without becoming ready
<stdin>:2: insmod for hal_pi_gpio failed, returned -1

any ideas?

I notice some disccusions about this matter in the forum but non of the ideas there helped me,
I tried 'sudo gpasswd -a cnc gpio' but got the reply that cnc is already a member of gpio.

any help will be most welcomed.

Please Log in or Create an account to join the conversation.

More
09 Feb 2025 18:44 #321090 by andypugh
It is possible that hal_gpio is not working because libgpiod is not installed

What does: sudo apt-get install libgpiod say?

Please Log in or Create an account to join the conversation.

More
09 Feb 2025 23:02 - 09 Feb 2025 23:19 #321128 by unknown
It does work, 2 users have had a couple of users have confirmed it.
I've also confirmed myself that loading of the driver as given in the docs also works.

Taking GPIO8 out of the input list allows the driver to load correctly. Which makes sense as GPIO08 as well as GPIO07 seemed to be claimed.

section lifted from gpioinfo
"GPIO7"   "spi0 CS1"  output   active-low [used]
"GPIO8"   "spi0 CS0"  output   active-low [used]

Commenting out spi out in /boot/broadcom/config.txt "fixes" the issue.
 
halcmd: loadrt hal_gpio inputs=GPIO18,GPIO23,GPIO24,GPIO25,GPIO8 outputs=GPIO4,GPIO17,GPIO27,GPIO22,GPIO10,GPIO9,GPIO26
Note: Using POSIX realtime
halcmd: show pin
Component Pins:
Owner   Type  Dir         Value  Name
     4  bit   IN          FALSE  hal_gpio.GPIO10-out
     4  bit   IN          FALSE  hal_gpio.GPIO17-out
     4  bit   OUT         FALSE  hal_gpio.GPIO18-in
     4  bit   OUT         FALSE  hal_gpio.GPIO18-in-not
     4  bit   IN          FALSE  hal_gpio.GPIO22-out
     4  bit   OUT         FALSE  hal_gpio.GPIO23-in
     4  bit   OUT         FALSE  hal_gpio.GPIO23-in-not
     4  bit   OUT         FALSE  hal_gpio.GPIO24-in
     4  bit   OUT         FALSE  hal_gpio.GPIO24-in-not
     4  bit   OUT         FALSE  hal_gpio.GPIO25-in
     4  bit   OUT         FALSE  hal_gpio.GPIO25-in-not
     4  bit   IN          FALSE  hal_gpio.GPIO26-out
     4  bit   IN          FALSE  hal_gpio.GPIO27-out
     4  bit   IN          FALSE  hal_gpio.GPIO4-out
     4  bit   OUT         FALSE  hal_gpio.GPIO8-in
     4  bit   OUT         FALSE  hal_gpio.GPIO8-in-not
     4  bit   IN          FALSE  hal_gpio.GPIO9-out
     4  s32   OUT             0  hal_gpio.read.time
     4  s32   OUT             0  hal_gpio.write.time
Last edit: 09 Feb 2025 23:19 by unknown.

Please Log in or Create an account to join the conversation.

More
26 Apr 2025 02:26 #327071 by mikereid0817
Hi, I got my latest image working. In /boot/broadcom under config.txt, you need to comment out the line that enables SPI: dtparam=spi=on -> #dtparam=spi=on.
Then you can use GPIO7 and GPIO8.

You do not need to load hal_pi_gpio, it doesn't work on PI5.

The good news is that you don't need it, either.

Please Log in or Create an account to join the conversation.

More
04 May 2025 17:37 #327694 by Grad
Hi, i have a similar problem with my RPi5 and GPIO but I think I/(the AI that helped me) screwed up with the .hal-File. Do you (or anyone) mind to put your working .hal here so I can see how it is done?

Please Log in or Create an account to join the conversation.

More
04 May 2025 18:21 #327699 by unknown
forum.linuxcnc.org/9-installing-linuxcnc...only?start=10#321296

WTF would you use AI ?????????


BTW Just about everything to do with the Rpi5\4 images is in the thread linked above, rather than waste time with AI read something, a lot of work has and is going into that thread.
The following user(s) said Thank You: Grad

Please Log in or Create an account to join the conversation.

More
04 May 2025 19:14 #327701 by Grad
Well, that thread helped me before but i somehow did not notice the "Basic Mill Config Using hal_gpio" ...would have saved me a lot of time... anyways - works fine now - Thank you!

Please Log in or Create an account to join the conversation.

Time to create page: 0.201 seconds
Powered by Kunena Forum