Skip to content

Commit eeb4be3

Browse files
authored
Merge pull request #31 from fede2cr/master
Initial support for Sifive's HiFive Unleashed
2 parents 9278f16 + dad8400 commit eeb4be3

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

adafruit_platformdetect/board.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060

6161
FTDI_FT232H = "FT232H"
6262
DRAGONBOARD_410C = "DRAGONBOARD_410C"
63+
64+
SIFIVE_UNLEASHED = "SIFIVE_UNLEASHED"
65+
6366
# pylint: enable=bad-whitespace
6467

6568
#OrangePI
@@ -119,6 +122,11 @@
119122
DRAGONBOARD_410C,
120123
)
121124

125+
126+
_SIFIVE_IDS = (
127+
SIFIVE_UNLEASHED,
128+
)
129+
122130
# BeagleBone eeprom board ids from:
123131
# https://github.com/beagleboard/image-builder
124132
# Thanks to zmatt on freenode #beagle for pointers.
@@ -305,6 +313,8 @@ def id(self):
305313
board_id = DRAGONBOARD_410C
306314
elif chip_id in (ap_chip.T210, ap_chip.T186, ap_chip.T194):
307315
board_id = self._tegra_id()
316+
elif chip_id == ap_chip.HFU540:
317+
board_id = self._sifive_id()
308318
return board_id
309319
# pylint: enable=invalid-name
310320

@@ -387,6 +397,13 @@ def _tegra_id(self):
387397
board = JETSON_NANO
388398
return board
389399

400+
def _sifive_id(self):
401+
"""Try to detect the id for Sifive RISCV64 board."""
402+
board_value = self.detector.get_device_model()
403+
if 'hifive-unleashed-a00' in board_value:
404+
return SIFIVE_UNLEASHED
405+
return None
406+
390407
@property
391408
def any_96boards(self):
392409
"""Check whether the current board is any 96boards board."""
@@ -432,12 +449,18 @@ def any_jetson_board(self):
432449
"""Check whether the current board is any defined Jetson Board."""
433450
return self.id in _JETSON_IDS
434451

452+
@property
453+
def any_sifive_board(self):
454+
"""Check whether the current board is any defined Jetson Board."""
455+
return self.id in _SIFIVE_IDS
456+
435457
@property
436458
def any_embedded_linux(self):
437459
"""Check whether the current board is any embedded Linux device."""
438460
return self.any_raspberry_pi or self.any_beaglebone or \
439461
self.any_orange_pi or self.any_giant_board or self.any_jetson_board or \
440-
self.any_coral_board or self.any_odroid_40_pin or self.any_96boards
462+
self.any_coral_board or self.any_odroid_40_pin or self.any_96boards or \
463+
self.any_sifive_board
441464

442465
def __getattr__(self, attr):
443466
"""

adafruit_platformdetect/chip.py

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
APQ8016 = "APQ8016"
1919
GENERIC_X86 = "GENERIC_X86"
2020
FT232H = "FT232H"
21+
HFU540 = "HFU540"
2122

2223
class Chip:
2324
"""Attempt detection of current chip / CPU."""
@@ -78,6 +79,9 @@ def _linux_id(self): # pylint: disable=too-many-branches
7879
if self.detector.check_dt_compatible_value("qcom,apq8016"):
7980
return APQ8016
8081

82+
if self.detector.check_dt_compatible_value("fu500"):
83+
return HFU540
84+
8185
linux_id = None
8286
hardware = self.detector.get_cpuinfo_field("Hardware")
8387

bin/detect.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
print("Is this a BBB?", detector.board.BEAGLEBONE_BLACK)
1616
print("Is this a Giant Board?", detector.board.GIANT_BOARD)
1717
print("Is this a Coral Edge TPU?", detector.board.CORAL_EDGE_TPU_DEV)
18+
print("Is this a SiFive Unleashed? ", detector.board.SIFIVE_UNLEASHED)
1819
print("Is this an embedded Linux system?", detector.board.any_embedded_linux)
1920
print("Is this a generic Linux PC?", detector.board.GENERIC_LINUX_PC)
2021

0 commit comments

Comments
 (0)