Skip to content

Initial support for Sifive's HiFive Unleashed #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion adafruit_platformdetect/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@

FTDI_FT232H = "FT232H"
DRAGONBOARD_410C = "DRAGONBOARD_410C"

SIFIVEHFUA00 = "SIFIVEHFUA00"

# pylint: enable=bad-whitespace

#OrangePI
Expand Down Expand Up @@ -119,6 +122,11 @@
DRAGONBOARD_410C,
)


_SIFIVE_IDS = (
SIFIVEHFUA00,
)

# BeagleBone eeprom board ids from:
# https://github.com/beagleboard/image-builder
# Thanks to zmatt on freenode #beagle for pointers.
Expand Down Expand Up @@ -305,6 +313,8 @@ def id(self):
board_id = DRAGONBOARD_410C
elif chip_id in (ap_chip.T210, ap_chip.T186, ap_chip.T194):
board_id = self._tegra_id()
elif chip_id == ap_chip.HFU540:
board_id = self._sifive_id()
return board_id
# pylint: enable=invalid-name

Expand Down Expand Up @@ -387,6 +397,12 @@ def _tegra_id(self):
board = JETSON_NANO
return board

def _sifive_id(self):
"""Try to detect the id for Sifive RISCV64 board."""
board_value = self.detector.get_device_model()
if 'hifive-unleashed-a00' in board_value:
return SIFIVEHFUA00

@property
def any_96boards(self):
"""Check whether the current board is any 96boards board."""
Expand Down Expand Up @@ -432,12 +448,18 @@ def any_jetson_board(self):
"""Check whether the current board is any defined Jetson Board."""
return self.id in _JETSON_IDS

@property
def any_sifive_board(self):
"""Check whether the current board is any defined Jetson Board."""
return self.id in _SIFIVE_IDS

@property
def any_embedded_linux(self):
"""Check whether the current board is any embedded Linux device."""
return self.any_raspberry_pi or self.any_beaglebone or \
self.any_orange_pi or self.any_giant_board or self.any_jetson_board or \
self.any_coral_board or self.any_odroid_40_pin or self.any_96boards
self.any_coral_board or self.any_odroid_40_pin or self.any_96boards or \
self.any_sifive_board

def __getattr__(self, attr):
"""
Expand Down
4 changes: 4 additions & 0 deletions adafruit_platformdetect/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
APQ8016 = "APQ8016"
GENERIC_X86 = "GENERIC_X86"
FT232H = "FT232H"
HFU540 = "HFU540"

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

if self.detector.check_dt_compatible_value("fu500"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably change this to a little longer string like "sifive,fu540gsifive"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of the 3 values in the proc file, only the first or third values work.

if self.detector.check_dt_compatible_value("fu500"): # Works
if self.detector.check_dt_compatible_value("sifive,fu540gsifive"): # Does not
if self.detector.check_dt_compatible_value("sifive"): # Works
if self.detector.check_dt_compatible_value("sifive,fu540gsifive,fu500"): # Does not

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

if self.detector.check_dt_compatible_value("fu540gsifive"):

return HFU540

linux_id = None
hardware = self.detector.get_cpuinfo_field("Hardware")

Expand Down