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.

Time to create page: 0.096 seconds
Powered by Kunena Forum