Jump to content

BananaPI M1: gpio.add_event_detect not working after switch to vanilla kernel


hcooh

Recommended Posts

Hi,

 

I was on the legacy kernel until recently with my bananaPi M1.

I switched to the vanilla kernel but since then, when I try to use the GPIO python library (for bananapi from LeMaker github), it works quite well except for functions

gpio.add_event_detect() or GPIO.wait_for_edge(channel, GPIO.RISING)

This usually disconnect my network and the event is never detected.

I have to reboot the PI to restore the state. 

 

Also, a normal read/write state GPIO.input(PIN_NUM) works perfectly...

 

I assume it is due to the vanilla kernel but could not find any documentation on why this is happening...

 

Any answer/comments would be much appreciated!

Let me know if you need more info on my setup.

Thanks and regards,

Fabien

Link to comment
Share on other sites

Hi, thanks for the link,

 

After some investigations and debugging, I got everything working again.

So I thought I would post my findings here if that can help someone else.

 

Basically, the RPi.GPIO python library is accessing the GPIO via two different methods for different actions:

-          Direct access and write to registers for setting pull-up and pull down, input and output

-          Using the /sys/class/gpio for all edge event detection

 

Switching between legacy and mainline kernel change the /sys/class/gpio numbering template:

-          Legacy: the gpio-sunxi kernel module is managing the creation of /sys/class/gpio/gpioXX (where XX is the board pin number)

-          Mainline: the kernel (no more specific module) is managing the creation of /sys/class/gpio/gpioXXX (where XXX is the physical port number see http://linux-sunxi.org/GPIO)

 

So to have the LeMaker RPi.GPIO library working again, some modifications are needed to the /source/event_gpio.c.

I have made the changes on my github repository:

https://github.com/hcoohb/RPi.GPIO_BP/tree/bananapi

(valid for bananapi branch only, I haven’t pushed the changes for bananapro branch)

 

Hope that helps anyone.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines