From 710f368a72faf253f1402984be69f32f3d0dd94b Mon Sep 17 00:00:00 2001 From: Dale Weber Date: Tue, 19 May 2020 05:32:12 -0700 Subject: [PATCH 1/9] Added board detection for UDOO Bolt using check_board_asset_value() and added it to detect.py --- adafruit_platformdetect/board.py | 3 ++- bin/detect.py | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index eae2868c..c0e3f743 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -50,6 +50,7 @@ class Board: def __init__(self, detector): self.detector = detector + self.board_asset_tag = self.detector.check_board_asset_tag_value().strip() # pylint: disable=invalid-name, protected-access @property @@ -117,7 +118,7 @@ def id(self): board_id = self._clockwork_pi_id() elif chip_id == chips.RK3308: board_id = self._rock_pi_id() - elif chip_id == chips.RYZEN_V1605B: + elif self.board_asset_tag == "SC40-2000-0000-C0|C": board_id = boards.UDOO_BOLT return board_id diff --git a/bin/detect.py b/bin/detect.py index e7ff9856..c163fe7d 100755 --- a/bin/detect.py +++ b/bin/detect.py @@ -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) @@ -23,12 +23,10 @@ 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 an OS environment variable special case?", - detector.board.FTDI_FT232H - | detector.board.MICROCHIP_MCP2221 - | detector.board.BINHO_NOVA - | detector.board.GREATFET_ONE, +print("Is this a UDOO Bolt?", detector.board.UDOO_BOLT) +print("Is this an OS environment variable special case?", + detector.board.FTDI_FT232H | detector.board.MICROCHIP_MCP2221 | + detector.board.BINHO_NOVA | detector.board.GREATFET_ONE ) if detector.board.any_raspberry_pi: From d0d36d1683ffb095307618f68169b7d5984b84d6 Mon Sep 17 00:00:00 2001 From: Dale Weber Date: Tue, 19 May 2020 05:41:15 -0700 Subject: [PATCH 2/9] Fixed code formatting --- bin/detect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/detect.py b/bin/detect.py index c163fe7d..6039ad77 100755 --- a/bin/detect.py +++ b/bin/detect.py @@ -25,8 +25,8 @@ 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 | detector.board.MICROCHIP_MCP2221 | - detector.board.BINHO_NOVA | detector.board.GREATFET_ONE + detector.board.FTDI_FT232H | detector.board.MICROCHIP_MCP2221 | + detector.board.BINHO_NOVA | detector.board.GREATFET_ONE ) if detector.board.any_raspberry_pi: From a5eb09d0ecb116de4df41934a60c68c716732d29 Mon Sep 17 00:00:00 2001 From: Dale Weber Date: Tue, 19 May 2020 05:46:38 -0700 Subject: [PATCH 3/9] Fixed code formatting, try #2 --- bin/detect.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/detect.py b/bin/detect.py index 6039ad77..ec86404d 100755 --- a/bin/detect.py +++ b/bin/detect.py @@ -24,9 +24,10 @@ 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 | detector.board.MICROCHIP_MCP2221 | - detector.board.BINHO_NOVA | detector.board.GREATFET_ONE +print("Is this an OS environment variable special case?", detector.board.FTDI_FT232H | + detector.board.MICROCHIP_MCP2221 | + detector.board.BINHO_NOVA | + detector.board.GREATFET_ONE ) if detector.board.any_raspberry_pi: From 0de104ca7a9b2f5182650f8c83c307821b640f4d Mon Sep 17 00:00:00 2001 From: Dale Weber Date: Tue, 19 May 2020 05:51:22 -0700 Subject: [PATCH 4/9] Fixed code formatting, try #3. Oh, my! --- bin/detect.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/detect.py b/bin/detect.py index ec86404d..e5ba8a1d 100755 --- a/bin/detect.py +++ b/bin/detect.py @@ -24,10 +24,10 @@ 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 | - detector.board.MICROCHIP_MCP2221 | - detector.board.BINHO_NOVA | - detector.board.GREATFET_ONE +print("Is this an OS environment variable special case?", detector.board.FTDI_FT232H + | detector.board.MICROCHIP_MCP2221 + | detector.board.BINHO_NOVA + | detector.board.GREATFET_ONE ) if detector.board.any_raspberry_pi: From d3cc2a29e0d3f8799e4de9c43234da08d537b479 Mon Sep 17 00:00:00 2001 From: Dale Weber Date: Tue, 19 May 2020 05:56:57 -0700 Subject: [PATCH 5/9] Fixed code formatting by running black on detect.py, try #4. Oh, my! --- bin/detect.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/detect.py b/bin/detect.py index e5ba8a1d..ff609f9b 100755 --- a/bin/detect.py +++ b/bin/detect.py @@ -24,10 +24,12 @@ 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 +print( + "Is this an OS environment variable special case?", + detector.board.FTDI_FT232H | detector.board.MICROCHIP_MCP2221 | detector.board.BINHO_NOVA - | detector.board.GREATFET_ONE + | detector.board.GREATFET_ONE, ) if detector.board.any_raspberry_pi: From ab2bd7dee41755ab2b887a99936b83c01dc858e8 Mon Sep 17 00:00:00 2001 From: Dale Weber Date: Wed, 20 May 2020 09:10:15 -0700 Subject: [PATCH 6/9] Changed names of UDOO_IDS and UDOO_ASSET_TAG; Corrected layout of UDOO_BOARD_IDS --- adafruit_platformdetect/__init__.py | 2 +- adafruit_platformdetect/board.py | 8 +++++++- adafruit_platformdetect/constants/boards.py | 11 +++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/adafruit_platformdetect/__init__.py b/adafruit_platformdetect/__init__.py index 3e7090df..915524f3 100644 --- a/adafruit_platformdetect/__init__.py +++ b/adafruit_platformdetect/__init__.py @@ -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 diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index c0e3f743..db2026a6 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -118,7 +118,7 @@ def id(self): board_id = self._clockwork_pi_id() elif chip_id == chips.RK3308: board_id = self._rock_pi_id() - elif self.board_asset_tag == "SC40-2000-0000-C0|C": + elif self.board_asset_tag == boards._UDOO_BOLT_BOARD_ASSET_TAG board_id = boards.UDOO_BOLT return board_id @@ -395,6 +395,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.""" @@ -414,6 +419,7 @@ def any_embedded_linux(self): self.any_pynq_board, self.any_rock_pi_board, self.any_clockwork_pi_board, + self.any_udoo_board, ] ) diff --git a/adafruit_platformdetect/constants/boards.py b/adafruit_platformdetect/constants/boards.py index bf9b947f..8c6a0126 100644 --- a/adafruit_platformdetect/constants/boards.py +++ b/adafruit_platformdetect/constants/boards.py @@ -95,8 +95,6 @@ GREATFET_ONE = "GREATFET_ONE" -UDOO_BOLT = "UDOO_BOLT" - # pylint: enable=bad-whitespace # OrangePI @@ -336,3 +334,12 @@ # Pine64 boards and devices _PINE64_DEV_IDS = (PINE64, PINEBOOK, PINEPHONE) + +UDOO_BOLT = "UDOO_BOLT" +_UDOO_BOLT_BOARD_ASSET_TAG = "SC40-2000-0000-C0|C" + +# UDOO +_UDOO_BOARD_IDS = ( + UDOO_BOLT, + _UDOO_BOLT_BOARD_ASSET_TAG, +) From 4c3b2190e57d6c7e4c1c7b7bcc23a10659e7dbf2 Mon Sep 17 00:00:00 2001 From: Dale Weber Date: Wed, 20 May 2020 09:22:13 -0700 Subject: [PATCH 7/9] Fixed error - added ':' in if statement.' --- adafruit_platformdetect/board.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index db2026a6..792fd128 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -118,7 +118,7 @@ def id(self): board_id = self._clockwork_pi_id() elif chip_id == chips.RK3308: board_id = self._rock_pi_id() - elif self.board_asset_tag == boards._UDOO_BOLT_BOARD_ASSET_TAG + elif self.board_asset_tag == boards._UDOO_BOLT_BOARD_ASSET_TAG: board_id = boards.UDOO_BOLT return board_id From 125f2adf90b00d0414a54be142998d1a12d62e06 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 21 May 2020 07:18:13 -0700 Subject: [PATCH 8/9] Updated code to search board IDs --- adafruit_platformdetect/board.py | 13 ++++++++++--- adafruit_platformdetect/constants/boards.py | 13 ++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index 792fd128..5bf7ec66 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -50,7 +50,6 @@ class Board: def __init__(self, detector): self.detector = detector - self.board_asset_tag = self.detector.check_board_asset_tag_value().strip() # pylint: disable=invalid-name, protected-access @property @@ -118,8 +117,8 @@ def id(self): board_id = self._clockwork_pi_id() elif chip_id == chips.RK3308: board_id = self._rock_pi_id() - elif self.board_asset_tag == boards._UDOO_BOLT_BOARD_ASSET_TAG: - board_id = boards.UDOO_BOLT + elif chip_id == chips.RYZEN_V1605B: + board_id = self._udoo_id() return board_id @@ -315,6 +314,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.""" diff --git a/adafruit_platformdetect/constants/boards.py b/adafruit_platformdetect/constants/boards.py index 8c6a0126..0e7cf07e 100644 --- a/adafruit_platformdetect/constants/boards.py +++ b/adafruit_platformdetect/constants/boards.py @@ -94,6 +94,7 @@ ROCK_PI_S = "ROCK_PI_S" GREATFET_ONE = "GREATFET_ONE" +UDOO_BOLT = "UDOO_BOLT" # pylint: enable=bad-whitespace @@ -335,11 +336,9 @@ # Pine64 boards and devices _PINE64_DEV_IDS = (PINE64, PINEBOOK, PINEPHONE) -UDOO_BOLT = "UDOO_BOLT" -_UDOO_BOLT_BOARD_ASSET_TAG = "SC40-2000-0000-C0|C" - # UDOO -_UDOO_BOARD_IDS = ( - UDOO_BOLT, - _UDOO_BOLT_BOARD_ASSET_TAG, -) +_UDOO_BOARD_IDS = { + UDOO_BOLT: ( + "SC40-2000-0000-C0|C", + ) +} From f418f0f16dee47571499265cb92e936f69b825eb Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 21 May 2020 07:24:36 -0700 Subject: [PATCH 9/9] Black formatting, fixed syntax error --- adafruit_platformdetect/board.py | 2 +- adafruit_platformdetect/constants/boards.py | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index 5bf7ec66..807fa4d7 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -316,7 +316,7 @@ def _clockwork_pi_id(self): def _udoo_id(self): """Try to detect the id of udoo board.""" - board_asset_tag == self.detector.check_board_asset_tag_value() + 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 diff --git a/adafruit_platformdetect/constants/boards.py b/adafruit_platformdetect/constants/boards.py index 0e7cf07e..996b9898 100644 --- a/adafruit_platformdetect/constants/boards.py +++ b/adafruit_platformdetect/constants/boards.py @@ -337,8 +337,4 @@ _PINE64_DEV_IDS = (PINE64, PINEBOOK, PINEPHONE) # UDOO -_UDOO_BOARD_IDS = { - UDOO_BOLT: ( - "SC40-2000-0000-C0|C", - ) -} +_UDOO_BOARD_IDS = {UDOO_BOLT: ("SC40-2000-0000-C0|C",)}