adafruit / Adafruit_Blinka

Add CircuitPython hardware API and libraries to MicroPython & CPython devices
https://learn.adafruit.com/circuitpython-on-raspberrypi-linux
MIT License
438 stars 328 forks source link

Update Rockchip rk3308 to use libgpiod #799

Closed makermelissa closed 3 months ago

makermelissa commented 3 months ago

Fixes #795. Updates the Rockchip from using SysFs to libgpiod. Tested on Armbian.

To get this to work, the following needs to be done: Setup a venv and activate:

sudo apt install python3-venv
python3 -m venv env --system-site-packages
source env/bin/activate

Then to give the user permissions without needing root access:

sudo groupadd gpiod
sudo usermod -G gpiod $USER
sudo nano /etc/udev/rules.d/60-gpiod.rules

Add the following to the file:

# udev rules for gpio port access through libgpiod
SUBSYSTEM=="gpio", KERNEL=="gpiochip0", GROUP="gpiod", MODE="0660"
SUBSYSTEM=="gpio", KERNEL=="gpiochip1", GROUP="gpiod", MODE="0660"
SUBSYSTEM=="gpio", KERNEL=="gpiochip2", GROUP="gpiod", MODE="0660"
SUBSYSTEM=="gpio", KERNEL=="gpiochip3", GROUP="gpiod", MODE="0660"
SUBSYSTEM=="gpio", KERNEL=="gpiochip4", GROUP="gpiod", MODE="0660"

Reboot, reactivate the venv, then run python. import board should now work.

johanez commented 2 weeks ago

@makermelissa Can confirm this works on RockPiS running dietpi (which is Armbian based).

Just came across the extra instructions here after a bit of digging. Maybe good to add this to the docs? What would be a good place, the installation instructions ?