From 1d30230656827399ce79da5765b800654c0d2d57 Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Sat, 31 Aug 2024 23:47:55 +0800 Subject: [PATCH 1/4] support allwinner h618 chip, bananapi m4berry and m4zero board --- adafruit_platformdetect/board.py | 14 ++++++++++++++ adafruit_platformdetect/chip.py | 3 +++ adafruit_platformdetect/constants/boards.py | 4 ++++ adafruit_platformdetect/constants/chips.py | 1 + bin/detect.py | 3 +++ 5 files changed, 25 insertions(+) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index 5df172ff..48b76319 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -156,6 +156,8 @@ def id(self) -> Optional[str]: or self._allwinner_variants_id() or self._repka_variants_id() ) + elif chip_id == chips.H618: + board_id = self._armbian_id() or self._allwinner_variants_id() elif chip_id == chips.H616: board_id = self._armbian_id() or self._allwinner_variants_id() elif chip_id == chips.A33: @@ -431,6 +433,10 @@ def _armbian_id(self) -> Optional[str]: board = boards.BANANA_PI_M2_PLUS elif board_value == "bananapim2berry": board = boards.BANANA_PI_M2_BERRY + elif board_value == "bananapim4berry": + board = boards.BANANA_PI_M4_BERRY + elif board_value == "bananapim4zero": + board = boards.BANANA_PI_M4_ZERO elif board_value == "bananapim5": board = boards.BANANA_PI_M5 elif board_value == "orangepizeroplus2-h5": @@ -758,6 +764,14 @@ def _allwinner_variants_id(self) -> Optional[str]: if "banana pi m2 berry" in board_value: board = boards.BANANA_PI_M2_BERRY + if any(x in board_value for x in ("banana pi", "bananapi")); + if "m2 berry" in board_value: + board = boards.BANANA_PI_M2_BERRY + elif "m4berry" in board_value or "m4 berry" in board_value: + board = boards.BANANA_PI_M4_BERRY + elif "m4zero" in board_value or "m4 zero" in board_value: + board = boards.BANANA_PI_M4_ZERO + if "nanopi" in board_value: if "neo" in board_value and "SUN8I" in chip_id: board = boards.NANOPI_NEO_AIR diff --git a/adafruit_platformdetect/chip.py b/adafruit_platformdetect/chip.py index 8728dd84..1c29bd7e 100644 --- a/adafruit_platformdetect/chip.py +++ b/adafruit_platformdetect/chip.py @@ -285,6 +285,9 @@ def _linux_id(self) -> Optional[str]: if self.detector.check_dt_compatible_value("sun50i-h5"): return chips.H5 + if self.detector.check_dt_compatible_value("sun50i-h618"): + return chips.H618 + if self.detector.check_dt_compatible_value("sun50i-h616"): return chips.H616 diff --git a/adafruit_platformdetect/constants/boards.py b/adafruit_platformdetect/constants/boards.py index 47c0efbd..86a1ff63 100644 --- a/adafruit_platformdetect/constants/boards.py +++ b/adafruit_platformdetect/constants/boards.py @@ -78,6 +78,8 @@ BANANA_PI_M2_ZERO = "BANANA_PI_M2_ZERO" BANANA_PI_M2_PLUS = "BANANA_PI_M2_PLUS" BANANA_PI_M2_BERRY = "BANANA_PI_M2_BERRY" +BANANA_PI_M4_BERRY = "BANANA_PI_M4_BERRY" +BANANA_PI_M4_ZERO = "BANANA_PI_M4_ZERO" BANANA_PI_M5 = "BANANA_PI_M5" # LeMaker boards @@ -305,6 +307,8 @@ BANANA_PI_M2_ZERO, BANANA_PI_M2_PLUS, BANANA_PI_M2_BERRY, + BANANA_PI_M4_BERRY, + BANANA_PI_M4_ZERO, BANANA_PI_M5, ) diff --git a/adafruit_platformdetect/constants/chips.py b/adafruit_platformdetect/constants/chips.py index 32107247..c785acf4 100644 --- a/adafruit_platformdetect/constants/chips.py +++ b/adafruit_platformdetect/constants/chips.py @@ -55,6 +55,7 @@ H5 = "H5" H3 = "H3" H616 = "H616" +H618 = "H618" RK3308 = "RK3308" RK3399 = "RK3399" RK3399_T = "RK3399_T" diff --git a/bin/detect.py b/bin/detect.py index d33a1f16..e234659c 100755 --- a/bin/detect.py +++ b/bin/detect.py @@ -75,6 +75,9 @@ "Is this an OS environment variable special case?", detector.board.os_environ_board ) +if detector.board.any_bananapi: + print("Bananapi board detected.") + if detector.board.any_jetson_board: print("Jetson platform detected.") From f5b0f3ed0c7cf8792460040cd5167851466c8c7a Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Mon, 2 Sep 2024 10:26:19 +0800 Subject: [PATCH 2/4] fix bananapi board detect error --- adafruit_platformdetect/board.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index 48b76319..2e2cedc7 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -761,10 +761,7 @@ def _allwinner_variants_id(self) -> Optional[str]: if "banana pro" in board_value: board = boards.LEMAKER_BANANA_PRO - if "banana pi m2 berry" in board_value: - board = boards.BANANA_PI_M2_BERRY - - if any(x in board_value for x in ("banana pi", "bananapi")); + if any(x in board_value for x in ("banana pi", "bananapi")): if "m2 berry" in board_value: board = boards.BANANA_PI_M2_BERRY elif "m4berry" in board_value or "m4 berry" in board_value: From 07bbea902c31f17ef5b520fdf44f4ab9a33b764a Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Tue, 3 Sep 2024 19:32:07 +0800 Subject: [PATCH 3/4] support spacemit k1, bananapif3 --- adafruit_platformdetect/board.py | 23 +++++++++++++++++++++ adafruit_platformdetect/chip.py | 3 +++ adafruit_platformdetect/constants/boards.py | 2 ++ adafruit_platformdetect/constants/chips.py | 1 + 4 files changed, 29 insertions(+) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index 2e2cedc7..220ac156 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -162,6 +162,8 @@ def id(self) -> Optional[str]: board_id = self._armbian_id() or self._allwinner_variants_id() elif chip_id == chips.A33: board_id = self._clockwork_pi_id() + elif chip_id == chips.K1: + board_id = self._armbian_id() or self._spacemit_variants_id() elif chip_id == chips.RK3308: board_id = self._rock_pi_id() elif chip_id == chips.RK3399: @@ -439,6 +441,8 @@ def _armbian_id(self) -> Optional[str]: board = boards.BANANA_PI_M4_ZERO elif board_value == "bananapim5": board = boards.BANANA_PI_M5 + elif board_value == "bananapif3": + board = boards.BANANA_PI_F3 elif board_value == "orangepizeroplus2-h5": board = boards.ORANGE_PI_ZERO_PLUS_2H5 elif board_value == "orangepizeroplus": @@ -790,6 +794,25 @@ def _allwinner_variants_id(self) -> Optional[str]: board = boards.OLIMEX_LIME2 return board + def _spacemit_variants_id(self) -> Optional[str]: + """Try to detect the id of spacemit based board. (bananapi)""" + board_value = self.detector.get_device_model() + board = None + if not board_value: + return board + board_value = board_value.lower() + chip_id = self.detector.chip.id + + if any(x in board_value for x in ("banana pi", "bananapi")): + if "bpi-f3" in board_value: + board = boards.BANANA_PI_F3 + + if "spacemit" in board_value: + if "deb1" in board_value: + board = boards.BANANA_PI_F3 + + return board + def _repka_variants_id(self) -> Optional[str]: board_value = self.detector.get_device_model() board = None diff --git a/adafruit_platformdetect/chip.py b/adafruit_platformdetect/chip.py index 1c29bd7e..7401400d 100644 --- a/adafruit_platformdetect/chip.py +++ b/adafruit_platformdetect/chip.py @@ -297,6 +297,9 @@ def _linux_id(self) -> Optional[str]: if self.detector.check_dt_compatible_value("sun50i-h6"): return chips.H6 + if self.detector.check_dt_compatible_value("spacemit,k1-x"): + return chips.K1 + if self.detector.check_dt_compatible_value("mediatek,mt8167"): return chips.MT8167 diff --git a/adafruit_platformdetect/constants/boards.py b/adafruit_platformdetect/constants/boards.py index 86a1ff63..adcd31f3 100644 --- a/adafruit_platformdetect/constants/boards.py +++ b/adafruit_platformdetect/constants/boards.py @@ -81,6 +81,7 @@ BANANA_PI_M4_BERRY = "BANANA_PI_M4_BERRY" BANANA_PI_M4_ZERO = "BANANA_PI_M4_ZERO" BANANA_PI_M5 = "BANANA_PI_M5" +BANANA_PI_F3 = "BANANA_PI_F3" # LeMaker boards LEMAKER_BANANA_PRO = "LEMAKER_BANANA_PRO" @@ -310,6 +311,7 @@ BANANA_PI_M4_BERRY, BANANA_PI_M4_ZERO, BANANA_PI_M5, + BANANA_PI_F3, ) # LeMaker diff --git a/adafruit_platformdetect/constants/chips.py b/adafruit_platformdetect/constants/chips.py index c785acf4..667079a0 100644 --- a/adafruit_platformdetect/constants/chips.py +++ b/adafruit_platformdetect/constants/chips.py @@ -80,6 +80,7 @@ D1_RISCV = "D1_RISCV" ATOM_J4105 = "ATOM_J4105" TH1520 = "TH1520" +K1 = "K1" BCM_RANGE = {"BCM2708", "BCM2709", "BCM2711", "BCM2712", "BCM2835", "BCM2837"} From dad9b44d4f6a5f7b62cdafe866e89810cc8b6562 Mon Sep 17 00:00:00 2001 From: August <2819763+Dangku@users.noreply.github.com> Date: Wed, 4 Sep 2024 09:47:37 +0800 Subject: [PATCH 4/4] remove unused variable --- adafruit_platformdetect/board.py | 1 - 1 file changed, 1 deletion(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index 220ac156..f36b8f50 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -801,7 +801,6 @@ def _spacemit_variants_id(self) -> Optional[str]: if not board_value: return board board_value = board_value.lower() - chip_id = self.detector.chip.id if any(x in board_value for x in ("banana pi", "bananapi")): if "bpi-f3" in board_value: