avafinger / bananapi-zero-ubuntu-base-minimal

BananaPi M2 Zero - Ubuntu Focal Base Minimal Image (Experimental) - U-Boot 2017.09 / Kernel 4.18.y / Kernel 4.19.y / Kernel 4.20.y / Kernel 5.3.y / Kernel 5.6.y / Kernel 5.7.y / Kernel 5.11.y
88 stars 17 forks source link

WiringPi or RPi.GPIO #24

Closed lbernstone closed 5 years ago

lbernstone commented 5 years ago

Is it possible to use WiringPi or RPi.GPIO with your images?

avafinger commented 5 years ago

Yes if you use WiringPi for the mainline kernel that has support for m2z. WiringPi from Rpi check for hardware compatibility and you need to disable this "check" in the code. There may be other changes needed. Check the differences here: https://github.com/BPI-SINOVOIP/BPI-WiringPi2

xqdzn commented 5 years ago

Hi @lbernstone, You can just compile it from source then append these line to /etc/environment

BOARD=bpi-m2z
BOARD_AUTO=bpi-m2z
BOARD_OLD=bpi-m64

And the next problem is I can't compile it properly using gcc -Wall -o blink blink.c -lwiringPi

ubuntu@bpi-m2z:~/test$ gcc blink.c -o blink -lwiringPi
/usr/lib/gcc/arm-linux-gnueabihf/5/../../../../lib/libwiringPi.so: undefined reference to `crypt'
/usr/lib/gcc/arm-linux-gnueabihf/5/../../../../lib/libwiringPi.so: undefined reference to `rint'
/usr/lib/gcc/arm-linux-gnueabihf/5/../../../../lib/libwiringPi.so: undefined reference to `pthread_join'
/usr/lib/gcc/arm-linux-gnueabihf/5/../../../../lib/libwiringPi.so: undefined reference to `pthread_create'
/usr/lib/gcc/arm-linux-gnueabihf/5/../../../../lib/libwiringPi.so: undefined reference to `pow'
/usr/lib/gcc/arm-linux-gnueabihf/5/../../../../lib/libwiringPi.so: undefined reference to `shm_open'
/usr/lib/gcc/arm-linux-gnueabihf/5/../../../../lib/libwiringPi.so: undefined reference to `pthread_cancel'
collect2: error: ld returned 1 exit status

I have to link few header manually like this: gcc blink.c -o blink -lwiringPi -lpthread -lcrypt -lm -lrt -lcrypt Cheers!

lbernstone commented 5 years ago

I am able to compile wiringPi (and don't get the linker error), but it does not actually change the pin states. I run gpio readall, and it shows me all the pins set as INPUTs. I try to set a pin to OUTPUT as root (I did a for x in {1..277} just to be thorough), and then when I read the state again, nothing has changed.

lbernstone commented 5 years ago

@xqdzn You were on the right track, but wrong location. It looks in /var/lib/bananapi/board.sh for the info:

BOARD=bpi-m2z
BOARD_AUTO=bpi-m2z
BOARD_OLD=bpi-m64

Now to figure out how to get rpi.gpio to work for a user :smile: