diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index cd05d602..538e0b32 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -81,7 +81,7 @@ def id(self): board_id = boards.FEATHER_HUZZAH elif chip_id == chips.SAMD21: board_id = boards.FEATHER_M0_EXPRESS - elif chip_id == chips.STM32: + elif chip_id == chips.STM32F405: board_id = boards.PYBOARD elif chip_id == chips.S805: board_id = boards.ODROID_C1 @@ -125,6 +125,8 @@ def id(self): board_id = self._udoo_id() elif chip_id == chips.PENTIUM_N3710: board_id = self._udoo_id() + elif chip_id == chips.STM32MP157: + board_id = self._stm32mp1_id() return board_id @@ -251,6 +253,13 @@ def _sama5_id(self): return boards.GIANT_BOARD return None + def _stm32mp1_id(self): + """Check what type stm32mp1 board.""" + board_value = self.detector.get_device_model() + if "STM32MP157C-DK2" in board_value: + return boards.STM32MP157C_DK2 + return None + def _imx8mx_id(self): """Check what type iMX8M board.""" board_value = self.detector.get_device_model() @@ -430,6 +439,11 @@ def any_asus_tinker_board(self): """Check to see if the current board is an ASUS Tinker Board""" return self.id in boards._ASUS_TINKER_BOARD_IDS + @property + def any_stm32mp1(self): + """Check whether the current board is any stm32mp1 board.""" + return self.id in boards._STM32MP1_IDS + @property def any_embedded_linux(self): """Check whether the current board is any embedded Linux device.""" @@ -451,6 +465,7 @@ def any_embedded_linux(self): self.any_clockwork_pi_board, self.any_udoo_board, self.any_asus_tinker_board, + self.any_stm32mp1, ] ) diff --git a/adafruit_platformdetect/chip.py b/adafruit_platformdetect/chip.py index 489c148b..3c912327 100644 --- a/adafruit_platformdetect/chip.py +++ b/adafruit_platformdetect/chip.py @@ -107,7 +107,7 @@ def id( if platform == "samd21": return chips.SAMD21 if platform == "pyboard": - return chips.STM32 + return chips.STM32F405 # nothing found! return None @@ -133,6 +133,9 @@ def _linux_id(self): if self.detector.check_dt_compatible_value("rockchip,rk3288"): return chips.RK3288 + if self.detector.check_dt_compatible_value("st,stm32mp157"): + return chips.STM32MP157 + linux_id = None hardware = self.detector.get_cpuinfo_field("Hardware") diff --git a/adafruit_platformdetect/constants/boards.py b/adafruit_platformdetect/constants/boards.py index 258a788e..0a7dec3b 100644 --- a/adafruit_platformdetect/constants/boards.py +++ b/adafruit_platformdetect/constants/boards.py @@ -1,6 +1,5 @@ """Definition of boards and/or ids""" # Allow for aligned constant definitions: -# pylint: disable=bad-whitespace BEAGLEBONE = "BEAGLEBONE" BEAGLEBONE_BLACK = "BEAGLEBONE_BLACK" BEAGLEBONE_BLUE = "BEAGLEBONE_BLUE" @@ -54,6 +53,9 @@ PYNQ_Z1 = "PYNQ_Z1" PYNQ_Z2 = "PYNQ_Z2" +# STM32 MPU boards +STM32MP157C_DK2 = "STM32MP157C_DK2" + # Various Raspberry Pi models RASPBERRY_PI_B_REV1 = "RASPBERRY_PI_B_REV1" RASPBERRY_PI_B_REV2 = "RASPBERRY_PI_B_REV2" @@ -104,11 +106,12 @@ UDOO_BOLT_V8 = "UDOO_BOLT_V8" UDOO_X86 = "UDOO_X86" -# pylint: enable=bad-whitespace - # Asus Tinkerboard _ASUS_TINKER_BOARD_IDS = (ASUS_TINKER_BOARD,) +# STM32MP1 +_STM32MP1_IDS = (STM32MP157C_DK2,) + # OrangePI _ORANGE_PI_IDS = ( ORANGE_PI_PC, diff --git a/adafruit_platformdetect/constants/chips.py b/adafruit_platformdetect/constants/chips.py index 363702a9..0d93bdf3 100644 --- a/adafruit_platformdetect/constants/chips.py +++ b/adafruit_platformdetect/constants/chips.py @@ -7,7 +7,6 @@ RYZEN_V1202B = "RYZEN_V1202B" RYZEN_V1605B = "RYZEN_V1605B" SAMD21 = "SAMD21" -STM32 = "STM32" SUN8I = "SUN8I" S805 = "S805" S905 = "S905" @@ -32,5 +31,7 @@ LPC4330 = "LPC4330" RK3288 = "RK3288" PENTIUM_N3710 = "PENTIUM_N3710" # SOC Braswell core +STM32F405 = "STM32F405" +STM32MP157 = "STM32MP157" BCM_RANGE = {"BCM2708", "BCM2709", "BCM2711", "BCM2835", "BCM2837"} diff --git a/bin/detect.py b/bin/detect.py index c96b7a11..192ebd3b 100644 --- a/bin/detect.py +++ b/bin/detect.py @@ -25,6 +25,7 @@ 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 ASUS Tinker Board?", detector.board.ASUS_TINKER_BOARD) +print("Is this an STM32MP1 Board?", detector.board.any_stm32mp1) print( "Is this an OS environment variable special case?", detector.board.FTDI_FT232H