Power & Source of Big Ideas

NanoPi M4V2 WiringPi broken

Moderators: chensy, FATechsupport

Hi!
I encountered a problem using wiringPi on a new NanoPi M4V2.
4.4.179 #1 SMP Thu Aug 29 17:08:23 CST 2019 aarch64 aarch64 aarch64 GNU/Linux

Using the following command
gpio -v
this gives me the following output
gpio version: 2.44
Copyright (c) 2012-2017 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

FriendlyELEC Board Details:
Type: Unknown, Revision: 00, Memory: 256MB
Maker: Hardkernel, Chip-Vendor: Unknown
* Device tree is enabled.
*--> FriendlyElec NanoPi M4 Ver2.0
* Root or sudo required for GPIO access.

Note the unknown type. Seems like WiringPi does not recognize the new NanoPi M4V2 hardware.

When compiling a C program and executing the program (which has worked on previous NanoPi M4 hardware) now it shows the following error:
wiringPiSetup: Unknown model

And the expected normal operation is broken too.
gpio readall
This also gives me the following output
wiringPiSetup: Unknown model

Is this problem known? Is there maybe a fix already available?
I see exactly the same problem on the M4v2.
Any progress on this matter? Were you able to solve it? I have also the same problem, latest friendlycore installed
It only supports FriendlyCore and FriendlyDesktop firmware and is not compatible with armbian.
The problem is still unresolved!
Today I downloaded the newest M4V2 image rk3399-eflasher-friendlycore-focal-4.4-arm64-20201027.img.zip
After running the command gpio readall it displayed the following error:
Oops: Unable to determine board revision from /proc/device-tree/system/linux,revision
or from /proc/cpuinfo
-> No "Hardware" line
-> You'd best google the error to find out why.
Then I checked /proc and there is no /proc/device-tree/system however, there is /proc/device-tree/board

Code: Select all

-r--r--r--   1 root root 19 Oct 29 11:07 compatible --> friendlyelec,board
-r--r--r--   1 root root  4 Oct 29 11:07 hwrev      --> !
-r--r--r--   1 root root  8 Oct 29 11:07 machine    --> NANOPI4
-r--r--r--   1 root root 10 Oct 29 11:07 model      --> NanoPi M4
-r--r--r--   1 root root  6 Oct 29 11:07 name       --> board
-r--r--r--   1 root root  4 Oct 29 11:07 phandle    --> ▒
Shouldn't the model have been "NanoPi M4V2"? And why is name = "board"?
If I understand correctly, WiringPi from FE distro from another board and and you need to install it manually:

From official wiki https://wiki.friendlyarm.com/wiki/index.php/WiringPi_for_RK3399#Install_WiringPi_on_T4.2FM4.2FNEO4

Code: Select all

# Delete "old" version
wget http://112.124.9.243:8888/wiringpi/friendlyelec-rk3399/remove_oldversion_wiringPi.sh
chmod 755 remove_oldversion_wiringPi.sh
sudo ./remove_oldversion_wiringPi.sh
# Download and install wiringPi for RK3399
wget http://112.124.9.243:8888/wiringpi/friendlyelec-rk3399/wiringpi-v2.44-friendlyelec-rk3399.deb
sudo dpkg -i  wiringpi-v2.44-friendlyelec-rk3399.deb


looks like it's work - from my M4/kernel 4.19/ubuntu 20.04

Code: Select all

gpio -v

FriendlyELEC Board Details:
  Type: NanoPi-M4, Revision: 01, Memory: 2048MB
  Maker: Hardkernel, Chip-Vendor: ROCKCHIP
  * Device tree is enabled.
  *--> FriendlyElec NanoPi M4
  * Root or sudo required for GPIO access.



upd:

Code: Select all

gpio readall
 +------+-----+----------+------+ 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  |   |      | I2C3_SCL |     |      |
 |      |     |  GND(0V) |      |   |  9 || 10 |   |      | I2C3_SDA |     |      |
 |   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  |
 |   40 |  12 | GPIO1_B0 |  ALT |   | 19 || 20 |   |      | GND(0V)  |     |      |
 |   39 |  13 | GPIO1_A7 |  ALT |   | 21 || 22 | 0 | IN   | GPIO1_D0 | 6   |  56  |
 |   41 |  14 | GPIO1_B1 |  ALT |   | 23 || 24 |   | ALT  | GPIO1_B2 | 10  |  42  |
 |      |     |  GND(0V) |      |   | 25 || 26 |   | ALT  | GPIO4_C5 | 11  |  140 |
 |      |     | I2C2_SDA |      |   | 27 || 28 |   |      | I2C2_SCL |     |      |
 |  121 |  21 | GPIO3_D1 |  ALT |   | 29 || 30 |   |      | GND(0V)  |     |      |
 |  122 |  22 | GPIO3_D2 |  ALT |   | 31 || 32 |   |      | I2S_CLK  |     |      |
 |  120 |  23 | GPIO3_D0 |  ALT |   | 33 || 34 |   |      | GND(0V)  |     |      |
 |  123 |  24 | GPIO3_D3 |  ALT |   | 35 || 36 |   | ALT  | GPIO3_D7 | 27  |  127 |
 |  124 |  25 | GPIO3_D4 |  ALT |   | 37 || 38 |   | ALT  | GPIO3_D5 | 28  |  125 |
 |      |     |  GND(0V) |      |   | 39 || 40 |   | ALT  | GPIO3_D6 | 29  |  126 |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
Hi!
My problem is with NanoPi M4 V2.
Revision 1 is no longer available. They are now selling the boards with revision 2. Therefore a "V2" is being added.
As I can see, you have tested the NanoPi M4 with revision 1:

Code: Select all

FriendlyELEC Board Details:
  Type: NanoPi-M4, Revision: 01, Memory: 2048MB
There is no problem with this. Revision 1 works for me as well.
But what should I do if I can only buy V2 in the future?
It would be nice if everything worked out by then. But the problem has been going on for a year and a half.
Today I started a new attempt.
So I went to FriendlyARM's Wiki again and repeated the steps they suggest to remove an old wiringPi installation and then install their latest version.
https://wiki.friendlyarm.com/wiki/index ... FM4.2FNEO4

In short: it works!

Code: Select all

root@NanoPi-M4v2:~# gpio -v

gpio version: 2.44
Copyright (c) 2012-2017 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

FriendlyELEC Board Details:
  Type: NanoPi-M4, Revision: 01, Memory: 2048MB
  Maker: Hardkernel, Chip-Vendor: ROCKCHIP
  * Device tree is enabled.
  *--> FriendlyElec NanoPi M4 Ver2.0
  * Root or sudo required for GPIO access.

In order not to waste the space unnecessarily, I save the messages from "gpio readall". It works too.

If you want, you can compare the messages from today with those in my first post on November 12, 2019.
It's bad that it took them over a year to fix the problem. Fortunately, I had the time to wait.

What's even worse is that they are violating the GPL in the process. The fix is only made available as a binary Debian package. According to the GPL license, they are obliged to provide the source code.
Shame on FriendlyElec/FriendlyARM !
Hello igorp!
I already knew that I can use sysfs to change GPIOs.
Unfortunately, sysfs lacks the support for pullup/pulldown configuration.
That's why I had to use wiringPi.
But as soon as sysfs can manage pullup/pulldown, I'll kick wiringPi out and get rid of the dependency.
GPIO sysfs interface is deprecated, use libgpiod [1] instead.

Code: Select all

Usage: gpioset [OPTIONS] <chip name/number> <offset1>=<value1> <offset2>=<value2> ...

Set GPIO line values of a GPIO chip and maintain the state until the process exits

Options:
  -h, --help:           display this message and exit
  -v, --version:        display the version and exit
  -l, --active-low:     set the line active state to low
  -B, --bias=[as-is|disable|pull-down|pull-up] (defaults to 'as-is'):
                set the line bias
  -D, --drive=[push-pull|open-drain|open-source] (defaults to 'push-pull'):
                set the line drive mode
  -m, --mode=[exit|wait|time|signal] (defaults to 'exit'):
                tell the program what to do after setting values
  -s, --sec=SEC:        specify the number of seconds to wait (only valid for --mode=time)
  -u, --usec=USEC:      specify the number of microseconds to wait (only valid for --mode=time)
  -b, --background:     after setting values: detach from the controlling terminal

Biases:
  as-is:        leave bias unchanged
  disable:      disable bias
  pull-up:      enable pull-up
  pull-down:    enable pull-down

Drives:
  push-pull:    drive the line both high and low
  open-drain:   drive the line low or go high impedance
  open-source:  drive the line high or go high impedance

Modes:
  exit:         set values and exit immediately
  wait:         set values and wait for user to press ENTER
  time:         set values and sleep for a specified amount of time
  signal:       set values and wait for SIGINT or SIGTERM

Note: the state of a GPIO line controlled over the character device reverts to default
when the last process referencing the file descriptor representing the device file exits.
This means that it's wrong to run gpioset, have it exit and expect the line to continue
being driven high or low. It may happen if given pin is floating but it must be interpreted
as undefined behavior.
[1] https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/README
There is an alternative for the deprecated WiringPi

https://github.com/vsergeev/c-periphery

which works fine on my NanoPi devices - Nano Pi (ARMv7/ARMv8) and NanoPI M1.

I am the author of the Dart port of c-periphery:
https://pub.dev/packages/dart_periphery

The GPIO numbering is a little challenging, but this sub project provides some infos about the GPIO numbering:
https://github.com/sgjava/java-periphery
usual user wrote:
GPIO sysfs interface is deprecated, use libgpiod [1] instead.


Okay, I installed gpiod via apt and tested the command gpiodetect.
And... the result is... none. No gpiochip has been detected.
There is no output message but also no error message.

Conclusion: it doesn't work on NanoPi M4 V2.
pezi wrote:
There is an alternative for the deprecated WiringPi
https://github.com/vsergeev/c-periphery

Okay, I gave it a try, although I did not expect it to work since NanoPi M1 is a different architecture.
Your code will have to support rockchip and most code does not.

I made a clone with git and compiled the source.
Then I called test_led to see if it does anything at all:

Code: Select all

# ./test_led led1

Starting test test_arguments():19
 [ OK ]  Arguments test passed.

Starting test test_open_config_close():31
 [ OK ]  /root/c-periphery/tests/test_led.c test_open_config_close():35  led != NULL
 [ OK ]  /root/c-periphery/tests/test_led.c test_open_config_close():38  led_open(led, "nonexistent") == LED_ERROR_OPEN
 [FAIL]  /root/c-periphery/tests/test_led.c test_open_config_close():41  led_open(led, device) == 0
test_led: /root/c-periphery/tests/test_led.c:41: test_open_config_close: Assertion `r' failed.
Aborted (core dumped)

Conclusion: it doesn't work on NanoPi M4 V2.
jernst wrote:
And... the result is... none. No gpiochip has been detected.
If no gpiochip is detected, the kernel is not configured to expose the necessary device nodes.

jernst wrote:
it doesn't work on NanoPi M4 V2

The gpiochip api is device independent, i.e. it is working for all devices in a similar manner as long as the kernel exposes the required /dev/gpiochipX nodes. Mainline kernel has the required support for the RK3399 SoC.
Same problem here on 4gb r4s - cake discipline is missing. Any ideas?
Meanwhile I tried the latest update of the firmware and it worked for me. M4 V2 is recognized and wiringpi GPIO is fine.
I used the FriendlyCore Bionic image.
Download link is on the wiki page
https://wiki.friendlyarm.com/wiki/index ... om_SD_Card

Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 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 4 guests