From 1b808c43ea0ef2851ff27bc9cbbeb769ade2132e Mon Sep 17 00:00:00 2001 From: razer Date: Tue, 30 Mar 2021 17:16:23 +0200 Subject: [PATCH] Support Allwinner detection on non armbian distros --- adafruit_platformdetect/board.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index eced6c37..8c7f3552 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -80,7 +80,7 @@ def id(self): elif chip_id == chips.GENERIC_X86: board_id = boards.GENERIC_LINUX_PC elif chip_id == chips.SUN8I: - board_id = self._armbian_id() + board_id = self._armbian_id() or self._allwinner_variants_id() elif chip_id == chips.SAMA5: board_id = self._sama5_id() elif chip_id == chips.IMX8MX: @@ -128,7 +128,7 @@ def id(self): elif chip_id == chips.H6: board_id = self._pine64_id() elif chip_id == chips.H5: - board_id = self._armbian_id() + board_id = self._armbian_id() or self._allwinner_variants_id() elif chip_id == chips.H616: board_id = self._armbian_id() elif chip_id == chips.A33: @@ -410,6 +410,24 @@ def _asus_tinker_board_id(self): board = boards._ASUS_TINKER_BOARD_IDS return board + def _allwinner_variants_id(self): + """Try to detect the id of allwinner based board. (orangepi, nanopi)""" + 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 "nanopi" in board_value: + if "neo" in board_value and 'SUN8I' in chip_id: + board = boards.NANOPI_NEO_AIR + # TODO: Add other specifc board contexts here + elif "orange pi" in board_value: + if "zero" in board_value and 'H5' in chip_id: + board = boards.ORANGE_PI_ZERO_PLUS_2H5 + # TODO: Add other specifc board contexts here + return board + @property def any_nanopi(self): """Check whether the current board is any defined Nano Pi."""