Power & Source of Big Ideas

Why can't I configure some GPIOs?

Moderators: chensy, FATechsupport

Hello. I am using the NanoPi NEO Core board with the Mini Shield for NanoPi NEO Core/Core2.

I am trying to configure some GPIOs using the RPI.GPIO_NP library and Python 3.7.7. This is the code I am using:

Code: Select all

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.IN) # Does not allow adding a GPIO detect event using GPIO.add_event_detect() - it returns RuntimeError: Failed to add edge detection
GPIO.setup(13, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
GPIO.setup(19, GPIO.IN)
GPIO.setup(21, GPIO.IN)
GPIO.setup(23, GPIO.IN)
GPIO.setup(35, GPIO.IN) # ValueError: The channel sent is invalid on a NanoPi
GPIO.setup(37, GPIO.IN)
GPIO.setup(12, GPIO.IN)
GPIO.setup(16, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(24, GPIO.IN)
GPIO.setup(62, GPIO.OUT)
GPIO.setup(64, GPIO.OUT) # ValueError: The channel sent is invalid on a NanoPi
GPIO.setup(66, GPIO.OUT) # ValueError: The channel sent is invalid on a NanoPi
GPIO.setup(26, GPIO.OUT)
GPIO.setup(28, GPIO.OUT)
GPIO.setup(32, GPIO.OUT)
GPIO.setup(30, GPIO.OUT)

GPIO.cleanup()

I've also run the script with sudo (e.g., sudo python3 gpio.py).

The problem is that GPIOs 35, 64 and 66 give ValueErrors, and GPIO 7 does not allow to configure a GPIO detect event. Does anybody know what is the problem?

This is the output of the gpio readall command of the WiringNP library:

Code: Select all

+-----+-----+----------+------+---+-NanoPi-NEO-Core--+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
 |  12 |   8 |  GPIOA12 | ALT5 | 0 |  3 || 4  |   |      | 5v       |     |     |
 |  11 |   9 |  GPIOA11 | ALT5 | 0 |  5 || 6  |   |      | 0v       |     |     |
 | 203 |   7 |  GPIOG11 |  OFF | 0 |  7 || 8  | 0 | ALT5 | GPIOG6   | 15  | 198 |
 |     |     |       0v |      |   |  9 || 10 | 0 | ALT5 | GPIOG7   | 16  | 199 |
 |   0 |   0 |   GPIOA0 | ALT5 | 0 | 11 || 12 | 0 |  OUT | GPIOA6   | 1   | 6   |
 |   2 |   2 |   GPIOA2 |  OFF | 0 | 13 || 14 |   |      | 0v       |     |     |
 |   3 |   3 |   GPIOA3 |  OFF | 0 | 15 || 16 | 0 |  OFF | GPIOG8   | 4   | 200 |
 |     |     |     3.3v |      |   | 17 || 18 | 0 |  OFF | GPIOG9   | 5   | 201 |
 |  64 |  12 |   GPIOC0 | ALT4 | 0 | 19 || 20 |   |      | 0v       |     |     |
 |  65 |  13 |   GPIOC1 | ALT4 | 0 | 21 || 22 | 0 | ALT5 | GPIOA1   | 6   | 1   |
 |  66 |  14 |   GPIOC2 | ALT4 | 0 | 23 || 24 | 1 |  OUT | GPIOC3   | 10  | 67  |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+-NanoPi-NEO-Core--+------+----------+-----+-----+

 +-----+-----+----------+---- NanoPi-NEO-Core USB/Audio ----+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |       5v |      |   | 25 || 26 | 0 | ALT4 | GPIOA15  | 22  | 15  |
 |     |     |     USB1 |      |   | 27 || 28 | 0 | ALT4 | GPIOA16  | 23  | 16  |
 |     |     |     USB1 |      |   | 29 || 30 | 0 | ALT4 | GPIOA14  | 21  | 14  |
 |     |     |     USB2 |      |   | 31 || 32 | 0 | ALT4 | GPIOA13  | 20  | 13  |
 |     |     |     USB2 |      |   | 33 || 34 |   |      | Mic      |     |     |
 |     |     |       IR |      |   | 35 || 36 |   |      | Mic      |     |     |
 |  17 |  19 |  GPIOA17 |  OFF | 0 | 37 || 38 |   |      | Audio    |     |     |
 |     |     |      I2S |      |   | 39 || 40 |   |      | Audio    |     |     |
 |     |     |      I2S |      |   | 41 || 42 | 0 | ALT5 | GPIOA5   | 18  | 5   |
 |     |     |      I2S |      |   | 43 || 44 | 0 | ALT5 | GPIOA4   | 17  | 4   |
 |     |     |      I2S |      |   | 45 || 46 |   |      | 5V       |     |     |
 |     |     |       0v |      |   | 47 || 48 |   |      | 0v       |     |     |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+-NanoPi-NEO-Core--+------+----------+-----+-----+

 +-----+-----+----------+---- NanoPi-NEO-Core Network ----+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |      Eth |      |   | 49 || 50 |   |      | Eth      |     |     |
 |     |     |      Eth |      |   | 51 || 52 |   |      | Eth      |     |     |
 |     |     |      Eth |      |   | 53 || 54 |   |      | Eth      |     |     |
 |     |     |       NC |      |   | 55 || 56 |   |      | NC       |     |     |
 |     |     |       NC |      |   | 57 || 58 |   |      | NC       |     |     |
 |     |     |       0v |      |   | 59 || 60 |   |      | 0v       |     |     |
 |     |     |     USB3 |      |   | 61 || 62 | 0 |  OFF | GPIOA7   | 24  | 7   |
 |     |     |     USB3 |      |   | 63 || 64 |   |      | GPIOE12  |     |     |
 |     |     |       5v |      |   | 65 || 66 |   |      | GPIOE13  |     |     |
 |     |     |       5v |      |   | 67 || 68 |   |      | 3.3v     |     |     |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+-NanoPi-NEO-Core--+------+----------+-----+-----+
Hi @CristianM

did you manage to get this working?

i'm facing the exact same problem.
i have the Mini shield with a Neo Core 2
It seems that the key button is tied to GPIOA7, but i just can't seem to find a way to read that value from the button.

using the command "gpio readall "
also does not show any relevant GPIOA7 pin out.

Does any one know how to solve this?
i might have gotten it working.

i used
$ gpio -g mode 7 in
$ gpio -g read 7

This corresponds to GPIOA7.... taking a guess from GPIOA6 with BCM value of 6

it seems that the key button is active high.
on press, it becomes low.

so read should give you a "1" but on press of key, it gives you a "0".
i hope this helps
use
$ gpio -g read 7
Thank you for your suggestion. Unfortunately, I cannot use the "gpio -g mode" command, because GPIOs 35, 64 and 66 do not have BCM values assigned to them, as seen in my question.

Maybe the Linux device tree needs to be modified in order to define these pins as regular GPIOs? If so, then how can I do this?

Who is online

In total there are 5 users online :: 0 registered, 0 hidden and 5 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 5 guests