raspberrypi / bookworm-feedback

14 stars 1 forks source link

CE0 and CE1 no longer usable on the Pi 5 in Python #179

Closed makermelissa closed 5 months ago

makermelissa commented 11 months ago

I'm not 100% sure this is the correct place, but since the Python error is an OSError, it seems to make sense.

When trying to access CE0 or CE1 via Python libgpiod bindings, I get OSError: [Errno 16] Device or resource busy. It works fine on a Pi 4 using the exact same SD card, so it seems to be a combination of OS and Hardware. If I try using gpiozero, I get "GPIO busy", which is essentially the same error.

I am just trying to run a simple script to toggle the GPIO on and off.

I have no device tree overlays loaded and using the lite version of the OS. SPI is enabled, but not actively being used.

makermelissa commented 11 months ago

I forgot to mention I have SPI enabled and can access the GPIO when it is disabled, but then SPI isn't available.

makermelissa commented 11 months ago

I did find a potential solution:

  1. I added dtoverlay=spi0-0cs to the bottom of /boot/firmware/config.txt
  2. I rebooted

After that code worked.

holmesha commented 11 months ago

@makermelissa Is that all you did? I have the same error when trying to use an Adafruit EYESPI beret for a display and still get the same error for the CE0. Nothing else could be using that pin...But when I run gpioinfo I see CE0 and CE1 are in use...

Tried your fix/reboot and still get the error...

holmesha commented 11 months ago

oooh I wonder if this is the solution? I haven't done this before so am worried I will mess up my gpio pins...

makermelissa commented 11 months ago

Yep, I updated that script so you can disable their usage by the OS. All it does is place the correct dtoverlay into the config along with parameters if needed. You can always just remove the dtoverlay from the config and it will go back to normal.

holmesha commented 11 months ago

Got it, thank you. Unfortunately that line alone in the config.txt file didn't seem to solve the issue for me.

holmesha commented 11 months ago

Actually never mind, I reloaded the Blinka library and it worked like a charm! Thank you for posting this Melissa! I thought I was going crazy...

lurch commented 5 months ago

Sounds like this has been solved / worked-around? So closing...