Can someone explain mraa vs wiringX for Python3

I am reading through this guide on GPIO: https://wiki.radxa.com/Rockpi4/hardware/gpio

Here, the subtitle “wiringX GPIO mapping” links to this external webpage: https://manual.wiringx.org/platforms/radxa/rock4.html#supported-features

It’s interesting but somewhat confusing to the beginner as to what to make of it.

Returning to the GPIO page I get to the bottom and there is another link to GPIO Libraries/API ( libmraa ): https://wiki.radxa.com/Rockpi4/dev/libmraa

I’ve implemented these steps and then on the bottom of this page it says:

More examples (including examples written in python and java) can be found at:
/usr/local/share/mraa/examples/

If I open up examples/python folder I see there are 13 examples. Opening one of these shows that a python library “mraa” is used.

I then discovered another reference to wiringX which is not listed on the GPIO page: https://wiki.radxa.com/WiringX

Here it says:

WiringX is a GPIO library similar to wiringPi, this document describes how to build and use mraa for ROCK Pi boards.

Then in their Python3 examples, wiringX is used. Does this mean mraa is under the hood or is this library a very different implementation.

So could someone explain what the differences are.

For example, why refer to wiringX if mraa is sufficient. Did I need to install the libmraa if I simply decided to use wiringX. All quite confusing for the noob.

PS. Just to note, neither work out of the box.

If I try to run the GPIO python example (gpio.py) from the /usr/local/share/mraa/examples/python folder
it returns an error saying that based on the file mraa.py in the python/dist-packages/ folder there is an invalid GPIO pin specified.

I did not even try to run similar example from the wiringX examples folder as it uses: gpio.setup(gpio.RASBERRYPI1B2), which is clearly not relevant here.

  1. wiringX can be able to directly operate register, and libmraa is based on sysFs, to some extent, wiringx is faster than libmraa, wiringX is a bit better than libmraa if you need speed to operate gpio
  2. wiringx does not support pwm operation at the moment, but libmraa does, however, wiringX will support it in the future, so if you need to operate pwm now, you can use libmraa only.
  3. you can use wiringX direct and faster if you’re familiar with wiringPi, because both functions are similar.
  4. both libmraa and wiringx support c 、 c++ 、python langauge. And libmraa also support java language, but wiringx not. If you want use java language to operate gpio, you can use libmraa
1 Like
  1. libmraa has a corresponding command line to use

codes in example are written in raspberry pi, you can’t use them directly on Radxa boards, if you want to run the example codes, you need to modify them.

Thanks for explaining.

It would be useful if that is added as a comment inside the example. It is also not that simple to find what other options are available to use for gpio.setup as nothing provided in the readme or on website. Takes a lot of searching through source code.

So instead of gpio.RASPERRYPI1B2 what would you use for Rock4c+ or Rock4se, for example.

I know with some other examples I’ve seen (for other MCU’s) they simply have the relevant line of code shown for each board but just comment them out. Then the new user simply uncomments / comments out the relevant details and proceeds.

You can refer this https://github.com/nascs/sample_code/tree/main/wiringX/python, in the future, I will update more examples which run on radxa board in this repository

1 Like