Page 1 of 1

Pins 6 and 7

Posted: Sun Aug 21, 2016 5:36 pm
by tadvi
What Linux GPIO numbers do single row Pins 6 and 7 correspond to?

6 GPIOL11/IR-RX - Linux GPIO # ?
7 SPDIF-OUT/GPIOA17 - Linux GPIO # ?

Re: Pins 6 and 7

Posted: Tue Aug 23, 2016 8:47 am
by jjm
tadvi wrote:
What Linux GPIO numbers do single row Pins 6 and 7 correspond to?

6 GPIOL11/IR-RX - Linux GPIO # ?
7 SPDIF-OUT/GPIOA17 - Linux GPIO # ?


Hello,
Accessing the GPIO pins through sysfs with mainline kernel The GPIO pins can be accessed from user space using sysfs. To enabled this you need the following kernel option enabled: CONFIG_GPIO_SYSFS

Device Drivers ---> GPIO Support ---> /sys/class/gpio/... (sysfs interface)
To access a GPIO pin you first need to export it with

echo XX > /sys/class/gpio/export
with XX being the number of the desired pin. To obtain the correct number you have to calculate it from the pin name (like PH18)[1]:

(position of letter in alphabet - 1) * 32 + pin number
E.g for PH18 this would be ( 8 - 1) * 32 + 18 = 224 + 18 = 242 (since 'h' is the 8th letter).

After you have successfully exported the pin you can access it through /sys/class/gpio/gpio*NUMBER* (in case of PH18 it's /sys/class/gpio/gpio242).

With /sys/class/gpio/gpio*NUMBER*/direction you can set the pin to out or in using

echo "out" > /sys/class/gpio/gpio*NUMBER*/direction
and you can read/write the value with /sys/class/gpio/gpio*NUMBER*/value.

When you are done unexport the pin with

echo XX > /sys/class/gpio/unexport

Re: Pins 6 and 7

Posted: Tue Aug 23, 2016 10:52 am
by HermannSW
Good question, the Neo Wiki does only provide Linux GPIO numbers for the double row connections:
http://wiki.friendlyarm.com/wiki/index.php/NanoPi_NEO#Layout

Re: Pins 6 and 7

Posted: Tue Aug 23, 2016 12:54 pm
by tadvi
Thank you "jjm" for very detailed answer.

Based on it pin 7 GPIOA17 should be Linux PIN 17. Unfortunately this does not work. I have just tried it by connecting relay to it. Other GPIO pins work (pins on two rows) and switch the relay ON/OFF but not PIN 17.

Based on calculation pin 6 GPIOL11 should be Linux PIN 363 which is calculated as (11*32)+11. Please confirm.