GPIO, Docker, Python

I want to access GPIO pins to create interrupts and control output pins. Problem is that I need to access GPIO from docker container Ubuntu:18.04. Problem is, that in a container I am not able to get the rockPi4 mraa library. Is there a way, how to control GPIO from the container?

docker run --privileged -d whatever

?
try checking the raspbian info and see how they are doing it

Thanks stuartiannaylor,

I know that I need to use --privileged parameter. My mistake I didn’t mention it. My problem is, which library should I use in a container, to control RockPi GPIO. I need interrupts and control pins. I am not able to install libmraa-rockpi4.

What distro (container) are you using as many have libs for gpio
https://wiki.radxa.com/Rockpi4/dev/libmraa

I use Ubuntu:18.04 as distro in container. Should I use mraa available in Ubuntu?

I haven’t tried gpio but its included in the Radxa bionic repo so unless radxa have made a mistake, then yes.
But its making sure the container has the permissions.

libmraa uses /sys/class/gpio for GPIO control low level. As long as you can access /sys and /dev in the container you can use libmraa.

wiringx and pyRock can not work on ROCK Pi 4 currently.

I also have a question.

I’m planning to use librelec in my RockPi 4b(I’m waiting for it to come from China). I like to always control my sbcs by power/reset switches installed on the gpios. These switches are controlled by python scripts.

My question is…
Will I be able to use the Raspberry Pi tools add-on to control the gpios and use these scripts to install the power switches?

Sorry if it’s a dumb question but it’s my first time using a non raspberry pi sbc.

Prob not the Pi scripts you would just have to translate the gpio calls to libmraa calls at a guess

Yes I was checking how different it is to call the gpios, so maybe the add-on is not going to work :frowning:

This add-on enables the gpio library in the libreelec

Prob the other way round the whatever gpio lib libreelec uses activates that device.
I don’t know how much work with libreelec has been done with rk3399 and its a libreelec question to ask their prob.

I tried to use the Raspberry Pi Tools Add-on to control the gpios and as soon as you run the script it stops it saying its not possible to run without being in a Raspberry.

Even though I still was able to install the X735 and control the power of the Rock Pi by a power and reset switch.

The only thing I’m struggling is how to set up a the software shutdown.