PN532pi Remote I/O error.
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- mikeysklar
- Posts: 17736
- Joined: Mon Aug 01, 2016 8:10 pm
Re: PN532pi Remote I/O error.
I'd like to see you be able to talk with the PN532. This can work with I2C (issues) and SPI, but Adafruit has only worked with this on Pi OS releases. Can you use another microSD install Pi OS on your Pi 5 or Pi 4 so we can get going in a known working environment?
- tantonj
- Posts: 19
- Joined: Sun Dec 15, 2024 1:15 pm
Re: PN532pi Remote I/O error.
Installed bookworm on an sd card and swapped it in my pi 5. Followed all steps and was still getting the soc error in a venv. This was after doing all steps EXCEPT uninstalling RPi.GPIO. Once I did this the venv python script was able to execute correctly and read tags/card uids.
This should have also been possible on ubuntu, the only difference was that
wouldn't run on ubuntu.
However, my dev container is still throwing the infinite recursion error. I figure if I do figure out why this is happening, I'll still have to figure out how to uninstall RPi.GPIO without crashing the docker build.
I'll report back when I've made progress on this.
Thanks for the assist here.
This should have also been possible on ubuntu, the only difference was that
Code: Select all
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/raspi-blinka.py
sudo -E env PATH=$PATH python3 raspi-blinka.py
However, my dev container is still throwing the infinite recursion error. I figure if I do figure out why this is happening, I'll still have to figure out how to uninstall RPi.GPIO without crashing the docker build.
I'll report back when I've made progress on this.
Thanks for the assist here.
- mikeysklar
- Posts: 17736
- Joined: Mon Aug 01, 2016 8:10 pm
Re: PN532pi Remote I/O error.
Nice progress. Now you got that you have the example up and running it proves out that the hardware / connections / configuration are good. It is a matter of working out the difference in behavior with Ubuntu and Pi OS.
The blinka script knows to detect a pi5 and swap the RPi.GPIO package for rpi-lgpio.
The blinka script knows to detect a pi5 and swap the RPi.GPIO package for rpi-lgpio.
Code: Select all
print("Detected Raspberry Pi 5, applying additional fixes...")
shell.run_command("sudo apt remove python3-rpi.gpio")
shell.run_command("pip3 uninstall -y RPi.GPIO", run_as_user=username)
shell.run_command("pip3 install --upgrade rpi-lgpio", run_as_user=username)
- tantonj
- Posts: 19
- Joined: Sun Dec 15, 2024 1:15 pm
Re: PN532pi Remote I/O error.
Well my big show stopper still lies with docker.
Whenever importing board I get the infinite recursion error
This is definitely independent of RPi.GPIO being installed, which I think I can figure a way around. But my first goal is to get the SOC error in my docker container.
The source of the error may lie in my base docker image. I've used
FROM debian:latest
FROM debian:bookworm-slim
and some 3rd party rpi specific images.
If you have any thoughts or suggestions here, they would be greatly appreciated. (my project really requires docker for multiple reasons outside of the adafruit stuff, eventually I would like it to be deployable on any rpi through docker)
Below is the pip3 list output in my container:
Whenever importing board I get the infinite recursion error
Code: Select all
Traceback (most recent call last):
File "/workspaces/OpenAccess/webserver/spinfc.py", line 11, in <module>
import board
File "/usr/local/lib/python3.11/dist-packages/board.py", line 21, in <module>
from adafruit_blinka.agnostic import board_id, detector
File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/agnostic/__init__.py", line 21, in <module>
chip_id = detector.chip.id
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/adafruit_platformdetect/chip.py", line 456, in __getattr__
raise AttributeError() # Avoid infinite recursion
^^^^^^^^^^^^^^^^^^^^^^
AttributeError
The source of the error may lie in my base docker image. I've used
FROM debian:latest
FROM debian:bookworm-slim
and some 3rd party rpi specific images.
If you have any thoughts or suggestions here, they would be greatly appreciated. (my project really requires docker for multiple reasons outside of the adafruit stuff, eventually I would like it to be deployable on any rpi through docker)
Below is the pip3 list output in my container:
Code: Select all
Package Version
---------------------------------------- -------
Adafruit-Blinka 8.50.0
adafruit-circuitpython-busdevice 5.2.10
adafruit-circuitpython-connectionmanager 3.1.2
adafruit-circuitpython-pn532 2.4.2
adafruit-circuitpython-requests 4.1.8
adafruit-circuitpython-typing 1.11.2
adafruit-fingerprint 1.0.3
Adafruit-PlatformDetect 3.75.0
Adafruit-PureIO 1.1.11
adafruit-python-shell 1.8.1
args 0.1.0
binho-host-adapter 0.1.6
blinker 1.9.0
click 8.1.8
clint 0.5.1
colorzero 2.0
Flask 3.1.0
gevent 24.11.1
gpiozero 2.0.1
greenlet 3.1.1
itsdangerous 2.2.0
Jinja2 3.1.5
lgpio 0.2.2.0
MarkupSafe 3.0.2
pillow 11.0.0
pip 23.0.1
pn532pi 1.7
pyfingerprint 1.5
pyftdi 0.56.0
pyserial 3.4
pyusb 1.2.1
rpi-lgpio 0.6
setuptools 66.1.1
spidev 3.6
sysv-ipc 1.1.0
typing 3.7.4.3
typing_extensions 4.12.2
Werkzeug 3.1.3
wheel 0.38.4
zope.event 5.0
zope.interface 7.2
- mikeysklar
- Posts: 17736
- Joined: Mon Aug 01, 2016 8:10 pm
Re: PN532pi Remote I/O error.
Take a closer look at chip.py and try adding some more debugging to see if you can see why it is erroring out here:
Code: Select all
File "/usr/local/lib/python3.11/dist-packages/adafruit_platformdetect/chip.py", line 456, in __getattr__
raise AttributeError() # Avoid infinite recursion
- tantonj
- Posts: 19
- Joined: Sun Dec 15, 2024 1:15 pm
Re: PN532pi Remote I/O error.
I started the process of this (just laid down in bed, got to get up early for the kids tomorrow).
Ended up constructing the detector object myself in both environments to see the difference. Inspecting the source, I thought it might have to do with the os.environ object. I printed the json of both to compare. Nothing jumped out at me, but the docker container had a lot less keys.
My next step will be to copy the entire detector module source code and debug them in both environments. But I'm too tired for that tonight. Ideally there is a fix on the docker side. I'll report back any findings here.
Ended up constructing the detector object myself in both environments to see the difference. Inspecting the source, I thought it might have to do with the os.environ object. I printed the json of both to compare. Nothing jumped out at me, but the docker container had a lot less keys.
My next step will be to copy the entire detector module source code and debug them in both environments. But I'm too tired for that tonight. Ideally there is a fix on the docker side. I'll report back any findings here.
- tantonj
- Posts: 19
- Joined: Sun Dec 15, 2024 1:15 pm
Re: PN532pi Remote I/O error.
I tracked down the problem to the container not having access to
/proc/device-tree/compatible.
I tried many things, adding this in devcontainer.json as a mount (type=bind). (type volume does not build the container). I tried doing what I do with /dev contents (doesn't work). I also tried copying the file in the container. In the end I caved and added the privledged property to the devcontainer which works.
However, I am not happy with this and will be searching for a while to give the container access to this file. Once the container could access this the board library can be imported without failure. The matrix and nfc libraries work.
However, I still have a No data read from serial port error when accessing the fingerprint library as noted on my other post viewtopic.php?p=1039835&hilit=fingerprint#p1039835
I'll post here if I find the proper solution without using privledged. For any others I needed the following in my docker file (some of the libraries are not necessary for just nfc)
/proc/device-tree/compatible.
I tried many things, adding this in devcontainer.json as a mount (type=bind). (type volume does not build the container). I tried doing what I do with /dev contents (doesn't work). I also tried copying the file in the container. In the end I caved and added the privledged property to the devcontainer which works.
However, I am not happy with this and will be searching for a while to give the container access to this file. Once the container could access this the board library can be imported without failure. The matrix and nfc libraries work.
However, I still have a No data read from serial port error when accessing the fingerprint library as noted on my other post viewtopic.php?p=1039835&hilit=fingerprint#p1039835
I'll post here if I find the proper solution without using privledged. For any others I needed the following in my docker file (some of the libraries are not necessary for just nfc)
Code: Select all
FROM debian:bookworm
COPY Pipfile ./
RUN apt update && apt install --upgrade -y wget python3 python3-setuptools libgpiod-dev python3-libgpiod python3-pip libnfc-bin
RUN pip3 install --upgrade rpi-lgpio adafruit-blinka pn532pi adafruit-circuitpython-pn532 adafruit_fingerprint pyfingerprint adafruit-python-shell gevent flask gpiozero --break-system-packages
- mikeysklar
- Posts: 17736
- Joined: Mon Aug 01, 2016 8:10 pm
Re: PN532pi Remote I/O error.
Good job narrowing it down to the /proc hardware description entry. I'm surprised that requires privleges.
If you are using an Adafruit fingerprint sensor please start a fresh thread with the read issue.
If you are using an Adafruit fingerprint sensor please start a fresh thread with the read issue.
- tantonj
- Posts: 19
- Joined: Sun Dec 15, 2024 1:15 pm
Re: PN532pi Remote I/O error.
I had linked it in my post above. But there must have been a copy/paste issue (you'll understand if you read the post)
viewtopic.php?t=215479&e=1&view=unread#unread
viewtopic.php?t=215479&e=1&view=unread#unread
Please be positive and constructive with your questions and comments.