Rock pi s GPIO library link

hi all

pls give me link for rock pi s GPIO access library.

because I try so much but I don’t find any libmraa library for rock pi s

1 Like

We recently added libmraa support on ROCK Pi S, you can refer on this:

https://wiki.radxa.com/RockpiS/dev/libmraa

Hi. I am a linux newbie and I am trying to install libmraa for GPIO programming.
I installed Debian Buster and I followed the link you’d given.

I added the following to /etc/apt/sources.list.d/apt-radxa-com.list

deb http://apt.radxa.com/buster-stable/ buster main <== 1line : It is already there.
#deb http://apt.radxa.com/buster-stable/ buster main <== 2line : It is already there.
export DISTRO=buster-testing <== 3line : I add it like the link said.

Then exit apt-radxa-com.list and type this in shell.

/#echo “deb http://apt.radxa.com/$DISTRO/ ${DISTRO%-*} main” | sudo tee -a /etc/apt/sources.list.d/apt-radxa-com.list

Finall my apt-radxa-com.list is

deb http://apt.radxa.com/buster-stable/ buster main
#deb http://apt.radxa.com/buster-stable/ buster main
export DISTRO=buster-testing
deb http://apt.radxa.com// main

Then Get the pub key

wget -O - apt.radxa.com/buster-testing/public.key | sudo apt-key add - <== install OK

Install essential packages

sudo apt-get update
I got errors.
E: Type ‘export’ is not known on line 3 in source list /etc/apt/sources.list.d/apt-radxa-com.list
E: The list of sources could not be read.

Could you help me??

Sorry, there is a mistake of that guide. But it is corrected. Check that link again.

You can do the following steps.

Firstly, add the following to /etc/apt/sources.list.d/apt-radxa-com.list

deb http://apt.radxa.com/buster-stable/ buster main
deb http://apt.radxa.com/buster-testing/ buster main

Secondly, execute the commands.

wget -O -  apt.radxa.com/buster-testing/public.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y rockchip-overlay rockpis-dtbo libmraa-rockpis

Needed packages are installed.

Please note that there are some differences between the system images when setting interface like i2c, uart, etc. Check this link, https://wiki.radxa.com/RockpiS/dev/libmraa, for more details.

1 Like

Now, it works.
Thanks. Great support!!

Hi.
I am making a project with Rock PI S.
The project is using lua and I want to add led control to this project.
So is it possible to use libmraa with lua??

I googled and found it. But I don’t understand whether it could be used with lua or not…

现在支持ubuntu 了吗?之前只支持Debian

ROCK Pi S Ubuntu system 也支持 libmraa。

I follwed the installation and it looked like being installed.
But I can’t import the library in python.

import mraa
print(mraa.getVersion())

python3.7 test.py

ModuleNotFoundError : No module named ‘mraa’

So I checked whether it installed or not.

#rpm -ql libmraa
package libmraa is not installed
#rpm -ql libmraa-rockpis
package libmraa is not installed

What did I wrong??

Hi. I´m pretty new in linux and I’m just trying to start with Rock Pi S. I´ve downloaded latest version of Debian and I was able to modify uEnv.txt to add overlays

As the original question in this post I’m having some trouble to get started with lbrmraa.

When I´ve tried to follow the instructions , in this step:

wget -O - apt.radxa.com/buster-testing/public.key | sudo apt-key add -

I get this response:

bash: wget: command not found
gpg: no valid OpenPGP data found

The next steps:

sudo apt-get update
sudo apt-get install -y rockchip-overlay rockpis-dtbo libmraa-rockpis

works fine, but when I try to test GPIO with

root@rockpis:/# mraa-gpio list

I get this:

bash: /#: No such file or directory

I´ve already checked that:

deb http://apt.radxa.com/buster-stable/ buster main
deb http://apt.radxa.com/buster-testing/ buster main

are in: /etc/apt/sources.list.d/apt-radxa-com.list.

I’ve also tried with ubuntu and I hace exactly the same problem.

I´m sorry if my lack of knowledge is the biggest problem, but any help regarding this issue will be deeply appreciated.

Best Regards

Gonzalo Guerrero

you need to install wget first.
sudo apt-get install wget

Thanks a lot.

Wget works!

But the other problem is still there when I try to test GPIO

root@rockpis:/# mraa-gpio list

I get this:

bash: /#: No such file or directory

Did you ever get an answer for this issue?

For me, bash: /#: No such file or directory

Means I needed to place ‘sudo’ before it.

When you do it the first time on boot without sudo you get the above error.

If you try first with sudo and the command after it without sudo I get: Pin 16 = -1

This incorrect since the value should be between 0-1. (probably the sudo)

To get to work without sudo:

I found a working solution at last!

First , create a group and add the user that needs access to the GPIOs to it (this is for the current user;
replace $USER with an explicit username if you want).

sudo groupadd gpio

sudo usermod -a -G gpio $USER

Now reboot

Second , add the following lines to /etc/rc.local (you will have to edit it as root, using sudo vi or whatever).
chown -R root:gpio /sys/class/gpio

chmod -R ug+rw /sys/class/gpio

Third , create a new udev rule in a file, say /etc/udev/rules.d/80-gpio-noroot.rules (you will have to edit it as root again):

# /etc/udev/rules.d/80-gpio-noroot.rules

 
# Corrects sys GPIO permissions on the Joule so non-root users in the gpio group can manipulate bits

 
# Change group to gpio

 
SUBSYSTEM=="gpio", PROGRAM="/bin/sh -c '/bin/chown -R root:gpio /sys/devices/platform/INT34D1:*/gpio'"

 
# Change user permissions to ensure user and group have read/write permissions

 
SUBSYSTEM=="gpio", PROGRAM="/bin/sh -c '/bin/chmod -R ug+rw /sys/devices/platform/INT34D1:*/gpio'"

Fourth , reboot or restart udev using
sudo udevadm trigger --subsystem-match=gpio

And finally test:
mraa-gpio get 16

The first call will not do anything but set up the GPIO, so the value will be -1, but following calls should work. And return a value between 0-1.