Configuracion y use de GPIO BPI-M2 Zero

hi Arturo, can you load it now on the new images repo? As I told you, the linux banana pi card is connected to the power supply of the industrial machine, so when I unplug the power cable to the machine several times a day, the linux banana pi card also turns off / on several times a day. I would like to avoid the operating system crash.

Which new best image should I upload from the repo? A thousand thanks

Interisting, do you have the code of the new library on your github, couldn’t find it!? Even it is not stable, I would be interested interested especially in the ‘gpio readall’ fix for the BCM numbers.

On the ‘pull-up’ problem I found a working fork of the BPI-SINOVOIP RPI-GPIO code:

With this I was able to activate the pull-ups I need for my LISY boards :slightly_smiling_face: see code below

#!/usr/bin/python import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_UP) print(‘pull up on GPIO.12 (Sound/DIP2) set’)

GPIO.setup(6, GPIO.IN, pull_up_down=GPIO.PUD_UP) print(‘pull up on GPIO.22 (TEST/DIP6) set’)

GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP) print(‘pull up on GPIO.23 (DEBUG/DIP7) set’)

GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP) print(‘pull up on GPIO.21 (Autostart/DIP8) set’)

1 Like

hi Bontango, do you know if the callback add_event_detect functions work stably (NO BUG) on banana pi M2 zero using those GPIO libraries?

GPIO ==> callback event detect function:

GPIO.add_event_detect (pin, GPIO.BOTH, call back = myFunction)

GPIO.add_event_detect (pin, GPIO.FALLING, call back = myFunction)

thank you

1 Like

I have not tried this function yet, but can check if you want. How can I test it? What is the bug with the other library version?

Hello Botango, I take up the quote from Roxas on the current instability (physical pins Library GPIO)

If you want you can test the add_event_detect functions on those Python GPIO libraries, you can do it with a Button connected to the physical GPIO pin of banana pi M2 Zero. I am attaching the Python script that triggers commands (bash script) when it detects callback events on the Python GPIO function buttonStateChanged () ==> buttonPressed> = 5 secbuttonCallback_1.py (1,4 KB)

worked for me:

grafik

only change I made is that I used GPIO.setmode(GPIO.BCM) instead of GPIO.setmode(GPIO.BOARD) and set pin=5 which is GPIO.21 because I’m not sure about the pin numbering with setmode(GPIO.BOARD)

Edit: happy to help you with this library, but if you further questions better open a new thread and I will answer you there, I do not want to ‘enter’ Roxas thread here and we are drifting away a bit from the original topic …

Good friend, look, I hope before Thursday or Friday I can upload the new image for you to test it, but if you want you can take a look at git so you can check the new changes to the script, since I have added the corrections and the library of the friend @ bontango

sure friend look now i have updated the git repository and add a function to fix the gpio table now the command you can use to query is (sudo gpioread)

the same for me it worked well but I think it would be better if you use sub process and there is no issue that they publish it here so we will have more info of any problem friend

Great friend Roxas, the new minimal image would have the fix on the error, checks the filesystem e2fsck on boot?

Roxas friend so the add_event_detect callback functions are now up and running on your GPIO libraries if I reinstall your script.sh?

Yes, thanks to the help of the friend Bontango, I updated the script with the new library and new examples that I quickly checked and carried out, in addition to the new sudo gpioread command for the new gpio and alrato table, I would only do a simple update to the repos like around 10 or 11 pm

Ok I await your new Ubuntu Armbian Minimal image release for Bpi-M2-Zero to recompile and reinstall everything inside with the script.sh. Thanks to Bontango for the callback

ah, I see … you are using the original output of ‘gpio readall’ and doing a ‘sed translation’. Based on your work I spend some hours to look into the BPI-WiringPi2 code and did the same thing there by adding a special translation table for M2-Zero I will try to ix also the ‘pull-up’ bug, but I guess that will take some time … You can find my fork of BPI-WiringPi2 on my github

grafik grafik

Thanks for your work!!!

Im having problems too with WiringPi in BPI.

My application was using WiringPiISR, and didn’t work in BPI, so im searching a workarround.

On Raspberry I was using " gpio wfi rising/falling/both within a shell script. gpio wfi do also use the WiringPiISR library function. ( Errormessage: wiringPiISR: wait for support (5) ) For Banana PI I was able to replace that with a small python script which uses the library below ( GPIO.add_event_detect(pin, GPIO.BOTH, callback=buttonStateChanged) )

Maybe you can use this … ?

hello friend Bontango, i am trying to execute callback_1.py from root banana pi, but i get error no rpi module.No_Module_Rpi I installed your library by following your simple board.sh file editing steps

which library did you install? for the callback_1.py you need to install the RPI.GPio library from my link above. My library gives you a new version of WiringPI2!

For python you need to:

git clone https://github.com/GrazerComputerClub/RPi.GPIO.git

sudo apt-get install python3-all python3-all-dev debhelper
sudo apt-get install python-all python-all-dev

cd RPi.GPIO

./make_deb

sudo python setup.py install

sudo python3 setup.py install

New image for banana m2 zero with experimental parks for the use of uart ttyS0 not yet tested, I will only leave it available for a while until I reach the final solution :sweat_smile:

https://www.mediafire.com/file/83b9ftcr1m8fsm6/Armbian_22.05.0-trunk_Bananapim2zero_focal_current_5.15.43-1.rar/file

./make_deb: 19: python: not found

image

Python2 Python3 Package installed image