Skip to content

Added board detection for UDOO Bolt using check_board_asset_value() #81

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 12 commits into from
May 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion adafruit_platformdetect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def check_board_asset_tag_value(self):

try:
with open("/sys/devices/virtual/dmi/id/board_asset_tag", "r") as tag_file:
tag = tag_file.read()
tag = tag_file.read().strip()
except FileNotFoundError:
pass

Expand Down
16 changes: 15 additions & 1 deletion adafruit_platformdetect/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def id(self):
elif chip_id == chips.RK3308:
board_id = self._rock_pi_id()
elif chip_id == chips.RYZEN_V1605B:
board_id = boards.UDOO_BOLT
board_id = self._udoo_id()

return board_id

Expand Down Expand Up @@ -316,6 +316,14 @@ def _clockwork_pi_id(self):
board = boards.CLOCKWORK_CPI3
return board

def _udoo_id(self):
"""Try to detect the id of udoo board."""
board_asset_tag = self.detector.check_board_asset_tag_value()
for board_id, board_tags in boards._UDOO_BOARD_IDS.items():
if any(v == board_asset_tag for v in board_tags):
return board_id
return None

@property
def any_96boards(self):
"""Check whether the current board is any 96boards board."""
Expand Down Expand Up @@ -396,6 +404,11 @@ def any_clockwork_pi_board(self):
"""Check whether the current board is any Clockwork Pi device."""
return self.CLOCKWORK_CPI3

@property
def any_udoo_board(self):
"""Check to see if the current board is an UDOO board"""
return self.id in boards._UDOO_BOARD_IDS

@property
def any_embedded_linux(self):
"""Check whether the current board is any embedded Linux device."""
Expand All @@ -415,6 +428,7 @@ def any_embedded_linux(self):
self.any_pynq_board,
self.any_rock_pi_board,
self.any_clockwork_pi_board,
self.any_udoo_board,
]
)

Expand Down
4 changes: 3 additions & 1 deletion adafruit_platformdetect/constants/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
ROCK_PI_S = "ROCK_PI_S"

GREATFET_ONE = "GREATFET_ONE"

UDOO_BOLT = "UDOO_BOLT"

# pylint: enable=bad-whitespace
Expand Down Expand Up @@ -344,3 +343,6 @@

# Pine64 boards and devices
_PINE64_DEV_IDS = (PINE64, PINEBOOK, PINEPHONE)

# UDOO
_UDOO_BOARD_IDS = {UDOO_BOLT: ("SC40-2000-0000-C0|C",)}
3 changes: 2 additions & 1 deletion bin/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
detector = adafruit_platformdetect.Detector()

print("Chip id: ", detector.chip.id)

print("Board id: ", detector.board.id)
print()

print("Is this a DragonBoard 410c?", detector.board.DRAGONBOARD_410C)
print("Is this a Pi 3B+?", detector.board.RASPBERRY_PI_3B_PLUS)
Expand All @@ -23,6 +23,7 @@
print("Is this a Clockwork Pi board?", detector.board.any_clockwork_pi_board)
print("Is this an embedded Linux system?", detector.board.any_embedded_linux)
print("Is this a generic Linux PC?", detector.board.GENERIC_LINUX_PC)
print("Is this a UDOO Bolt?", detector.board.UDOO_BOLT)
print(
"Is this an OS environment variable special case?",
detector.board.FTDI_FT232H
Expand Down