pimoroni / blinkt

Python Library for Blinkt; 8 APA102 LEDs for your Raspberry Pi
https://shop.pimoroni.com/products/blinkt
MIT License
314 stars 103 forks source link

Bookworm/Pi5 Compatibility: Upgrade to latest boilerplate #102

Open Gadgetoid opened 1 year ago

Gadgetoid commented 1 year ago

Testing

If you're a Bookworm / Pi 5 user running into virtual environment issues, you can try this library like so:

git clone https://github.com/pimoroni/blinkt -b repackage
cd blinkt
./install.sh --unstable

The ./install.sh script will create a pimoroni virtual environment that's shared between our products. (or use your existing venv if you've already activated one.)

For the reasons behind these changes and other information, see:

Troubleshooting

OSError: Device or resource busy

If you see an error like this:

OSError: [Errno 16] Device or resource busy

You should install sudo apt install gpiod and run gpioinfo to see what's using your pins. There should be a name in the column of "unused" things. If it's something like "sysfs" then something like RPi.GPIO (on an older Pi 4 OS) has already claimed the pin via /sys/class/gpio and gpiod will not let you use it.

Or, as of recent changes, a more useful error like this:

RuntimeError: some pins we need are in use:
 ⚠️  Data (GPIO 23) is currently claimed by blinkt
 ⚠️  Clock (GPIO 23) is currently claimed by blinkt

Then make sure you close whatever process, or disable whatever service is implicated as the claimant :laughing:

PermissionError: Permission denied

If you see an error like this:

PermissionError: [Errno 13] Permission denied

You may need to add yourself to the "dialout" group, or whatever group arbitrates GPIO access on your distro. For example on Raspberry Pi Ubuntu -

sudo usermod -a -G dialout phil
coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 9351867446

Details


Totals Coverage Status
Change from base Build 1820718973: 21.2%
Covered Lines: 79
Relevant Lines: 83

💛 - Coveralls
Gadgetoid commented 1 year ago

Okay looks like on Ubuntu Pi 4 (and probably 5) /dev/gpiochip0 is accessible to the "dialout" group, whereas /dev/gpiochip1 is not. Any attempt to enumerate chips might hit the second one and fail, need to catch permissions errors.

ls -hal /dev/gpiochip*
crw-rw----+ 1 root dialout 254, 0 Oct 13 15:58 /dev/gpiochip0
crw-------  1 root root    254, 1 Oct 13 15:58 /dev/gpiochip1
phoeinx commented 8 months ago

Hi,

Short question about compatibility of the blinkt library with Pi5: As far as I've understood from other discussions like this one, the RPi.GPIO library doesn't have support for the Pi5 yet. And as this packages uses the RPi.GPIO library, this PR alone will not be enough to make the blinkt library directly usable on the Pi5 right?

There seem to be some intermediate fixes, e.g. dropping in the rpi-lgpio library. I have to get access to a Pi5 first, but will report whether that worked for us.

Thanks in advance!

Gadgetoid commented 8 months ago

this PR alone will not be enough to make the blinkt library directly usable on the Pi5 right?

It should work. I even went so far as to test Blinkt! on not-a-Pi devices which have never supported RPi.GPIO.

Some of the finer points of finding the right GPIO interface and lines remain an open question, so I'd be very interested in your feedback if you get a chance to try this library.

phoeinx commented 4 months ago

this PR alone will not be enough to make the blinkt library directly usable on the Pi5 right?

It should work. I even went so far as to test Blinkt! on not-a-Pi devices which have never supported RPi.GPIO.

Some of the finer points of finding the right GPIO interface and lines remain an open question, so I'd be very interested in your feedback if you get a chance to try this library.

Hi thank you for your quick reply! And sorry for getting back so late on this. When I got my hands on the RPi5 I could verify that installing the Blinkt! package out of the box (with the dependency on RPi.GPIO) didn't work. Or to be more precise: the install did work, but we got errors regarding GPIO access. This is the part of the error trace in the Blinkt! package code:

File "/usr/share/python/lib/python3.11/site-packages/blinkt.py", line 76, in show
    GPIO.setup(DAT, GPIO.OUT)
RuntimeError: Cannot determine SOC peripheral base address

We didn't investigate this any further, as replacing the RPi.GPIO install with rpi.lgpio (https://pypi.org/project/rpi-lgpio/) fixed the issue for us.