Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: GPIO busy
#1
Hi,

I was running Moode 8.3.6 without any major issue and did a fresh install of Moode 9.1.5. I now face an error when running a startup script (as the last command in /etc/rc.local) which initializes the handling of an ATX-like Audiophonics Pi power supply board (https://www.audiophonics.fr/en/power-sup...11504.html).

Executing the script manually (through Windows / Putty) gives the following "GPIO busy" error :

Code:
pi@moode:~ $ python /home/pi/spc_moode.py
Traceback (most recent call last):
 File "/home/pi/spc_moode.py", line 27, in <module>
   GPIO.setup(17, GPIO.IN)
 File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 696, in setup
   _check(lgpio.gpio_claim_input(_chip, gpio, {
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/lib/python3/dist-packages/lgpio.py", line 755, in gpio_claim_input
   return _u2i(_lgpio._gpio_claim_input(handle&0xffff, lFlags, gpio))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i
   raise error(error_text(v))
lgpio.error: 'GPIO busy'


where spc_moode.py and line 27 are :
Code:
#!/usr/bin/python3
# MoOde 7
# All-in-One script for Audiophonics SPC II power management board
# Modded 2020-01-24 by Ph. Deysine
# Shutdown Button handled by overlay to be added in /boot/config.txt :
# dtoverlay=gpio-shutdown,gpio_pin=17,active_low=0,gpio_pull=down
#
# Start the script without parameter to initialise :
# - GPIO outputs 4 (SofthutDown) and 22 (BootOK)
# - GPIO input 17 (Shutdown Button)
# Power LED stops blinking when MoOde is ready
#
# "spc_moode.py reboot" to reboot
#
# "spc_moode.py shutdown" to shutdown


import sys
import os
import time
import RPi.GPIO as GPIO
import subprocess

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(17, GPIO.IN)  <----line 27
GPIO.setup(22, GPIO.OUT)

.../...

Does it mean that Moode v9 now takes some exclusive handling of the (input) GPIO ports, or ...?
(GPIO buttons are left as is which means "not selected" in Moode/Configure/Peripherals/Other Peripherals)

Thank you very much for your help as I have limited knowledge of Linux and Raspberry OS apart from some memory of early Unix systems  Confused  !

Best regards.

Philippe
Reply
#2
Your best bet is to contact Audiophonics since its their script thats failing.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
Hello again,

Thanks Tim for what you achieve with Moode and nevertheless your attention to my previous message. Audiophonics may have nice hardware but software maintenance is mainly a customer job which I did !

In Moode 9,  Rpi.GPIO is implemented through lgpio which leads to subtle differences with the native version. (rpi-lgpio 0.6 Documentation). An accurate control of GPIO pin usage and ownership is now provided leading to a"GPIO busy" error in case of a potential conflict.

In my case, the error was due to one GPIO pin setuped twice (without being first released) even redundantly :

Code:
dtoverlay=gpio-shutdown,gpio_pin=17,active_low=0,gpio_pull=down


de facto setups GPIO 17 as an input and marks is as used (gpioinfo) which conflicts with a later GPIO.setup(17, GPIO.IN) in ther initialisation script.

Voilà !

Best regards,

Philippe

(Sorry not to know how to turn "Problem" into "Solved"
Reply
#4
Glad its fixed :-)

I marked the thread as SOLVED.
To do this just edit the first post (#1) and change to SOLVED in the dropdown.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: