Jump to content
  • 1

Need help with GPIO on NanoPi M4V2


radu
 Share

Question

Armbianmonitor:

Hello,

 

I bought myself a NanoPi M4V2 and 4x SATA HAT for NanoPi M4, hoping to make a small home made server with some docker containers. I installed Armbian buster 5.10.21, downloaded from your site and managed to boot the OS from an attached SATA drive.

I have some experience with linux (mostly Ubuntu/Debian), I own and I’ve played with Raspberry boards and I wrote small python scripts to work with GPIO on raspberry pi (how to blink a led or how to connect and display some text on an I2C 16x2 LCD).

I thought that might be a nice project if I could connect an I2C LCD to nanopi and display some text text from python script, but here where I hit a brick wall. I found and read on this forum some discussion about user space GPIO, installing WiringPi, sysfs, tried them all, but none worked. Regarding user space GPIO, I have no idea where to start; sysfs seems to be deprecated (I don’t care), however I have no /sys/class/gpio/gpio50 (or any other pin); wiringpi has no Hardware line in /proc/cpuinfo and gpio readall responds with wiringPiSetup: Unknown model.

I’ve managed to work with GPIO pins (from Python script) on FriendlyElec official OS and using WiringPi library, but I prefer Armbian because I can make it boot from SATA drive (which I don’t know if is possible with FriendlyElec OS).

Let me know if you need more hardware infos and how I can get them for you. Thank you.

 

Radu

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

it is WiringNP  for GPIO .

and gpio just works only you hve to calculate the pin

 

 but you are talking connecting a i2c device 

 

for lcd some you can add to dts and compile a kernel module .

 

 or through a script wich calls the i2c bus only just watch the bus number and device id .

ow and watch the voltage of the i2c bus

 

 

Link to comment
Share on other sites

When discussing a problem make sure to provide full logs!

  • 0

Thank you for your message thc13. You are talking about WiringNP from here?

 

https://github.com/friendlyarm/WiringNP

 

Unfortunately I’ve tried this, too, but without too much success.

When executing gpio readall, I still get 

 Unable to determine board revision from /proc/cpuinfo
 -> Is not NanoPi based board. 
 ->  You may want to check:
 ->  http://www.lemaker.org/

 

I don’t understand why every library that I've tried, needs something from cpuinfo and why that info is not present there on Armbian OS? It seems that the WiringPi installed on FriendlyElec OS has no problem finding what it needs in cpuinfo. I wonder:  is there any way to write into /proc/cpuinfo? From previous attempts, it seems that I need to add a Hardware line, or something like that.

Link to comment
Share on other sites

  • 0
18 hours ago, radu said:

I don’t understand why every library that I've tried, needs something from cpuinfo and why that info is not present there on Armbian OS? It seems that the WiringPi installed on FriendlyElec OS has no problem finding what it needs in cpuinfo. I wonder:  is there any way to write into /proc/cpuinfo? From previous attempts, it seems that I need to add a Hardware line, or something like that.

 

Because GPIO pin mappings are different on every single SBC that exists, and often times they are not called out by hand? The software needs to know which board you're on, and vendor kernels can often times put in nonstandard hacks that don't exist elsewhere.

 

Also, WiringPi isn't exactly a standard product, and I'm unsure if it's supported outside the FriendlyElec build. Perhaps you'd want to try something actually built for this project? https://forum.armbian.com/topic/5655-armbianio-api-proposal/

 

Barring that, I'd suggest installing gpiod, and using gpioinfo, gpioget, gpioset, etc ...

Link to comment
Share on other sites

  • 0

I've been using the following table with the M4v2:

 

------+-----+----------+------+ Model  NanoPi-M4 +------+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | Physical | V | Mode |   Name   | wPi | GPIO |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
 |      |     |     3.3V |      |   |  1 || 2  |   |      | 5V       |     |      |
 |      |     | I2C2_SDA |      |   |  3 || 4  |   |      | 5V       |     |      |
 |      |     | I2C2_SCL |      |   |  5 || 6  |   |      | GND(0V)  |     |      |
 |   32 |   7 | GPIO1_A0 |  OUT | 0 |  7 || 8  |   | ALT  | GPIO4_C1 | 15  |  145 |
 |      |     |  GND(0V) |      |   |  9 || 10 |   | ALT  | GPIO4_C0 | 16  |  144 |
 |   33 |   0 | GPIO1_A1 |   IN | 0 | 11 || 12 | 1 | IN   | GPIO1_C2 | 1   |  50  |
 |   35 |   2 | GPIO1_A3 |   IN | 0 | 13 || 14 |   |      | GND(0V)  |     |      |
 |   36 |   3 | GPIO1_A4 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO1_C6 | 4   |  54  |
 |      |     |     3.3V |      |   | 17 || 18 | 0 | IN   | GPIO1_C7 | 5   |  55  |
 |      |     | UART4_TX |      |   | 19 || 20 |   |      | GND(0V)  |     |      |
 |      |     | UART4_RX |      |   | 21 || 22 | 0 | IN   | GPIO1_D0 | 6   |  56  |
 |      |     | SPI1_CLK |      |   | 23 || 24 |   |      | SPI1_CSn |     |      |
 |      |     |  GND(0V) |      |   | 25 || 26 |   | ALT  | GPIO4_C5 | 11  |  149 |
 |      |     | I2C2_SDA |      |   | 27 || 28 |   |      | I2C2_SCL |     |      |
 |      |     | I2S0_LRX |      |   | 29 || 30 |   |      | GND(0V)  |     |      |
 |      |     | I2S0_LTX |      |   | 31 || 32 |   |      | I2S_CLK  |     |      |
 |      |     | I2S0_SCL |      |   | 33 || 34 |   |      | GND(0V)  |     |      |
 |      |     | I2S0SDI0 |      |   | 35 || 36 |   |      | I2S0SDO0 |     |      |
 |      |     | I2S0I1O3 |      |   | 37 || 38 |   |      | I2S0I2O2 |     |      |
 |      |     |  GND(0V) |      |   | 39 || 40 |   |      | I2S0I3O1 |     |      |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+

 

Let's try GPIO1_A4:

 

echo 36 > /sys/class/gpio/export
echo "out" >/sys/class/gpio/gpio36/direction
echo "1" > /sys/class/gpio/gpio36/value

 

And then I can measure 3v with a multimeter hooked to the physical pin 15.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...