Fail to set GPIO


I have installed the libmraa to the Rock Pi X with the steps listed on this link:

However, I can’t set the GPIO pin with its sample command or python script:

  • When I try: sudo mraa-gpio set 7 1
    -> It returned: Could not initialize gpio 7
  • When I try the in /usr/local/share/mraa/examples/python
    -> It shows:
    Traceback (most recent call last):
    File “./”, line 15, in
    gpio_1 = mraa.Gpio(23)
    File “/usr/local/lib/python3.8/dist-packages/”, line 474, in init
    this = _mraa.new_Gpio(pin, owner, raw)
    ValueError: Invalid GPIO pin specified

Actually the command: mraa-gpio list works and could show exact 40 pin listed in aforementioned link. I also try different pin in, but no luck!

Here is my system:
OS: Ubuntu 20.04.4 LTS
mraa-gpio version: Version v2.1.0-15-g03d3059 on ROCK PI X

Does anyone have solution on this? Thanks!

Can you try with different pin numbers and see if you get a different response?

Anything in dmesg?

Yes, I have tried another pin number, still got same error
For sudo mraa-gpio set 7 1, dmesg shows:
export store: invalid GPIO 335

I have checked the folder under /sys/class/gpio:
gpiochip737, gpiochip740, gpiochip826,gpiochip853,gpiochip926
It seems the chip’s base value are different from this link:

Thus, I tried to use sysfs to control the gpio. Although it works, I still can’t use mraa in python script

Here are the new GPIO pin number I found:
335 -> 847
334 -> 846
338 -> 850
329 -> 841
229 -> 741
348 -> 860
342 -> 854
346 -> 858
332 -> 844
336 -> 848

Ah, that’s very interesting - I was trying to write a dtb for a SPI/TFT display and was trying to work out why the example elsewhere on github used numbers that made no sense given the wiki page.