-
Notifications
You must be signed in to change notification settings - Fork 626
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
Support for Raspberry Pi 5 #528
Comments
The Pi 5 has significant hardware changes that might make some of this library difficult or impossible to migrate. I’m not qualified to know exactly how bad it is, but the changes are significant enough that a straight hardware ID addition isn’t going to cut it. We need one of the wizards involved in writing or extending the core functionality of rp_ws281x to step in and give us the lowdown. I’ve talked to folks at Pi about creating a PIO-backed WS281X library for RP1, but there’s no telling when it if that - or the tools to make it happen - will materialise. |
I've definitely been wanting to add support for that, if possible.
Unfortunately, I don't yet have a RPi 5 to actually work on.
Jeremy
…On Sat, Nov 4, 2023 at 5:14 AM Thomas Pötz ***@***.***> wrote:
Hi,
I just got a Raspberry Pi 5 and am getting an error that my hardware
revision is not supported.
Can someone please add support for the Raspberry Pi 5 or give me a
guideline on how to do it myself?
I'd greatly appreciate it.
Best regards,
Thomas
—
Reply to this email directly, view it on GitHub
<#528>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACB55G3XJNYO3S4VOUTRPTTYCYPQ3AVCNFSM6AAAAAA65QFT3CVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE3TOMRYGY2TANQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Wow, of all the things I expected- it wasn't the big guns! I hope you're well.
That's something I can probably fix if you want to give support a shot! |
Hi Phillip! I'm good, thanks! I'm on a waiting list to get a RPi 5, but I
have no idea when it'll ship. I'm definitely willing to give support a
shot. Sounds kinda fun. Any help you can offer is greatly appreciated!
…On Mon, Nov 6, 2023 at 6:16 AM Philip Howard ***@***.***> wrote:
I've definitely been wanting to add support for that, if possible.
Wow, of all the things I expected- it wasn't the big guns! I hope you're
well.
Unfortunately, I don't yet have a RPi 5 to actually work on.
That's something I can probably fix if you want to give support a shot!
—
Reply to this email directly, view it on GitHub
<#528 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACB55GY2FJAJXYR2DBDML4DYDDPJFAVCNFSM6AAAAAA65QFT3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJUHAYDIOJSHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@jgarff If you are in Us/Canada, I can send you a RPi5 to support the port and any other way I can support this. I am getting a similar issue:
|
Hi @jgarff , I tried to add HW spec and debug the library (with //
// Raspberry Pi 5
//
{
.hwver = 0xc04170,
.type = RPI_HWVER_TYPE_PI5,
.periph_base = PERIPH_BASE_RPI4,
.videocore_base = VIDEOCORE_BASE_RPI2,
.desc = "Pi 5 Model B - 4GB 1.0"
}, where Lines 939 to 940 in 1f47b59
here is the dmesg output for that request:
And ioctl errno corresponds to I know nothing about RPi (this is my first device) and mailboxes etc. but I tried to run a simpler code (
And I don't know if any of these helps to diagnose the issue, but I wanted to post my findings. If this issue seems to be resolved quickly, I would like to help it (but it seems way beyond my knowledge). |
That would be fantastic! I'm hoping to get a little time over the holidays
to work on this a bit.
…On Wed, Nov 8, 2023 at 11:22 AM Ubo Project ***@***.***> wrote:
@jgarff <https://github.com/jgarff> If you are in Us/Canada, I can send
you a RPi5 to support the port and any other way I can support this. I am
getting a similar issue:
raise RuntimeError(
RuntimeError: ws2811_init failed with code -3 (Hardware revision is not supported)
—
Reply to this email directly, view it on GitHub
<#528 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACB55G6US4J3ASQFP2KZOY3YDPEX5AVCNFSM6AAAAAA65QFT3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBSGQZDENRWGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Do you mind sending me an email to mehrdad@getubo.com so that I can arrange to have one shipped to you? |
I've now got hardware to play with. Many many thanks to @ubopod for the very generous donation! I've started looking into it, and have found the following so far:
I'll keep you guys posted with updates. Please be patient though, as I'm fairly busy, but hoping to work more on this over the holidays. |
Just a quick update.
|
I was playing for a few hours with attempting (unsuccessfully) a port to work on the Pi 5. I can confirm that most of the videocore firmware mailbox interfaces have been ripped out (https://forums.raspberrypi.com/viewtopic.php?t=359477) so definitely you need to drop that whole mechanism. Another thing is the peripheral base address is now 0x107c000000 (instead of 0xfe000000 as on the Pi 4). I believe the new RP1 DMA/PIO will have to be configured through registers in that space, and because it's a base address over the 32-bit limit, you may need to |
Thanks @mbevand for the info. Since the RP1 is connected via PCIe, doesn't the base of the registers land in a PCIe BAR?
Are they remapping that somewhere else (0x107c000000?) in the rp1 driver? |
It doesn't conflict. Because the mapping goes from Per my understanding the mapping at |
I'm not worried about a conflict. What I'm suggesting is that the peripherals that are built into the bcm2712 (dma/pcm/pwm/etc.) are no longer being used on the Pi5. Instead the GPIOs are now wired to the RP1, not the SoC. The RP1 in turn is available to the SoC over PCIe, with all the registers mapped inside a RP1 BAR. Basically we can't use the peripherals in the 2712 anymore as they aren't wired to the actual pins anymore. Seeing a schematic would be nice though. :) |
Doh! I wasn't thinking straight. You are right, of course. The register region at |
No worries. I wish you were right. This would be much easier if the pins were still connected to the SoC IP. |
I don't know if that's useful or if you already know it, but the BAR can be accessed through sysfs. I wrote this sample code that shows how to read the FIFO_CTRL register of PWM0 on RP1. On my Pi 5 it prints
|
Thanks. I'm well aware of these mechanisms. The tricky part isn't
register access. It's the dma.
…On Tue, Dec 5, 2023, 5:48 PM mbevand ***@***.***> wrote:
I don't know if that's useful or if you already know it, but the BAR can
be accessed through sysfs. I wrote this sample code that shows how to read
the FIFO_CTRL register of PWM0 on RP1. On my Pi 5 it prints FIFO_CTRL:
20000 since that's the default value of this register, as per page 39 of
https://datasheets.raspberrypi.com/rp1/rp1-peripherals.pdf :
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <assert.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#define OFFSET_PWM0 0x98000
#define OFFSET_PWM1 0x9c000
#define PWM_GLOBAL_CTRL 0x00
#define PWM_FIFO_CTRL 0x04
uint32_t my_read(void *base, ssize_t count, uint32_t offset)
{
assert(count == 4);
return *(uint32_t *)((uint8_t *)base + offset);
}
int main() {
const char *fname = "/sys/bus/pci/devices/0000:01:00.0/resource1";
void *base;
int fd;
uint32_t reg;
if (-1 == (fd = open(fname, O_RDWR)))
perror("open"), exit(1);
base = mmap(NULL, 0x400000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (base == MAP_FAILED)
perror("mmap"), exit(1);
if (-1 == close(fd))
perror("close"), exit(1);
reg = my_read(base, 4, OFFSET_PWM0 + PWM_FIFO_CTRL);
printf("FIFO_CTRL: %x\n", reg);
return 0;
}
—
Reply to this email directly, view it on GitHub
<#528 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACB55G3QZE22TIHHP7R34DTYH66GVAVCNFSM6AAAAAA65QFT3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBRHA4TEMRYGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hey guys, i've got the same issue. is there already a solution? Maybe an update for the RPI_WS281x? |
Hallo Jeremy, did you make any progress on this for the PI5, we are looking forward to it if you can fix it to get it working again. Thanks Raymond |
Hi Raymond, I was able to work on this some over the holidays. I have some open questions in a developer forum regarding the DMA that I'm hoping can be answered. Unfortunately, the specs available thus far are lacking in specific functionality of the RP1. Some of which are tied up behind non-public specifications for intellectual property from third parties used in the RP1. |
Thank you for your fast response, let hope they respond, this makes the use of the pins not very usefull anymore if the cannot be addressed as in the PI4 and older versions.
Raymond
From: Jeremy Garff ***@***.***>
Sent: Tuesday, 2 January 2024 17:18
To: jgarff/rpi_ws281x ***@***.***>
Cc: Raymond Garnier ***@***.***>; Manual ***@***.***>
Subject: Re: [jgarff/rpi_ws281x] Support for Raspberry Pi 5 (Issue #528)
Hi Raymond, I was able to work on this some over the holidays. I have some open questions in a developer forum regarding the DMA that I'm hoping can be answered. Unfortunately, the specs available thus far are lacking in specific functionality of the RP1. Some of which are tied up behind non-public specifications for intellectual property from third parties used in the RP1.
—
Reply to this email directly, view it on GitHub<#528 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEFBLSKPAHWAAME4OIUC74TYMQXLDAVCNFSM6AAAAAA65QFT3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZUGIZTQMBVHE>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.******@***.***>>
|
@jgarff Thanks again for the efforts! I hope the necessary information come out soon. If you link to relevant developer forum questions here, we can collectively try to get that information for Raspberry Pi. I have a few contacts in the commercial side and can also ask around to get more attention to it. |
That would be great @mehrdadfeller. The specific questions I have are as follows:
|
Thanks guys, this was also the problem i experienced
A3 works
Now only need to figure out how to get then python working😂
Sent from Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Jeremy Garff ***@***.***>
Sent: Thursday, October 31, 2024 7:43:10 PM
To: jgarff/rpi_ws281x ***@***.***>
Cc: Raymond Garnier ***@***.***>; Mention ***@***.***>
Subject: Re: [jgarff/rpi_ws281x] Support for Raspberry Pi 5 (Issue #528)
Hey Jeremy, thanks for all the hard work on supporting raspberry pi5. We tested it and managed to make it work, there are however a few typos in the wiki page<https://github.com/jgarff/rpi_ws281x/wiki/Raspberry-Pi-5-Support#choosing-the-correct-pwm-channel>. According to the rp1 datasheet<https://datasheets.raspberrypi.com/rp1/rp1-peripherals.pdf>, the functions for the PWM ong GPIO 18 and 19 should be a3, not a2. The other gpios functions are OK. We confirm that it works when we use $ sudo pinctrl set 18 a3 pn But fails when we use $ sudo pinctrl set 18 a2 pn like it is mentionned in the doc.
Thanks !
Thank you very much for letting me know about the typo on the Wiki page. I will get that fixed right now. It's also great to know that you're able to make it work successfully. Thanks again.
—
Reply to this email directly, view it on GitHub<#528 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEFBLSPLHJP5JOQIQEPNA7TZ6J235AVCNFSM6AAAAAA65QFT3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJQGU4DONZXGA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
😅 |
With the Python bindings the closest I can get is:
I clearly have some catching up to do! Edit: Okay, now I have found and followed the wiki it appears to work for some examples but not others. Unicorn HAT's "demo.py" has never been so smoooth. The above error still happens for rainbow.py and for the lowlevel.py shipped with rpi-ws281x-python. Some debugging to do! Edit - again: Okay so the malloc() issue is due to the library zero-initing both channels, if I drop that it works for all examples. It's bizarre that it only fails for some, and that it's very consistent about which ones it fails for. The setup is no different between them. New test release: https://github.com/rpi-ws281x/rpi-ws281x-python/releases/tag/pi5-beta2 |
Great work from everyone on this! |
Worth a try, though I do wonder if this should (or even could?) lean on the RP1 PIO driver when it's ready. |
I'm _extremely_ interested in getting this into the kernel. I think it's
still useful as is, because it would free the PIO to be used for other
things at the same time. As soon as I get the other channels working, I'll
have the driver ready to submit a PR.
Thanks,
Jeremy
…On Mon, Nov 4, 2024 at 3:54 PM Philip Howard ***@***.***> wrote:
I'm sure they would be open to merging that in. Happy to help the process
if needed.
Worth a try, though I do wonder if this should (or even could?) lean on
the RP1 PIO driver when it's ready.
—
Reply to this email directly, view it on GitHub
<#528 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACB55G5QCCHT5IPCBKGSXCLZ673JNAVCNFSM6AAAAAA65QFT3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJVHA3DKNBQHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yea I think both would definitely be useful! |
Hallo Jeremy
I hope you can help me out,
Building the python versions gives me this output. I am not able to get this up and running
***@***.***://home/rpi_ws281x/rpi-ws281x-python/library# sudo /home/Display/.venv/bin/pip install .
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing /home/rpi_ws281x/rpi-ws281x-python/library
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: rpi_ws281x
Building wheel for rpi_ws281x (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for rpi_ws281x (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
running bdist_wheel
running build
running build_py
Compiling ws281x library...
copying rpi_ws281x/rpi_ws281x.py -> build/lib.linux-aarch64-cpython-311/rpi_ws281x
copying rpi_ws281x/__init__.py -> build/lib.linux-aarch64-cpython-311/rpi_ws281x
running build_ext
building '_rpi_ws281x' extension
aarch64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I. -I/home/Display/.venv/include -I/usr/include/python3.11 -c lib/dma.c -o build/temp.linux-aarch64-cpython-311/lib/dma.o
cc1: fatal error: lib/dma.c: No such file or directory
compilation terminated.
error: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for rpi_ws281x
Failed to build rpi_ws281x
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (rpi_ws281x)
|
root@00000002:/home/rpi_ws281x/rpi-ws281x-python/examples# sudo /home/Display/.venv/bin/python strandtest.py |
Looks like the old version is not updated with new code. root@00000002:/home/rpi_ws281x/rpi-ws281x-python/examples# sudo /home/Display/.venv/bin/pip show rpi_ws281x |
Needs the Pi 5 branch of the bindings - https://github.com/rpi-ws281x/rpi-ws281x-python/tree/pi5 Don’t forget to Prebuilt wheels also available https://github.com/rpi-ws281x/rpi-ws281x-python/releases/tag/v5.0.0 |
Thanks to everyone for the efforts to bring the library to the Pi 5! Much appreciated!! 🙏🏼 I tried to follow the discussion here. Did I get that right, that it is currently only possible to use GPIO 18? And if yes, what would I do, if I need Audio at the same time? 🤔 Just not possible right now? |
Please see the wiki. The restriction on pin 18 is fixed. You can use one of pins 12, 13, 14, 15, 18, 19 now. https://github.com/jgarff/rpi_ws281x/wiki/Raspberry-Pi-5-Support |
Oh, my bad! Thank you so much! Might be a good idea to remove or edit this in the introduction of the wiki page. It confused me. 😇
|
Hi @jgarff, thanks for your efforts regarding PI5 suport. `
` The $DISPLAY will be unset and my application will not recognize the attached touchscreen i have on my PI5. Before performing the steps mentioned above the contents of the $DISPLAY variable are as usual :0. After those steps the variable is unset. Do you maybe have any idea what the issues here could be? Thank you very much |
PIO support has now also been made public: https://github.com/raspberrypi/utils/blob/master/piolib/examples/ws2812.c |
Hi @jgarff, I assume you're preparing concurrent channel PWM support (you updated the wiki 3 weeks ago). I've tried preparing your kernel driver to be merged to Pi Kernel upstream (*). See: https://github.com/ragazenta/raspi-linux/commits/pwm-ws281x-rp1/ I'm not sure this should go to I have several requests, to make the patches series simpler, hopefully you can address:
PS: |
Hello,
I upgraded everything with apt before I tried anything. |
Is there any chance of making this work nicely with the OctoPrint plugin WS281x_LED_Status so that root access / building a kernel module isn't required? |
Yeah. Although I'm hoping to have more time to finish that up over the holidays.
That's great! I'd be happy to merge our changes together to submit it.
Using driver/pwm sounds more appropriate to me actually.
Sure, those sound like good changes to me. Thanks! |
I'm not sure what might be the problem without more information here. First I assume this is a Pi5, 64-bit OS, etc.? I would be good if you could help describe your exact setup. |
Unfortunately, having root (for non Pi5 systems) is absolutely required to get to the hardware blocks needed. As for running without a kernel module on a Pi5, that's also not possible. A device driver is required. Having said that, it is possible for you to change the permissions on the device file (on a Pi5 w/kernel module), and then run the userspace application non-root. I haven't tried that, but I think it should work. This could be done using a udev rule or something. |
I'm not sure why the DISPLAY variable would change. There is nothing in those commands that I'm aware of that would cause this. I suspect it might be something else in your setup. In any event, it might be worthwhile to save it off before those commands and restore it afterwards if you're having trouble. |
Yes Pi5 4Gb with 64bit OS lite. Some changes have been made to the config.txt (few overlays in use, maybe that's the problem). I'll test do those affect. |
Got it working! Seems like the problem was dtoverlay=pwm on config.txt |
Just in case its useful Raspberry Pi recently posted information about a official userspace library called pioLib with examples of driving addressable leds among other things. https://www.raspberrypi.com/news/piolib-a-userspace-library-for-pio-control/ |
Raspberry Pi now has official PIO driver for WS2812 LEDs: raspberrypi/linux@d6d83ad |
I understand that there is a PIO driver now. That's great. I still think there are a couple things that I think keep this module still worth while as follows:
|
Is this for either the piolib userspace driver or the ws2812 led driver as I did not find any mention of this? |
Hi,
I just got a Raspberry Pi 5 and am getting an error that my hardware revision is not supported.
Here is some hardware information from
cat /proc/cpuinfo
:I also ran this coding to get
paddr=10, baddr=C0000000
.I hope someone can use this information to add a new hardware type and support for the Raspberry Pie 5 🙂
I unfortunately don't know C and have no clue about hardware, so I can't create a PR myself.
Best regards,
Thomas
The text was updated successfully, but these errors were encountered: