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

lgpio.error: 'GPIO not allocated' #26

Closed
akza opened this issue Nov 9, 2024 · 12 comments
Closed

lgpio.error: 'GPIO not allocated' #26

akza opened this issue Nov 9, 2024 · 12 comments

Comments

@akza
Copy link

akza commented Nov 9, 2024

I am running a Raspberry PI 2W with a 4.2inch Waveshare (Rev2.2)
So far, I have followed all the instructions, and triple checked my pin setup

when trying to execute
sudo python main.py

I get the following:

epd.config loaded new
Traceback (most recent call last):
File "/home/zero/zerowriter1/e-Paper/RaspberryPi_JetsonNano/python/examples/main.py", line 32, in
zero_writer.initialize()
File "/home/zero/zerowriter1/e-Paper/RaspberryPi_JetsonNano/python/examples/zerowriter.py", line 156, in initialize
self.epd.init()
File "/home/zero/zerowriter1/e-Paper/RaspberryPi_JetsonNano/python/examples/waveshare_epd/epd4in2_V2.py", line 127, in init
if epdconfig.module_init() != 0:
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zero/zerowriter1/e-Paper/RaspberryPi_JetsonNano/python/examples/waveshare_epd/epdconfig.py", line 73, in module_init
self.GPIO.setup(self.CS_PIN, self.GPIO.OUT)
File "/usr/lib/python3/dist-packages/RPi/GPIO/init.py", line 704, in setup
initial = _check(lgpio.gpio_read(_chip, gpio))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/lgpio.py", line 903, in gpio_read
return _u2i(_lgpio._gpio_read(handle&0xffff, gpio))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i
raise error(error_text(v))
lgpio.error: 'GPIO not allocated'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/zero/zerowriter1/e-Paper/RaspberryPi_JetsonNano/python/examples/main.py", line 40, in
zero_writer.epd.init()
File "/home/zero/zerowriter1/e-Paper/RaspberryPi_JetsonNano/python/examples/waveshare_epd/epd4in2_V2.py", line 127, in init
if epdconfig.module_init() != 0:
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zero/zerowriter1/e-Paper/RaspberryPi_JetsonNano/python/examples/waveshare_epd/epdconfig.py", line 73, in module_init
self.GPIO.setup(self.CS_PIN, self.GPIO.OUT)
File "/usr/lib/python3/dist-packages/RPi/GPIO/init.py", line 704, in setup
initial = _check(lgpio.gpio_read(_chip, gpio))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/lgpio.py", line 903, in gpio_read
return _u2i(_lgpio._gpio_read(handle&0xffff, gpio))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i
raise error(error_text(v))
lgpio.error: 'GPIO not allocated'

After trying to find a solution for this I am unable to get past this. It might be a known issue that I cant find documented, so any guidance would be hugely appreciated here!

@zerowriter
Copy link
Owner

zerowriter commented Nov 9, 2024 via email

@akza
Copy link
Author

akza commented Nov 9, 2024

Hi!! Thanks for the speedy reply :)

I do not see any activity on the ePaper at this point.

@zerowriter
Copy link
Owner

zerowriter commented Nov 9, 2024 via email

@TCD1138
Copy link

TCD1138 commented Nov 9, 2024

Well this thread is timely!

I decided to make a zerowriter as a gift this week and have encountered the same issue after getting everything put together today.

Just attempted with the demo code from waveshare to the same result as OP above.

After doing some reading. I think it's due to the kernel being 6.6 now? Unless you already have accounted for the GPIO pins being renumbered? The closest thing I can find is this on stack overflow https://stackoverflow.com/a/78605522

@zerowriter
Copy link
Owner

zerowriter commented Nov 10, 2024 via email

@akza
Copy link
Author

akza commented Nov 10, 2024

Yes, definitely using the 2.2 branch.
Here is the wiring guide I followed - just to double check that I am connecting things correctly.
image

@zerowriter
Copy link
Owner

zerowriter commented Nov 10, 2024 via email

@zerowriter
Copy link
Owner

zerowriter commented Nov 10, 2024 via email

@zerowriter
Copy link
Owner

zerowriter commented Nov 10, 2024 via email

@akza
Copy link
Author

akza commented Nov 10, 2024

Thanks! This is super helpful. Everything I have been digging up seems to indicate some gpio conflicts! Let me give this a go!!! Appreciate it!

@TCD1138
Copy link

TCD1138 commented Nov 10, 2024

https://downloads.raspberrypi.com/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2024-10-28/2024-10-22-raspios-bullseye-armhf-lite.img.xz

Try this one. (Raspberry pi legacy os lite runing bullseye)

Using the release from this link fixed the GPIO issue for me, hopefully will for OP as well!

Thank you!

@akza
Copy link
Author

akza commented Nov 10, 2024

Or possibly an archived version of bookworm:
https://www.raspberrypi.com/software/operating-systems/

I tried the arched Bookworm release (from March 2024) and this resolved the GPIO issue for me also!

Thank you!!

@akza akza closed this as completed Nov 10, 2024
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

3 participants