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

detector.chip.id raise AttributeError() # Avoid infinite recursion on RPI 3 B #342

Open
Elwinmage opened this issue Feb 25, 2024 · 9 comments

Comments

@Elwinmage
Copy link

Hi, I have an AttributeError() trying to detect my chip id (RPI 3B)

$ pip list |grep -i adafruit

Adafruit-PlatformDetect 3.60.0

python 3.11.8 (main, Feb 19 2024, 17:01:17) [GCC 13.2.1 20231014] on linux
Type "help", "copyright", "credits" or "license" for more information.

from adafruit_platformdetect import Detector
detector = Detector()
print("Chip id: ", detector.chip.id)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.11/site-packages/adafruit_platformdetect/chip.py", line 428, in getattr
raise AttributeError() # Avoid infinite recursion
^^^^^^^^^^^^^^^^^^^^^^
AttributeError

$ cat /etc/os-release

NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.19.1
PRETTY_NAME="Alpine Linux v3.19"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"

$ cat /proc/cpuinfo

processor : 0
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

processor : 1
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

processor : 2
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

processor : 3
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

Revision : a22082
Serial : 000000008a496a07
Model : Raspberry Pi 3 Model B Rev 1.2

@Elwinmage
Copy link
Author

Same problem with a RPI 4B also running HAOSS (Home assistant).

@makermelissa
Copy link
Collaborator

Interesting. Not much has changed with Blinka/PlatformDetect in a while. I wonder if this is something that is showing up in newer Python versions.

@Firestorm7893
Copy link

Unfortunately I'm having the same issue, RPI 5, I am running the library through docker though.

@makermelissa
Copy link
Collaborator

I am running the library through docker though.

Hmm, ok. Maybe that's why I haven't seen the issue before. Thank you.

@pbrownrobo
Copy link

I am having same problem, but I'm just blindly copying code from another codebase and trying to get it to work with my new hardware.

I would appreciate it if someone could spell out for idiots, what are the typical causes for this recursion problem?

@mnuriyumusak
Copy link

if you are using docker, then you need to somehow forward your /dev to your docker. the best way is give "--priviliged" status to your docker container. in this way error is gone since docker can see the devices.

@torchiaf
Copy link

torchiaf commented Dec 30, 2024

I had the same issue running a docker image on Pi5. I used --privileged option in docker run and the error went away.

@pbrownrobo
Copy link

same symptom different reasons. your docker issue was simply "driver cant access hardware", but thats because you didnt give it docker privs to do so.
Mine was "driver cant access hardware" for other reasons, I believe.

@BoxenOfDonuts
Copy link

BoxenOfDonuts commented Jan 2, 2025

Was running into a similar issue, a container that worked on a pi zero w, was throwing the same error above on a pi zero 2 w.

Looks like here it checks for Hardware in /proc/cpuinfo. On the Pi Zero it returns BCM2835 but on the Zero 2 it returns none. It looks like the arm64 version of /proc/cpuinfo doesn't contain Hardware.

When not running in a container the chip will be detected via information in /proc/device-tree/compatible here, but that doesn't exist inside the container without setting --privileged.

I was able to get around it by setting the container to run privileged, or passing BLINKA_FORCEBOARD and BLINKA_FORCECHIP environment variables

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

7 participants