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

pigpio will not run on a Pi 5 #589

Open
JinShil opened this issue Nov 7, 2023 · 24 comments
Open

pigpio will not run on a Pi 5 #589

JinShil opened this issue Nov 7, 2023 · 24 comments

Comments

@JinShil
Copy link

JinShil commented Nov 7, 2023

pigpio is hard-coded to not run on a Pi5. See

pigpio/pigpio.c

Lines 7353 to 7356 in c33738a

"+---------------------------------------------------------+\n" \
"|Sorry, this system does not appear to be a raspberry pi. |\n" \
"|aborting. |\n" \
"+---------------------------------------------------------+\n\n");

Do the maintainers plan to update pigpio to support the Pi5? Will this repository entertain pull requests to port pigpio to the pi5?

If not, please update the README and/or archive this repository to let users know.

@guymcswain
Copy link
Collaborator

or archive this repository to let users know

... seems fairly rash given the installed base of a bazillion working devices vs the literal handful of pi5.

Do the maintainers plan to update pigpio to support the Pi5?

I have the aspiration to do so but my first quick read of the available docs suggest this will be a huge task, if not impossible without breaking compatibility.

Will this repository entertain pull requests to port pigpio to the pi65?

Given the potentially monumental task, I think it would be wise to lean into the community for help. At a minimum, we would want to retain architectural oversight of the project.

@sworteu
Copy link

sworteu commented Nov 7, 2023

@guymcswain what would be so different between thos pi's 4 and 4 ? Isn't the pi meant to be backwards compatible?
I'm basicly having the same banner on the systemd pigpiod run (it fails with the same message). All other gpio (raspi-gpio) also fail except for sysfs..

@guymcswain
Copy link
Collaborator

@sworteu pi4 is supported. You need to open a separate issue and give details around the failure.

Isn't the pi meant to be backwards compatible?

Yes but this meaning ends at the os level. pigpio touches the metal.

@sworteu
Copy link

sworteu commented Nov 8, 2023

i tried libgpiod and that seems to work..;)
https://kernel.googlesource.com/pub/scm/libs/libgpiod/libgpiod/+/v0.2.x/README.md
installed trough: sudo apt install gpiod
Note this is not pigpiod but gpiod.
Perhaps some dev may find this useful to resume pigpiod.

@ebaauw
Copy link

ebaauw commented Nov 8, 2023

Maybe better to list the full log:

Nov 08 17:18:45 pi15 systemd[1]: Started pigpiod.service - Daemon required to control GPIO pins via pigpio.
Nov 08 17:18:45 pi15 pigpiod[2059]: 2023-11-08 17:18:45 gpioHardwareRevision: unknown rev code (d04170)
Nov 08 17:18:45 pi15 pigpiod[2059]: 2023-11-08 17:18:45 initCheckPermitted:
Nov 08 17:18:45 pi15 pigpiod[2059]: +---------------------------------------------------------+
Nov 08 17:18:45 pi15 pigpiod[2059]: |Sorry, this system does not appear to be a raspberry pi. |
Nov 08 17:18:45 pi15 pigpiod[2059]: |aborting.                                                |
Nov 08 17:18:45 pi15 pigpiod[2059]: +---------------------------------------------------------+
Nov 08 17:18:45 pi15 pigpiod[2059]: Can't initialise pigpio library

Looks like the revision code for the Pi 5 isn't whitelisted. This is the 8GB model; I think the 4GB model uses c04170.

@ebaauw
Copy link

ebaauw commented Nov 8, 2023

Or more precisely, the code for the BCM2712.

pigpio/pigpio.c

Lines 13791 to 13830 in c33738a

switch ((rev >> 12) & 0xF) /* just interested in BCM model */
{
case 0x0: /* BCM2835 */
pi_ispi = 1;
piCores = 1;
pi_peri_phys = 0x20000000;
pi_dram_bus = 0x40000000;
pi_mem_flag = 0x0C;
break;
case 0x1: /* BCM2836 */
case 0x2: /* BCM2837 */
pi_ispi = 1;
piCores = 4;
pi_peri_phys = 0x3F000000;
pi_dram_bus = 0xC0000000;
pi_mem_flag = 0x04;
break;
case 0x3: /* BCM2711 */
pi_ispi = 1;
piCores = 4;
pi_peri_phys = 0xFE000000;
pi_dram_bus = 0xC0000000;
pi_mem_flag = 0x04;
pi_is_2711 = 1;
clk_osc_freq = CLK_OSC_FREQ_2711;
clk_plld_freq = CLK_PLLD_FREQ_2711;
hw_pwm_max_freq = PI_HW_PWM_MAX_FREQ_2711;
hw_clk_min_freq = PI_HW_CLK_MIN_FREQ_2711;
hw_clk_max_freq = PI_HW_CLK_MAX_FREQ_2711;
break;
default:
DBG(DBG_ALWAYS, "unknown rev code (%x)", rev);
rev=0;
pi_ispi = 0;
break;
}

I would create a PR, but I don't know what values to provide. I suspect the BCM2711 values won't work, now that GPIO is handled by the RP1 southbridge?

@guymcswain
Copy link
Collaborator

pi5 is not supported by pigpio. pi5 is built with a new chip architecture that is incompatible with previous iterations.

@huesla
Copy link

huesla commented Nov 12, 2023

Some thoughts of a user:
Perhaps one could evaluate which features still work on the Pi5 and which do not, and then create a slimmed-down PiGpio version just for the Pi5, to which the (still) missing features are gradually added. This would destroy backwards compatibility, but it would allow users to use still working features (if available) right away and at the same time create a basis for the future.
Unfortunately, I do not have the expertise to support in the development. I am using PiGpio only, especially I2C and Wave Pulsing.

@pelwell
Copy link

pelwell commented Nov 12, 2023

Although I recommend the use of libgpiod, for direct hardware access you may find the RP1 support in pinctrl (https://github.com/raspberrypi/utils) useful as a starting point.

@guymcswain
Copy link
Collaborator

guymcswain commented Nov 14, 2023

... create a slimmed-down PiGpio version just for the Pi5, to which the (still) missing features are gradually added.

I would generally agree with this strategy, however, there are features/capabilities of pigpio that distinguish it from all other gpio libraries: the DMA read engine for sampling gpio and the DMA write engine for pwm, servo and custom waveforms. I have not taken the time to look into it yet but I'm hoping there exists compatible interfaces on Pi5 such as the VPU mailbox registers allowing the DMA peripheral (and supporting peripherals to pace DMA) to be memory mapped. If a more kernel friendly approach is available, that should be explored as well.

@Brunnian
Copy link

I have just experienced this problem too

gpioHardwareRevision: unknown rev code (d04170)

so I am currently snookered

@dhrynyk
Copy link

dhrynyk commented Mar 21, 2024

Simply, I would like to add that I would appreciate seeing pigpio support the Pi 5.

In addition, I would be happy to provide testing support for any update to pigpio. While I'm not familiar with the architecture and design of pigpio, I would be willing to contribute to the development of the Pi 5 support.

@samskiter
Copy link

Is there a beer/coffee fund to which one could contribute to support RPi5 development? Appreciate it's a monumental task, but this is an excellent library and it would be a shame to see the ecosystem of RPi GPIO libraries grow ever larger!

standards

@alessandromrc
Copy link

Between this repo https://github.com/G33KatWork/RP1-Reverse-Engineering and the pinctrl source, it shouldn't be too hard to implement basic GPIO features... on the other hand, re-implementing servo control etc can become a little harder...

@SonoraTechnical
Copy link

IS rpi-lgpio a near drop in replacement for basic functionality?
Can we do this?
sudo apt remove python3-rpi.gpio
pip3 install --break-system-packages rpi-lgpio

@gitphoex
Copy link

gitphoex commented Jun 5, 2024

Is there a beer/coffee fund to which one could contribute to support RPi5 development? Appreciate it's a monumental task, but this is an excellent library and it would be a shame to see the ecosystem of RPi GPIO libraries grow ever larger!

I don't mind contributing to coffee/beer or even a fancy dinner fund to support this project. Just put up a buy me a coffee link or may be setup Github Sponsors

@guymcswain
Copy link
Collaborator

Is there a beer/coffee fund to which one could contribute to support RPi5 development? Appreciate it's a monumental task, but this is an excellent library and it would be a shame to see the ecosystem of RPi GPIO libraries grow ever larger!

Beer and coffee are not the problem. I'd do it for free if the Raspberry Pi Foundation would publish APIs to access the internal peripherals - like DMA in particular - and memory mapping IO. All of this was done using a mailbox interface to the VC processor in generations 1-4. That's all changed in gen 5. Thus, a new standard (architecture).

@dhrynyk
Copy link

dhrynyk commented Jun 26, 2024 via email

@guymcswain
Copy link
Collaborator

Unfortunately, I don't have any working relationship or contacts within the foundation. The author of this library, @joan2937, perhaps does.

@pelwell
Copy link

pelwell commented Jun 26, 2024

  1. It's not the Foundation - it's the engineering company Raspberry Pi Ltd. that you would need to talk to, but...
  2. I don't know which API you are referring to. Most of pigpio does direct accesses to the hardware from userspace. The datasheet for RP1 (responsible for the user-facing GPIOs on Pi 5) is available, as is the source code for pinctrl - the replacement for raspi-gpio that also does direct hardware accesses.
  3. I don't think you should ping Joan - if they wanted to be involved with Pi 5 they would have by now.

@guymcswain
Copy link
Collaborator

Thanks Phil, the problem is not the gpio control but all of the DMA control that is at the core of pigpio. All that was done through facilities known as mailbox registers via the video core processor. All is that is gone with pi5.

It will be a huge lift to rewrite the core part of this library and a non starter if there is no assurance that it changes again in the future.

People smarter than me wrote this code. I’d be happy to take a look if someone could point me to documentation that allows the same functionality on the pi5.

@pelwell
Copy link

pelwell commented Jun 27, 2024

With Pi 5 the role of the firmware has reduced. Apart from some basic power and clocks management, its job is basically to load the kernel and get out of the way. Having said that, I think it's only the memory allocation that is performed by the firmware - there is no "DMA this data to here" API. Since RP1 has access to all of system RAM there is no need for a special allocator.

AFAIK we aren't permitted to publish the documentation for the Synopsys DMA controller, but the Linux driver is available as executable documentation: https://github.com/raspberrypi/linux/blob/rpi-6.1.y/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c

@JinShil
Copy link
Author

JinShil commented Jun 27, 2024

@pelwell I think the DMA feature that is being referred to here is the clever usage of it to achieve hardware timed PWM. See https://stackoverflow.com/a/53033272/539972

PIO is supposed to come to the Pi5, right? If so, I think that would make pigpio less relevant for the Pi5, or at least provide a way to implement the features that pigpio currently provides for the Pi4 and earlier.

@John-Smiths
Copy link

在 py 中使用gpiod

apt update && apt upgrade && pip install gpiod && apt install libgpiod-dev

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