From f5bfd071fefef07d29c089df45186f34759e92ac Mon Sep 17 00:00:00 2001 From: Hyeonki Hong Date: Thu, 21 May 2020 16:31:03 +0900 Subject: [PATCH 1/3] ODROID-XU4: add support for Hardkernel Odroid XU4 --- adafruit_platformdetect/board.py | 2 ++ adafruit_platformdetect/chip.py | 4 ++++ adafruit_platformdetect/constants/boards.py | 10 +++++++++- adafruit_platformdetect/constants/chips.py | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index eae2868c..8f91203c 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -91,6 +91,8 @@ def id(self): board_id = boards.ODROID_C4 elif chip_id == chips.S922X: board_id = boards.ODROID_N2 + elif chip_id == chips.EXYNOS5422: + board_id = boards.ODROID_XU4 elif chip_id == chips.FT232H: board_id = boards.FTDI_FT232H elif chip_id == chips.APQ8016: diff --git a/adafruit_platformdetect/chip.py b/adafruit_platformdetect/chip.py index 485629ba..1bf9ea97 100644 --- a/adafruit_platformdetect/chip.py +++ b/adafruit_platformdetect/chip.py @@ -170,6 +170,8 @@ def _linux_id(self): return chips.S905X3 if compatible and "sun50i-a64" in compatible: linux_id = chips.A64 + if compatible and "odroid-xu4" in compatible: + linux_id = chips.EXYNOS5422 cpu_model = self.detector.get_cpuinfo_field("cpu model") @@ -200,6 +202,8 @@ def _linux_id(self): linux_id = chips.S922X elif "ODROID-C4" in hardware: linux_id = chips.S905X3 + elif "ODROID-XU4" in hardware: + linux_id = chips.EXYNOS5422 elif "SAMA5" in hardware: linux_id = chips.SAMA5 elif "Pinebook" in hardware: diff --git a/adafruit_platformdetect/constants/boards.py b/adafruit_platformdetect/constants/boards.py index bf9b947f..fdbb20bf 100644 --- a/adafruit_platformdetect/constants/boards.py +++ b/adafruit_platformdetect/constants/boards.py @@ -74,6 +74,7 @@ ODROID_C2 = "ODROID_C2" ODROID_C4 = "ODROID_C4" ODROID_N2 = "ODROID_N2" +ODROID_XU4 = "ODROID_XU4" FTDI_FT232H = "FTDI_FT232H" DRAGONBOARD_410C = "DRAGONBOARD_410C" @@ -153,7 +154,14 @@ _RASPBERRY_PI_CM_IDS = (RASPBERRY_PI_CM1, RASPBERRY_PI_CM3, RASPBERRY_PI_CM3_PLUS) -_ODROID_40_PIN_IDS = (ODROID_C1, ODROID_C1_PLUS, ODROID_C2, ODROID_C4, ODROID_N2) +_ODROID_40_PIN_IDS = ( + ODROID_C1, + ODROID_C1_PLUS, + ODROID_C2, + ODROID_C4, + ODROID_N2, + ODROID_XU4, +) _BEAGLEBONE_IDS = ( BEAGLEBONE, diff --git a/adafruit_platformdetect/constants/chips.py b/adafruit_platformdetect/constants/chips.py index 59fdc7be..fa96cd15 100644 --- a/adafruit_platformdetect/constants/chips.py +++ b/adafruit_platformdetect/constants/chips.py @@ -3,6 +3,7 @@ IMX8MX = "IMX8MX" BCM2XXX = "BCM2XXX" ESP8266 = "ESP8266" +EXYNOS5422 = "EXYNOS5422" RYZEN_V1605B = "RYZEN_V1605B" SAMD21 = "SAMD21" STM32 = "STM32" From 125f2adf90b00d0414a54be142998d1a12d62e06 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 21 May 2020 07:18:13 -0700 Subject: [PATCH 2/3] 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 3/3] 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",)}