Browse Source

Updated with newer boards

Melissa LeBlanc-Williams 3 months ago
parent
commit
56bcd0374d

+ 5
- 2
README.rst View File

@@ -11,8 +11,11 @@ generally dependent on the former.  Platform info is gathered from:
11 11
 
12 12
   - Python's `sys.platform`
13 13
 
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)
16 19
 
17 20
   - Beaglebone EEPROM board IDs
18 21
 

+ 11
- 0
adafruit_platformdetect/__init__.py View File

@@ -55,6 +55,17 @@ class Detector:
55 55
 
56 56
         return None
57 57
 
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
+
58 69
     def get_armbian_release_field(self, field):
59 70
         """
60 71
         Search /etc/armbian-release, if it exists, for a field and return its

+ 14
- 0
adafruit_platformdetect/board.py View File

@@ -58,6 +58,7 @@ ODROID_C1_PLUS              = "ODROID_C1_PLUS"
58 58
 ODROID_C2                   = "ODROID_C2"
59 59
 
60 60
 FTDI_FT232H                 = "FT232H"
61
+LINARO_96BOARDS             = "LINARO_96BOARDS"
61 62
 # pylint: enable=bad-whitespace
62 63
 
63 64
 #OrangePI
@@ -289,6 +290,10 @@ class Board:
289 290
             board_id = ODROID_C2
290 291
         elif chip_id == ap_chip.FT232H:
291 292
             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
292 297
         elif chip_id in (ap_chip.T210, ap_chip.T186, ap_chip.T194):
293 298
             board_id = self._tegra_id()
294 299
         return board_id
@@ -373,6 +378,15 @@ class Board:
373 378
         return None
374 379
 
375 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
+
389
+    @property
376 390
     def any_raspberry_pi(self):
377 391
         """Check whether the current board is any Raspberry Pi."""
378 392
         return self._pi_rev_code() is not None

+ 5
- 1
adafruit_platformdetect/chip.py View File

@@ -15,6 +15,7 @@ SAMA5 = "SAMA5"
15 15
 T210 = "T210"
16 16
 T186 = "T186"
17 17
 T194 = "T194"
18
+APQ8016 = "APQ8016"
18 19
 GENERIC_X86 = "GENERIC_X86"
19 20
 FT232H = "FT232H"
20 21
 
@@ -73,8 +74,11 @@ class Chip:
73 74
 
74 75
     def _linux_id(self): # pylint: disable=too-many-branches
75 76
         """Attempt to detect the CPU on a computer running the Linux kernel."""
76
-        linux_id = None
77 77
 
78
+        if self.detector.check_dt_compatible_value("qcom,apq8016"):
79
+            return APQ8016
80
+
81
+        linux_id = None
78 82
         hardware = self.detector.get_cpuinfo_field("Hardware")
79 83
 
80 84
         if hardware is None:

+ 1
- 0
bin/detect.py View File

@@ -8,6 +8,7 @@ print("Chip id: ", detector.chip.id)
8 8
 
9 9
 print("Board id: ", detector.board.id)
10 10
 
11
+print("Is this a 96Boards board?", detector.board.LINARO_96BOARDS)
11 12
 print("Is this a Pi 3B+?", detector.board.RASPBERRY_PI_3B_PLUS)
12 13
 print("Is this a 40-pin Raspberry Pi?", detector.board.any_raspberry_pi_40_pin)
13 14
 print("Is this a BBB?", detector.board.BEAGLEBONE_BLACK)

Loading…
Cancel
Save