Banana Pi M2 Berry and RPi.GPIO python module

Hi,

I’ve ran into the following problem trying to use the RPi.GPIO edge detection functions with a BPi M2 Berry:

First, some informations of the OS:

root@BPI-A:/home/pi/RPi.GPIO_BP# lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 8.0 (jessie)
Release:	8.0
Codename:	jessie
root@BPI-A:/home/pi/RPi.GPIO_BP# uname -a
Linux BPI-A 3.10.107-BPI-M2U-Kernel #1 SMP Thu Aug 24 08:01:24 CST 2017 armv7l GNU/Linux
root@BPI-A:/home/pi/RPi.GPIO_BP# 

The “gpio readall” read-outs all work for the pins i’ve tested: Pins 29 and 31 connected to display LEDs, and pins 33, 35, and 37 are connected with a button switch so that it is connected through a pull-up resistor to 3.3V when the button is not pressed, and ground when the button is pressed.

When I used RPi.GPIO 0.6.3 that was already installed on the BPi, reading from pins 33 and 35 works, with same output shown by “gpio readall”, but neither wait_for_edge nor add_event_detect are triggered by button presses. GPIO.output also works, the LED connected to the pin set to GPIO.HIGH lit up as expected.

When I used RPi.GPIO 0.5.8 from

reading from pins 33 and 35 always show 1 even with button pressed, and still neither wait_for_edge nor add_event_detect are triggered by button presses. GPIO.output also does not work, the LED connected to the pin set to GPIO.HIGH did not lit up.

The functions wait_for_edge and add_event_detect both worked with another board, Raspberry Pi 3 Model B. Does the edge detection functions work with BPi M2 Berry?

Here is the test script for inputs I used: (Outputs I just used the python console)

#!/usr/bin/env python2.7
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
GPIO.setup(33, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(35, GPIO.IN, pull_up_down=GPIO.PUD_UP)


def falling_callback(channel):
    print "power edge detected."
    time.sleep(0.5)
    if GPIO.input(channel) == GPIO.LOW:
        print "Button was held down."
    else:
        print "Button was let go."
    return


GPIO.add_event_detect(33, GPIO.FALLING, callback=falling_callback, bouncetime=100)
try:
    while True:
        print "GPIO 33: ", GPIO.input(33)
        print "GPIO 35: ", GPIO.input(35)
        GPIO.wait_for_edge(35, GPIO.FALLING)
        print "red edge detected."
        time.sleep(1)
        print "Done sleeping."
except KeyboardInterrupt:
    GPIO.cleanup()

@hochiang13 assuming that you solved the issue - which one of those many Rpi.GPIO versions/forks “that will work on BPI” found in the wild eventually turned out to be working? Thanks!

@kroko you won’t have any luck there. I reported this bug of Rpi.GPIO a year ago but no reaction from SinoVoip. If you want to use Gpio choose some other hardware vendor and not Banana Pi. since there is no support it’s just crap

I finally got wiringpi and Rpi.GPIO to work on a Banana Pi M2 Berry (I am running Armbian Buster with kernel 5.3.0 on it) from these repositories:

First the code from these repositories did not work - it gave the error that only Raspberry Pi is supported.

Then with intensive “googeling” and some luck I stumbled upon this forum entry

which solved the problem. In short you have to create a shell scripts that reports the board version so that the wiringpi and RPi.GPIO can identify the hardware. For details see the forum entry.

Sinovoip should really mention that in the README and INSTALL - that would save many people a lot of time and trouble!!

PS: I did not yet test edge detection and interrupts on the inputs.

With the “official” image Raspbian jessie 8.0 2018-5-24 which is running kernel 3.10.x I had the problem that edge detection and interrupts did not work:

My hope is that with the newer kernel this might be fixed.

One great improvement of the new Kernel 5.3.0 already is a much lower idle load. With kernel 3.10 the system was showing a load of around 0.50 even when the board was doing nothing. With kernel 5.3.0 the idle load is 0 - 0.07