How to install and use GPIO on NanoPi 2?

Average Man
Hi

I want to try some GPIO add on boards from the Raspberry Pi, but I can't
find any documentation on using the NanoPi 2 GPIO?

Can you share install/setup and usage instructions?

Thanks

Hussam Al-Hertani
I see the i2c (/dev/i2c-0/1) and SPI (/dev/spidev0.0) buses but nothing for
PWM (no /dev/pwm).

Control of the GPIOs (via SYSFS) should be accessible through
'/sys/class/gpio' but it would be nice if someone more knowledgeable could
chime in on the proper way to access the GPIOs and PWM via built-in Linux
drivers and/or SYSFS.

jjm
If  you  want to use NanoPi 2 physical GPIO pins , you  can refer to
the following steps:

# cd /sys/class/gpio  

# for i in gpiochip* ; do  echo `cat $i/label`: `cat $i/base` ; done   

nxp-gpio.0:0

nxp-gpio.4:128

nxp-gpio.5:160

nxp-gpio.1:32

nxp-gpio.2:64

nxp-gpio.3:96

Actually the gpio.0 express GPIOA, gpio.1 express GPIOB...

For example , if you want to use GPIOB30 of NanoPi 2 , we can use the GPIO
such as :64 + 30 = 94.

ghost
hi @jjm,

do you have any simple example showing how to read/write GPIO via built-int
linux drivers? I read the code from
https://github.com/friendlyarm/matrix/blob/nanopi/lib/gpio.c and there is a
MACRO defined as below:

#define GPIO_FILENAME_DEFINE(pin,field) char fileName[255] = {0}; \
        sprintf(fileName, "/sys/devices/virtual/gpio/gpio%d/%s", pin,
field);

but I checked the file system of Nanopi2 and could not find any GPIO files
under /sys/devices/virtual/, I guess this is because the GPIO device is not
"booted" but don't know how.

FATechsupport
Hi you can refer to our Matrix components' wiki sites:
Here is one :

http://wiki.friendlyarm.com/wiki/index.php/Matrix_-_Ball_Rolling_Switch

I would encourage you to post on www.friendlyarm.com/forum which we visit
more often

Peter Scargill
Much of this is just WAY too complicated. Isn't there a module to help run
the GPIO pins?  These boards are in the same marketplace as Raspberry Pi
and there is a TON of documentation - and several drivers to run simple I/O
(on/off), PWM, I2c etc. We need similar for these boards.

I have a FriendlyArm NanoPC 2 running Jessie and Node-Red, I've only been
able to get 1 of the 4 UARTS running and can find nothing in the way of
examples of which ports are available and how to access them.

A simple guide with examples would help.

jjm
Hi you can refer the Matrix components' wiki sites , and there are much
more  course and code  you can refer :

http://wiki.friendlyarm.com/wiki/index.php/Main_Page#Matrix

Ashish
I am trying to run matrix gpio-out on nano pi s2 to blink led but getting
these error?
what went wrong please reply?

fa@NanoPi2:~/matrix$ matrix-gpio_out
Hardware:NANOPI2
Revision:0002
BoardType:-1
FAHW-Lib: Fail to initPinGPIO
FAHW-Lib: Fail to initPwmGPIO
Fail to init board
fa@NanoPi2:~/matrix$