Skip to content

Commit 366a41f

Browse files
authored
Merge pull request #97 from makermelissa/master
Added STM32MP1 detection
2 parents 0de2f8b + 95a3fdd commit 366a41f

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

adafruit_platformdetect/board.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def id(self):
8181
board_id = boards.FEATHER_HUZZAH
8282
elif chip_id == chips.SAMD21:
8383
board_id = boards.FEATHER_M0_EXPRESS
84-
elif chip_id == chips.STM32:
84+
elif chip_id == chips.STM32F405:
8585
board_id = boards.PYBOARD
8686
elif chip_id == chips.S805:
8787
board_id = boards.ODROID_C1
@@ -125,6 +125,8 @@ def id(self):
125125
board_id = self._udoo_id()
126126
elif chip_id == chips.PENTIUM_N3710:
127127
board_id = self._udoo_id()
128+
elif chip_id == chips.STM32MP157:
129+
board_id = self._stm32mp1_id()
128130

129131
return board_id
130132

@@ -251,6 +253,13 @@ def _sama5_id(self):
251253
return boards.GIANT_BOARD
252254
return None
253255

256+
def _stm32mp1_id(self):
257+
"""Check what type stm32mp1 board."""
258+
board_value = self.detector.get_device_model()
259+
if "STM32MP157C-DK2" in board_value:
260+
return boards.STM32MP157C_DK2
261+
return None
262+
254263
def _imx8mx_id(self):
255264
"""Check what type iMX8M board."""
256265
board_value = self.detector.get_device_model()
@@ -430,6 +439,11 @@ def any_asus_tinker_board(self):
430439
"""Check to see if the current board is an ASUS Tinker Board"""
431440
return self.id in boards._ASUS_TINKER_BOARD_IDS
432441

442+
@property
443+
def any_stm32mp1(self):
444+
"""Check whether the current board is any stm32mp1 board."""
445+
return self.id in boards._STM32MP1_IDS
446+
433447
@property
434448
def any_embedded_linux(self):
435449
"""Check whether the current board is any embedded Linux device."""
@@ -451,6 +465,7 @@ def any_embedded_linux(self):
451465
self.any_clockwork_pi_board,
452466
self.any_udoo_board,
453467
self.any_asus_tinker_board,
468+
self.any_stm32mp1,
454469
]
455470
)
456471

adafruit_platformdetect/chip.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def id(
107107
if platform == "samd21":
108108
return chips.SAMD21
109109
if platform == "pyboard":
110-
return chips.STM32
110+
return chips.STM32F405
111111
# nothing found!
112112
return None
113113

@@ -133,6 +133,9 @@ def _linux_id(self):
133133
if self.detector.check_dt_compatible_value("rockchip,rk3288"):
134134
return chips.RK3288
135135

136+
if self.detector.check_dt_compatible_value("st,stm32mp157"):
137+
return chips.STM32MP157
138+
136139
linux_id = None
137140
hardware = self.detector.get_cpuinfo_field("Hardware")
138141

adafruit_platformdetect/constants/boards.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Definition of boards and/or ids"""
22
# Allow for aligned constant definitions:
3-
# pylint: disable=bad-whitespace
43
BEAGLEBONE = "BEAGLEBONE"
54
BEAGLEBONE_BLACK = "BEAGLEBONE_BLACK"
65
BEAGLEBONE_BLUE = "BEAGLEBONE_BLUE"
@@ -54,6 +53,9 @@
5453
PYNQ_Z1 = "PYNQ_Z1"
5554
PYNQ_Z2 = "PYNQ_Z2"
5655

56+
# STM32 MPU boards
57+
STM32MP157C_DK2 = "STM32MP157C_DK2"
58+
5759
# Various Raspberry Pi models
5860
RASPBERRY_PI_B_REV1 = "RASPBERRY_PI_B_REV1"
5961
RASPBERRY_PI_B_REV2 = "RASPBERRY_PI_B_REV2"
@@ -104,11 +106,12 @@
104106
UDOO_BOLT_V8 = "UDOO_BOLT_V8"
105107
UDOO_X86 = "UDOO_X86"
106108

107-
# pylint: enable=bad-whitespace
108-
109109
# Asus Tinkerboard
110110
_ASUS_TINKER_BOARD_IDS = (ASUS_TINKER_BOARD,)
111111

112+
# STM32MP1
113+
_STM32MP1_IDS = (STM32MP157C_DK2,)
114+
112115
# OrangePI
113116
_ORANGE_PI_IDS = (
114117
ORANGE_PI_PC,

adafruit_platformdetect/constants/chips.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
RYZEN_V1202B = "RYZEN_V1202B"
88
RYZEN_V1605B = "RYZEN_V1605B"
99
SAMD21 = "SAMD21"
10-
STM32 = "STM32"
1110
SUN8I = "SUN8I"
1211
S805 = "S805"
1312
S905 = "S905"
@@ -32,5 +31,7 @@
3231
LPC4330 = "LPC4330"
3332
RK3288 = "RK3288"
3433
PENTIUM_N3710 = "PENTIUM_N3710" # SOC Braswell core
34+
STM32F405 = "STM32F405"
35+
STM32MP157 = "STM32MP157"
3536

3637
BCM_RANGE = {"BCM2708", "BCM2709", "BCM2711", "BCM2835", "BCM2837"}

bin/detect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
print("Is this a generic Linux PC?", detector.board.GENERIC_LINUX_PC)
2626
print("Is this a UDOO Bolt?", detector.board.UDOO_BOLT)
2727
print("Is this an ASUS Tinker Board?", detector.board.ASUS_TINKER_BOARD)
28+
print("Is this an STM32MP1 Board?", detector.board.any_stm32mp1)
2829
print(
2930
"Is this an OS environment variable special case?",
3031
detector.board.FTDI_FT232H

0 commit comments

Comments
 (0)