Skip to content

support bananapi m4berry, m4zero and f3 #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions adafruit_platformdetect/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,14 @@ 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:
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:
Expand Down Expand Up @@ -431,8 +435,14 @@ 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 == "bananapif3":
board = boards.BANANA_PI_F3
elif board_value == "orangepizeroplus2-h5":
board = boards.ORANGE_PI_ZERO_PLUS_2H5
elif board_value == "orangepizeroplus":
Expand Down Expand Up @@ -755,8 +765,13 @@ 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 "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:
Expand All @@ -779,6 +794,24 @@ 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()

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
Expand Down
6 changes: 6 additions & 0 deletions adafruit_platformdetect/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -294,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

Expand Down
6 changes: 6 additions & 0 deletions adafruit_platformdetect/constants/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@
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"
BANANA_PI_F3 = "BANANA_PI_F3"

# LeMaker boards
LEMAKER_BANANA_PRO = "LEMAKER_BANANA_PRO"
Expand Down Expand Up @@ -305,7 +308,10 @@
BANANA_PI_M2_ZERO,
BANANA_PI_M2_PLUS,
BANANA_PI_M2_BERRY,
BANANA_PI_M4_BERRY,
BANANA_PI_M4_ZERO,
BANANA_PI_M5,
BANANA_PI_F3,
)

# LeMaker
Expand Down
2 changes: 2 additions & 0 deletions adafruit_platformdetect/constants/chips.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
H5 = "H5"
H3 = "H3"
H616 = "H616"
H618 = "H618"
RK3308 = "RK3308"
RK3399 = "RK3399"
RK3399_T = "RK3399_T"
Expand All @@ -79,6 +80,7 @@
D1_RISCV = "D1_RISCV"
ATOM_J4105 = "ATOM_J4105"
TH1520 = "TH1520"
K1 = "K1"

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

Expand Down
3 changes: 3 additions & 0 deletions bin/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down
Loading