unknown platform due to very wrong detection mechanism
andrematzke opened this issue · 1 comments
Hello,
the detection mechanism is IMHO buggy(?) and works, if it works, partly by accident.
in platform_detect.py
I can see the following lines:
with open('/proc/cpuinfo', 'r') as infile: cpuinfo = infile.read() # Match a line like 'Hardware : BCM2709' match = re.search('^Hardware\s+:\s+(\w+)$', cpuinfo, flags=re.MULTILINE | re.IGNORECASE) if not match: # Couldn't find the hardware, assume it isn't a pi. return None if match.group(1) == 'BCM2708': # Pi 1 return 1 elif match.group(1) == 'BCM2709': # Pi 2 return 2 elif match.group(1) == 'BCM2835': # Pi 3 return 3 elif match.group(1) == 'BCM2837': # Pi 3b+ return 3
https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications
Pi1: The BCM2835 is on all Pi 1 used
Pi2 BCM2836 (Pi 2B) & BCM2837 (Pi 2B V1.2)
Pi3 BCM2837B0 (A+) BCM2837 (B) BCM2837B0 (B+)
So partly by accident it is working with pattern BCM2835 with return 3
(as Pi3) on Pi1 devices and with BCM2837 as Pi3b+ also with return 3
on Pi2BV1.2 and all Pi3 devices.
BCM2708/9 is never matching, hence no Pi device has such SoC, and poor owners of BCM2836 will get an unknown platform
error.
I also got raspis on other arm distributions (e.g. manjaro-arm) with different cpuinfo-output, which does not show the SoC-label - so all these will also raise an unkown platform
error. So this detection method is quite problematic at all.
Why it is so important to detect different versions of Pis. And because its seems it is not actually working the way intended, could it be enough to may be parameterized e.g. in read_retry(sensor,pin,platform)
with platform={'Pi'|'Beagle'}
?
BR,
Andre
we;re deprecating this library soon, please try https://github.com/adafruit/Adafruit_CircuitPython_DHT