Browse Source

Refactor library in order to separate components.

yeyeto2788 1 month ago
parent
commit
98a65eb537

+ 2
- 2
adafruit_platformdetect/__init__.py View File

@@ -22,12 +22,12 @@
22 22
 """
23 23
 Attempt to detect the current platform.
24 24
 """
25
-import sys
26
-import platform
27 25
 import re
26
+
28 27
 from adafruit_platformdetect.board import Board
29 28
 from adafruit_platformdetect.chip import Chip
30 29
 
30
+
31 31
 # Various methods here may retain state in future, so tell pylint not to worry
32 32
 # that they don't use self right now:
33 33
 # pylint: disable=no-self-use

+ 89
- 393
adafruit_platformdetect/board.py View File

@@ -2,326 +2,14 @@
2 2
 import os
3 3
 import re
4 4
 
5
-import adafruit_platformdetect.chip as ap_chip
6
-
7 5
 # Allow for aligned constant definitions:
8 6
 # pylint: disable=bad-whitespace
9
-BEAGLEBONE                  = 'BEAGLEBONE'
10
-BEAGLEBONE_BLACK            = 'BEAGLEBONE_BLACK'
11
-BEAGLEBONE_BLUE             = 'BEAGLEBONE_BLUE'
12
-BEAGLEBONE_BLACK_WIRELESS   = 'BEAGLEBONE_BLACK_WIRELESS'
13
-BEAGLEBONE_POCKETBEAGLE     = 'BEAGLEBONE_POCKETBEAGLE'
14
-BEAGLEBONE_GREEN            = 'BEAGLEBONE_GREEN'
15
-BEAGLEBONE_GREEN_WIRELESS   = 'BEAGLEBONE_GREEN_WIRELESS'
16
-BEAGLEBONE_BLACK_INDUSTRIAL = 'BEAGLEBONE_BLACK_INDUSTRIAL'
17
-BEAGLEBONE_ENHANCED         = 'BEAGLEBONE_ENHANCED'
18
-BEAGLEBONE_USOMIQ           = 'BEAGLEBONE_USOMIQ'
19
-BEAGLEBONE_AIR              = 'BEAGLEBONE_AIR'
20
-BEAGLEBONE_POCKETBONE       = 'BEAGLEBONE_POCKETBONE'
21
-BEAGLELOGIC_STANDALONE      = 'BEAGLELOGIC_STANDALONE'
22
-OSD3358_DEV_BOARD           = 'OSD3358_DEV_BOARD'
23
-OSD3358_SM_RED              = 'OSD3358_SM_RED'
24
-
25
-FEATHER_HUZZAH              = "FEATHER_HUZZAH"
26
-FEATHER_M0_EXPRESS          = "FEATHER_M0_EXPRESS"
27
-GENERIC_LINUX_PC            = "GENERIC_LINUX_PC"
28
-PYBOARD                     = "PYBOARD"
29
-NODEMCU                     = "NODEMCU"
30
-GIANT_BOARD                 = "GIANT_BOARD"
31
-
32
-# Orange Pi boards
33
-ORANGE_PI_PC                = "ORANGE_PI_PC"
34
-ORANGE_PI_R1                = "ORANGE_PI_R1"
35
-ORANGE_PI_ZERO              = "ORANGE_PI_ZERO"
36
-ORANGE_PI_ONE               = "ORANGE_PI_ONE"
37
-ORANGE_PI_LITE              = "ORANGE_PI_LITE"
38
-ORANGE_PI_PC_PLUS           = "ORANGE_PI_PC_PLUS"
39
-ORANGE_PI_PLUS_2E           = "ORANGE_PI_PLUS_2E"
40
-
41
-# NVIDIA Jetson boards
42
-JETSON_TX1                  = 'JETSON_TX1'
43
-JETSON_TX2                  = 'JETSON_TX2'
44
-JETSON_XAVIER               = 'JETSON_XAVIER'
45
-JETSON_NANO                 = 'JETSON_NANO'
46
-
47
-# Google Coral dev board
48
-CORAL_EDGE_TPU_DEV          = "CORAL_EDGE_TPU_DEV"
49
-
50
-# Various Raspberry Pi models
51
-RASPBERRY_PI_B_REV1         = "RASPBERRY_PI_B_REV1"
52
-RASPBERRY_PI_B_REV2         = "RASPBERRY_PI_B_REV2"
53
-RASPBERRY_PI_B_PLUS         = "RASPBERRY_PI_B_PLUS"
54
-RASPBERRY_PI_A              = "RASPBERRY_PI_A"
55
-RASPBERRY_PI_A_PLUS         = "RASPBERRY_PI_A_PLUS"
56
-RASPBERRY_PI_CM1            = "RASPBERRY_PI_CM1"
57
-RASPBERRY_PI_ZERO           = "RASPBERRY_PI_ZERO"
58
-RASPBERRY_PI_ZERO_W         = "RASPBERRY_PI_ZERO_W"
59
-RASPBERRY_PI_2B             = "RASPBERRY_PI_2B"
60
-RASPBERRY_PI_3B             = "RASPBERRY_PI_3B"
61
-RASPBERRY_PI_3B_PLUS        = "RASPBERRY_PI_3B_PLUS"
62
-RASPBERRY_PI_CM3            = "RASPBERRY_PI_CM3"
63
-RASPBERRY_PI_3A_PLUS        = "RASPBERRY_PI_3A_PLUS"
64
-RASPBERRY_PI_CM3_PLUS       = "RASPBERRY_PI_CM3_PLUS"
65
-RASPBERRY_PI_4B             = "RASPBERRY_PI_4B"
66
-
67
-ODROID_C1                   = "ODROID_C1"
68
-ODROID_C1_PLUS              = "ODROID_C1_PLUS"
69
-ODROID_C2                   = "ODROID_C2"
70
-ODROID_N2                   = "ODROID_N2"
71
-
72
-FTDI_FT232H                 = "FTDI_FT232H"
73
-DRAGONBOARD_410C            = "DRAGONBOARD_410C"
74
-
75
-SIFIVE_UNLEASHED            = "SIFIVE_UNLEASHED"
76
-
77
-MICROCHIP_MCP2221           = "MICROCHIP_MCP2221"
78
-
79
-BINHO_NOVA                  = "BINHO_NOVA"
80
-
81
-ONION_OMEGA                 = "ONION_OMEGA"
82
-ONION_OMEGA2                = "ONION_OMEGA2"
83
-
84
-PINE64 = "PINE64"
85
-PINEBOOK = "PINEBOOK"
86
-PINEPHONE = "PINEPHONE"
87
-
88
-# pylint: enable=bad-whitespace
89
-
90
-#OrangePI
91
-_ORANGE_PI_IDS = (
92
-    ORANGE_PI_PC,
93
-    ORANGE_PI_R1,
94
-    ORANGE_PI_ZERO,
95
-    ORANGE_PI_ONE,
96
-    ORANGE_PI_LITE,
97
-    ORANGE_PI_PC_PLUS,
98
-    ORANGE_PI_PLUS_2E,
99
-)
100
-
101
-_CORAL_IDS = (
102
-    CORAL_EDGE_TPU_DEV,
103
-)
104
-
105
-_JETSON_IDS = (
106
-    JETSON_TX1,
107
-    JETSON_TX2,
108
-    JETSON_XAVIER,
109
-    JETSON_NANO
110
-)
111
-
112
-_RASPBERRY_PI_40_PIN_IDS = (
113
-    RASPBERRY_PI_B_PLUS,
114
-    RASPBERRY_PI_A_PLUS,
115
-    RASPBERRY_PI_ZERO,
116
-    RASPBERRY_PI_ZERO_W,
117
-    RASPBERRY_PI_2B,
118
-    RASPBERRY_PI_3B,
119
-    RASPBERRY_PI_3B_PLUS,
120
-    RASPBERRY_PI_3A_PLUS,
121
-    RASPBERRY_PI_4B
122
-)
123
-
124
-_RASPBERRY_PI_CM_IDS = (
125
-    RASPBERRY_PI_CM1,
126
-    RASPBERRY_PI_CM3,
127
-    RASPBERRY_PI_CM3_PLUS
128
-)
129
-
130
-_ODROID_40_PIN_IDS = (
131
-    ODROID_C1,
132
-    ODROID_C1_PLUS,
133
-    ODROID_C2,
134
-    ODROID_N2
135
-)
136
-
137
-_BEAGLEBONE_IDS = (
138
-    BEAGLEBONE,
139
-    BEAGLEBONE_BLACK,
140
-    BEAGLEBONE_BLUE,
141
-    BEAGLEBONE_BLACK_WIRELESS,
142
-    BEAGLEBONE_POCKETBEAGLE,
143
-    BEAGLEBONE_GREEN,
144
-    BEAGLEBONE_GREEN_WIRELESS,
145
-    BEAGLEBONE_BLACK_INDUSTRIAL,
146
-    BEAGLEBONE_ENHANCED,
147
-    BEAGLEBONE_USOMIQ,
148
-    BEAGLEBONE_AIR,
149
-    BEAGLEBONE_POCKETBONE,
150
-    BEAGLELOGIC_STANDALONE,
151
-    OSD3358_DEV_BOARD,
152
-    OSD3358_SM_RED,
153
-)
154
-
155
-_LINARO_96BOARDS_IDS = (
156
-    DRAGONBOARD_410C,
157
-)
158
-
159
-
160
-_SIFIVE_IDS = (
161
-    SIFIVE_UNLEASHED,
162
-)
163
-
164
-# BeagleBone eeprom board ids from:
165
-#   https://github.com/beagleboard/image-builder
166
-# Thanks to zmatt on freenode #beagle for pointers.
167
-_BEAGLEBONE_BOARD_IDS = {
168
-    # Original bone/white:
169
-    BEAGLEBONE: (
170
-        ('A4', 'A335BONE00A4'),
171
-        ('A5', 'A335BONE00A5'),
172
-        ('A6', 'A335BONE00A6'),
173
-        ('A6A', 'A335BONE0A6A'),
174
-        ('A6B', 'A335BONE0A6B'),
175
-        ('B', 'A335BONE000B'),
176
-    ),
177
-    BEAGLEBONE_BLACK: (
178
-        ('A5', 'A335BNLT00A5'),
179
-        ('A5A', 'A335BNLT0A5A'),
180
-        ('A5B', 'A335BNLT0A5B'),
181
-        ('A5C', 'A335BNLT0A5C'),
182
-        ('A6', 'A335BNLT00A6'),
183
-        ('C', 'A335BNLT000C'),
184
-        ('C', 'A335BNLT00C0'),
185
-    ),
186
-    BEAGLEBONE_BLUE: (
187
-        ('A2', 'A335BNLTBLA2'),
188
-    ),
189
-    BEAGLEBONE_BLACK_WIRELESS: (
190
-        ('A5', 'A335BNLTBWA5'),
191
-    ),
192
-    BEAGLEBONE_POCKETBEAGLE: (
193
-        ('A2', 'A335PBGL00A2'),
194
-    ),
195
-    BEAGLEBONE_GREEN: (
196
-        ('1A', 'A335BNLT....'),
197
-        ('UNKNOWN', 'A335BNLTBBG1'),
198
-    ),
199
-    BEAGLEBONE_GREEN_WIRELESS: (
200
-        ('W1A', 'A335BNLTGW1A'),
201
-    ),
202
-    BEAGLEBONE_BLACK_INDUSTRIAL: (
203
-        ('A0', 'A335BNLTAIA0'), # Arrow
204
-        ('A0', 'A335BNLTEIA0'), # Element14
205
-    ),
206
-    BEAGLEBONE_ENHANCED: (
207
-        ('A', 'A335BNLTSE0A'),
208
-    ),
209
-    BEAGLEBONE_USOMIQ: (
210
-        ('6', 'A335BNLTME06'),
211
-    ),
212
-    BEAGLEBONE_AIR: (
213
-        ('A0', 'A335BNLTNAD0'),
214
-    ),
215
-    BEAGLEBONE_POCKETBONE: (
216
-        ('0', 'A335BNLTBP00'),
217
-    ),
218
-    OSD3358_DEV_BOARD: (
219
-        ('0.1', 'A335BNLTGH01'),
220
-    ),
221
-    OSD3358_SM_RED: (
222
-        ('0', 'A335BNLTOS00'),
223
-    ),
224
-    BEAGLELOGIC_STANDALONE: (
225
-        ('A', 'A335BLGC000A'),
226
-    )
227
-}
228
-
229
-# Pi revision codes from:
230
-#   https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
231
-
232
-# Each tuple here contains both the base codes, and the versions that indicate
233
-# the Pi is overvolted / overclocked - for 4-digit codes, this will be prefixed
234
-# with 1000, and for 6-digit codes it'll be prefixed with 1.  These are placed
235
-# on separate lines.
236
-
237
-_PI_REV_CODES = {
238
-    RASPBERRY_PI_B_REV1: (
239
-        # Regular codes:
240
-        '0002', '0003',
241
-
242
-        # Overvolted/clocked versions:
243
-        '1000002', '1000003',
244
-    ),
245
-    RASPBERRY_PI_B_REV2: (
246
-        '0005', '0006', '000d', '000e', '000f',
247
-        '1000005', '1000006', '100000d', '100000e', '100000f',
248
-    ),
249
-    RASPBERRY_PI_B_PLUS: (
250
-        '0010', '0013', '900032',
251
-        '1000010', '1000013', '1900032',
252
-    ),
253
-    RASPBERRY_PI_A: (
254
-        '0007', '0008', '0009',
255
-        '1000007', '1000008', '1000009',
256
-    ),
257
-    RASPBERRY_PI_A_PLUS: (
258
-        '0012', '0015', '900021',
259
-        '1000012', '1000015', '1900021',
260
-    ),
261
-    RASPBERRY_PI_CM1: (
262
-        '0011', '0014',
263
-        '10000011', '10000014',
264
-    ),
265
-    RASPBERRY_PI_ZERO: (
266
-        '900092', '920092', '900093', '920093',
267
-        '1900092', '1920092', '1900093', '1920093',  # warranty bit 24
268
-        '2900092', '2920092', '2900093', '2920093',  # warranty bit 25
269
-    ),
270
-    RASPBERRY_PI_ZERO_W: (
271
-        '9000c1',
272
-        '19000c1', '29000c1',  # warranty bits
273
-    ),
274
-    RASPBERRY_PI_2B: (
275
-        'a01040', 'a01041', 'a21041', 'a22042',
276
-        '1a01040', '1a01041', '1a21041', '1a22042',  # warranty bit 24
277
-        '2a01040', '2a01041', '2a21041', '2a22042',  # warranty bit 25
278
-    ),
279
-    RASPBERRY_PI_3B: (
280
-        'a02082', 'a22082', 'a32082', 'a52082',
281
-        '1a02082', '1a22082', '1a32082', '1a52082',  # warranty bit 24
282
-        '2a02082', '2a22082', '2a32082', '2a52082',  # warranty bit 25
283
-    ),
284
-    RASPBERRY_PI_3B_PLUS: (
285
-        'a020d3',
286
-        '1a020d3', '2a020d3',  # warranty bits
287
-    ),
288
-    RASPBERRY_PI_CM3: (
289
-        'a020a0', 'a220a0',
290
-        '1a020a0', '2a020a0',  # warranty bits
291
-        '1a220a0', '2a220a0',
292
-    ),
293
-    RASPBERRY_PI_3A_PLUS: (
294
-        '9020e0',
295
-        '19020e0', '29020e0',  # warranty bits
296
-    ),
297
-    RASPBERRY_PI_CM3_PLUS: (
298
-        'a02100',
299
-        '1a02100', '2a02100',  # warranty bits
300
-    ),
301
-    RASPBERRY_PI_4B: (
302
-        'a03111', 'b03111', 'c03111',
303
-        'a03112', 'b03112', 'c03112',
304
-        '1a03111', '2a03111', '1b03111', '2b03111',  # warranty bits
305
-        '1c03111', '2c03111', '1a03112', '2a03112',
306
-        '1b03112', '2b03112', '1c03112', '2c03112',
307
-    ),
308
-}
309
-
310
-# Onion omega boards
311
-_ONION_OMEGA_BOARD_IDS = (
312
-    ONION_OMEGA,
313
-    ONION_OMEGA2,
314
-)
315
-
316
-# Pine64 boards and devices
317
-_PINE64_DEV_IDS = (
318
-    PINE64,
319
-    PINEBOOK,
320
-    PINEPHONE
321
-)
7
+from adafruit_platformdetect.constants import boards, chips
8
+
322 9
 
323 10
 class Board:
324 11
     """Attempt to detect specific boards."""
12
+
325 13
     def __init__(self, detector):
326 14
         self.detector = detector
327 15
 
@@ -333,55 +21,56 @@ class Board:
333 21
         # say if a raspberry pi doesn't have the right ID, or for testing
334 22
         try:
335 23
             return os.environ['BLINKA_FORCEBOARD']
336
-        except KeyError: # no forced board, continue with testing!
24
+        except KeyError:  # no forced board, continue with testing!
337 25
             pass
338 26
 
339 27
         chip_id = self.detector.chip.id
340 28
         board_id = None
341 29
 
342
-        if chip_id == ap_chip.BCM2XXX:
30
+        if chip_id == chips.BCM2XXX:
343 31
             board_id = self._pi_id()
344
-        elif chip_id == ap_chip.AM33XX:
32
+        elif chip_id == chips.AM33XX:
345 33
             board_id = self._beaglebone_id()
346
-        elif chip_id == ap_chip.GENERIC_X86:
347
-            board_id = GENERIC_LINUX_PC
348
-        elif chip_id == ap_chip.SUN8I:
34
+        elif chip_id == chips.GENERIC_X86:
35
+            board_id = boards.GENERIC_LINUX_PC
36
+        elif chip_id == chips.SUN8I:
349 37
             board_id = self._armbian_id()
350
-        elif chip_id == ap_chip.SAMA5:
38
+        elif chip_id == chips.SAMA5:
351 39
             board_id = self._sama5_id()
352
-        elif chip_id == ap_chip.IMX8MX:
40
+        elif chip_id == chips.IMX8MX:
353 41
             board_id = self._imx8mx_id()
354
-        elif chip_id == ap_chip.ESP8266:
355
-            board_id = FEATHER_HUZZAH
356
-        elif chip_id == ap_chip.SAMD21:
357
-            board_id = FEATHER_M0_EXPRESS
358
-        elif chip_id == ap_chip.STM32:
359
-            board_id = PYBOARD
360
-        elif chip_id == ap_chip.S805:
361
-            board_id = ODROID_C1
362
-        elif chip_id == ap_chip.S905:
363
-            board_id = ODROID_C2
364
-        elif chip_id == ap_chip.S922X:
365
-            board_id = ODROID_N2
366
-        elif chip_id == ap_chip.FT232H:
367
-            board_id = FTDI_FT232H
368
-        elif chip_id == ap_chip.APQ8016:
369
-            board_id = DRAGONBOARD_410C
370
-        elif chip_id in (ap_chip.T210, ap_chip.T186, ap_chip.T194):
42
+        elif chip_id == chips.ESP8266:
43
+            board_id = boards.FEATHER_HUZZAH
44
+        elif chip_id == chips.SAMD21:
45
+            board_id = boards.FEATHER_M0_EXPRESS
46
+        elif chip_id == chips.STM32:
47
+            board_id = boards.PYBOARD
48
+        elif chip_id == chips.S805:
49
+            board_id = boards.ODROID_C1
50
+        elif chip_id == chips.S905:
51
+            board_id = boards.ODROID_C2
52
+        elif chip_id == chips.S922X:
53
+            board_id = boards.ODROID_N2
54
+        elif chip_id == chips.FT232H:
55
+            board_id = boards.FTDI_FT232H
56
+        elif chip_id == chips.APQ8016:
57
+            board_id = boards.DRAGONBOARD_410C
58
+        elif chip_id in (chips.T210, chips.T186, chips.T194):
371 59
             board_id = self._tegra_id()
372
-        elif chip_id == ap_chip.HFU540:
60
+        elif chip_id == chips.HFU540:
373 61
             board_id = self._sifive_id()
374
-        elif chip_id == ap_chip.MCP2221:
375
-            board_id = MICROCHIP_MCP2221
376
-        elif chip_id == ap_chip.BINHO:
377
-            board_id = BINHO_NOVA
378
-        elif chip_id == ap_chip.MIPS24KC:
379
-            board_id = ONION_OMEGA
380
-        elif chip_id == ap_chip.MIPS24KEC:
381
-            board_id = ONION_OMEGA2
382
-        elif chip_id == ap_chip.A64:
62
+        elif chip_id == chips.MCP2221:
63
+            board_id = boards.MICROCHIP_MCP2221
64
+        elif chip_id == chips.BINHO:
65
+            board_id = boards.BINHO_NOVA
66
+        elif chip_id == chips.MIPS24KC:
67
+            board_id = boards.ONION_OMEGA
68
+        elif chip_id == chips.MIPS24KEC:
69
+            board_id = boards.ONION_OMEGA2
70
+        elif chip_id == chips.A64:
383 71
             board_id = self._pine64_id()
384 72
         return board_id
73
+
385 74
     # pylint: enable=invalid-name
386 75
 
387 76
     def _pi_id(self):
@@ -389,7 +78,7 @@ class Board:
389 78
         # Check for Pi boards:
390 79
         pi_rev_code = self._pi_rev_code()
391 80
         if pi_rev_code:
392
-            for model, codes in _PI_REV_CODES.items():
81
+            for model, codes in boards._PI_REV_CODES.items():
393 82
                 if pi_rev_code in codes:
394 83
                     return model
395 84
 
@@ -402,16 +91,16 @@ class Board:
402 91
                 if "PLUS" in pi_model:
403 92
                     re_model = re.search(r'(RASPBERRY_PI_\d).*([AB]_*)(PLUS)',
404 93
                                          pi_model)
405
-                elif "CM" in pi_model: # untested for Compute Module
94
+                elif "CM" in pi_model:  # untested for Compute Module
406 95
                     re_model = re.search(r'(RASPBERRY_PI_CM)(\d)',
407 96
                                          pi_model)
408
-                else: # untested for non-plus models
97
+                else:  # untested for non-plus models
409 98
                     re_model = re.search(r'(RASPBERRY_PI_\d).*([AB]_*)',
410 99
                                          pi_model)
411 100
 
412 101
                 if re_model:
413 102
                     pi_model = "".join(re_model.groups())
414
-                    available_models = _PI_REV_CODES.keys()
103
+                    available_models = boards._PI_REV_CODES.keys()
415 104
                     for model in available_models:
416 105
                         if model == pi_model:
417 106
                             return model
@@ -424,7 +113,7 @@ class Board:
424 113
         # 2709 is Pi 2
425 114
         # 2835 is Pi 3 (or greater) on 4.9.x kernel
426 115
         # Anything else is not a Pi.
427
-        if self.detector.chip.id != ap_chip.BCM2XXX:
116
+        if self.detector.chip.id != chips.BCM2XXX:
428 117
             # Something else, not a Pi.
429 118
             return None
430 119
         return self.detector.get_cpuinfo_field('Revision')
@@ -442,37 +131,40 @@ class Board:
442 131
             return None
443 132
 
444 133
         id_string = eeprom_bytes[4:].decode("ascii")
445
-        for model, bb_ids in _BEAGLEBONE_BOARD_IDS.items():
134
+        for model, bb_ids in boards._BEAGLEBONE_BOARD_IDS.items():
446 135
             for bb_id in bb_ids:
447 136
                 if id_string == bb_id[1]:
448 137
                     return model
449 138
 
450 139
         return None
140
+
451 141
     # pylint: enable=no-self-use
452 142
 
453 143
     # pylint: disable=too-many-return-statements
454 144
     def _armbian_id(self):
455
-        """Check whether the current board is an OrangePi PC or OrangePI R1."""
145
+        """Check whether the current board is an OrangePi board."""
456 146
         board_value = self.detector.get_armbian_release_field('BOARD')
147
+        board = None
457 148
 
458 149
         if board_value == "orangepipc":
459
-            return ORANGE_PI_PC
150
+            board = boards.ORANGE_PI_PC
460 151
         if board_value == "orangepi-r1":
461
-            return ORANGE_PI_R1
152
+            board = boards.ORANGE_PI_R1
462 153
         if board_value == "orangepizero":
463
-            return ORANGE_PI_ZERO
154
+            board = boards.ORANGE_PI_ZERO
464 155
         if board_value == "orangepione":
465
-            return ORANGE_PI_ONE
156
+            board = boards.ORANGE_PI_ONE
466 157
         if board_value == "orangepilite":
467
-            return ORANGE_PI_LITE
158
+            board = boards.ORANGE_PI_LITE
468 159
         if board_value == "orangepiplus2e":
469
-            return ORANGE_PI_PLUS_2E
160
+            board = boards.ORANGE_PI_PLUS_2E
470 161
         if board_value == "orangepipcplus":
471
-            return ORANGE_PI_PC_PLUS
162
+            board = boards.ORANGE_PI_PC_PLUS
472 163
         if board_value == "pinebook-a64":
473
-            return PINEBOOK
164
+            board = boards.PINEBOOK
165
+
166
+        return board
474 167
 
475
-        return None
476 168
     # pylint: enable=too-many-return-statements
477 169
 
478 170
     # pylint: enable=too-many-return-statements
@@ -481,14 +173,14 @@ class Board:
481 173
         """Check what type sama5 board."""
482 174
         board_value = self.detector.get_device_model()
483 175
         if "Giant Board" in board_value:
484
-            return GIANT_BOARD
176
+            return boards.GIANT_BOARD
485 177
         return None
486 178
 
487 179
     def _imx8mx_id(self):
488 180
         """Check what type iMX8M board."""
489 181
         board_value = self.detector.get_device_model()
490 182
         if "Phanbell" in board_value:
491
-            return CORAL_EDGE_TPU_DEV
183
+            return boards.CORAL_EDGE_TPU_DEV
492 184
         return None
493 185
 
494 186
     def _tegra_id(self):
@@ -496,20 +188,20 @@ class Board:
496 188
         board_value = self.detector.get_device_model()
497 189
         board = None
498 190
         if 'tx1' in board_value.lower():
499
-            board = JETSON_TX1
191
+            board = boards.JETSON_TX1
500 192
         elif 'quill' in board_value or "storm" in board_value or "lightning" in board_value:
501
-            board = JETSON_TX2
193
+            board = boards.JETSON_TX2
502 194
         elif 'xavier' in board_value.lower() or 'agx' in board_value.lower():
503
-            board = JETSON_XAVIER
195
+            board = boards.JETSON_XAVIER
504 196
         elif 'nano' in board_value.lower():
505
-            board = JETSON_NANO
197
+            board = boards.JETSON_NANO
506 198
         return board
507 199
 
508 200
     def _sifive_id(self):
509 201
         """Try to detect the id for Sifive RISCV64 board."""
510 202
         board_value = self.detector.get_device_model()
511 203
         if 'hifive-unleashed-a00' in board_value:
512
-            return SIFIVE_UNLEASHED
204
+            return boards.SIFIVE_UNLEASHED
513 205
         return None
514 206
 
515 207
     def _pine64_id(self):
@@ -517,17 +209,17 @@ class Board:
517 209
         board_value = self.detector.get_device_model()
518 210
         board = None
519 211
         if 'pine64' in board_value.lower():
520
-            board = PINE64
212
+            board = boards.PINE64
521 213
         elif 'pinebook' in board_value.lower():
522
-            board = PINEBOOK
214
+            board = boards.PINEBOOK
523 215
         elif 'pinephone' in board_value.lower():
524
-            board = PINEPHONE
216
+            board = boards.PINEPHONE
525 217
         return board
526 218
 
527 219
     @property
528 220
     def any_96boards(self):
529 221
         """Check whether the current board is any 96boards board."""
530
-        return self.id in _LINARO_96BOARDS_IDS
222
+        return self.id in boards._LINARO_96BOARDS_IDS
531 223
 
532 224
     @property
533 225
     def any_raspberry_pi(self):
@@ -537,22 +229,22 @@ class Board:
537 229
     @property
538 230
     def any_raspberry_pi_40_pin(self):
539 231
         """Check whether the current board is any 40-pin Raspberry Pi."""
540
-        return self.id in _RASPBERRY_PI_40_PIN_IDS
232
+        return self.id in boards._RASPBERRY_PI_40_PIN_IDS
541 233
 
542 234
     @property
543 235
     def any_raspberry_pi_cm(self):
544 236
         """Check whether the current board is any Compute Module Raspberry Pi."""
545
-        return self.id in _RASPBERRY_PI_CM_IDS
237
+        return self.id in boards._RASPBERRY_PI_CM_IDS
546 238
 
547 239
     @property
548 240
     def any_beaglebone(self):
549 241
         """Check whether the current board is any Beaglebone-family system."""
550
-        return self.id in _BEAGLEBONE_IDS
242
+        return self.id in boards._BEAGLEBONE_IDS
551 243
 
552 244
     @property
553 245
     def any_orange_pi(self):
554 246
         """Check whether the current board is any defined Orange Pi."""
555
-        return self.id in _ORANGE_PI_IDS
247
+        return self.id in boards._ORANGE_PI_IDS
556 248
 
557 249
     @property
558 250
     def any_coral_board(self):
@@ -567,50 +259,54 @@ class Board:
567 259
     @property
568 260
     def any_odroid_40_pin(self):
569 261
         """Check whether the current board is any defined 40-pin Odroid."""
570
-        return self.id in _ODROID_40_PIN_IDS
262
+        return self.id in boards._ODROID_40_PIN_IDS
571 263
 
572 264
     @property
573 265
     def any_jetson_board(self):
574 266
         """Check whether the current board is any defined Jetson Board."""
575
-        return self.id in _JETSON_IDS
267
+        return self.id in boards._JETSON_IDS
576 268
 
577 269
     @property
578 270
     def any_sifive_board(self):
579 271
         """Check whether the current board is any defined Jetson Board."""
580
-        return self.id in _SIFIVE_IDS
272
+        return self.id in boards._SIFIVE_IDS
581 273
 
582 274
     @property
583 275
     def any_onion_omega_board(self):
584 276
         """Check whether the current board is any defined OpenWRT board."""
585
-        return self.id in _ONION_OMEGA_BOARD_IDS
277
+        return self.id in boards._ONION_OMEGA_BOARD_IDS
586 278
 
587 279
     @property
588 280
     def any_pine64_board(self):
589 281
         """Check whether the current board is any Pine64 device."""
590
-        return self.id in _PINE64_DEV_IDS
282
+        return self.id in boards._PINE64_DEV_IDS
591 283
 
592 284
     @property
593 285
     def any_embedded_linux(self):
594 286
         """Check whether the current board is any embedded Linux device."""
595
-        return self.any_raspberry_pi or self.any_beaglebone or \
596
-         self.any_orange_pi or self.any_giant_board or self.any_jetson_board or \
597
-         self.any_coral_board or self.any_odroid_40_pin or self.any_96boards or \
598
-         self.any_sifive_board or self.any_onion_omega_board or self.any_pine64_board
287
+        return any(
288
+            [
289
+                self.any_raspberry_pi, self.any_beaglebone, self.any_orange_pi,
290
+                self.any_giant_board, self.any_jetson_board, self.any_coral_board,
291
+                self.any_odroid_40_pin, self.any_96boards, self.any_sifive_board,
292
+                self.any_onion_omega_board, self.any_pine64_board,
293
+            ]
294
+        )
599 295
 
600 296
     @property
601 297
     def ftdi_ft232h(self):
602 298
         """Check whether the current board is an FTDI FT232H."""
603
-        return self.id == FTDI_FT232H
299
+        return self.id == boards.FTDI_FT232H
604 300
 
605 301
     @property
606 302
     def microchip_mcp2221(self):
607 303
         """Check whether the current board is a Microchip MCP2221."""
608
-        return self.id == MICROCHIP_MCP2221
304
+        return self.id == boards.MICROCHIP_MCP2221
609 305
 
610 306
     @property
611 307
     def binho_nova(self):
612 308
         """Check whether the current board is an BINHO NOVA."""
613
-        return self.id == BINHO_NOVA
309
+        return self.id == boards.BINHO_NOVA
614 310
 
615 311
     def __getattr__(self, attr):
616 312
         """

+ 30
- 55
adafruit_platformdetect/chip.py View File

@@ -2,32 +2,7 @@
2 2
 import os
3 3
 import sys
4 4
 
5
-AM33XX = "AM33XX"
6
-IMX8MX = "IMX8MX"
7
-BCM2XXX = "BCM2XXX"
8
-ESP8266 = "ESP8266"
9
-SAMD21 = "SAMD21"
10
-STM32 = "STM32"
11
-SUN8I = "SUN8I"
12
-S805 = "S805"
13
-S905 = "S905"
14
-S922X = "S922X"
15
-SAMA5 = "SAMA5"
16
-T210 = "T210"
17
-T186 = "T186"
18
-T194 = "T194"
19
-APQ8016 = "APQ8016"
20
-GENERIC_X86 = "GENERIC_X86"
21
-FT232H = "FT232H"
22
-HFU540 = "HFU540"
23
-MCP2221 = "MCP2221"
24
-BINHO = "BINHO"
25
-MIPS24KC = "MIPS24KC"
26
-MIPS24KEC = "MIPS24KEC"
27
-A64 = "A64"
28
-
29
-BCM_RANGE = {'BCM2708', 'BCM2709', 'BCM2835', 'BCM2837', 'bcm2708', 'bcm2709',
30
-             'bcm2835', 'bcm2837'}
5
+from adafruit_platformdetect.constants import chips
31 6
 
32 7
 
33 8
 class Chip:
@@ -54,27 +29,27 @@ class Chip:
54 29
             if count == 0:
55 30
                 raise RuntimeError('BLINKA_FT232H environment variable ' + \
56 31
                                    'set, but no FT232H device found')
57
-            return FT232H
32
+            return chips.FT232H
58 33
         if os.environ.get('BLINKA_MCP2221'):
59 34
             import hid  # pylint: disable=import-error
60 35
             # look for it based on PID/VID
61 36
             for dev in hid.enumerate():
62 37
                 if dev['vendor_id'] == 0x04D8 and dev['product_id'] == 0x00DD:
63
-                    return MCP2221
38
+                    return chips.MCP2221
64 39
             raise RuntimeError('BLINKA_MCP2221 environment variable ' + \
65 40
                                'set, but no MCP2221 device found')
66 41
         if os.environ.get('BLINKA_NOVA'):
67
-            return BINHO
42
+            return chips.BINHO
68 43
 
69 44
         platform = sys.platform
70 45
         if platform in ('linux', 'linux2'):
71 46
             return self._linux_id()
72 47
         if platform == 'esp8266':
73
-            return ESP8266
48
+            return chips.ESP8266
74 49
         if platform == 'samd21':
75
-            return SAMD21
50
+            return chips.SAMD21
76 51
         if platform == 'pyboard':
77
-            return STM32
52
+            return chips.STM32
78 53
         # nothing found!
79 54
         return None
80 55
 
@@ -84,10 +59,10 @@ class Chip:
84 59
         """Attempt to detect the CPU on a computer running the Linux kernel."""
85 60
 
86 61
         if self.detector.check_dt_compatible_value('qcom,apq8016'):
87
-            return APQ8016
62
+            return chips.APQ8016
88 63
 
89 64
         if self.detector.check_dt_compatible_value('fu500'):
90
-            return HFU540
65
+            return chips.HFU540
91 66
 
92 67
         linux_id = None
93 68
         hardware = self.detector.get_cpuinfo_field('Hardware')
@@ -95,30 +70,30 @@ class Chip:
95 70
         if hardware is None:
96 71
             vendor_id = self.detector.get_cpuinfo_field('vendor_id')
97 72
             if vendor_id in ('GenuineIntel', 'AuthenticAMD'):
98
-                linux_id = GENERIC_X86
73
+                linux_id = chips.GENERIC_X86
99 74
 
100 75
             compatible = self.detector.get_device_compatible()
101 76
             if compatible and 'tegra' in compatible:
102 77
                 if 'cv' in compatible or 'nano' in compatible:
103
-                    linux_id = T210
78
+                    linux_id = chips.T210
104 79
                 elif 'quill' in compatible:
105
-                    linux_id = T186
80
+                    linux_id = chips.T186
106 81
                 elif 'xavier' in compatible:
107
-                    linux_id = T194
82
+                    linux_id = chips.T194
108 83
             if compatible and 'imx8m' in compatible:
109
-                linux_id = IMX8MX
84
+                linux_id = chips.IMX8MX
110 85
             if compatible and 'odroid-c2' in compatible:
111
-                linux_id = S905
86
+                linux_id = chips.S905
112 87
             if compatible and 'amlogic, g12b' in compatible:
113
-                linux_id = S922X
88
+                linux_id = chips.S922X
114 89
 
115 90
             cpu_model = self.detector.get_cpuinfo_field("cpu model")
116 91
 
117 92
             if cpu_model is not None:
118 93
                 if "MIPS 24Kc" in cpu_model:
119
-                    linux_id = MIPS24KC
94
+                    linux_id = chips.MIPS24KC
120 95
                 elif "MIPS 24KEc" in cpu_model:
121
-                    linux_id = MIPS24KEC
96
+                    linux_id = chips.MIPS24KEC
122 97
 
123 98
             # we still haven't identified the hardware, so
124 99
             # convert it to a list and let the remaining
@@ -130,28 +105,28 @@ class Chip:
130 105
 
131 106
         if not linux_id:
132 107
             if 'AM33XX' in hardware:
133
-                linux_id = AM33XX
108
+                linux_id = chips.AM33XX
134 109
             elif 'sun8i' in hardware:
135
-                linux_id = SUN8I
110
+                linux_id = chips.SUN8I
136 111
             elif 'ODROIDC' in hardware:
137
-                linux_id = S805
112
+                linux_id = chips.S805
138 113
             elif 'ODROID-C2' in hardware:
139
-                linux_id = S905
114
+                linux_id = chips.S905
140 115
             elif 'ODROID-N2' in hardware:
141
-                linux_id = S922X
116
+                linux_id = chips.S922X
142 117
             elif 'SAMA5' in hardware:
143
-                linux_id = SAMA5
118
+                linux_id = chips.SAMA5
144 119
             elif "Pinebook" in hardware:
145
-                linux_id = A64
120
+                linux_id = chips.A64
146 121
             elif "sun50iw1p1" in hardware:
147
-                linux_id = A64
122
+                linux_id = chips.A64
148 123
             else:
149 124
                 if isinstance(hardware, str):
150
-                    if hardware in BCM_RANGE:
151
-                        linux_id = BCM2XXX
125
+                    if hardware in chips.BCM_RANGE:
126
+                        linux_id = chips.BCM2XXX
152 127
                 elif isinstance(hardware, list):
153
-                    if set(hardware) & BCM_RANGE:
154
-                        linux_id = BCM2XXX
128
+                    if set(hardware) & chips.BCM_RANGE:
129
+                        linux_id = chips.BCM2XXX
155 130
 
156 131
         return linux_id
157 132
 

+ 1
- 0
adafruit_platformdetect/constants/__init__.py View File

@@ -0,0 +1 @@
1
+"""Common constants used all over the module."""

+ 315
- 0
adafruit_platformdetect/constants/boards.py View File

@@ -0,0 +1,315 @@
1
+"""Definition of boards and/or ids"""
2
+# Allow for aligned constant definitions:
3
+# pylint: disable=bad-whitespace
4
+BEAGLEBONE = 'BEAGLEBONE'
5
+BEAGLEBONE_BLACK = 'BEAGLEBONE_BLACK'
6
+BEAGLEBONE_BLUE = 'BEAGLEBONE_BLUE'
7
+BEAGLEBONE_BLACK_WIRELESS = 'BEAGLEBONE_BLACK_WIRELESS'
8
+BEAGLEBONE_POCKETBEAGLE = 'BEAGLEBONE_POCKETBEAGLE'
9
+BEAGLEBONE_GREEN = 'BEAGLEBONE_GREEN'
10
+BEAGLEBONE_GREEN_WIRELESS = 'BEAGLEBONE_GREEN_WIRELESS'
11
+BEAGLEBONE_BLACK_INDUSTRIAL = 'BEAGLEBONE_BLACK_INDUSTRIAL'
12
+BEAGLEBONE_ENHANCED = 'BEAGLEBONE_ENHANCED'
13
+BEAGLEBONE_USOMIQ = 'BEAGLEBONE_USOMIQ'
14
+BEAGLEBONE_AIR = 'BEAGLEBONE_AIR'
15
+BEAGLEBONE_POCKETBONE = 'BEAGLEBONE_POCKETBONE'
16
+BEAGLELOGIC_STANDALONE = 'BEAGLELOGIC_STANDALONE'
17
+OSD3358_DEV_BOARD = 'OSD3358_DEV_BOARD'
18
+OSD3358_SM_RED = 'OSD3358_SM_RED'
19
+
20
+FEATHER_HUZZAH = "FEATHER_HUZZAH"
21
+FEATHER_M0_EXPRESS = "FEATHER_M0_EXPRESS"
22
+GENERIC_LINUX_PC = "GENERIC_LINUX_PC"
23
+PYBOARD = "PYBOARD"
24
+NODEMCU = "NODEMCU"
25
+GIANT_BOARD = "GIANT_BOARD"
26
+
27
+# Orange Pi boards
28
+ORANGE_PI_PC = "ORANGE_PI_PC"
29
+ORANGE_PI_R1 = "ORANGE_PI_R1"
30
+ORANGE_PI_ZERO = "ORANGE_PI_ZERO"
31
+ORANGE_PI_ONE = "ORANGE_PI_ONE"
32
+ORANGE_PI_LITE = "ORANGE_PI_LITE"
33
+ORANGE_PI_PC_PLUS = "ORANGE_PI_PC_PLUS"
34
+ORANGE_PI_PLUS_2E = "ORANGE_PI_PLUS_2E"
35
+
36
+# NVIDIA Jetson boards
37
+JETSON_TX1 = 'JETSON_TX1'
38
+JETSON_TX2 = 'JETSON_TX2'
39
+JETSON_XAVIER = 'JETSON_XAVIER'
40
+JETSON_NANO = 'JETSON_NANO'
41
+
42
+# Google Coral dev board
43
+CORAL_EDGE_TPU_DEV = "CORAL_EDGE_TPU_DEV"
44
+
45
+# Various Raspberry Pi models
46
+RASPBERRY_PI_B_REV1 = "RASPBERRY_PI_B_REV1"
47
+RASPBERRY_PI_B_REV2 = "RASPBERRY_PI_B_REV2"
48
+RASPBERRY_PI_B_PLUS = "RASPBERRY_PI_B_PLUS"
49
+RASPBERRY_PI_A = "RASPBERRY_PI_A"
50
+RASPBERRY_PI_A_PLUS = "RASPBERRY_PI_A_PLUS"
51
+RASPBERRY_PI_CM1 = "RASPBERRY_PI_CM1"
52
+RASPBERRY_PI_ZERO = "RASPBERRY_PI_ZERO"
53
+RASPBERRY_PI_ZERO_W = "RASPBERRY_PI_ZERO_W"
54
+RASPBERRY_PI_2B = "RASPBERRY_PI_2B"
55
+RASPBERRY_PI_3B = "RASPBERRY_PI_3B"
56
+RASPBERRY_PI_3B_PLUS = "RASPBERRY_PI_3B_PLUS"
57
+RASPBERRY_PI_CM3 = "RASPBERRY_PI_CM3"
58
+RASPBERRY_PI_3A_PLUS = "RASPBERRY_PI_3A_PLUS"
59
+RASPBERRY_PI_CM3_PLUS = "RASPBERRY_PI_CM3_PLUS"
60
+RASPBERRY_PI_4B = "RASPBERRY_PI_4B"
61
+
62
+ODROID_C1 = "ODROID_C1"
63
+ODROID_C1_PLUS = "ODROID_C1_PLUS"
64
+ODROID_C2 = "ODROID_C2"
65
+ODROID_N2 = "ODROID_N2"
66
+
67
+FTDI_FT232H = "FTDI_FT232H"
68
+DRAGONBOARD_410C = "DRAGONBOARD_410C"
69
+
70
+SIFIVE_UNLEASHED = "SIFIVE_UNLEASHED"
71
+
72
+MICROCHIP_MCP2221 = "MICROCHIP_MCP2221"
73
+
74
+BINHO_NOVA = "BINHO_NOVA"
75
+
76
+ONION_OMEGA = "ONION_OMEGA"
77
+ONION_OMEGA2 = "ONION_OMEGA2"
78
+
79
+PINE64 = "PINE64"
80
+PINEBOOK = "PINEBOOK"
81
+PINEPHONE = "PINEPHONE"
82
+
83
+# pylint: enable=bad-whitespace
84
+
85
+# OrangePI
86
+_ORANGE_PI_IDS = (
87
+    ORANGE_PI_PC,
88
+    ORANGE_PI_R1,
89
+    ORANGE_PI_ZERO,
90
+    ORANGE_PI_ONE,
91
+    ORANGE_PI_LITE,
92
+    ORANGE_PI_PC_PLUS,
93
+    ORANGE_PI_PLUS_2E,
94
+)
95
+
96
+_CORAL_IDS = (
97
+    CORAL_EDGE_TPU_DEV,
98
+)
99
+
100
+_JETSON_IDS = (
101
+    JETSON_TX1,
102
+    JETSON_TX2,
103
+    JETSON_XAVIER,
104
+    JETSON_NANO
105
+)
106
+
107
+_RASPBERRY_PI_40_PIN_IDS = (
108
+    RASPBERRY_PI_B_PLUS,
109
+    RASPBERRY_PI_A_PLUS,
110
+    RASPBERRY_PI_ZERO,
111
+    RASPBERRY_PI_ZERO_W,
112
+    RASPBERRY_PI_2B,
113
+    RASPBERRY_PI_3B,
114
+    RASPBERRY_PI_3B_PLUS,
115
+    RASPBERRY_PI_3A_PLUS,
116
+    RASPBERRY_PI_4B
117
+)
118
+
119
+_RASPBERRY_PI_CM_IDS = (
120
+    RASPBERRY_PI_CM1,
121
+    RASPBERRY_PI_CM3,
122
+    RASPBERRY_PI_CM3_PLUS
123
+)
124
+
125
+_ODROID_40_PIN_IDS = (
126
+    ODROID_C1,
127
+    ODROID_C1_PLUS,
128
+    ODROID_C2,
129
+    ODROID_N2
130
+)
131
+
132
+_BEAGLEBONE_IDS = (
133
+    BEAGLEBONE,
134
+    BEAGLEBONE_BLACK,
135
+    BEAGLEBONE_BLUE,
136
+    BEAGLEBONE_BLACK_WIRELESS,
137
+    BEAGLEBONE_POCKETBEAGLE,
138
+    BEAGLEBONE_GREEN,
139
+    BEAGLEBONE_GREEN_WIRELESS,
140
+    BEAGLEBONE_BLACK_INDUSTRIAL,
141
+    BEAGLEBONE_ENHANCED,
142
+    BEAGLEBONE_USOMIQ,
143
+    BEAGLEBONE_AIR,
144
+    BEAGLEBONE_POCKETBONE,
145
+    BEAGLELOGIC_STANDALONE,
146
+    OSD3358_DEV_BOARD,
147
+    OSD3358_SM_RED,
148
+)
149
+
150
+_LINARO_96BOARDS_IDS = (
151
+    DRAGONBOARD_410C,
152
+)
153
+
154
+_SIFIVE_IDS = (
155
+    SIFIVE_UNLEASHED,
156
+)
157
+
158
+# BeagleBone eeprom board ids from:
159
+#   https://github.com/beagleboard/image-builder
160
+# Thanks to zmatt on freenode #beagle for pointers.
161
+_BEAGLEBONE_BOARD_IDS = {
162
+    # Original bone/white:
163
+    BEAGLEBONE: (
164
+        ('A4', 'A335BONE00A4'),
165
+        ('A5', 'A335BONE00A5'),
166
+        ('A6', 'A335BONE00A6'),
167
+        ('A6A', 'A335BONE0A6A'),
168
+        ('A6B', 'A335BONE0A6B'),
169
+        ('B', 'A335BONE000B'),
170
+    ),
171
+    BEAGLEBONE_BLACK: (
172
+        ('A5', 'A335BNLT00A5'),
173
+        ('A5A', 'A335BNLT0A5A'),
174
+        ('A5B', 'A335BNLT0A5B'),
175
+        ('A5C', 'A335BNLT0A5C'),
176
+        ('A6', 'A335BNLT00A6'),
177
+        ('C', 'A335BNLT000C'),
178
+        ('C', 'A335BNLT00C0'),
179
+    ),
180
+    BEAGLEBONE_BLUE: (
181
+        ('A2', 'A335BNLTBLA2'),
182
+    ),
183
+    BEAGLEBONE_BLACK_WIRELESS: (
184
+        ('A5', 'A335BNLTBWA5'),
185
+    ),
186
+    BEAGLEBONE_POCKETBEAGLE: (
187
+        ('A2', 'A335PBGL00A2'),
188
+    ),
189
+    BEAGLEBONE_GREEN: (
190
+        ('1A', 'A335BNLT....'),
191
+        ('UNKNOWN', 'A335BNLTBBG1'),
192
+    ),
193
+    BEAGLEBONE_GREEN_WIRELESS: (
194
+        ('W1A', 'A335BNLTGW1A'),
195
+    ),
196
+    BEAGLEBONE_BLACK_INDUSTRIAL: (
197
+        ('A0', 'A335BNLTAIA0'),  # Arrow
198
+        ('A0', 'A335BNLTEIA0'),  # Element14
199
+    ),
200
+    BEAGLEBONE_ENHANCED: (
201
+        ('A', 'A335BNLTSE0A'),
202
+    ),
203
+    BEAGLEBONE_USOMIQ: (
204
+        ('6', 'A335BNLTME06'),
205
+    ),
206
+    BEAGLEBONE_AIR: (
207
+        ('A0', 'A335BNLTNAD0'),
208
+    ),
209
+    BEAGLEBONE_POCKETBONE: (
210
+        ('0', 'A335BNLTBP00'),
211
+    ),
212
+    OSD3358_DEV_BOARD: (
213
+        ('0.1', 'A335BNLTGH01'),
214
+    ),
215
+    OSD3358_SM_RED: (
216
+        ('0', 'A335BNLTOS00'),
217
+    ),
218
+    BEAGLELOGIC_STANDALONE: (
219
+        ('A', 'A335BLGC000A'),
220
+    )
221
+}
222
+
223
+# Pi revision codes from:
224
+#   https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
225
+
226
+# Each tuple here contains both the base codes, and the versions that indicate
227
+# the Pi is overvolted / overclocked - for 4-digit codes, this will be prefixed
228
+# with 1000, and for 6-digit codes it'll be prefixed with 1.  These are placed
229
+# on separate lines.
230
+
231
+_PI_REV_CODES = {
232
+    RASPBERRY_PI_B_REV1: (
233
+        # Regular codes:
234
+        '0002', '0003',
235
+
236
+        # Overvolted/clocked versions:
237
+        '1000002', '1000003',
238
+    ),
239
+    RASPBERRY_PI_B_REV2: (
240
+        '0005', '0006', '000d', '000e', '000f',
241
+        '1000005', '1000006', '100000d', '100000e', '100000f',
242
+    ),
243
+    RASPBERRY_PI_B_PLUS: (
244
+        '0010', '0013', '900032',
245
+        '1000010', '1000013', '1900032',
246
+    ),
247
+    RASPBERRY_PI_A: (
248
+        '0007', '0008', '0009',
249
+        '1000007', '1000008', '1000009',
250
+    ),
251
+    RASPBERRY_PI_A_PLUS: (
252
+        '0012', '0015', '900021',
253
+        '1000012', '1000015', '1900021',
254
+    ),
255
+    RASPBERRY_PI_CM1: (
256
+        '0011', '0014',
257
+        '10000011', '10000014',
258
+    ),
259
+    RASPBERRY_PI_ZERO: (
260
+        '900092', '920092', '900093', '920093',
261
+        '1900092', '1920092', '1900093', '1920093',  # warranty bit 24
262
+        '2900092', '2920092', '2900093', '2920093',  # warranty bit 25
263
+    ),
264
+    RASPBERRY_PI_ZERO_W: (
265
+        '9000c1',
266
+        '19000c1', '29000c1',  # warranty bits
267
+    ),
268
+    RASPBERRY_PI_2B: (
269
+        'a01040', 'a01041', 'a21041', 'a22042',
270
+        '1a01040', '1a01041', '1a21041', '1a22042',  # warranty bit 24
271
+        '2a01040', '2a01041', '2a21041', '2a22042',  # warranty bit 25
272
+    ),
273
+    RASPBERRY_PI_3B: (
274
+        'a02082', 'a22082', 'a32082', 'a52082',
275
+        '1a02082', '1a22082', '1a32082', '1a52082',  # warranty bit 24
276
+        '2a02082', '2a22082', '2a32082', '2a52082',  # warranty bit 25
277
+    ),
278
+    RASPBERRY_PI_3B_PLUS: (
279
+        'a020d3',
280
+        '1a020d3', '2a020d3',  # warranty bits
281
+    ),
282
+    RASPBERRY_PI_CM3: (
283
+        'a020a0', 'a220a0',
284
+        '1a020a0', '2a020a0',  # warranty bits
285
+        '1a220a0', '2a220a0',
286
+    ),
287
+    RASPBERRY_PI_3A_PLUS: (
288
+        '9020e0',
289
+        '19020e0', '29020e0',  # warranty bits
290
+    ),
291
+    RASPBERRY_PI_CM3_PLUS: (
292
+        'a02100',
293
+        '1a02100', '2a02100',  # warranty bits
294
+    ),
295
+    RASPBERRY_PI_4B: (
296
+        'a03111', 'b03111', 'c03111',
297
+        'a03112', 'b03112', 'c03112',
298
+        '1a03111', '2a03111', '1b03111', '2b03111',  # warranty bits
299
+        '1c03111', '2c03111', '1a03112', '2a03112',
300
+        '1b03112', '2b03112', '1c03112', '2c03112',
301
+    ),
302
+}
303
+
304
+# Onion omega boards
305
+_ONION_OMEGA_BOARD_IDS = (
306
+    ONION_OMEGA,
307
+    ONION_OMEGA2,
308
+)
309
+
310
+# Pine64 boards and devices
311
+_PINE64_DEV_IDS = (
312
+    PINE64,
313
+    PINEBOOK,
314
+    PINEPHONE
315
+)

+ 27
- 0
adafruit_platformdetect/constants/chips.py View File

@@ -0,0 +1,27 @@
1
+"""Definition of chips."""
2
+AM33XX = "AM33XX"
3
+IMX8MX = "IMX8MX"
4
+BCM2XXX = "BCM2XXX"
5
+ESP8266 = "ESP8266"
6
+SAMD21 = "SAMD21"
7
+STM32 = "STM32"
8
+SUN8I = "SUN8I"
9
+S805 = "S805"
10
+S905 = "S905"
11
+S922X = "S922X"
12
+SAMA5 = "SAMA5"
13
+T210 = "T210"
14
+T186 = "T186"
15
+T194 = "T194"
16
+APQ8016 = "APQ8016"
17
+GENERIC_X86 = "GENERIC_X86"
18
+FT232H = "FT232H"
19
+HFU540 = "HFU540"
20
+MCP2221 = "MCP2221"
21
+BINHO = "BINHO"
22
+MIPS24KC = "MIPS24KC"
23
+MIPS24KEC = "MIPS24KEC"
24
+A64 = "A64"
25
+
26
+BCM_RANGE = {'BCM2708', 'BCM2709', 'BCM2835', 'BCM2837', 'bcm2708', 'bcm2709',
27
+             'bcm2835', 'bcm2837'}

Loading…
Cancel
Save