WiringPI for NanoPI M1

wertyzp
Hi, please check my attempt to port WiringPI to NanoPI M1
https://github.com/wertyzp/WiringNP
I need someone to test GPIO IN/OUT functions and PWM
Please report any errors to github

Thomas Asche
I got warnings during first compile on my NanoPI NEO. See attachment.

Thomas Asche
Result:

# ./build
./build: 3: ./build: [[: not found
wiringPi Build script
=====================


WiringPi Library
[UnInstall]
[Compile] wiringPi.c
wiringPi.c:288:24: warning: 'pinMutex' defined but not used
[-Wunused-variable]
 static pthread_mutex_t pinMutex;
                        ^
wiringPi.c:333:16: warning: 'gpioToGPFSEL' defined but not used
[-Wunused-variable]
 static uint8_t gpioToGPFSEL [] ={
                ^
wiringPi.c:346:16: warning: 'gpioToShift' defined but not used
[-Wunused-variable]
 static uint8_t gpioToShift [] ={
                ^
wiringPi.c:358:16: warning: 'gpioToGPSET' defined but not used
[-Wunused-variable]
 static uint8_t gpioToGPSET [] ={
                ^
wiringPi.c:366:16: warning: 'gpioToGPCLR' defined but not used
[-Wunused-variable]
 static uint8_t gpioToGPCLR [] ={
                ^
wiringPi.c:375:16: warning: 'gpioToGPLEV' defined but not used
[-Wunused-variable]
 static uint8_t gpioToGPLEV [] ={
                ^
wiringPi.c:388:16: warning: 'gpioToPUDCLK' defined but not used
[-Wunused-variable]
 static uint8_t gpioToPUDCLK [] ={
                ^
wiringPi.c:397:16: warning: 'gpioToPwmPort' defined but not used
[-Wunused-variable]
 static uint8_t gpioToPwmPort [] ={
                ^
wiringPi.c:423:16: warning: 'gpioToClkCon' defined but not used
[-Wunused-variable]
 static uint8_t gpioToClkCon [] ={
                ^
wiringPi.c:434:16: warning: 'gpioToClkDiv' defined but not used
[-Wunused-variable]
 static uint8_t gpioToClkDiv [] ={
                ^
wiringPi.c:1849:14: warning: 'interruptHandler' defined but not used
[-Wunused-function]
 static void *interruptHandler(void *arg) {
              ^
wiringPi.c: In function 'digitalRead':
wiringPi.c:1555:13: warning: ignoring return value of 'read', declared with
attribute warn_unused_result [-Wunused-result]
             read(sysFds [pin], &c, 1);
             ^
wiringPi.c: In function 'digitalWrite':
wiringPi.c:1613:21: warning: ignoring return value of 'write', declared
with attribute warn_unused_result [-Wunused-result]
                     write(sysFds [pin], "0\n", 2);
                     ^
wiringPi.c:1615:21: warning: ignoring return value of 'write', declared
with attribute warn_unused_result [-Wunused-result]
                     write(sysFds [pin], "1\n", 2);
                     ^
wiringPi.c: In function 'waitForInterrupt':
wiringPi.c:1836:5: warning: ignoring return value of 'read', declared with
attribute warn_unused_result [-Wunused-result]
     (void) read(fd, &c, 1);
     ^
wiringPi.c: In function 'wiringPiISR':
wiringPi.c:1895:1: warning: control reaches end of non-void function
[-Wreturn-type]
 }
 ^
[Compile] wiringSerial.c
wiringSerial.c: In function 'serialPutchar':
wiringSerial.c:146:3: warning: ignoring return value of 'write', declared
with attribute warn_unused_result [-Wunused-result]
   write (fd, &c, 1) ;
   ^
wiringSerial.c: In function 'serialPuts':
wiringSerial.c:158:3: warning: ignoring return value of 'write', declared
with attribute warn_unused_result [-Wunused-result]
   write (fd, s, strlen (s)) ;
   ^
[Compile] wiringShift.c
[Compile] piHiPri.c
[Compile] piThread.c
[Compile] wiringPiSPI.c
[Compile] wiringPiI2C.c
[Compile] softPwm.c
[Compile] softTone.c
[Compile] softServo.c
[Compile] mcp23008.c
[Compile] mcp23016.c
[Compile] mcp23017.c
[Compile] mcp23s08.c
[Compile] mcp23s17.c
[Compile] sr595.c
[Compile] pcf8574.c
[Compile] pcf8591.c
pcf8591.c: In function 'myAnalogWrite':
pcf8591.c:44:3: warning: ignoring return value of 'write', declared with
attribute warn_unused_result [-Wunused-result]
   write (node->fd, b, 2) ;
   ^
[Compile] mcp3002.c
[Compile] mcp3004.c
[Compile] mcp4802.c
[Compile] mcp3422.c
mcp3422.c: In function 'myAnalogRead':
mcp3422.c:62:7: warning: ignoring return value of 'read', declared with
attribute warn_unused_result [-Wunused-result]
       read (node->fd, buffer, 4) ;
       ^
mcp3422.c:68:7: warning: ignoring return value of 'read', declared with
attribute warn_unused_result [-Wunused-result]
       read (node->fd, buffer, 3) ;
       ^
mcp3422.c:74:7: warning: ignoring return value of 'read', declared with
attribute warn_unused_result [-Wunused-result]
       read (node->fd, buffer, 3) ;
       ^
mcp3422.c:80:7: warning: ignoring return value of 'read', declared with
attribute warn_unused_result [-Wunused-result]
       read (node->fd, buffer, 3) ;
       ^
[Compile] max31855.c
[Compile] max5322.c
[Compile] sn3218.c
[Compile] drcSerial.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
gpio.c: In function 'doUsbP':
gpio.c:842:22: warning: too many arguments for format [-Wformat-extra-args]
     fprintf (stderr, "USB power is not supported\n", argv [0]) ;
                      ^
gpio.c: At top level:
gpio.c:804:13: warning: 'doPadDrive' defined but not used
[-Wunused-function]
 static void doPadDrive (int argc, char *argv [])
             ^
gpio.c:854:13: warning: 'doGbw' defined but not used [-Wunused-function]
 static void doGbw (int argc, char *argv [])
             ^
gpio.c:896:13: warning: 'doGbr' defined but not used [-Wunused-function]
 static void doGbr (int argc, char *argv [])
             ^
gpio.c: In function 'doLoad':
gpio.c:228:6: warning: ignoring return value of 'system', declared with
attribute warn_unused_result [-Wunused-result]
      system (cmd) ;
      ^
gpio.c:235:6: warning: ignoring return value of 'system', declared with
attribute warn_unused_result [-Wunused-result]
      system (cmd) ;
      ^
gpio.c:274:7: warning: ignoring return value of 'system', declared with
attribute warn_unused_result [-Wunused-result]
       system (cmd) ;
       ^
gpio.c:280:7: warning: ignoring return value of 'system', declared with
attribute warn_unused_result [-Wunused-result]
       system (cmd) ;
       ^
[Compile] extensions.c
[Compile] readall.c
[Compile] pins.c
[Link]
[Install]

All Done.

NOTE: To compile programs with wiringBP v2, 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).

#

HermannSW
I got the warnings as well.

Overall WiringPi works well with 14 of the 16 GPIO pins I tested. But it
does not work with WiringPi pins 2 and 3:
http://www.friendlyarm.com/Forum/viewtopic.php?f=47&t=260

@wertyzp: Comments?

Hermann.

DEM
Hi!!!
Here are some examples for NanoPi 2 in Python.
http://www.friendlyarm.net/forum/topic/6810
http://www.friendlyarm.net/forum/topic/6811

Use library MAtrix
https://github.com/friendlyarm/matrix

HermannSW
WiringPi library should be much faster since it does memory mapped GPIO
access while matrix library directly accesses/modifies
"/sys/class/gpio(..." files.

Hermann.

wertyzp
https://github.com/wertyzp/WiringNP
Check latest commit, fixed warnings and pins 2, 3

HermannSW
Pins 2 and 3 work fine now, some warnings are left, see details here:
http://www.friendlyarm.com/Forum/viewtopic.php?f=47&t=260&p=831#...

Peter
Hi, 

excellent work. All GPIOs are running on my NanoPi Neo. Thank you for the
lib. 
As I would do some programming with the NEO in python. Do you know a python
lib which will work with your WiringNP?

Regards

Peter