[opensuse-arm] Problem running python script using GPIO

I am using a Raspberry Pi 1B to count some pulses on one of the GPIO pins, using Python script. This script runs fine on an older version of Tumbleweed, namely 20160625. When I run my script on the current version, 20180502, it throws an error message: GPIO.add_event_detect(PIN, GPIO.FALLING, callback=cb, bouncetime=100) RuntimeError: Failed to add edge detection I found a message from Frank Kunz about using the pins via sysfs, of which I have the feeling this related. Maybe not! The solution that was mentioned was installing the pinmux driver. However I can't find such a thing. -- fr.gr. member openSUSE Freek de Kruijf -- To unsubscribe, e-mail: opensuse-arm+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-arm+owner@opensuse.org

On 13.06.18 14:27, Freek de Kruijf wrote:
I am using a Raspberry Pi 1B to count some pulses on one of the GPIO pins, using Python script. This script runs fine on an older version of Tumbleweed, namely 20160625. When I run my script on the current version, 20180502, it throws an error message: GPIO.add_event_detect(PIN, GPIO.FALLING, callback=cb, bouncetime=100) RuntimeError: Failed to add edge detection
Try to find out who throws that error. Maybe just grep for the error message in the python library directory. Another thing that may give hints is to run strace on your application and see what it tries to access before and what doesn't work?
I found a message from Frank Kunz about using the pins via sysfs, of which I have the feeling this related. Maybe not! The solution that was mentioned was installing the pinmux driver. However I can't find such a thing.
The in-kernel pinmux driver is =y, so no need to install or load anything: https://kernel.opensuse.org/cgit/kernel-source/tree/config/armv6hl/default#n... Alex -- To unsubscribe, e-mail: opensuse-arm+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-arm+owner@opensuse.org

Op woensdag 13 juni 2018 15:58:25 CEST schreef Alexander Graf:
On 13.06.18 14:27, Freek de Kruijf wrote:
I am using a Raspberry Pi 1B to count some pulses on one of the GPIO pins, using Python script. This script runs fine on an older version of Tumbleweed, namely 20160625. When I run my script on the current version, 20180502, it throws an error
message: GPIO.add_event_detect(PIN, GPIO.FALLING, callback=cb, bouncetime=100)
RuntimeError: Failed to add edge detection
Try to find out who throws that error. Maybe just grep for the error message in the python library directory.
Another thing that may give hints is to run strace on your application and see what it tries to access before and what doesn't work?
I found a message from Frank Kunz about using the pins via sysfs, of which I have the feeling this related. Maybe not! The solution that was mentioned was installing the pinmux driver. However I can't find such a thing.
The in-kernel pinmux driver is =y, so no need to install or load anything:
https://kernel.opensuse.org/cgit/kernel-source/tree/config/armv6hl/default#n 3208
Alex
I used the strace and found that in fact the equivalent bash command: echo "4" > /sys/class/gpio/export gives the error message: -bash: echo: write error: Invalid argument This command should create new devices /sys/class/gpio/gpio4/* which one can use to change the behavior of the GPIO pins. What can be done to make this basic bash command work. Below some more information as root: # ls -l /sys/class/gpio/ total 0 --w------- 1 root root 4096 jun 14 17:41 export lrwxrwxrwx 1 root root 0 apr 23 09:40 gpiochip298 -> ../../devices/ platform/soc/20200000.gpio/gpio/gpiochip298 --w------- 1 root root 4096 jun 14 16:34 unexport -- fr.gr. member openSUSE Freek de Kruijf -- To unsubscribe, e-mail: opensuse-arm+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-arm+owner@opensuse.org

On 06/14/2018 05:43 PM, Freek de Kruijf wrote:
Op woensdag 13 juni 2018 15:58:25 CEST schreef Alexander Graf:
On 13.06.18 14:27, Freek de Kruijf wrote:
I am using a Raspberry Pi 1B to count some pulses on one of the GPIO pins, using Python script. This script runs fine on an older version of Tumbleweed, namely 20160625. When I run my script on the current version, 20180502, it throws an error
message: GPIO.add_event_detect(PIN, GPIO.FALLING, callback=cb, bouncetime=100)
RuntimeError: Failed to add edge detection Try to find out who throws that error. Maybe just grep for the error message in the python library directory.
Another thing that may give hints is to run strace on your application and see what it tries to access before and what doesn't work?
I found a message from Frank Kunz about using the pins via sysfs, of which I have the feeling this related. Maybe not! The solution that was mentioned was installing the pinmux driver. However I can't find such a thing. The in-kernel pinmux driver is =y, so no need to install or load anything:
https://kernel.opensuse.org/cgit/kernel-source/tree/config/armv6hl/default#n 3208
Alex I used the strace and found that in fact the equivalent bash command: echo "4" > /sys/class/gpio/export gives the error message: -bash: echo: write error: Invalid argument This command should create new devices /sys/class/gpio/gpio4/* which one can use to change the behavior of the GPIO pins.
What can be done to make this basic bash command work. Below some more information as root: # ls -l /sys/class/gpio/ total 0 --w------- 1 root root 4096 jun 14 17:41 export lrwxrwxrwx 1 root root 0 apr 23 09:40 gpiochip298 -> ../../devices/ platform/soc/20200000.gpio/gpio/gpiochip298 --w------- 1 root root 4096 jun 14 16:34 unexport
Sounds like the library doesn't realize that there is an offset for GPIO numbers on the system. The DT usually indicates what the respective offset is. Alex -- To unsubscribe, e-mail: opensuse-arm+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-arm+owner@opensuse.org

On Donnerstag, 14. Juni 2018 17:50:56 CEST Alexander Graf wrote:
On 06/14/2018 05:43 PM, Freek de Kruijf wrote:
Op woensdag 13 juni 2018 15:58:25 CEST schreef Alexander Graf:
On 13.06.18 14:27, Freek de Kruijf wrote:
I used the strace and found that in fact the equivalent bash command: echo "4" > /sys/class/gpio/export gives the error message: -bash: echo: write error: Invalid argument This command should create new devices /sys/class/gpio/gpio4/* which one can use to change the behavior of the GPIO pins.
What can be done to make this basic bash command work. Below some more information as root: # ls -l /sys/class/gpio/ total 0 --w------- 1 root root 4096 jun 14 17:41 export lrwxrwxrwx 1 root root 0 apr 23 09:40 gpiochip298 -> ../../devices/ platform/soc/20200000.gpio/gpio/gpiochip298 --w------- 1 root root 4096 jun 14 16:34 unexport
Sounds like the library doesn't realize that there is an offset for GPIO numbers on the system. The DT usually indicates what the respective offset is.
Unfortunately the RPi foundation kernel is patched to hardcode the offset to 0, so any of these simplistic wrappers only work with the foundation kernel, but not with the upstream kernel, or on any other boards. Kind regards, Stefan-- To unsubscribe, e-mail: opensuse-arm+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-arm+owner@opensuse.org

Op donderdag 14 juni 2018 17:56:41 CEST schreef Brüns, Stefan:
On Donnerstag, 14. Juni 2018 17:50:56 CEST Alexander Graf wrote:
On 06/14/2018 05:43 PM, Freek de Kruijf wrote:
Op woensdag 13 juni 2018 15:58:25 CEST schreef Alexander Graf:
On 13.06.18 14:27, Freek de Kruijf wrote: I used the strace and found that in fact the equivalent bash command: echo "4" > /sys/class/gpio/export gives the error message: -bash: echo: write error: Invalid argument This command should create new devices /sys/class/gpio/gpio4/* which one can use to change the behavior of the GPIO pins.
What can be done to make this basic bash command work. Below some more information as root: # ls -l /sys/class/gpio/ total 0 --w------- 1 root root 4096 jun 14 17:41 export lrwxrwxrwx 1 root root 0 apr 23 09:40 gpiochip298 -> ../../devices/ platform/soc/20200000.gpio/gpio/gpiochip298 --w------- 1 root root 4096 jun 14 16:34 unexport
Sounds like the library doesn't realize that there is an offset for GPIO numbers on the system. The DT usually indicates what the respective offset is.
Unfortunately the RPi foundation kernel is patched to hardcode the offset to 0, so any of these simplistic wrappers only work with the foundation kernel, but not with the upstream kernel, or on any other boards.
This made me think about a patch I made to generate a proper version og RPi.GPIO for openSUSE, which is needed to compensate for the fact that raspbian uses gpiochip0, where as you can see above, openSUSE uses a non-zero value, namely 298. To get the RPi.GPIO packet I used pip, which is apparently a version that assumes gpiochip0. I inspected build.opensuse.org and found that in the project hardware / python-RPi.GPIO the patch is included. However generating it for armv6l, armv7l, and aarch64 in openSUSE_Factory_ARM is disabled. It is not mentioned for these architectures for Leap 42.3 and 15.0 and for Tumbleweed. Could this be enabled, such that the package appears in a repository, preferably the standard repository for Leap 42.3, 15.0 and Tumbleweed? -- fr.gr. member openSUSE Freek de Kruijf -- To unsubscribe, e-mail: opensuse-arm+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-arm+owner@opensuse.org

Op donderdag 14 juni 2018 21:06:03 CEST schreef Freek de Kruijf:
Op donderdag 14 juni 2018 17:56:41 CEST schreef Brüns, Stefan:
On Donnerstag, 14. Juni 2018 17:50:56 CEST Alexander Graf wrote:
On 06/14/2018 05:43 PM, Freek de Kruijf wrote:
Op woensdag 13 juni 2018 15:58:25 CEST schreef Alexander Graf:
On 13.06.18 14:27, Freek de Kruijf wrote: I used the strace and found that in fact the equivalent bash command: echo "4" > /sys/class/gpio/export gives the error message: -bash: echo: write error: Invalid argument This command should create new devices /sys/class/gpio/gpio4/* which one can use to change the behavior of the GPIO pins.
What can be done to make this basic bash command work. Below some more information as root: # ls -l /sys/class/gpio/ total 0 --w------- 1 root root 4096 jun 14 17:41 export lrwxrwxrwx 1 root root 0 apr 23 09:40 gpiochip298 -> ../../devices/ platform/soc/20200000.gpio/gpio/gpiochip298 --w------- 1 root root 4096 jun 14 16:34 unexport
Sounds like the library doesn't realize that there is an offset for GPIO numbers on the system. The DT usually indicates what the respective offset is.
Unfortunately the RPi foundation kernel is patched to hardcode the offset to 0, so any of these simplistic wrappers only work with the foundation kernel, but not with the upstream kernel, or on any other boards.
This made me think about a patch I made to generate a proper version og RPi.GPIO for openSUSE, which is needed to compensate for the fact that raspbian uses gpiochip0, where as you can see above, openSUSE uses a non-zero value, namely 298.
To get the RPi.GPIO packet I used pip, which is apparently a version that assumes gpiochip0.
I inspected build.opensuse.org and found that in the project hardware / python-RPi.GPIO the patch is included. However generating it for armv6l, armv7l, and aarch64 in openSUSE_Factory_ARM is disabled. It is not mentioned for these architectures for Leap 42.3 and 15.0 and for Tumbleweed.
Could this be enabled, such that the package appears in a repository, preferably the standard repository for Leap 42.3, 15.0 and Tumbleweed?
Some time ago I already generated versions for the three architectures and for python 2 and 3. Must have slipped my older brain. I did a "pip uninstall RPi.GPIO" and installed my packet for python2 and armv6hl. Problem solved for me. Two years ago I already made a ticked for the product on sourceforge providing the patch, which should also work for /sys/class/gpio/gpiochip0 -- fr.gr. member openSUSE Freek de Kruijf -- To unsubscribe, e-mail: opensuse-arm+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-arm+owner@opensuse.org

Am 14.06.2018 um 21:06 schrieb Freek de Kruijf:
I inspected build.opensuse.org and found that in the project hardware / python-RPi.GPIO the patch is included. However generating it for armv6l, armv7l, and aarch64 in openSUSE_Factory_ARM is disabled. It is not mentioned for these architectures for Leap 42.3 and 15.0 and for Tumbleweed.
Could this be enabled, such that the package appears in a repository, preferably the standard repository for Leap 42.3, 15.0 and Tumbleweed?
Done for Factory ARM - the other repositories need to be set up first. Regards, Andreas -- SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-arm+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-arm+owner@opensuse.org
participants (4)
-
Alexander Graf
-
Andreas Färber
-
Brüns, Stefan
-
Freek de Kruijf