Skip to content

Commit 10f588d

Browse files
authored
Merge pull request #13 from Groboards/master
Add support for Giant Board and other SAMA5 based boards
2 parents ea528db + 5a79a95 commit 10f588d

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

adafruit_platformdetect/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,15 @@ def get_armbian_release_field(self, field):
7373
pass
7474

7575
return field_value
76+
77+
def get_device_model(self):
78+
"""
79+
Search /proc/device-tree/model for the device model and return its value, if found,
80+
otherwise None.
81+
"""
82+
try:
83+
with open('/proc/device-tree/model', 'r') as model_file:
84+
model = model_file.read()
85+
return model
86+
except FileNotFoundError:
87+
pass

adafruit_platformdetect/board.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
PYBOARD = "PYBOARD"
2727
NODEMCU = "NODEMCU"
2828
ORANGE_PI_PC = "ORANGE_PI_PC"
29+
GIANT_BOARD = "GIANT_BOARD"
2930

3031
RASPBERRY_PI_B_REV1 = "RASPBERRY_PI_B_REV1"
3132
RASPBERRY_PI_B_REV2 = "RASPBERRY_PI_B_REV2"
@@ -244,6 +245,8 @@ def id(self):
244245
board_id = GENERIC_LINUX_PC
245246
elif chip_id == ap_chip.SUN8I:
246247
board_id = self._armbian_id()
248+
elif chip_id == ap_chip.SAMA5:
249+
board_id = self._sama5_id()
247250
elif chip_id == ap_chip.ESP8266:
248251
board_id = FEATHER_HUZZAH
249252
elif chip_id == ap_chip.SAMD21:
@@ -308,6 +311,13 @@ def _armbian_id(self):
308311
return ORANGE_PI_PC
309312
return None
310313

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
320+
311321
@property
312322
def any_raspberry_pi(self):
313323
"""Check whether the current board is any Raspberry Pi."""
@@ -328,10 +338,16 @@ def any_orange_pi(self):
328338
"""Check whether the current board is any defined Orange Pi."""
329339
return self.ORANGE_PI_PC
330340

341+
@property
342+
def any_giant_board(self):
343+
"""Check whether the current board is any defined Giant Board."""
344+
return self.GIANT_BOARD
345+
331346
@property
332347
def any_embedded_linux(self):
333348
"""Check whether the current board is any embedded Linux device."""
334-
return self.any_raspberry_pi or self.any_beaglebone or self.any_orange_pi
349+
return self.any_raspberry_pi or self.any_beaglebone or \
350+
self.any_orange_pi or self.any_giant_board
335351

336352
def __getattr__(self, attr):
337353
"""

adafruit_platformdetect/chip.py

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

@@ -86,6 +87,8 @@ def _linux_id(self):
8687
linux_id = S805
8788
elif "ODROID-C2" in hardware:
8889
linux_id = S905
90+
elif "SAMA5" in hardware:
91+
linux_id = SAMA5
8992

9093
return linux_id
9194

bin/detect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
print("Is this a 40-pin Raspberry Pi?", detector.board.any_raspberry_pi_40_pin)
1313
print("Is this a BBB?", detector.board.BEAGLEBONE_BLACK)
1414
print("Is this an Orange Pi PC?", detector.board.ORANGE_PI_PC)
15+
print("Is this a Giant Board?", detector.board.GIANT_BOARD)
1516
print("Is this an embedded Linux system?", detector.board.any_embedded_linux)
1617
print("Is this a generic Linux PC?", detector.board.GENERIC_LINUX_PC)
1718

0 commit comments

Comments
 (0)