Close

Getting WiringNP to work in DietPi

A project log for Handheld Linux Terminal [HaLiTerm]

A compact serial terminal with a built-in NanoPi Neo Air running DietPi.

balazsBalazs 08/02/2023 at 11:160 Comments

FreindlyElec has its own WiringPi based library called WiringNP. It compiles with several warning massages. Trying to execute "gpio readall" in DietPi returns an error massage:

piBoardRev: Unable to determine board revision from /proc/cpuinfo
 -> Is not NanoPi based board.
 -> You may want to check:
 -> http://www.lemaker.org/
open /sys/class/sunxi_info/sys_info failed

While /proc/cpuinfo looks good in DietPi, sys/class/sunxi_info/sys_info doesn't exist. According to this workaround, you can redirect WiringNP to /etc/sys_info by editing WiringNP/wiringPi/boardtype_friendlyelec.c before executing ./build.

Original:

if (!(f = fopen("/sys/class/sunxi_info/sys_info", "r"))) {
        LOGE("open /sys/class/sunxi_info/sys_info failed.");
        return -1;
    }

Modified:

if (!(f = fopen("/sys/class/sunxi_info/sys_info", "r"))) {
    if (!(f = fopen("/etc/sys_info", "r"))) {
        LOGE("open /sys/class/sunxi_info/sys_info failed.");
        return -1;
    }
}

In FriendlyCore for the NanoPi NEO Air sys_info looks like this:

sunxi_platform    : sun8iw7p1
sunxi_secure      : normal
sunxi_chipid      : unsupported
sunxi_chiptype    : unsupported
sunxi_batchno     : unsupported
sunxi_board_id    : 2(0)
board_manufacturer: FriendlyElec
board_name        : FriendlyElec Nanopi-NEO-Air

With this workaround "gpio readall" returns the expected output:

 +-----+-----+----------+------+---+-NanoPi-NEO-Air--+------+----------+-----+-----+
 | 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 |  OFF | GPIOG6   | 15  | 198 |
 |     |     |       0v |      |   |  9 || 10 | 0 |  OFF | GPIOG7   | 16  | 199 |
 |   0 |   0 |   GPIOA0 |  OFF | 0 | 11 || 12 | 0 |  OFF | 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 |  OFF | 0 | 19 || 20 |   |      | 0v       |     |     |
 |  65 |  13 |   GPIOC1 |  OFF | 0 | 21 || 22 | 0 |  OFF | GPIOA1   | 6   | 1   |
 |  66 |  14 |   GPIOC2 |  OFF | 0 | 23 || 24 | 0 |  OFF | GPIOC3   | 10  | 67  |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+-NanoPi-NEO-Air--+------+----------+-----+-----+

 +-----+----NanoPi-NEO-Air USB/Audio-+----+
 | BCM | wPi |   Name   | Mode | V | Ph |
 +-----+-----+----------+------+---+----+
 |     |     |       5V |      |   | 25 |
 |     |     |  USB-DP1 |      |   | 26 |
 |     |     |  USB-DM1 |      |   | 27 |
 |     |     |  USB-DP2 |      |   | 28 |
 |     |     |  USB-DM2 |      |   | 29 |
 |     |     |    IR-RX |      |   | 30 |
 |  17 |  19 |  GPIOA17 |  OFF | 0 | 31 |
 |     |     |  PCM/I2C |      |   | 32 |
 |     |     |  PCM/I2C |      |   | 33 |
 |     |     |  PCM/I2C |      |   | 34 |
 |     |     |  PCM/I2C |      |   | 35 |
 |     |     |       0V |      |   | 36 |
 +-----+-----+----------+------+---+----+

 +-----+----NanoPi-NEO-Air Debug UART-+----+
 | BCM | wPi |   Name   | Mode | V | Ph |
 +-----+-----+----------+------+---+----+
 |   4 |  17 |   GPIOA4 | ALT5 | 0 | 37 |
 |   5 |  18 |   GPIOA5 | ALT5 | 0 | 38 |
 +-----+-----+----------+------+---+----+

I was surprised to see, that in FriendlyCore the DS3231 RTC was automatically assigned to /dev/rtc1. I still had to manually sync the system time to it.

Discussions