Banana Pi BPI-M2 Zero - wiringPi2

Hey, I tried to install https://github.com/BPI-SINOVOIP/BPI-WiringPi2 on my Banana Pi M2 Zero with this image: http://forum.banana-pi.org/t/bpi-m2-zero-new-image-2017-12-04-armbian-5-36-m2-zero-ubuntu-xenial-next-4-14-3-desktop-preview-buildbybpi/4325/26 But I only get this message if I try to use gpio readall:

Unable to determine hardware version. I see: Hardware : Allwinner sun8i Family
,
- expecting BCM2708, BCM2709 or BCM2835.
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.

Can anyone help me with this problem? Thanks

1 Like

Here is the solution:

  1. Copy the files from https://github.com/BPI-SINOVOIP/BPI-files/tree/master/others/bpi-service to your system
  2. Change bpi-m3 to bpi-m2z in this file var/lib/bananapi/board.sh
  3. Install https://github.com/BPI-SINOVOIP/BPI-WiringPi2
  4. Have fun with wiringPi
4 Likes

+1, worked for me, thanks

1 Like

Or, to minimse the effort. Just append these lines to your /etc/environment

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

I append it after compiling BPI-WiringPi2 from source. Here’s what i got

ubuntu@bpi-m2z:~$ gpio -1 mode 10 out
ubuntu@bpi-m2z:~$ gpio -1 write 10 1
ubuntu@bpi-m2z:~$ gpio readall
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |  12 |   8 |   SDA.1 | ALT5 | 0 |  3 || 4  |   |      | 5v      |     |     |
 |  11 |   9 |   SCL.1 | ALT5 | 0 |  5 || 6  |   |      | 0v      |     |     |
 |   6 |   7 | GPIO. 7 | ALT3 | 0 |  7 || 8  | 0 | ALT3 | TxD     | 15  | 13  |
 |     |     |      0v |      |   |  9 || 10 | 1 | OUT  | RxD     | 16  | 14  |
 |   1 |   0 | GPIO. 0 | ALT3 | 0 | 11 || 12 | 0 | ALT3 | GPIO. 1 | 1   | 16  |
 |   0 |   2 | GPIO. 2 | ALT3 | 0 | 13 || 14 |   |      | 0v      |     |     |
 |   3 |   3 | GPIO. 3 | ALT3 | 0 | 15 || 16 | 0 | ALT3 | GPIO. 4 | 4   | 15  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | ALT3 | GPIO. 5 | 5   | 68  |
 |  64 |  12 |    MOSI | ALT3 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |  65 |  13 |    MISO | ALT3 | 0 | 21 || 22 | 0 | ALT3 | GPIO. 6 | 6   | 2   |
 |  66 |  14 |    SCLK | ALT3 | 0 | 23 || 24 | 0 | ALT3 | CE0     | 10  | 67  |
 |     |     |      0v |      |   | 25 || 26 | 0 | ALT3 | CE1     | 11  | 71  |
 |  19 |  30 |   SDA.0 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.0   | 31  | 18  |
 |   7 |  21 | GPIO.21 | ALT3 | 0 | 29 || 30 |   |      | 0v      |     |     |
 |   8 |  22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | GPIO.26 | 26  | 354 |
 |   9 |  23 | GPIO.23 | ALT3 | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  10 |  24 | GPIO.24 | ALT3 | 0 | 35 || 36 | 0 | OUT  | GPIO.27 | 27  | 356 |
 |  17 |  25 | GPIO.25 | ALT3 | 0 | 37 || 38 | 0 | ALT3 | GPIO.28 | 28  | 21  |
 |     |     |      0v |      |   | 39 || 40 | 0 | ALT3 | GPIO.29 | 29  | 20  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
ubuntu@bpi-m2z:~$ gpio -1 write 10 0
ubuntu@bpi-m2z:~$ gpio readall
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |  12 |   8 |   SDA.1 | ALT5 | 0 |  3 || 4  |   |      | 5v      |     |     |
 |  11 |   9 |   SCL.1 | ALT5 | 0 |  5 || 6  |   |      | 0v      |     |     |
 |   6 |   7 | GPIO. 7 | ALT3 | 0 |  7 || 8  | 0 | ALT3 | TxD     | 15  | 13  |
 |     |     |      0v |      |   |  9 || 10 | 0 | OUT  | RxD     | 16  | 14  |
 |   1 |   0 | GPIO. 0 | ALT3 | 0 | 11 || 12 | 0 | ALT3 | GPIO. 1 | 1   | 16  |
 |   0 |   2 | GPIO. 2 | ALT3 | 0 | 13 || 14 |   |      | 0v      |     |     |
 |   3 |   3 | GPIO. 3 | ALT3 | 0 | 15 || 16 | 0 | ALT3 | GPIO. 4 | 4   | 15  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | ALT3 | GPIO. 5 | 5   | 68  |
 |  64 |  12 |    MOSI | ALT3 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |  65 |  13 |    MISO | ALT3 | 0 | 21 || 22 | 0 | ALT3 | GPIO. 6 | 6   | 2   |
 |  66 |  14 |    SCLK | ALT3 | 0 | 23 || 24 | 0 | ALT3 | CE0     | 10  | 67  |
 |     |     |      0v |      |   | 25 || 26 | 0 | ALT3 | CE1     | 11  | 71  |
 |  19 |  30 |   SDA.0 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.0   | 31  | 18  |
 |   7 |  21 | GPIO.21 | ALT3 | 0 | 29 || 30 |   |      | 0v      |     |     |
 |   8 |  22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | GPIO.26 | 26  | 354 |
 |   9 |  23 | GPIO.23 | ALT3 | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  10 |  24 | GPIO.24 | ALT3 | 0 | 35 || 36 | 0 | OUT  | GPIO.27 | 27  | 356 |
 |  17 |  25 | GPIO.25 | ALT3 | 0 | 37 || 38 | 0 | ALT3 | GPIO.28 | 28  | 21  |
 |     |     |      0v |      |   | 39 || 40 | 0 | ALT3 | GPIO.29 | 29  | 20  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
ubuntu@bpi-m2z:~$ 

Next thing to solve is how to compile a C code properly using wiringPi. Because I always failed at it:

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

You need to pass:

-lpthread -lm -lcrypt

I am receiving the same Error. I am running

Welcome to Ubuntu 19.10 (GNU/Linux 5.3.18 armv7l)

on the Banana Pi Zero

how to fix this problem ?

add

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

to /etc/environment is not solving the problem

Here is how to build BPI-WiringPi2

ubuntu@bpi-m2z:~$ git clone https://github.com/BPI-SINOVOIP/BPI-WiringPi2
Cloning into 'BPI-WiringPi2'...
remote: Enumerating objects: 1368, done.
remote: Total 1368 (delta 0), reused 0 (delta 0), pack-reused 1368
Receiving objects: 100% (1368/1368), 1.03 MiB | 1.35 MiB/s, done.
Resolving deltas: 100% (838/838), done.
ubuntu@bpi-m2z:~$ cd BPI-WiringPi2/

Create an environment

ubuntu@bpi-m2z:~/BPI-WiringPi2$ sudo su
root@bpi-m2z:/home/ubuntu/BPI-WiringPi2# mkdir -p /var/lib/bananapi
root@bpi-m2z:/home/ubuntu/BPI-WiringPi2# echo "BOARD=bpi-m2z" > /var/lib/bananapi/board.sh
root@bpi-m2z:/home/ubuntu/BPI-WiringPi2# echo "BOARD_AUTO=bpi-m2z" >> /var/lib/bananapi/board.sh
root@bpi-m2z:/home/ubuntu/BPI-WiringPi2# echo "BOARD_OLD=bpi-m64" >> /var/lib/bananapi/board.sh
root@bpi-m2z:/home/ubuntu/BPI-WiringPi2# cat /var/lib/bananapi/board.sh
BOARD=bpi-m2z
BOARD_AUTO=bpi-m2z
BOARD_OLD=bpi-m64
root@bpi-m2z:/home/ubuntu/BPI-WiringPi2i# exit

Building

ubuntu@bpi-m2z:~/BPI-WiringPi2$ sudo ./build
wiringPi Build script
=====================


WiringPi Library
[UnInstall]
[Compile] wiringPi.c
[Compile] wiringPi_bpi.c
[Compile] wiringSerial.c
[Compile] wiringShift.c
[Compile] piHiPri.c
[Compile] piThread.c
[Compile] wiringPiSPI.c
wiringSerial.c: In function ‘serialPutchar’:
wiringSerial.c:158:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
  158 |   write (fd, &c, 1) ;
      |   ^~~~~~~~~~~~~~~~~
wiringSerial.c: In function ‘serialPuts’:
wiringSerial.c:170:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
  170 |   write (fd, s, strlen (s)) ;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
wiringPiSPI.c:43:26: warning: ‘spiDev1’ defined but not used [-Wunused-variable]
   43 | static const char       *spiDev1  = "/dev/spidev0.1" ;
      |                          ^~~~~~~
wiringPiSPI.c:42:26: warning: ‘spiDev0’ defined but not used [-Wunused-variable]
   42 | static const char       *spiDev0  = "/dev/spidev0.0" ;
      |                          ^~~~~~~
[Compile] wiringPiI2C.c
[Compile] softPwm.c
wiringPi.c: In function ‘digitalRead’:
wiringPi.c:1603:7: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
 1603 |       read   (sysFds [pin], &c, 1) ;
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
wiringPi.c: In function ‘digitalWrite’:
wiringPi.c:1671:4: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
 1671 |    write (sysFds [pin], "0\n", 2) ;
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wiringPi.c:1673:4: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
 1673 |    write (sysFds [pin], "1\n", 2) ;
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wiringPi.c: In function ‘waitForInterrupt’:
wiringPi.c:1979:11: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
 1979 |     (void)read (fd, &c, 1) ; // Read & clear
      |           ^~~~~~~~~~~~~~~~
wiringPi.c: In function ‘wiringPiISR’:
wiringPi.c:2100:5: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
 2100 |     read (sysFds [bcmGpioPin], &c, 1) ;
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Compile] softTone.c
wiringPi_bpi.c: In function ‘bpi_digitalRead’:
wiringPi_bpi.c:1178:7: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
 1178 |       read   (sysFds [pin], &c, 1) ;
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
wiringPi_bpi.c: In function ‘bpi_digitalWrite’:
wiringPi_bpi.c:1232:11: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
 1232 |           write (sysFds [pin], "0\n", 2) ;
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wiringPi_bpi.c:1234:11: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
 1234 |           write (sysFds [pin], "1\n", 2) ;
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At top level:
wiringPi.c:1355:21: warning: ‘digitalWrite8Dummy’ defined but not used [-Wunused-function]
 1355 | static         void digitalWrite8Dummy       (UNU struct wiringPiNodeStruct *node, UNU int pin, UNU int value) { return ; }
      |                     ^~~~~~~~~~~~~~~~~~
wiringPi.c:1354:21: warning: ‘digitalRead8Dummy’ defined but not used [-Wunused-function]
 1354 | static unsigned int digitalRead8Dummy        (UNU struct wiringPiNodeStruct *node, UNU int UNU pin)            { return 0 ; }
      |                     ^~~~~~~~~~~~~~~~~
wiringPi_bpi.c: In function ‘bpi_piGpioLayout’:
wiringPi_bpi.c:1408:5: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
 1408 |     fgets(buffer, sizeof(buffer), bpiFd);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At top level:
wiringPi_bpi.c:165:12: warning: ‘edge’ defined but not used [-Wunused-variable]
  165 | static int edge [64] =
      |            ^~~~
[Compile] mcp23008.c
[Compile] mcp23016.c
[Compile] mcp23017.c
[Compile] mcp23s08.c
[Compile] mcp23s17.c
[Compile] sr595.c
[Compile] pcf8574.c
[Compile] pcf8591.c
[Compile] mcp3002.c
[Compile] mcp3004.c
pcf8591.c: In function ‘myAnalogWrite’:
pcf8591.c:44:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
   44 |   write (node->fd, b, 2) ;
      |   ^~~~~~~~~~~~~~~~~~~~~~
[Compile] mcp4802.c
[Compile] mcp3422.c
[Compile] max31855.c
[Compile] max5322.c
[Compile] ads1115.c
mcp3422.c: In function ‘waitForConversion’:
mcp3422.c:50:5: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
   50 |     read (fd, buffer, n) ;
      |     ^~~~~~~~~~~~~~~~~~~~
[Compile] sn3218.c
[Compile] bmp180.c
[Compile] htu21d.c
[Compile] ds18b20.c
[Compile] rht03.c
[Compile] drcSerial.c
[Compile] drcNet.c
[Compile] pseudoPins.c
[Compile] wpiExtensions.c
drcNet.c: In function ‘authenticate’:
drcNet.c:112:24: warning: ‘%s’ directive writing up to 1023 bytes into a region of size 1021 [-Wformat-overflow=]
   89 |       return &buf [10] ;
      |              ~~~~~~~~~  
......
  112 |   sprintf (salted, "$6$%s$", challenge) ;
      |                        ^~
In file included from /usr/include/stdio.h:867,
                 from drcNet.c:25:
/usr/include/arm-linux-gnueabihf/bits/stdio2.h:36:10: note: ‘__builtin___sprintf_chk’ output between 5 and 1028 bytes into a destination of size 1024
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[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] scrollPhat.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 ‘doVersion’:
gpio.c:1292:7: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
 1292 |       fgets (name, 80, fd) ;
      |       ^~~~~~~~~~~~~~~~~~~~
gpio.c: In function ‘doLoad’:
gpio.c:285:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
  285 |     system (cmd) ;
      |     ^~~~~~~~~~~~
gpio.c:291:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
  291 |     system (cmd) ;
      |     ^~~~~~~~~~~~
gpio.c: In function ‘doUnLoad’:
gpio.c:345:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
  345 |     system (cmd) ;
      |     ^~~~~~~~~~~~
gpio.c:351:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
  351 |     system (cmd) ;
      |     ^~~~~~~~~~~~
[Link]
[Install]

All Done.

NOTE: To compile programs with wiringPi, you need to add:
    -lwiringPi
  to your compile line(s) To use the Gertboard, MaxDetect, etc.
  code (the devLib), you need to also add:
    -lwiringPiDev
  to your compile line(s).

Testing BPI-WiringPi2

ubuntu@bpi-m2z:~/BPI-WiringPi2$ gpio readall
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |  12 |   8 |   SDA.1 | ALT5 | 0 |  3 || 4  |   |      | 5v      |     |     |
 |  11 |   9 |   SCL.1 | ALT5 | 0 |  5 || 6  |   |      | 0v      |     |     |
 |   6 |   7 | GPIO. 7 | ALT3 | 0 |  7 || 8  | 0 | ALT4 | TxD     | 15  | 13  |
 |     |     |      0v |      |   |  9 || 10 | 0 | ALT4 | RxD     | 16  | 14  |
 |   1 |   0 | GPIO. 0 | ALT3 | 0 | 11 || 12 | 0 | ALT3 | GPIO. 1 | 1   | 16  |
 |   0 |   2 | GPIO. 2 | ALT3 | 0 | 13 || 14 |   |      | 0v      |     |     |
 |   3 |   3 | GPIO. 3 | ALT3 | 0 | 15 || 16 | 0 | ALT3 | GPIO. 4 | 4   | 15  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | ALT3 | GPIO. 5 | 5   | 68  |
 |  64 |  12 |    MOSI | ALT3 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |  65 |  13 |    MISO | ALT3 | 0 | 21 || 22 | 0 | ALT3 | GPIO. 6 | 6   | 2   |
 |  66 |  14 |    SCLK | ALT3 | 0 | 23 || 24 | 0 | ALT3 | CE0     | 10  | 67  |
 |     |     |      0v |      |   | 25 || 26 | 0 | ALT3 | CE1     | 11  | 71  |
 |  19 |  30 |   SDA.0 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.0   | 31  | 18  |
 |   7 |  21 | GPIO.21 | ALT3 | 0 | 29 || 30 |   |      | 0v      |     |     |
 |   8 |  22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | GPIO.26 | 26  | 354 |
 |   9 |  23 | GPIO.23 | ALT3 | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  10 |  24 | GPIO.24 | ALT3 | 0 | 35 || 36 | 0 | ALT3 | GPIO.27 | 27  | 356 |
 |  17 |  25 | GPIO.25 | ALT3 | 0 | 37 || 38 | 0 | ALT3 | GPIO.28 | 28  | 21  |
 |     |     |      0v |      |   | 39 || 40 | 0 | ALT3 | GPIO.29 | 29  | 20  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
ubuntu@bpi-m2z:~/BPI-WiringPi2$ gpio -1 mode 10 out
ubuntu@bpi-m2z:~/BPI-WiringPi2$ gpio -1 write 10 1
ubuntu@bpi-m2z:~/BPI-WiringPi2$ gpio readall
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |  12 |   8 |   SDA.1 | ALT5 | 0 |  3 || 4  |   |      | 5v      |     |     |
 |  11 |   9 |   SCL.1 | ALT5 | 0 |  5 || 6  |   |      | 0v      |     |     |
 |   6 |   7 | GPIO. 7 | ALT3 | 0 |  7 || 8  | 0 | ALT4 | TxD     | 15  | 13  |
 |     |     |      0v |      |   |  9 || 10 | 1 | OUT  | RxD     | 16  | 14  |
 |   1 |   0 | GPIO. 0 | ALT3 | 0 | 11 || 12 | 0 | ALT3 | GPIO. 1 | 1   | 16  |
 |   0 |   2 | GPIO. 2 | ALT3 | 0 | 13 || 14 |   |      | 0v      |     |     |
 |   3 |   3 | GPIO. 3 | ALT3 | 0 | 15 || 16 | 0 | ALT3 | GPIO. 4 | 4   | 15  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | ALT3 | GPIO. 5 | 5   | 68  |
 |  64 |  12 |    MOSI | ALT3 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |  65 |  13 |    MISO | ALT3 | 0 | 21 || 22 | 0 | ALT3 | GPIO. 6 | 6   | 2   |
 |  66 |  14 |    SCLK | ALT3 | 0 | 23 || 24 | 0 | ALT3 | CE0     | 10  | 67  |
 |     |     |      0v |      |   | 25 || 26 | 0 | ALT3 | CE1     | 11  | 71  |
 |  19 |  30 |   SDA.0 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.0   | 31  | 18  |
 |   7 |  21 | GPIO.21 | ALT3 | 0 | 29 || 30 |   |      | 0v      |     |     |
 |   8 |  22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | GPIO.26 | 26  | 354 |
 |   9 |  23 | GPIO.23 | ALT3 | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  10 |  24 | GPIO.24 | ALT3 | 0 | 35 || 36 | 0 | ALT3 | GPIO.27 | 27  | 356 |
 |  17 |  25 | GPIO.25 | ALT3 | 0 | 37 || 38 | 0 | ALT3 | GPIO.28 | 28  | 21  |
 |     |     |      0v |      |   | 39 || 40 | 0 | ALT3 | GPIO.29 | 29  | 20  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi ?---+---+------+---------+-----+-----+
ubuntu@bpi-m2z:~/BPI-WiringPi2$ 

Building bpi_test

ubuntu@bpi-m2z:~/BPI-WiringPi2$ cd bpi_test/
ubuntu@bpi-m2z:~/BPI-WiringPi2/bpi_test$ l
52pi.c*     bpi_test_52pi*    bpi_test_lcd1602*  gpio40.c*    hello.c*
Makefile*   bpi_test_gpio40*  c.sh*              gpio40_bcm*  lcd1602.c*
apple.dat*  bpi_test_hello*   c2.sh*             gpio40_wpi*  pwm_test.c*
ubuntu@bpi-m2z:~/BPI-WiringPi2/bpi_test$ make
[CC] 52pi.c
[link]
[CC] hello.c
hello.c: In function ‘main’:
hello.c:121:25: warning: implicit declaration of function ‘atoi’ [-Wimplicit-function-declaration]
  121 |                 color = atoi(argv[1]);
      |                         ^~~~
hello.c:135:59: warning: implicit declaration of function ‘random’ [-Wimplicit-function-declaration]
  135 |                                                 set(i, j, random()%7+1);
      |                                                           ^~~~~~
hello.c:85:19: warning: variable ‘color’ set but not used [-Wunused-but-set-variable]
   85 |         int i, j, color;
      |                   ^~~~~
[link]
[CC] lcd1602.c
[link]
[CC] gpio40.c
gpio40.c:85:13: warning: ‘single_led_test’ defined but not used [-Wunused-function]
   85 | static void single_led_test(void)
      |             ^~~~~~~~~~~~~~~
gpio40.c:62:13: warning: ‘wpi_led_test’ defined but not used [-Wunused-function]
   62 | static void wpi_led_test(void)
      |             ^~~~~~~~~~~~
gpio40.c:39:13: warning: ‘bcm_led_test’ defined but not used [-Wunused-function]
   39 | static void bcm_led_test(void)
      |             ^~~~~~~~~~~~
[link]
ubuntu@bpi-m2z:~/BPI-WiringPi2/bpi_test$ ll
total 3428
drwxrwxr-x  2 ubuntu ubuntu    4096 Feb 19 23:27 ./
drwxrwxr-x 12 ubuntu ubuntu    4096 Feb 19 22:56 ../
-rwxrwxr-x  1 ubuntu ubuntu    8848 Feb 19 23:27 52pi*
-rwxrwxr-x  1 ubuntu ubuntu    1711 Feb 19 22:56 52pi.c*
-rw-rw-r--  1 ubuntu ubuntu    2628 Feb 19 23:27 52pi.o
-rwxrwxr-x  1 ubuntu ubuntu    2018 Feb 19 22:56 Makefile*
-rwxrwxr-x  1 ubuntu ubuntu 3358720 Feb 19 22:56 apple.dat*
-rwxrwxr-x  1 ubuntu ubuntu    9052 Feb 19 22:56 bpi_test_52pi*
-rwxrwxr-x  1 ubuntu ubuntu    8504 Feb 19 22:56 bpi_test_gpio40*
-rwxrwxr-x  1 ubuntu ubuntu    9064 Feb 19 22:56 bpi_test_hello*
-rwxrwxr-x  1 ubuntu ubuntu    8668 Feb 19 22:56 bpi_test_lcd1602*
-rwxrwxr-x  1 ubuntu ubuntu     113 Feb 19 22:56 c.sh*
-rwxrwxr-x  1 ubuntu ubuntu      64 Feb 19 22:56 c2.sh*
-rwxrwxr-x  1 ubuntu ubuntu    8244 Feb 19 23:27 gpio40*
-rwxrwxr-x  1 ubuntu ubuntu    2295 Feb 19 22:56 gpio40.c*
-rw-rw-r--  1 ubuntu ubuntu    1600 Feb 19 23:27 gpio40.o
-rwxrwxr-x  1 ubuntu ubuntu    8368 Feb 19 22:56 gpio40_bcm*
-rwxrwxr-x  1 ubuntu ubuntu    8364 Feb 19 22:56 gpio40_wpi*
-rwxrwxr-x  1 ubuntu ubuntu    8792 Feb 19 23:27 hello*
-rwxrwxr-x  1 ubuntu ubuntu    3379 Feb 19 22:56 hello.c*
-rw-rw-r--  1 ubuntu ubuntu    2688 Feb 19 23:27 hello.o
-rwxrwxr-x  1 ubuntu ubuntu    8424 Feb 19 23:27 lcd1602*
-rwxrwxr-x  1 ubuntu ubuntu    1006 Feb 19 22:56 lcd1602.c*
-rw-rw-r--  1 ubuntu ubuntu    1900 Feb 19 23:27 lcd1602.o
-rwxrwxr-x  1 ubuntu ubuntu     420 Feb 19 22:56 pwm_test.c*
ubuntu@bpi-m2z:~/BPI-WiringPi2/bpi_test$
2 Likes

Thank you @avaf Your description worked very well !:grinning:

1 Like

This worked perfectly on a visual level for me… Unfortunately after it’s all said and done I am not actually reading and writing to the hardware, everything appears to be working gpio readall gives the expected output, but when I run a test, or manually set an input low the state of the hardware doesn’t change.

You may have a permission issue. Try running the above test with root user and compare the results from the previous post.

Unfortunately I am unable to set pin 10 to out, it’s stuck on RxD; however, I can set pin 7 to out and it’s detected. The problem persists when using the root user gpio readall detects the pin is in mode out and that it’s set high, but testing the physical pin shows no voltage :-/

362 | 7 | GPIO. 7 | OUT | 1 | 7

The ./build script did end up with an error, see below. Could you please give me a hint for a solution? I have an BPI M2 Zero with debian bullseye as image

drcNet.c:112:24: warning: ‘%s’ directive writing up to 1023 bytes into a region of size 1021 [-Wformat-overflow=] 89 | return &buf [10] ; | ~~~~~~~~~ … 112 | sprintf (salted, “$6$%s$”, challenge) ; | ^~ drcNet.c:112:3: note: ‘sprintf’ output between 5 and 1028 bytes into a destination of size 1024 112 | sprintf (salted, “$6$%s$”, challenge) ; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Link (Dynamic)] /usr/bin/ld: wpiExtensions.o:(.bss+0x404): multiple definition of `comDat’; drcNet.o:(.bss+0x400): first defined here collect2: error: ld returned 1 exit status make: *** [Makefile:82: libwiringPi.so.2.44] Error 1 pi@clearview:~/BPI-WiringPi2$ sudo ./build wiringPi Build script

I’m getting the same error when I run ./build. Anyone have any thoughts on how to fix this?

  112 |   sprintf (salted, "$6$%s$", challenge) ;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Link (Dynamic)]
/usr/bin/ld: wpiExtensions.o:(.bss+0x404): multiple definition of `comDat'; drcNet.o:(.bss+0x400): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:82: libwiringPi.so.2.44] Error 1