-
Notifications
You must be signed in to change notification settings - Fork 184
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
Repackage to latest boilerplate, Pi 5 + Bookworm compatibility #126
Conversation
Pull Request Test Coverage Report for Build 6877866546
💛 - Coveralls |
Co-authored-by: Phil Howard <[email protected]>
c269342
to
11c2188
Compare
FWIW I'll give this a test soon; requires me to rebuild the Pi Zero that's on my desk in my home office running an Enviro, but given this relates to a bug I'd previously raised, it is on my radar to get to it sometime shortly. |
That would be super appreciated, thank you. I don't have a Pi Zero set up for testing at the moment, so who knows what chaos might ensue. Right now some of the libraries only do GPIO detection for Pi 4 and Pi 5 so I suspect everything will break horribly and I'll need to fire up a Pi Zero to do some sleuthing. I have released ported versions of all the libraries Enviro depends upon, so things are probably more broken than when I started right now 😭 With gpiod the location and names of GPIO "lines" seems to be inconsistent across Pi platforms, and certainly inconsistent between Pi and ROCK, and I'm trying very hard not to write yet another Pi-specific unify-all-the-pins library since that will surely bite me later. |
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.
bd9a0ef
to
e6cd19c
Compare
I've had some fun on an old Pi Zero W - I forgot how pokey they are compared with 2W, but that's where my Enviro+ has been living. Fresh install of Bookworm needed a few additional packages (which may have been missing due to my choosing a lite version) - as a minimum
Also needed to manually I also found that calls to The sensors are now working, but anything that tries to use the LCD fails: $ python all-in-one-enviro-mini.py
2023-11-24 15:20:42.283 INFO all-in-one.py - Displays readings from all of Enviro plus" sensors
Press Ctrl+C to exit!
Woah there, suitable gpiochip not found!
❌ PIN21: not found - /dev/gpiochip0 (pinctrl-bcm2835)! For the sake of additional info, here's the output from $ pinctrl -p
1: 3v3
2: 5v
3: a0 -- | hi // GPIO2 = SDA1
4: 5v
5: a0 -- | hi // GPIO3 = SCL1
6: gnd
7: ip -- | hi // GPIO4 = input
8: ip -- | lo // GPIO14 = input
9: gnd
10: ip -- | hi // GPIO15 = input
11: ip -- | lo // GPIO17 = input
12: a0 -- | lo // GPIO18 = PCM_CLK
13: ip -- | hi // GPIO27 = input
14: gnd
15: ip -- | hi // GPIO22 = input
16: ip -- | lo // GPIO23 = input
17: 3v3
18: op -- -- | lo // GPIO24 = output
19: a0 -- | lo // GPIO10 = SPI0_MOSI
20: gnd
21: a0 -- | lo // GPIO9 = SPI0_MISO
22: ip -- | lo // GPIO25 = input
23: a0 -- | lo // GPIO11 = SPI0_SCLK
24: op -- -- | hi // GPIO8 = output
25: gnd
26: op -- -- | hi // GPIO7 = output
27: ip -- | hi // GPIO0 = input
28: ip -- | hi // GPIO1 = input
29: ip -- | hi // GPIO5 = input
30: gnd
31: ip -- | hi // GPIO6 = input
32: ip -- | lo // GPIO12 = input
33: ip -- | lo // GPIO13 = input
34: gnd
35: a0 -- | lo // GPIO19 = PCM_FS
36: ip -- | lo // GPIO16 = input
37: ip -- | lo // GPIO26 = input
38: a0 -- | lo // GPIO20 = PCM_DIN
39: gnd
40: a0 -- | lo // GPIO21 = PCM_DOUT Oh, and the PMS stuff has issues... $ python combined.py
2023-11-24 15:30:01.341 INFO combined.py - Displays readings from all of Enviro plus' sensors
Press Ctrl+C to exit!
Traceback (most recent call last):
File "/home/andypiper/enviroplus-python/examples/combined.py", line 43, in <module>
pms5003 = PMS5003()
^^^^^^^^^
File "/home/andypiper/.virtualenvs/pimoroni/lib/python3.11/site-packages/pms5003/__init__.py", line 109, in __init__
self._pin_enable, self._pin_reset = gpiodevice.get_pins_for_platform(PLATFORMS)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 0) ... but as you said, things are likely broken where the pins are not consistent, and the underlying libraries need ports... :-/ |
Thank you! I think both of these problems relate to missing pin definitions for Pi Zero. With any luck pushing out a new version of Looks like in the case of What do you see if you: cat and |
Note that $ gpioinfo
gpiochip0 - 54 lines:
line 0: "ID_SDA" unused input active-high
line 1: "ID_SCL" unused input active-high
line 2: "SDA1" unused input active-high
line 3: "SCL1" unused input active-high
line 4: "GPIO_GCLK" unused input active-high
line 5: "GPIO5" unused input active-high
line 6: "GPIO6" unused input active-high
line 7: "SPI_CE1_N" "spi0 CS1" output active-low [used]
line 8: "SPI_CE0_N" "spi0 CS0" output active-low [used]
line 9: "SPI_MISO" unused input active-high
line 10: "SPI_MOSI" unused input active-high
line 11: "SPI_SCLK" unused input active-high
line 12: "GPIO12" unused input active-high
line 13: "GPIO13" unused input active-high
line 14: "TXD1" unused input active-high
line 15: "RXD1" unused input active-high
line 16: "GPIO16" unused input active-high
line 17: "GPIO17" unused input active-high
line 18: "GPIO18" unused input active-high
line 19: "GPIO19" unused input active-high
line 20: "GPIO20" unused input active-high
line 21: "GPIO21" unused input active-high
line 22: "GPIO22" unused input active-high
line 23: "GPIO23" unused input active-high
line 24: "GPIO24" unused input active-high
line 25: "GPIO25" unused input active-high
line 26: "GPIO26" unused input active-high
line 27: "GPIO27" unused input active-high
line 28: "SDA0" unused input active-high
line 29: "SCL0" unused input active-high
line 30: "CTS0" unused input active-high
line 31: "RTS0" unused input active-high
line 32: "TXD0" unused input active-high
line 33: "RXD0" unused input active-high
line 34: "SD1_CLK" unused input active-high
line 35: "SD1_CMD" unused input active-high
line 36: "SD1_DATA0" unused input active-high
line 37: "SD1_DATA1" unused input active-high
line 38: "SD1_DATA2" unused input active-high
line 39: "SD1_DATA3" unused input active-high
line 40: "CAM_GPIO1" unused output active-high
line 41: "WL_ON" unused output active-high
line 42: "NC" unused input active-high
line 43: "WIFI_CLK" unused input active-high
line 44: "CAM_GPIO0" "cam1_regulator" output active-high [used]
line 45: "BT_ON" "shutdown" output active-high [used]
line 46: "HDMI_HPD_N" "hpd" input active-low [used]
line 47: "STATUS_LED_N" "ACT" output active-low [used]
line 48: "SD_CLK_R" unused input active-high
line 49: "SD_CMD_R" unused input active-high
line 50: "SD_DATA0_R" unused input active-high
line 51: "SD_DATA1_R" unused input active-high
line 52: "SD_DATA2_R" unused input active-high
line 53: "SD_DATA3_R" unused input active-high And I think sys should be proc for the other command... $ cat /proc/device-tree/model
Raspberry Pi Zero W Rev 1.1 (really really old and smol!) |
@Gadgetoid Hi. I have bought enviro. I'm trying it with Raspbery PI ZERO too. I have exactly the same issue for all-in-one-enviro-mini.py like andypiper: Are there any updates? When we can expect fix for this problem? How can I help you? Note: There are some issues for Bookworm with RPI Imager compatibility. It is not so easy to set Wifi connection profile during microSD card flashing via RPI Imager. I have spent a lot of time to be able flash microSD card for Bookworm with wifi connection profile - so I'm sharing my steps also here - https://raspberrypi.stackexchange.com/questions/144850/headless-wi-fi-setup-without-the-rpi-imager-bootfs-wpa-supplicant-conf-not-supp/145264#145264 Thanks |
The There's no longer any standard naming scheme for IO, since that was something that In most cases if The comments try, but fail, to make this clear: enviroplus-python/examples/lcd.py Line 24 in e6cd19c
I'll probably have to try and to platform detection and smooth over this. |
I'll take a look at this on my board tomorrow and see if I can "monkey-patch" for a Pi Zero at least. |
Thanks! I have checked the code and the only thing I have found is, that here https://github.com/pimoroni/gpiodevice-python/blob/main/gpiodevice/platform/pi.py is missing "pinctrl-bcm2835" :
But dont think it solves the problem. |
I should probably add this for completeness, but PMS5003 uses the platform set:
So any effort to auto-detect will fail, since I'm guessing If you could post the output of From tinkering elsewhere it looks like the GPIO banks and pins are named via the device tree overlays, I may be making a fatal mistake assuming they'll ever be consistent enough for me to do pin defaults across multiple libraries 😬 ... it's tricky balancing the "argh everything is broken I must fix this now" with the "I must fix this in an actually robust, future-proof way." |
Thanks! |
And some another findings:
and the output is: Woah there, suitable gpiochip not found! I tried to set all green GPIO numbers for |
I guess you should be using
(Sorry for the long delay, much-needed Christmas hols!) |
Thanks! This combination works on my RPI Zero:
But if I try I will give it a try on my RPI 4, too, if the problem persists also on RPI 4 8GB model |
* CI: Update GitHub Actions versions. * QA: Add shellcheck and fix/ignore all issues. * install.sh: slightly better feedback for setup commands.
* install.sh: fix quoting bug in do_config_backup. * install.sh: don't output printf commands.
Any update if this will be merged? |
Error during installation:
|
Ouch, that means the install script is effectively running:
Which results in:
Rather than the subtly different:
I have broken the apt package management somehow, and probably everywhere too 😬 Edit: Okay, I see it. sigh Also, on Bullseye the installer seems to mostly work save for:
Which I can't easily fix without abstracting the call to raspi-config. This change was made across these commits: |
608b2df
to
3db288d
Compare
As of raspberrypi/linux@bd9542b all downstream GPIO line names use the form GPIOn, and PIN_n is deprecated. Simplify code and examples to reflect this.
f071fb4
to
ee253e9
Compare
Quotes would cause a list of packages to be treated as a single package and lookup would fail. Reported-by: thirdr <[email protected]>
ee253e9
to
65c7e9d
Compare
Using This Branch
Hey ho, this is the first Pimoroni Python product - ignoring all of its library dependencies - to make a full transition to gpiod, virtual environments and the shiny new Pi 5.
As such, I'd really like your feedback!
To use this library:
A venv should be created for you, though this step will be skipped if you're already inside one (in theory).
Things to look out for:
/boot/firmware/config.txt
/boot/config.txt
is still a symlink to/boot/firmware/config.txt
- I thinksed
breaks this horribly~/Pimoroni
Some debugging steps:
gpioinfo
to see the state of your IO (needsapt install gpiod
)cat /proc/device-tree/model
sincegpiodevice
looks here to try and do per-platform pin setupTODO
Pre-requisites
gpiodevice-python
where it will fail quite cryptically if you try to look up a number rather than a pin label, eek!Need porting (maybe)
Gotchas
Caught in this port,
raspi-config nonint do_serial
has now changed to ignore the nonint flag and show a UI. Seems to have been split intodo_serial
anddo_serial_pi5
- https://github.com/RPi-Distro/raspi-config/blob/9ccd4bbe5eccaf09137cc42eefd18f95072c70f2/raspi-config#L1174-L1218