How to control the GPIO?

I agree with @few. There already exists a WiringNP, which is WiringPi for Nano PI from friedlyelec.
It shouldn’t be a big problem to fork the repo and include also RockPi 4.

The board is detected using CPU information in boardtype_friendlyelec.c. I don’t have any of the boards yet, but I do think that if you compile the repo the board will be detected as Nano Pi M4, which uses RK3399. In the wiringPi.c there are various schemas related to detected board. You should patch the GPIO schema of NanoPi M4 according to RockPi 4. An experienced programmer would need some hour to fork, patch and make the WiringPI for RockPi.

I do agree, that Radxa team should spend this hour of labour work to clone almost done work.

However, not all apps would work, even if you would have WiringPi implemented. Only the apps, referencing with header pin number shall work. For others you would still need to change the GPIO numbers in source.

In my opinion It is no-sense to develop a board which want to be as much as possible compatible with Pi3 and on the other side not supporting the ecosystem of Pi3 world, and in particular the porting of one of the most well working libraries for Gpio

One doesn’t need to support all the childish hacks that are built for pi. Just because a lot of noobs use something stupid does not make it correct or reasonable.

1 Like

I agree with @luke1962. Those noobs are actually buying your boards, don’t forget it.

Dear Radxa,

I would like to have WiringPi and RPI.GPIO library for interfacing ready made examples for Raspberry Pi. I have noticed that FriendlyElec already ported those libraries to their Nano Pi M4. Unfortunately they violate the license agreement and their library are not open source, so no possible port to Rock Pi 4. You could inform them about their violation, they had copied opens source and made it like their own source??? We (buyers of Rock Pi) would expect also from Radxa, to port those widely used libraries made for Rpi.

Thank you.

1 Like

We prefer to support WiringX, which is a more general library.

1 Like

It doesn’t seem to support RockPi4.

1 Like

I found a port of wiringX by Radxa, but it seems to be for Rock SBC rather than Rock Pi 4.

Personally, I am plan to try using the GPIO via a bash or python script like here:

Hey @Nechoj

May I use your posted code in an open source (GPLv3) program/script?


I have a good news :slight_smile: The wiringX maintainer agreed to help us get ROCK Pi 4 supported. We will send him a kit. Let’s wait…

1 Like

Sorry I missed your message. Of course you can.

1 Like

@jack Could you please elaborate on this?

There is no apparent rhyme or reason to your example. Without clarifying the significance of each value or group of values, there is no way for me to figure out what I need to change, in order to discover the GPIO number for GPIO4_A3… After all, 11*9 + 9*4 + 22 is also 157, but you didn’t use that in your example…

Hi I understand some of the equation above don’t understand where the 8*3 part comes from!
Can you clarify this a bit more?


Its explained in the Wiki:

  GPIO4_D5 = 4*32 + 3*8 + 5 = 157
  (A=0, B=1, C=2, D=3)

Hope its clear now.

Edit- image added to wiki.


Sorry I must have missed that!
I’m a complete newbie to Rock as I’ve always been a Raspberry Pi guy but loved the SFF of the S.
Thanks for your reply

1 Like

Hi there.
Many thanks I’ve now got it working and currently looking at writing my own library to read multiple ports
Really grateful for the swift reply
Stay safe everyone!

1 Like

Hi, I’m a newbye with libmraa.
I’m tryng to intergace an old OV7670 camera module, having 8 bit data output.

Is there a way for reading an entire bank (8bit) with one single instruction ?
If yes which is the command in cpp?

Hi jack,
To run “echo 157 > export” need change user to root. And I want my GPIO to be exported when system bootup, how to config a GPIO as exported by default?

Put it on /etc/rc.local, you will have it when system booting up. It’s running as root.

1 Like

It works.
Thank you!