Skip to content

Commit 9c861c6

Browse files
committed
Merge branch 'db410c' of https://github.com/ric96/Adafruit_Python_PlatformDetect into ric96-db410c
Additional fixes a syntax error and (I'm pretty sure) a logic bug.
2 parents bc4cede + 8339fbf commit 9c861c6

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

adafruit_platformdetect/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ def get_cpuinfo_field(self, field):
5555

5656
return None
5757

58+
def get_dt_compatible_field(self, field):
59+
"""
60+
Search /proc/device-tree/compatible for a field and return True, if found,
61+
otherwise False.
62+
"""
63+
# Match a value like 'qcom,apq8016-sbc':
64+
if field in open('/proc/device-tree/compatible').read():
65+
return True
66+
67+
return False
68+
5869
def get_armbian_release_field(self, field):
5970
"""
6071
Search /etc/armbian-release, if it exists, for a field and return its

adafruit_platformdetect/board.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
ODROID_C2 = "ODROID_C2"
4747

4848
FTDI_FT232H = "FT232H"
49+
# XXX: naming
50+
_96BOARDS = "96BOARDS"
4951
# pylint: enable=bad-whitespace
5052

5153
_RASPBERRY_PI_40_PIN_IDS = (
@@ -253,6 +255,9 @@ def id(self):
253255
board_id = ODROID_C2
254256
elif chip_id == ap_chip.FT232H:
255257
board_id = FTDI_FT232H
258+
else:
259+
board_id = self._is_96boards()
260+
256261
return board_id
257262
# pylint: enable=invalid-name
258263

@@ -298,6 +303,11 @@ def _beaglebone_id(self):
298303
return None
299304
# pylint: enable=no-self-use
300305

306+
def _is_96Boards(self):
307+
if self.detector.get_dt_compatible_field("qcom,apq8016-sbc") or self.detector.get_dt_compatible_field("hisilicon,hi3660-hikey960") or self.detector.get_dt_compatible_field("hisilicon,hi6220-hikey"):
308+
return _96BOARDS
309+
return None
310+
301311
def _armbian_id(self):
302312
"""Check whether the current board is an OrangePi PC."""
303313
board_value = self.detector.get_armbian_release_field('BOARD')

adafruit_platformdetect/chip.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
SUN8I = "SUN8I"
1111
S805 = "S805"
1212
S905 = "S905"
13+
APQ8016 = "APQ8016"
1314
GENERIC_X86 = "GENERIC_X86"
1415
FT232H = "FT232H"
1516

@@ -72,11 +73,15 @@ def _linux_id(self):
7273

7374
hardware = self.detector.get_cpuinfo_field("Hardware")
7475

76+
if self.detector.get_dt_compatible_field("qcom,apq8016"):
77+
linux_id = APQ8016
78+
return linux_id
79+
7580
if hardware is None:
7681
vendor_id = self.detector.get_cpuinfo_field("vendor_id")
7782
if vendor_id in ("GenuineIntel", "AuthenticAMD"):
7883
linux_id = GENERIC_X86
79-
elif hardware in ("BCM2708", "BCM2709", "BCM2835"):
84+
elif hardware in ("BCM2708", "BCM2708", "BCM2835"):
8085
linux_id = BCM2XXX
8186
elif "AM33XX" in hardware:
8287
linux_id = AM33XX

0 commit comments

Comments
 (0)