Skip to content

Commit 56bcd03

Browse files
committed
Updated with newer boards
2 parents 71805ae + dcdd646 commit 56bcd03

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
lines changed

README.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ generally dependent on the former. Platform info is gathered from:
1111

1212
- Python's `sys.platform`
1313

14-
- The `/proc/cpuinfo` file on Linux systems (for processor info, Raspberry Pi
15-
hardware revisions, etc.)
14+
- Various files on Linux systems:
15+
16+
- `/proc/cpuinfo` (for processor info, Raspberry Pi hardware revisions, etc.)
17+
18+
- `/proc/device-tree/compatible` (for 96Boards info)
1619

1720
- Beaglebone EEPROM board IDs
1821

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 check_dt_compatible_value(self, value):
59+
"""
60+
Search /proc/device-tree/compatible for a value and return True, if found,
61+
otherwise False.
62+
"""
63+
# Match a value like 'qcom,apq8016-sbc':
64+
if value 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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
ODROID_C2 = "ODROID_C2"
5959

6060
FTDI_FT232H = "FT232H"
61+
LINARO_96BOARDS = "LINARO_96BOARDS"
6162
# pylint: enable=bad-whitespace
6263

6364
#OrangePI
@@ -289,6 +290,10 @@ def id(self):
289290
board_id = ODROID_C2
290291
elif chip_id == ap_chip.FT232H:
291292
board_id = FTDI_FT232H
293+
# TODO do we want to check chip ID at all for 96Boards?
294+
# elif chip_id == APQ8016:
295+
elif self.any_96boards:
296+
board_id = LINARO_96BOARDS
292297
elif chip_id in (ap_chip.T210, ap_chip.T186, ap_chip.T194):
293298
board_id = self._tegra_id()
294299
return board_id
@@ -372,6 +377,15 @@ def _tegra_id(self):
372377
return JETSON_NANO
373378
return None
374379

380+
@property
381+
def any_96boards(self):
382+
"""Check if the current board is any 96Boards-family board."""
383+
return (
384+
self.detector.check_dt_compatible_value("qcom,apq8016-sbc")
385+
or self.detector.check_dt_compatible_value("hisilicon,hi3660-hikey960")
386+
or self.detector.check_dt_compatible_value("hisilicon,hi6220-hikey")
387+
)
388+
375389
@property
376390
def any_raspberry_pi(self):
377391
"""Check whether the current board is any Raspberry Pi."""

adafruit_platformdetect/chip.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
T210 = "T210"
1616
T186 = "T186"
1717
T194 = "T194"
18+
APQ8016 = "APQ8016"
1819
GENERIC_X86 = "GENERIC_X86"
1920
FT232H = "FT232H"
2021

@@ -73,8 +74,11 @@ def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return-s
7374

7475
def _linux_id(self): # pylint: disable=too-many-branches
7576
"""Attempt to detect the CPU on a computer running the Linux kernel."""
76-
linux_id = None
7777

78+
if self.detector.check_dt_compatible_value("qcom,apq8016"):
79+
return APQ8016
80+
81+
linux_id = None
7882
hardware = self.detector.get_cpuinfo_field("Hardware")
7983

8084
if hardware is None:

bin/detect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
print("Board id: ", detector.board.id)
1010

11+
print("Is this a 96Boards board?", detector.board.LINARO_96BOARDS)
1112
print("Is this a Pi 3B+?", detector.board.RASPBERRY_PI_3B_PLUS)
1213
print("Is this a 40-pin Raspberry Pi?", detector.board.any_raspberry_pi_40_pin)
1314
print("Is this a BBB?", detector.board.BEAGLEBONE_BLACK)

0 commit comments

Comments
 (0)