Browse Source

Add support to detect SAMA5 chips and the Giant Board

Christopher Alessandro 1 week ago
parent
commit
d209a3a544

+ 11
- 0
adafruit_platformdetect/__init__.py View File

@@ -73,3 +73,14 @@ class Detector:
73 73
             pass
74 74
 
75 75
         return field_value
76
+        
77
+    def get_device_model(self):
78
+        """
79
+        otherwise None.
80
+        """
81
+        try:
82
+	        with open('/proc/device-tree/model', 'r') as model_file:
83
+		        model = model_file.read()
84
+		    return model
85
+        except FileNotFoundError:
86
+	        pass

+ 14
- 0
adafruit_platformdetect/board.py View File

@@ -26,6 +26,7 @@ GENERIC_LINUX_PC            = "GENERIC_LINUX_PC"
26 26
 PYBOARD                     = "PYBOARD"
27 27
 NODEMCU                     = "NODEMCU"
28 28
 ORANGE_PI_PC                = "ORANGE_PI_PC"
29
+GIANT_BOARD                 = "GIANT_BOARD"
29 30
 
30 31
 RASPBERRY_PI_B_REV1         = "RASPBERRY_PI_B_REV1"
31 32
 RASPBERRY_PI_B_REV2         = "RASPBERRY_PI_B_REV2"
@@ -244,6 +245,8 @@ class Board:
244 245
             board_id = GENERIC_LINUX_PC
245 246
         elif chip_id == ap_chip.SUN8I:
246 247
             board_id = self._armbian_id()
248
+        elif chip_id == ap_chip.SAMA5:
249
+            board_id = self._sama5_id()
247 250
         elif chip_id == ap_chip.ESP8266:
248 251
             board_id = FEATHER_HUZZAH
249 252
         elif chip_id == ap_chip.SAMD21:
@@ -307,6 +310,13 @@ class Board:
307 310
         if board_value == "orangepipc":
308 311
             return ORANGE_PI_PC
309 312
         return None
313
+        
314
+	def _sama5_id(self):
315
+        """Check what type sama5 board."""
316
+        board_value = self.detector.get_device_model()
317
+        if "Giant Board" in board_value:
318
+            return GIANT_BOARD
319
+        return None
310 320
 
311 321
     @property
312 322
     def any_raspberry_pi(self):
@@ -327,6 +337,10 @@ class Board:
327 337
     def any_orange_pi(self):
328 338
         """Check whether the current board is any defined Orange Pi."""
329 339
         return self.ORANGE_PI_PC
340
+        
341
+	@property
342
+    def any_giant_board(self):
343
+        return self.GIANT_BOARD
330 344
 
331 345
     @property
332 346
     def any_embedded_linux(self):

+ 3
- 0
adafruit_platformdetect/chip.py View File

@@ -10,6 +10,7 @@ STM32 = "STM32"
10 10
 SUN8I = "SUN8I"
11 11
 S805 = "S805"
12 12
 S905 = "S905"
13
+SAMA5 = "SAMA5"
13 14
 GENERIC_X86 = "GENERIC_X86"
14 15
 FT232H = "FT232H"
15 16
 
@@ -86,6 +87,8 @@ class Chip:
86 87
             linux_id = S805
87 88
         elif "ODROID-C2" in hardware:
88 89
             linux_id = S905
90
+        elif "SAMA5" in hardware:
91
+            linux_id = SAMA5
89 92
 
90 93
         return linux_id
91 94
 

+ 1
- 0
bin/detect.py View File

@@ -12,6 +12,7 @@ print("Is this a Pi 3B+?", detector.board.RASPBERRY_PI_3B_PLUS)
12 12
 print("Is this a 40-pin Raspberry Pi?", detector.board.any_raspberry_pi_40_pin)
13 13
 print("Is this a BBB?", detector.board.BEAGLEBONE_BLACK)
14 14
 print("Is this an Orange Pi PC?", detector.board.ORANGE_PI_PC)
15
+print("Is this a Giant Board?", detector.board.GIANT_BOARD)
15 16
 print("Is this an embedded Linux system?", detector.board.any_embedded_linux)
16 17
 print("Is this a generic Linux PC?", detector.board.GENERIC_LINUX_PC)
17 18