How to: banana pi BPI-M3 install BPI-WiringPi

Download For BPI-M3.

git clone https://github.com/BPI-SINOVOIP/BPI-WiringPi.git -b BPI_M3

Installation:

cd BPI-WiringPi
chmod +x ./build
sudo ./build

test wiringPi is install success

gpio -v

gpio readall

create new : blink.c

#include <wiringPi.h>
int main(void)
{
  wiringPiSetup() ;
  pinMode (0, OUTPUT) ;
  for(;;) 
  {
    digitalWrite(0, HIGH) ; delay (500) ;
    digitalWrite(0,  LOW) ; delay (500) ;
  }
}

compile and run it:

gcc -Wall -o blink blink.c -lwiringPi

runing it:

sudo ./blink

link from: http://forum.banana-pi.org.cn/thread-1003-1-1.html

1 Like

How do i use the hardware PWM correctly? I already figured out that i have to use wiringPi Pin 7. I executed the following code:

gpio mode 7 pwm
gpio pwm-ms
gpio pwmr 128
gpio pwmc 6
gpio pwm 7 120

But i get the following error:

val pwmWrite 0 <= X <= 1024 Or you can set new range by yourself by pwmSetRange(range

The same error occured when i coded the same with the C library:

#include <wiringPi.h>

int main ()
{
  if (wiringPiSetup() == -1)
    return 1;
  pwmSetMode(PWM_MODE_MS);
  pinMode(7, PWM_OUTPUT);
  pwmSetRange(128);
  pwmSetClock(6);
  pwmWrite(7,120);
  return 0 ;
}

But i got the same error. I think there is still a bug. Please confirm or give any suggestions, what i’m doing wrong.

Does anybody have an idea?

Maybe the vendor you got hardware and software from? Think positive and stay calm! Maybe they need just another 2 months to ignore your question but then maybe they’re in the mood to look into. But I would suspect they give a shit as usual.

BTW: Do you have something below /sys/devices/platform/sunxi_pwm available? If not why do you expect that PWM should work?

How to force m3 to allow exporting gpio? example: echo 7 > /sys/class/gpio/export -su: echo: write error: Invalid argument

Hi, i Followed the instruction but become an error. Can anybody help me?

HI: please reference the document and provider error messages.

https://bananapi.gitbooks.io/bpi-m3/content/bpi-m3_wiringpi.html.

Error message is in the Picture of my last post

you can run “gpio readall” commnad?

Yes, i can run the command. But become an error Message

Unable to determine Hardware version. I see: Hardware : sun8i

HI: Please reference it

This not help me, I followed the instructions above but output the same error message .

[quote]

[email protected]:~# Welcome to Ubuntu 15.10 (GNU/Linux 3.4.39-BPI-M3-Kernel armv7l)

 * Documentation:  https://help.ubuntu.com/

0 packages can be updated.
0 updates are security updates.

New release '16.04 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

[email protected]:~/BPI-WiringPi/m3_test# gpio readall
Unable to determine hardware version. I see: Hardware   : sun8i

 - expecting BCM2708 or BCM2709. Please report this to [email protected]
[email protected]:~/BPI-WiringPi/m3_test# 
[/quote]

If you are unable to help me, say it and let other try to help.

Regards

First you must remove WiringPi: sudo apt-get remove wiringpi .
Then compile new Bpi-wiringpi.

Thanks, It works.

Best regards

1 Like

Hello, I NEED to run WiringPi as normal user since I will be implementing it with ROS. I followed that guide:

but I can’t find anywhere the gpio files that should be under /sys/class/gpio, where are them?

Hi, I tried to install BPI-WiringPi on BananaPi M3 with Raspian Jessie Mate… But i have build failed Error…

[email protected]:~# sudo apt-get remove wiringpi
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'wiringpi' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
[email protected]:~#


[email protected]:/home/pi# git clone https://github.com/BPI-SINOVOIP/BPI-WiringPi.git -b BPI_M3
Cloning into 'BPI-WiringPi'...
remote: Counting objects: 306, done.
remote: Total 306 (delta 0), reused 0 (delta 0), pack-reused 306
Receiving objects: 100% (306/306), 548.28 KiB | 480.00 KiB/s, done.
Resolving deltas: 100% (168/168), done.
Checking connectivity... done.
[email protected]:/home/pi# cd BPI-WiringPi
[email protected]:/home/pi/BPI-WiringPi# chmod +x ./build
[email protected]:/home/pi/BPI-WiringPi# sudo ./build
./build: 4: ./build: [[: not found
wiringPi Build script
=====================


WiringPi Library
[UnInstall]
[Compile] wiringPi.c
[Compile] wiringSerial.c
[Compile] wiringShift.c
[Compile] piHiPri.c
[Compile] piThread.c
[Compile] wiringPiSPI.c
[Compile] wiringPiI2C.c
[Compile] softPwm.c
wiringPi.c:666:3: warning: excess elements in array initializer
   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
   ^
wiringPi.c:666:3: warning: (near initialization for ‘pinTobcm_BP’)
wiringPi.c:756:3: warning: excess elements in array initializer
   {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PN
   ^
wiringPi.c:756:3: warning: (near initialization for ‘BP_PIN_MASK’)
wiringPi.c: In function ‘sunxi_gpio_unexports’:
wiringPi.c:798:13: warning: assignment makes integer from pointer without a cast
     if ((fd = fopen ("/sys/class/gpio/unexport", "w")) == NULL)
             ^
wiringPi.c:798:56: warning: comparison between pointer and integer
     if ((fd = fopen ("/sys/class/gpio/unexport", "w")) == NULL)
                                                        ^
wiringPi.c:807:14: warning: passing argument 1 of ‘fprintf’ makes pointer from integer without a cast
     fprintf (fd, "%d\n", pin) ;
              ^
In file included from wiringPi.c:55:0:
/usr/include/stdio.h:356:12: note: expected ‘struct FILE * __restrict__’ but argument is of type ‘int’
 extern int fprintf (FILE *__restrict __stream,
            ^
wiringPi.c:808:13: warning: passing argument 1 of ‘fclose’ makes pointer from integer without a cast
     fclose (fd) ;
             ^
In file included from wiringPi.c:55:0:
/usr/include/stdio.h:237:12: note: expected ‘struct FILE *’ but argument is of type ‘int’
 extern int fclose (FILE *__stream);
            ^
[Compile] softTone.c
[Compile] mcp23008.c
[Compile] mcp23016.c
[Compile] mcp23017.c
wiringPi.c: At top level:
wiringPi.c:719:12: warning: ‘physToGpioR3’ defined but not used [-Wunused-variable]
 static int physToGpioR3 [64] =//head num map to BCMpin
            ^
[Compile] mcp23s08.c
[Compile] mcp23s17.c
[Compile] sr595.c
[Compile] pcf8574.c
[Compile] pcf8591.c
[Compile] mcp3002.c
[Compile] mcp3004.c
[Compile] mcp4802.c
[Compile] mcp3422.c
[Compile] max31855.c
[Compile] max5322.c
[Compile] sn3218.c
[Compile] drcSerial.c
[Compile] wpiExtensions.c
[Link (Dynamic)]
[Install Headers]
[Install Dynamic Lib]

WiringPi Devices Library
[UnInstall]
[Compile] ds1302.c
[Compile] maxdetect.c
[Compile] piNes.c
[Compile] gertboard.c
[Compile] piFace.c
[Compile] lcd128x64.c
[Compile] lcd.c
[Compile] piGlow.c
[Link (Dynamic)]
[Install Headers]
[Install Dynamic Lib]

GPIO Utility
[Compile] gpio.c
[Compile] readall.c
[Compile] pins.c
gpio.c: In function ‘doExports’:
gpio.c:428:5: warning: implicit declaration of function ‘sunxi_gpio_exports’ [-Wimplicit-function-declaration]
     sunxi_gpio_exports();
     ^
gpio.c:420:20: warning: unused variable ‘pin’ [-Wunused-variable]
   int i, l, first, pin;
                    ^
gpio.c: In function ‘doUnexportall’:
gpio.c:757:5: warning: implicit declaration of function ‘sunxi_gpio_unexports’ [-Wimplicit-function-declaration]
     sunxi_gpio_unexports();
     ^
gpio.c: At top level:
gpio.c:877:13: warning: ‘doPadDrive’ defined but not used [-Wunused-function]
 static void doPadDrive (int argc, char *argv [])
             ^
gpio.c:965:13: warning: ‘doGbw’ defined but not used [-Wunused-function]
 static void doGbw (int argc, char *argv [])
             ^
gpio.c:1007:13: warning: ‘doGbr’ defined but not used [-Wunused-function]
 static void doGbr (int argc, char *argv [])
             ^
[Link]
/usr/bin/ld: gpio.o: undefined reference to symbol '[email protected]@GLIBC_2.4'
//lib/arm-linux-gnueabihf/libc.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:51: recipe for target 'gpio' failed
make: *** [gpio] Error 1

Make Failed… Please check the messages and fix any problems. If you’re still stuck, then please email all the output and as many details as you can to [email protected]

@BPI_Justin I have a similar problem as @Osa_Kozak

However i am using: Ubuntu 16.04 mate… Release Date: 2017-07-20

When i follow your tutorial explicitly i get the following error:

[email protected]:~$ cd BPI-WiringPi
[email protected]:~/BPI-WiringPi$ chmod +x ./build
[email protected]:~/BPI-WiringPi$ sudo ./build
[sudo] password for pi:
./build: 4: ./build: [[: not found
wiringPi Build script
=====================


WiringPi Library
[UnInstall]
make: Nothing to be done for 'all'.
[Install Headers]
[Install Dynamic Lib]

WiringPi Devices Library
[UnInstall]
make: Nothing to be done for 'all'.
[Install Headers]
[Install Dynamic Lib]

GPIO Utility
[Link]
/usr/bin/ld: gpio.o: undefined reference to symbol '[email protected]@GLIBC_2.4'
//lib/arm-linux-gnueabihf/libc.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:51: recipe for target 'gpio' failed
make: *** [gpio] Error 1

Make Failed...
Please check the messages and fix any problems. If you're still stuck,
then please email all the output and as many details as you can to
  [email protected]

[email protected]:~/BPI-WiringPi$

However when i change: git clone https://github.com/BPI-SINOVOIP/BPI-WiringPi.git -b BPI_M3

To: git clone https://github.com/BPI-SINOVOIP/BPI-WiringPi2.git

It installs ok. but there is no test file in the M3_test folder

What is wrong with the: git clone https://github.com/BPI-SINOVOIP/BPI-WiringPi.git -b BPI_M3 ???

newest wiringpi:

Your new version lead to the same message error describe by @Shadow3561

Unable to determine hardware version. I see: Hardware : sun8i

  • expecting BCM2708, BCM2709, BCM2709. If this is a genuine Raspberry Pi then please report this to [email protected]. If this is not a Raspberry Pi then you are on your own as wiringpi is designed to support the Raspberry Pi ONLY

So, conclusion, even if you provide something from another developer (who seems to be not happy of that)… can you please give the correct patch to implement the gpio.

Thank you

WiringPi broke my kernel but WiringPi2 worked without any problems thanks @sinovoip great work!

1 Like