Invalid Channel

StereoPi hardware discussion
Post Reply
fnouguie
Posts: 1
Joined: Thu Jan 14, 2021 10:37 pm

Invalid Channel

Post by fnouguie »

Hi everyone,

I just bought a stereopi and tried my first tests on it. I want to play with stereo capability and stepper motors.
While I was waiting for the stereopi board delivery, I played with a stepper motor (and its controler) on a regular Raspberry pi 3 and it was working just fine.
I wired the motor on the stereoPi card (taking care of the 180 deg rotation of the GPIO pins) but wasn't able to make it running properly.

While initiating the pins to use (7,11,13,15, 31,33,35,37):
>> GPIO.setmode(GPIO.BOARD)
>> GPIO.setup(pin, GPIO.OUT)

I get first a warning for pin #7:
"RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings."
then an error when setting up pin #31:"The channel sent is invalid on a Raspberry Pi"


I tried to change GPIO.BOARD to GPIO.BCM in GPIO.setmode() but it did not help.
Any clue ?

Thanks in advance
Fred

stereomaton
Posts: 210
Joined: Tue May 21, 2019 12:33 pm
Location: France

Re: Invalid Channel

Post by stereomaton »

It seems that the GPIO you want to use is used by another program/driver.
It is quite strange since there is nothing special there that could a priori be in conflict, though I do not have the original image on my StereoPi to compare.

The linux kernel has a special file to see what GPIO are in use by the drivers: /sys/kernel/debug/gpio
If it does not exist (I do not have the original image in my StereoPi to check), you may have to mount the debugfs filesystem: mount -t debugfs none /sys/kernel/debug/

For example, on my current system I have:

Code: Select all

[email protected]:~ $ sudo cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-53, parent: platform/3f200000.gpio, pinctrl-bcm2835:
 gpio-3   (                    |sysfs               ) in  hi IRQ

gpiochip2: GPIOs 100-101, brcmvirt-gpio, can sleep:
 gpio-100 (                    |led0                ) out hi    

gpiochip1: GPIOs 504-511, parent: platform/soc:firmware:expgpio, raspberrypi-exp-gpio, can sleep:
We see that GPIO 3 ("BCM notation") is used by sysfs (the driver that allows to control the GPIO in user programs) and that the GPIO 100 is used by the led driver (the led is showing activity on SD card).

To know which program uses the GPIO through a sysfs driver, you can run fuser $(realpath /sys/class/gpio/gpio3/value) (for GPIO 3 here) This gives the process ID of the program, which you can then pass to other programs to retrieve details, for example ps u -p 486 (for process ID 486 here)

This can be a first step to see what is going on.
Stereophotographer and hacker
Despite my quite active participation in the forum, I am not in the StereoPi team
StereoPi (v1) Standard Edition + CM3Lite module + a few cameras

Post Reply