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

Install no longer compatible with Bullseye (or Bookworm!) #38

Open
ahnlak opened this issue Dec 23, 2023 · 12 comments
Open

Install no longer compatible with Bullseye (or Bookworm!) #38

ahnlak opened this issue Dec 23, 2023 · 12 comments

Comments

@ahnlak
Copy link

ahnlak commented Dec 23, 2023

With the move to the "new" way of doing things, we've broken compatibility with Bullseye ("Raspberry OS Legacy");

  • the install script now objects to being run as root, but the "one line install" (curl -sSL https://get.pimoroni.com/grow | bash) still attempts to run this via sudo
  • the st7735 library really doesn't seem to like Bullseye at 1.0.0, so needs to be pinned to 0.0.5

At the same time, the venv stuff doesn't quite work under Bookworm, because the service created by the install has no understanding of venv; I would give you a patch for that, but I got stuck in a quagmire of things like numpy refusing to play ball and it all felt like a wider job than just Grow (I'm guessing other Pimoroni products take a service-based approach so perhaps the venv approach needs more looking at?)

@oliverlucas85
Copy link

Any tips on getting grow working would be much appreciated. I just fired it up expecting it to work and sadly disappointed and it doesn't look like anyone from Pimoroni monitors these issues?

@ahnlak
Copy link
Author

ahnlak commented Jan 25, 2024

I've assembled a procedure to get up and running on Bullseye, which has been reported as successful by others:

  • Install Legacy OS
  • Run CURL installer (curl -sSL https://get.pimoroni.com/grow | bash) (this installer will end abruptly complaining about not running under root; don’t worry!)
  • Checkout the grow hat repo (git clone https://github.com/pimoroni/grow-python) and move into this directory (cd grow-python)
  • Switch to a slightly older version of that repo, from before they broke Bullseye compatablity (git checkout 581a025)
  • Run the installer (sudo ./install.sh)
  • Regress the display library (sudo pip install st7735==0.0.5)
  • REBOOT

I'm aware that there is a mammoth task to get things more Bookworm-friendly across their whole range, so I'm reluctant to start throwing PRs at them until there's a clearer path forward there.

@oliverlucas85
Copy link

OMG - Thank you so much, looks to be powering up the display now and the systemd service is all working - Thank you so much for the assist!

Honestly not sure I would have got to a working solution without your help!

@Gadgetoid
Copy link
Member

@ahnlak thanks for the sleuthing here- I've created a new branch: https://github.com/pimoroni/grow-python/tree/bullseye

And released a new version 0.0.3 that explicitly targets the dependency versions before my break-all-the-things updates.

Aaaand retargeted the "get" script to bull the bullseye branch.

(I do monitor these issues but currently everything is broken and cloning myself into an almighty Python army is still out of my grasp)

@xoblite
Copy link

xoblite commented Jan 27, 2024

After some ugly manual installation hackery with the public branch, I managed to run lcd-demo.py successfully, but the main attraction was still standing:

user@host:~/Pimoroni/growhat/examples $ python3 monitor.py
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.11/site-packages/grow/moisture.py", line 41, in init
GPIO.add_event_detect(self._gpio_pin, GPIO.RISING, callback=self._event_handler, bouncetime=1)
RuntimeError: Failed to add edge detection

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/Pimoroni/growhat/examples/monitor.py", line 1158, in
main()
File "/home/pi/Pimoroni/growhat/examples/monitor.py", line 1042, in main
Channel(2, 2, 2),
^^^^^^^^^^^^^^^^
File "/home/pi/Pimoroni/growhat/examples/monitor.py", line 647, in init
self.sensor = Moisture(sensor_channel)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/.local/lib/python3.11/site-packages/grow/moisture.py", line 44, in init
raise RuntimeError("""Unable to set up edge detection on BCM8.
RuntimeError: Unable to set up edge detection on BCM8.

Please ensure you add the following to /boot/config.txt and reboot:

dtoverlay=spi0-cs,cs0_pin=14 # Re-assign CS0 from BCM 8 so that Grow can use it

...however the config.txt lines are already in there. Unfortunately I don't know any Python, so can't help out with this one I'm afraid. Any easy fix to get around the above? Or is this already sorted out in the new 0.0.3 preview branch? (I don't have the Pi nearby currently so haven't been able to check it out yet)

@ahnlak
Copy link
Author

ahnlak commented Jan 28, 2024

You'd need to provide more information (at a bare minimum, the Pi version and OS version you're using, and potentially more details on the "ugly hackery" - although this really doesn't sound like it's related to this particular issue?

@xoblite
Copy link

xoblite commented Jan 28, 2024

Sorry, the title included "Bookworm" so I just assumed this issue was mainly intended to address the fact that the public v0.0.1 is seriously broken on what is nowadays the mainstream choice for most people; I wasn't aware that it was also broken on Bullseye (?). Anyway, the "ugly" way to get around the core installation issues currently present was really to manually force install things, which as noted above made it possible to at least run the lcd-demo.py demo successfully, but not monitor.py. As I wasn't sure whether the above errors where hidden by other factors for other people, I figured I should post it here; hopefully @Gadgetoid will recognize and know what to do with it.

Linux 6.1.0-rpi7-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 on Raspberry Pi 3A+

@jlbrewer
Copy link

jlbrewer commented Feb 25, 2025

I think I may be having the same issue as Xoblite and I'll provide what details I can. I have a Pi 4B and I'm on Bookworm (uname -a: Linux raspberrypi 6.6.74+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.74-1+rpt1 (2025-01-27) aarch64 GNU/Linux). I've been able to get a virtual env going and the service can execute but it's failing at the moisture sensors. I'm on the 0.0.2 version of growhat.

I tried putting the dtoverlay line in its proper place for the current Raspberry Pi OS configuration (/boot/config.txt has moved to /boot/firmware/config.txt and spi0_cs has been renamed to spi0_2cs). I've also tried putting in the spi0 dtoverlay in with the dtoverlay command. In all cases, trying to start the Moisture code results in:

Traceback (most recent call last):
File "", line 1, in
File "/home/jlb/.virtualenvs/pimoroni/lib/python3.11/site-packages/grow/moisture.py", line 52, in init
raise e
File "/home/jlb/.virtualenvs/pimoroni/lib/python3.11/site-packages/grow/moisture.py", line 41, in init
GPIO.add_event_detect(self._gpio_pin, GPIO.RISING, callback=self._event_handler, bouncetime=1)
RuntimeError: Failed to add edge detection

This is on ALL the moisture sensor pins, not just the second sensor as in the old bug. I've been stepping through the code a bit at a time through the Python RPEL. I can control the LCD screen; I don't have pump stuff to test with currently, I haven't worked my way through testing other things like the light sensor and buzzer yet. I do have spi and ic2 enabled.

Edit: Buzzer works...

@Gadgetoid
Copy link
Member

IIRC this is because RPi.GPIO is broken on Bookworm and must be swapped with the libgpiod wrapper: rpi-lgpio

If you're running in a virtualenv then pip install rpi-lgpio might work 😬

I am long, long overdue a look into all this stuff again- I have been waiting what seems like an eternity for the Pi 5 landscape to settle and for various PWM features that I gently shepherded to land.

@Gadgetoid
Copy link
Member

I've updated my gpiod port to switch the moisture sensors to libgpiod. Since event handling works very differently than the implicit thread that RPi.GPIO gave us, I'd had to significantly rework it- but it seems to produce reasonable values (based on my shorting a pin with jumper jerky tests).

This might completely sidestep your moisture problems altogether if you're using that branch.

@jlbrewer
Copy link

jlbrewer commented Feb 26, 2025

So I kept doing research after leaving my comment and started to understand the shift to rpi-lgpio and/or libgpiod. I also came across https://github.com/bobrathbone/GPIOconverter, a shim between RPi.GPIO and libgpiod.

This is...not something that's necessarily a good idea for production code (and it's not in pip so it's inconvenient for adding to a venv) but trying it as a workaround got me into much more familiar territory. I had to bugfix their code to support lists of pins on GPIO.setup (pull request pending), but fixing that let me get the grow-monitor service code running.

So my workarround for running on Bookworm with the current main branch goes thusly:

  • Set up growhat in a virtual environment
  • In that virtual environment: pip install lgpio
  • clone the GPIOConverter repo (my branch with the bugfix is at https://github.com/jlbrewer/GPIOconverter
  • cd to the GPIOConverter repo folder
  • git checkout setup-multi-pins-fix
  • Copy the RPi folder from the repo into the lib/lib64 (depending on your os) folder of your virtual environment.
  • edit /etc/systemd/system/grow-monitor service and add the path to your virtual environment to the ExecStart option line like so:
  • ExecStart=/path/to/.virtualenvs/pimoroni/bin/python /usr/bin/grow-monitor /etc/default/grow

I may check out your gpiod branch later...until this morning it had been long enough since an update that I wasn't hopeful :)

@Gadgetoid
Copy link
Member

This is...not something that's necessarily a good idea for production code

That is more or less the same thought I had about rpi.lgpio. It's good for end users to shore up existing code if they want, but probably not something I should be relying upon.

Sorry for the loooong wait, it's astonishing how much time can pass between me finding a moment to look into this stuff. MicroPython and its ilk have all but consumed me.

For better or worse I do tend to dip into the things where people are actively poking the GitHub issues 😬

Anyway thanks for sharing your setup, I had not come across GPIOconverter but I'm not surprised it exists. We really were all just left out in the cold with GPIO 😢

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

No branches or pull requests

5 participants