From 024f0cf46c15682505b374329e18d27d9aba51ce Mon Sep 17 00:00:00 2001 From: ecarozzo Date: Sat, 26 Nov 2022 10:28:41 +0100 Subject: [PATCH 1/7] Added support to SeeedStudio Odyssey X86J5105 --- adafruit_platformdetect/board.py | 7 +++++++ adafruit_platformdetect/chip.py | 2 ++ adafruit_platformdetect/constants/boards.py | 6 ++++++ adafruit_platformdetect/constants/chips.py | 2 +- bin/detect.py | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index db7f3f6a..9dfdf372 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -153,6 +153,8 @@ def id(self) -> Optional[str]: board_id = self._rock_pi_id() or self._armbian_id() elif chip_id == chips.ATOM_X5_Z8350: board_id = self._rock_pi_id() + elif chip_id == chips.ATOM_J4105: + board_id = self._odyssey_id() elif chip_id == chips.RK3288: board_id = self._asus_tinker_board_id() elif chip_id == chips.RK3328: @@ -529,6 +531,11 @@ def _udoo_id(self) -> Optional[str]: return None + def _odyssey_id(self) -> Optional[str]: + """Try to detect the id of Seeed board.""" + board = boards.ODYSSEY_X86J4105 + return board + def _asus_tinker_board_id(self) -> Optional[str]: """Check what type of Tinker Board.""" board_value = self.detector.get_device_model() diff --git a/adafruit_platformdetect/chip.py b/adafruit_platformdetect/chip.py index 9377635d..2e08d02b 100644 --- a/adafruit_platformdetect/chip.py +++ b/adafruit_platformdetect/chip.py @@ -290,6 +290,8 @@ def _linux_id(self) -> Optional[str]: linux_id = chips.PENTIUM_N3710 elif "X5-Z8350" in model_name: linux_id = chips.ATOM_X5_Z8350 + elif "J4105" in model_name: + linux_id = chips.ATOM_J4105 else: linux_id = chips.GENERIC_X86 ## print("linux_id = ", linux_id) diff --git a/adafruit_platformdetect/constants/boards.py b/adafruit_platformdetect/constants/boards.py index a2a6b81a..63c85a60 100644 --- a/adafruit_platformdetect/constants/boards.py +++ b/adafruit_platformdetect/constants/boards.py @@ -172,6 +172,9 @@ GREATFET_ONE = "GREATFET_ONE" +#SeeedStudio boards +ODYSSEY_X86J4105 = "ODYSSEY_X86J4105" + # Udoo boards UDOO_BOLT_V3 = "UDOO_BOLT_V3" UDOO_BOLT_V8 = "UDOO_BOLT_V8" @@ -538,6 +541,9 @@ # UDOO _UDOO_BOARD_IDS = {UDOO_BOLT_V8: ("SC40-2000-0000-C0|C",), UDOO_X86: ("dummy",)} +#SeeedStudio boards +_SEEED_BOARD_IDS = (ODYSSEY_X86J4105) + # MaaXBoard boards _MAAXBOARD_IDS = ("MAAXBOARD", "MAAXBOARD_MINI") diff --git a/adafruit_platformdetect/constants/chips.py b/adafruit_platformdetect/constants/chips.py index dd622021..6a4b35fc 100644 --- a/adafruit_platformdetect/constants/chips.py +++ b/adafruit_platformdetect/constants/chips.py @@ -68,6 +68,6 @@ ATOM_X5_Z8350 = "X5-Z8350" RP2040_U2IF = "RP2040_U2IF" D1_RISCV = "D1_RISCV" - +ATOM_J4105 = "ATOM_J4105" BCM_RANGE = {"BCM2708", "BCM2709", "BCM2711", "BCM2835", "BCM2837"} diff --git a/bin/detect.py b/bin/detect.py index 764e8ad1..5ba5c782 100755 --- a/bin/detect.py +++ b/bin/detect.py @@ -53,6 +53,7 @@ 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 a ODYSSEY X86YJ4105?", detector.board.ODYSSEY_X86J4105) print("Is this an ASUS Tinker Board?", detector.board.ASUS_TINKER_BOARD) print("Is this an STM32MP1 Board?", detector.board.any_stm32mp1) print( From 6435addf39fa5be4fefbd99f94d3c37fb3c3c98c Mon Sep 17 00:00:00 2001 From: ecarozzo Date: Sat, 26 Nov 2022 11:22:46 +0100 Subject: [PATCH 2/7] Added any_embedded_linux definition --- adafruit_platformdetect/board.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index 9dfdf372..ad53f4e5 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -719,6 +719,11 @@ def any_udoo_board(self) -> bool: """Check to see if the current board is an UDOO board""" return self.id in boards._UDOO_BOARD_IDS + @property + def any_seeed_board(self) -> bool: + """Check to see if the current board is an SEEED board""" + return self.id in boards._SEEED_BOARD_IDS + @property def any_asus_tinker_board(self) -> bool: """Check to see if the current board is an ASUS Tinker Board""" @@ -782,6 +787,7 @@ def lazily_generate_conditions(): yield self.any_rock_pi_board yield self.any_clockwork_pi_board yield self.any_udoo_board + yield self.any_seeed_board yield self.any_asus_tinker_board yield self.any_stm32mp1 yield self.any_lubancat From a66c9d45d435e8e6c8f6df55f5f145f97e555ee7 Mon Sep 17 00:00:00 2001 From: ecarozzo Date: Sat, 26 Nov 2022 13:08:00 +0100 Subject: [PATCH 3/7] Add more precise detection --- adafruit_platformdetect/board.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index ad53f4e5..19f7e033 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -154,7 +154,7 @@ def id(self) -> Optional[str]: elif chip_id == chips.ATOM_X5_Z8350: board_id = self._rock_pi_id() elif chip_id == chips.ATOM_J4105: - board_id = self._odyssey_id() + board_id = self._j4105_id() elif chip_id == chips.RK3288: board_id = self._asus_tinker_board_id() elif chip_id == chips.RK3328: @@ -531,9 +531,13 @@ def _udoo_id(self) -> Optional[str]: return None - def _odyssey_id(self) -> Optional[str]: - """Try to detect the id of Seeed board.""" - board = boards.ODYSSEY_X86J4105 + def _j4105_id(self) -> Optional[str]: + """Try to detect the id of J4105 board.""" + with open('/sys/devices/virtual/dmi/id/board_name', 'r') as file: + board_value = file.read().rstrip() + board = None + if board_value == "ODYSSEY-X86J4105": + board = boards.ODYSSEY_X86J4105 return board def _asus_tinker_board_id(self) -> Optional[str]: From 7ac797b940225e2609fe613769e6235578868719 Mon Sep 17 00:00:00 2001 From: ecarozzo Date: Sat, 26 Nov 2022 14:30:16 +0100 Subject: [PATCH 4/7] Add encoding in open function --- adafruit_platformdetect/board.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index 19f7e033..cd9707df 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -533,12 +533,14 @@ def _udoo_id(self) -> Optional[str]: def _j4105_id(self) -> Optional[str]: """Try to detect the id of J4105 board.""" - with open('/sys/devices/virtual/dmi/id/board_name', 'r') as file: - board_value = file.read().rstrip() - board = None - if board_value == "ODYSSEY-X86J4105": - board = boards.ODYSSEY_X86J4105 - return board + try: + with open('/sys/devices/virtual/dmi/id/board_name', 'r', encoding="utf-8") as board_name: + board_value = board_name.read().rstrip() + if board_value == "ODYSSEY-X86J4105": + return boards.ODYSSEY_X86J4105 + return None + except FileNotFoundError: + return None def _asus_tinker_board_id(self) -> Optional[str]: """Check what type of Tinker Board.""" From 12a8129b278af759fd2e117f71f3e8e3d7f5d077 Mon Sep 17 00:00:00 2001 From: ecarozzo Date: Sat, 26 Nov 2022 14:56:23 +0100 Subject: [PATCH 5/7] Error correction --- 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 cd9707df..b7800822 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -534,7 +534,7 @@ def _udoo_id(self) -> Optional[str]: def _j4105_id(self) -> Optional[str]: """Try to detect the id of J4105 board.""" try: - with open('/sys/devices/virtual/dmi/id/board_name', 'r', encoding="utf-8") as board_name: + with open("/sys/devices/virtual/dmi/id/board_name", "r", encoding="utf-8") as board_name: board_value = board_name.read().rstrip() if board_value == "ODYSSEY-X86J4105": return boards.ODYSSEY_X86J4105 From ca36d5d97125206932b3683df212ff342bc57f8d Mon Sep 17 00:00:00 2001 From: ecarozzo Date: Sat, 26 Nov 2022 15:21:31 +0100 Subject: [PATCH 6/7] word break --- adafruit_platformdetect/board.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index b7800822..187841fb 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -534,7 +534,8 @@ def _udoo_id(self) -> Optional[str]: def _j4105_id(self) -> Optional[str]: """Try to detect the id of J4105 board.""" try: - with open("/sys/devices/virtual/dmi/id/board_name", "r", encoding="utf-8") as board_name: + with open("/sys/devices/virtual/dmi/id/board_name", + "r", encoding="utf-8") as board_name: board_value = board_name.read().rstrip() if board_value == "ODYSSEY-X86J4105": return boards.ODYSSEY_X86J4105 From fa920788de2e88cba168b7f274d49738cd7ba024 Mon Sep 17 00:00:00 2001 From: ecarozzo Date: Sat, 26 Nov 2022 15:38:15 +0100 Subject: [PATCH 7/7] Black formatted --- adafruit_platformdetect/board.py | 5 +++-- adafruit_platformdetect/constants/boards.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index 187841fb..47c104ba 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -534,8 +534,9 @@ def _udoo_id(self) -> Optional[str]: def _j4105_id(self) -> Optional[str]: """Try to detect the id of J4105 board.""" try: - with open("/sys/devices/virtual/dmi/id/board_name", - "r", encoding="utf-8") as board_name: + with open( + "/sys/devices/virtual/dmi/id/board_name", "r", encoding="utf-8" + ) as board_name: board_value = board_name.read().rstrip() if board_value == "ODYSSEY-X86J4105": return boards.ODYSSEY_X86J4105 diff --git a/adafruit_platformdetect/constants/boards.py b/adafruit_platformdetect/constants/boards.py index 63c85a60..52800a57 100644 --- a/adafruit_platformdetect/constants/boards.py +++ b/adafruit_platformdetect/constants/boards.py @@ -172,7 +172,7 @@ GREATFET_ONE = "GREATFET_ONE" -#SeeedStudio boards +# SeeedStudio boards ODYSSEY_X86J4105 = "ODYSSEY_X86J4105" # Udoo boards @@ -541,8 +541,8 @@ # UDOO _UDOO_BOARD_IDS = {UDOO_BOLT_V8: ("SC40-2000-0000-C0|C",), UDOO_X86: ("dummy",)} -#SeeedStudio boards -_SEEED_BOARD_IDS = (ODYSSEY_X86J4105) +# SeeedStudio boards +_SEEED_BOARD_IDS = ODYSSEY_X86J4105 # MaaXBoard boards _MAAXBOARD_IDS = ("MAAXBOARD", "MAAXBOARD_MINI")