Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bookworm/Pi5 Compatibility: Upgrade to latest boilerplate #102

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

Gadgetoid
Copy link
Member

@Gadgetoid Gadgetoid commented Oct 31, 2023

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 😆

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

@Gadgetoid Gadgetoid mentioned this pull request Oct 31, 2023
@coveralls
Copy link

coveralls commented Oct 31, 2023

Pull Request Test Coverage Report for Build 9351867446

Details

  • 27 of 27 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+21.2%) to 95.181%

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

💛 - Coveralls

Tested so far on a Pi 4 running Bullseye and a Pi 5 running Bookworm.
@Gadgetoid
Copy link
Member Author

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

This was referenced Nov 2, 2023
Fix a bug where auto_venv.sh was being created in a non-existent directory.

Trap exit codes for some commands and add some help text + GitHUb url at
the end of the install process.

Try to comment what some sections do, and insert linebreaks so they are
more logically broken up in the installer output.

Try to be more consistent with colours.

Try to be more friendly with colours- remove full red warning text in
favour of a prefix so the errors/warnings are easier to read.

Return a failure exit code if bits of the script have failed.

Try to re-order output so it's more logical.

Re-word venv creation message.
@Gadgetoid Gadgetoid force-pushed the repackage branch 2 times, most recently from 2f171f5 to 7c3284a Compare November 23, 2023 11:24
@Gadgetoid Gadgetoid changed the title Repackage to latest boilerplate and port to gpiod Bookworm/Pi5 Compatibility: Upgrade to latest boilerplate Feb 13, 2024
@phoeinx
Copy link

phoeinx commented Mar 20, 2024

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
Copy link
Member Author

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
Copy link

phoeinx commented Jul 3, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants