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

RPi 5 support(?) #106

Open
GuyPerets106 opened this issue Dec 24, 2023 · 20 comments
Open

RPi 5 support(?) #106

GuyPerets106 opened this issue Dec 24, 2023 · 20 comments

Comments

@GuyPerets106
Copy link

Hi , I'm using RPi 5 after using the same ws2812b strip on the RPi 4. It now says Hardware revision is not supported.
It is expected soon?
Thanks

@JustBKen
Copy link

JustBKen commented Oct 21, 2024

jgarff/rpi_ws281x#528 (comment)

RPI5 support is currently WIP in the original C code. It works, but is not not implemented in the mainline. Would be great if this fix is integrated into this repo.

@Gadgetoid
Copy link
Member

J. dropped me a heads up, and I've been watching the GitHub notifications flood in. Taking a bit of a back seat because I have so much else to do, but once it's in mainline I'm happy to bump the module here.

Possible we need a bunch of bugfixes to the bindings too, since the issues are piling up 🫠

@jgarff
Copy link

jgarff commented Oct 31, 2024

J. dropped me a heads up, and I've been watching the GitHub notifications flood in. Taking a bit of a back seat because I have so much else to do, but once it's in mainline I'm happy to bump the module here.

Possible we need a bunch of bugfixes to the bindings too, since the issues are piling up 🫠

In the meantime, it might be good to have a rpi5 branch that points to the rpi_ws281x C library rpi5 branch. Then folks could build it on that branch and it would work in Python without having to do submodule/copy tricks. I can help out there, but I don't know if I have permission to do this in the python repo.

@Gadgetoid
Copy link
Member

Gadgetoid commented Nov 1, 2024

In the meantime, it might be good to have a rpi5 branch that points to the rpi_ws281x C library rpi5 branch.

I did wonder, as I typed the above, if that would be a smart idea!

Edit: Turns out I'd long forgotten who set this org up and you'll need @penfold42 to give you write access!

@Gadgetoid
Copy link
Member

Tagged a release and hung some (untested) test builds here: https://github.com/rpi-ws281x/rpi-ws281x-python/releases/tag/pi5-beta1

Hopefully it just works, all my Pi 5s are busy! 😆 😬

@Gadgetoid
Copy link
Member

I've since tested and released a new build here: https://github.com/rpi-ws281x/rpi-ws281x-python/releases/tag/pi5-beta2

@GuyPerets106
Copy link
Author

GuyPerets106 commented Nov 18, 2024

I've since tested and released a new build here: https://github.com/rpi-ws281x/rpi-ws281x-python/releases/tag/pi5-beta2

I get this error when using the pip command in the link you provided:
ERROR: rpi_ws281x-6.0.0-cp311-cp311-linux_aarch64.whl is not a supported wheel on this platform.

I think it's due to the fact I'm using Python 3.12, and your whl file denotes cp311.

There is an expected time for a full release?

@timonsku
Copy link

On my install (after doing a apt upgrade) I get a RuntimeError: ws2811_init failed with code -3 (Hardware revision is not supported)
Though it is working with the C library test program. Is the python lib shipping its own copy of the library and maybe not using the Pi5 branch? Though not sure how it could have worked so far.
My Pi5 has a revision code 0xd04170

@timonsku
Copy link

timonsku commented Nov 18, 2024

Nevermind this was from an older install that snuck into system packages and not passing the venv path to sudo -E correctly.
If anyone else stumbles over this, this is how I run it:
sudo -E env PATH=$PATH python3 strandtest.py from the examples folder. Working well!

@Gadgetoid
Copy link
Member

There is an expected time for a full release?

🤷 this is based upon a development branch of rpi_ws281x discussed here ( jgarff/rpi_ws281x#528 ) so whenever that's merged, I guess!

I think it's due to the fact I'm using Python 3.12, and your whl file denotes cp311.

That'll probably do it. I don't know how compatible the bindings are but you could try just renaming the file to rpi_ws281x-6.0.0-cp312-cp312-linux_aarch64.whl iirc (I could easily be making this up) it actually parses the Python wheel filenames.

Unfortunately I can't connect to my build Pi right now to try cutting a 312 build, but you could try building from source.

@Tetrikus
Copy link

Tetrikus commented Nov 19, 2024

Unfortunately I'm still struggling with this installation. I've built the kernel driver, the device tree overlay, then loaded the kernel driver, as described here. The Installation went well and testing the C-Script was running as it should. After that, I installed the pi5-beta2 from here into the venv and it worked fine. Now, after a reboot, it stopped working again with the original message "Hardware revision is not supported".

File "/home/pi/venvpp/lib/python3.11/site-packages/rpi_ws281x/rpi_ws281x.py", line 135, in begin raise RuntimeError('ws2811_init failed with code {0} ({1})'.format(resp, str_resp)) RuntimeError: ws2811_init failed with code -3 (Hardware revision is not supported)

When I do all the steps again, it works again, until I reboot the device. What am I missing?

And for when it works, is there already a possibility to use multiple channels/GPIO pins for multiple strips at the same time? As far as I can see, the LED_PIN in the Strip Configuration of the Python script is just ignored at the moment, right?

@anico97as
Copy link

anico97as commented Nov 19, 2024

Hi i have done the steps but it unfortunately never works. After installing the kernel driver etc. the test c script works well. After that i installed beta version 6.0.0 into my virtual env. However i always get following error when calling my script:

Traceback (most recent call last):
  File "/home/fotobot/Desktop/fotobot/pylight.py", line 159, in <module>
    raise RuntimeError('ws2811_init failed with code {0} ({1})'.format(resp, message))
RuntimeError: ws2811_init failed with code -3 (Hardware revision is not supported)
swig/python detected a memory leak of type 'struct ws2811_t *', no destructor found.

My HW revision is = 7041c000

Is the lib correctly binded. When checking the .so with nm i get this bindings:

                  U usleep@GLIBC_2.17
00000000000303c0 D width
                 U write@GLIBC_2.17
000000000000bea0 T ws2811_channel_get
0000000000005f40 T ws2811_cleanup
0000000000006d00 T ws2811_fini
0000000000007270 T ws2811_get_return_t_str
0000000000006100 T ws2811_init
000000000000bbb0 T ws2811_led_get
000000000000bcf0 T ws2811_led_set
0000000000006de0 T ws2811_render
00000000000072a0 T ws2811_set_custom_gamma_factor
0000000000006c80 T ws2811_wait

Has somebody an idea?

@GuyPerets106
Copy link
Author

I think it's due to the fact I'm using Python 3.12, and your whl file denotes cp311.

That'll probably do it. I don't know how compatible the bindings are but you could try just renaming the file to rpi_ws281x-6.0.0-cp312-cp312-linux_aarch64.whl iirc (I could easily be making this up) it actually parses the Python wheel filenames.

After renaming the file it successfully installed it. But the examples (strandtest.py for example) won't work.
I did everything regarding the linux-headers/device tree overlay etc. and the test compiled C script runs fine.

The error I get is ModuleNotFoundError: No module named '_rpi_ws281x'

Just to be sure - when running sudo --preserve-env PATH python3 strandtest.py I should replace PATH python3 with something like sudo --preserve-env ~/.pyenv/versions/<MYENVNAME>/bin/python3 strandtest.py (I'm using pyenv for virtual evns)

@Gadgetoid
Copy link
Member

Just to be sure - when running sudo --preserve-env PATH python3 strandtest.py I should replace PATH python3 with something like sudo --preserve-env ~/.pyenv/versions/<MYENVNAME>/bin/python3 strandtest.py (I'm using pyenv for virtual evns)

@GuyPerets106 - PATH is the name of the environment variable to preserve, so it should just be sudo --preserve-env PATH python3 strandtest.py or you can sudo /home/<USER>/.pyenv/versions/<MYENVNAME>/bin/python3 strandtest.py which I believe has the same effect. You're preserving PATH so that sudo executes the venv Python rather than the system Python.

@Tetrikus - did you re-activate the virtual environment after rebooting?

@anico97as - are you using sudo --preserve-env PATH python3 strandtest.py to ensure you're actually running the virtualenv version of the package and not the system package?

@anico97as
Copy link

anico97as commented Nov 20, 2024

hi @Gadgetoid,
thanks for your reply. I solved that by repeating following steps:

    Loading the kernel module from the driver directory. Use the pwm_channel from the GPIO list above. The following example applies to GPIO 14 and 18.

        $ sudo insmod ./rp1_ws281x_pwm.ko pwm_channel=2

    Loading the device tree overlay. This will initialize the device.

        $ sudo dtoverlay -d . rp1_ws281x_pwm

    Setting up the GPIO (for GPIO 18). Use the GPIO number and aX parameter from the list above.

        $ sudo pinctrl set 18 a3 pn

After that it was not a problem to control my 8x32 matrix.
However I can confirm what @Tetrikus said, after a reboot i will again get the error "Hardware revision is not supported...". Then I have to repeat above mentioned steps in order to get it working until the next reboot.

Could it be that the device tree overlay or kernel module is not persisted somehow and that it will not be loaded by the kernel by default?

@GuyPerets106
Copy link
Author

Just to be sure - when running sudo --preserve-env PATH python3 strandtest.py I should replace PATH python3 with something like sudo --preserve-env ~/.pyenv/versions/<MYENVNAME>/bin/python3 strandtest.py (I'm using pyenv for virtual evns)

@GuyPerets106 - PATH is the name of the environment variable to preserve, so it should just be sudo --preserve-env PATH python3 strandtest.py or you can sudo /home/<USER>/.pyenv/versions/<MYENVNAME>/bin/python3 strandtest.py which I believe has the same effect. You're preserving PATH so that sudo executes the venv Python rather than the system Python.

So unfortunately it does not work, because I did just that :/
I get an error about the module not found, so probably I miss a step(?)
It seems that it can't find the _rpi_ws281x module - you know what it's related to?

Thanks for the help!

@Gadgetoid
Copy link
Member

So unfortunately it does not work, because I did just that :/ I get an error about the module not found, so probably I miss a step(?) It seems that it can't find the _rpi_ws281x module - you know what it's related to?

@GuyPerets106 - Sorry too many crossed wires and I forgot to properly respond to you here. I'm pretty sure this is because the .so file that contains the _rpi_ws281x C part of the module is still named _rpi_ws281x.cpython-311-aarch64-linux-gnu.so. You could probably rename that in the same way, using pip show rpi-ws281x to find where it's installed.

I'll cut a proper 3.12 build in the meantime. (Raspberry Pi OS bookworm is still on 3.11, are you using another OS?)

@Tetrikus
Copy link

Tetrikus commented Nov 21, 2024

@Tetrikus - did you re-activate the virtual environment after rebooting?

Yes, I've re-activating it after rebooting and have the same issue every time.

@GuyPerets106
Copy link
Author

@GuyPerets106 - Sorry too many crossed wires and I forgot to properly respond to you here. I'm pretty sure this is because the .so file that contains the _rpi_ws281x C part of the module is still named _rpi_ws281x.cpython-311-aarch64-linux-gnu.so. You could probably rename that in the same way, using pip show rpi-ws281x to find where it's installed.

I'll cut a proper 3.12 build in the meantime. (Raspberry Pi OS bookworm is still on 3.11, are you using another OS?)

I created a new 3.11 venv and tested it again. It works (thank you!) but just one time for some reason. When I run sudo --preserve-env /home/pi/.pyenv/shims/python3 strandtest.py and then try to run again, the script itself runs in the terminal but nothing happens on the LEDs.

Also, I have the same issue @Tetrikus experiencing when rebooting the device and have to go over all the setup again to make it work.

@Gadgetoid
Copy link
Member

@Tetrikus @GuyPerets106 oh the other thing I recall from the setup guide is that it tells you to load and configure the overlays once in a way that doesn't stick, ie:

sudo insmod ./rp1_ws281x_pwm.ko pwm_channel=2
sudo dtoverlay -d . rp1_ws281x_pwm
sudo pinctrl set 18 a3 pn

The inserted module, dtoverlay and pinctrl changes will reset at reboot. It should be possible to make a dtoverlay (to be loaded via config.txt) that sets the pin state correctly and loads and configures the module, taking PWM channel and pin as an argument but that's an upstream and not a Python problem.

For now... you'll need to repeat at least those commands on every boot.

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

7 participants