Merge branch 'master' into master

This commit is contained in:
Melissa LeBlanc-Williams 2020-11-01 10:19:54 -07:00 committed by GitHub
commit ffbbf59487
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 179 additions and 60 deletions

View file

@ -35,7 +35,7 @@ jobs:
source actions-ci/install.sh
- name: Pip install pylint, black, & Sphinx
run: |
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
pip install --force-reinstall pylint black Sphinx sphinx-rtd-theme
- name: Library version
run: git describe --dirty --always --tags
- name: Check formatting

View file

@ -121,7 +121,7 @@ class Detector:
def check_board_asset_tag_value(self):
"""
Search /proc/device-tree/model for the device model and return its value, if found,
Search /sys/devices/virtual/dmi/id for the device model and return its value, if found,
otherwise None.
"""
tag = None
@ -133,3 +133,18 @@ class Detector:
pass
return tag
def check_board_name_value(self):
"""
Search /sys/devices/virtual/dmi/id for the device model and return its value, if found,
otherwise None. Debian/ubuntu based
"""
board_name = None
try:
with open("/sys/devices/virtual/dmi/id/board_name", "r") as board_name_file:
board_name = board_name_file.read().strip()
except FileNotFoundError:
pass
return board_name

View file

@ -50,6 +50,7 @@ class Board:
def __init__(self, detector):
self.detector = detector
self._board_id = None
# pylint: disable=invalid-name, protected-access
@property
@ -57,6 +58,11 @@ class Board:
"""Return a unique id for the detected board, if any."""
# There are some times we want to trick the platform detection
# say if a raspberry pi doesn't have the right ID, or for testing
# Caching
if self._board_id:
return self._board_id
try:
return os.environ["BLINKA_FORCEBOARD"]
except KeyError: # no forced board, continue with testing!
@ -81,7 +87,7 @@ class Board:
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
@ -117,6 +123,8 @@ class Board:
board_id = self._pine64_id()
elif chip_id == chips.H6:
board_id = self._pine64_id()
elif chip_id == chips.H5:
board_id = self._armbian_id()
elif chip_id == chips.A33:
board_id = self._clockwork_pi_id()
elif chip_id == chips.RK3308:
@ -125,7 +133,12 @@ class Board:
board_id = self._asus_tinker_board_id()
elif chip_id == chips.RYZEN_V1605B:
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()
self._board_id = board_id
return board_id
# pylint: enable=invalid-name
@ -239,6 +252,8 @@ class Board:
board = boards.PINEH64
if board_value == "orangepi2":
board = boards.ORANGE_PI_2
if board_value == "bananapim2zero":
board = boards.BANANA_PI_M2_ZERO
return board
@ -253,6 +268,13 @@ class Board:
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()
@ -266,7 +288,7 @@ class Board:
if not compatible:
return None
compats = compatible.split("\x00")
for board_id, board_compats in boards._JETSON_IDS.items():
for board_id, board_compats in boards._JETSON_IDS:
if any(v in compats for v in board_compats):
return board_id
return None
@ -330,6 +352,10 @@ class Board:
for board_id, board_tags in boards._UDOO_BOARD_IDS.items():
if any(v == board_asset_tag for v in board_tags):
return board_id
if self.detector.check_board_name_value() == "UDOO x86":
return boards.UDOO_X86
return None
def _asus_tinker_board_id(self):
@ -393,7 +419,7 @@ class Board:
@property
def any_jetson_board(self):
"""Check whether the current board is any defined Jetson Board."""
return self.id in boards._JETSON_IDS
return self.id in [v[0] for v in boards._JETSON_IDS]
@property
def any_sifive_board(self):
@ -425,10 +451,16 @@ class Board:
"""Check to see if the current board is an UDOO board"""
return self.id in boards._UDOO_BOARD_IDS
@property
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."""
@ -450,6 +482,7 @@ class Board:
self.any_clockwork_pi_board,
self.any_udoo_board,
self.any_asus_tinker_board,
self.any_stm32mp1,
]
)

View file

@ -51,6 +51,7 @@ class Chip:
def __init__(self, detector):
self.detector = detector
self._chip_id = None
@property
def id(
@ -59,6 +60,11 @@ class Chip:
"""Return a unique id for the detected chip, if any."""
# There are some times we want to trick the platform detection
# say if a raspberry pi doesn't have the right ID, or for testing
# Caching
if self._chip_id:
return self._chip_id
try:
return os.environ["BLINKA_FORCECHIP"]
except KeyError: # no forced chip, continue with testing!
@ -75,14 +81,16 @@ class Chip:
"BLINKA_FT232H environment variable "
+ "set, but no FT232H device found"
)
return chips.FT232H
self._chip_id = chips.FT232H
return self._chip_id
if os.environ.get("BLINKA_MCP2221"):
import hid
# look for it based on PID/VID
for dev in hid.enumerate():
if dev["vendor_id"] == 0x04D8 and dev["product_id"] == 0x00DD:
return chips.MCP2221
self._chip_id = chips.MCP2221
return self._chip_id
raise RuntimeError(
"BLINKA_MCP2221 environment variable "
+ "set, but no MCP2221 device found"
@ -91,23 +99,29 @@ class Chip:
import usb
if usb.core.find(idVendor=0x1D50, idProduct=0x60E6) is not None:
return chips.LPC4330
self._chip_id = chips.LPC4330
return self._chip_id
raise RuntimeError(
"BLINKA_GREATFET environment variable "
+ "set, but no GreatFET device found"
)
if os.environ.get("BLINKA_NOVA"):
return chips.BINHO
self._chip_id = chips.BINHO
return self._chip_id
platform = sys.platform
if platform in ("linux", "linux2"):
return self._linux_id()
self._chip_id = self._linux_id()
return self._chip_id
if platform == "esp8266":
return chips.ESP8266
self._chip_id = chips.ESP8266
return self._chip_id
if platform == "samd21":
return chips.SAMD21
self._chip_id = chips.SAMD21
return self._chip_id
if platform == "pyboard":
return chips.STM32
self._chip_id = chips.STM32F405
return self._chip_id
# nothing found!
return None
@ -133,6 +147,12 @@ class Chip:
if self.detector.check_dt_compatible_value("rockchip,rk3288"):
return chips.RK3288
if self.detector.check_dt_compatible_value("st,stm32mp157"):
return chips.STM32MP157
if self.detector.check_dt_compatible_value("sun50i-a64"):
return chips.A64
linux_id = None
hardware = self.detector.get_cpuinfo_field("Hardware")
if (
@ -150,8 +170,15 @@ class Chip:
linux_id = chips.RYZEN_V1605B
else:
linux_id = chips.GENERIC_X86
## print("linux_id = ", linux_id)
elif vendor_id == "GenuineIntel":
linux_id = chips.GENERIC_X86
model_name = self.detector.get_cpuinfo_field("model name").upper()
## print('model_name =', model_name)
if "N3710" in model_name:
linux_id = chips.PENTIUM_N3710
else:
linux_id = chips.GENERIC_X86
## print("linux_id = ", linux_id)
compatible = self.detector.get_device_compatible()
if compatible and "tegra" in compatible:
@ -181,6 +208,8 @@ class Chip:
linux_id = chips.A64
if compatible and "sun50i-h6" in compatible:
linux_id = chips.H6
if compatible and "sun50i-h5" in compatible:
linux_id = chips.H5
if compatible and "odroid-xu4" in compatible:
linux_id = chips.EXYNOS5422
@ -219,9 +248,6 @@ class Chip:
linux_id = chips.SAMA5
elif "Pinebook" in hardware:
linux_id = chips.A64
# elif "sun50iw1p1" in hardware: #sun50iw1p1 is a common identfier in Allwinner SOC's. I do not believe it should be
# linux_id = chips.A64 #used as an identifier. I feel it makes more sense to rely on the device compatible field. Otherwise it will be
# Impossible to differentiate between Allwinner A64's and Allwinner H6's.
elif "ASUS_TINKER_BOARD" in hardware:
linux_id = chips.RK3288
elif "Xilinx Zynq" in hardware:

View file

@ -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"
@ -8,6 +7,7 @@ BEAGLEBONE_BLACK_WIRELESS = "BEAGLEBONE_BLACK_WIRELESS"
BEAGLEBONE_POCKETBEAGLE = "BEAGLEBONE_POCKETBEAGLE"
BEAGLEBONE_GREEN = "BEAGLEBONE_GREEN"
BEAGLEBONE_GREEN_WIRELESS = "BEAGLEBONE_GREEN_WIRELESS"
BEAGLEBONE_GREEN_GATEWAY = "BEAGLEBONE_GREEN_GATEWAY"
BEAGLEBONE_BLACK_INDUSTRIAL = "BEAGLEBONE_BLACK_INDUSTRIAL"
BEAGLEBONE_ENHANCED = "BEAGLEBONE_ENHANCED"
BEAGLEBONE_USOMIQ = "BEAGLEBONE_USOMIQ"
@ -23,7 +23,6 @@ GENERIC_LINUX_PC = "GENERIC_LINUX_PC"
PYBOARD = "PYBOARD"
NODEMCU = "NODEMCU"
GIANT_BOARD = "GIANT_BOARD"
_ASUS_TINKER_BOARD = "ASUS_TINKER_BOARD"
# ASUS Tinker Boards
ASUS_TINKER_BOARD = "ASUS_TINKER_BOARD"
@ -40,10 +39,15 @@ ORANGE_PI_LITE = "ORANGE_PI_LITE"
ORANGE_PI_PC_PLUS = "ORANGE_PI_PC_PLUS"
ORANGE_PI_PLUS_2E = "ORANGE_PI_PLUS_2E"
ORANGE_PI_2 = "ORANGE_PI_2"
ORANGE_PI_ZERO_PLUS_2H5 = "ORANGE_PI_ZERO_PLUS_2H5"
# Banana Pi boards
BANANA_PI_M2_ZERO = "BANANA_PI_M2_ZERO"
# NVIDIA Jetson boards
JETSON_TX1 = "JETSON_TX1"
JETSON_TX2 = "JETSON_TX2"
CLARA_AGX_XAVIER = "CLARA_AGX_XAVIER"
JETSON_XAVIER = "JETSON_XAVIER"
JETSON_NANO = "JETSON_NANO"
JETSON_NX = "JETSON_NX"
@ -55,6 +59,9 @@ CORAL_EDGE_TPU_DEV = "CORAL_EDGE_TPU_DEV"
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"
@ -100,12 +107,17 @@ PINEPHONE = "PINEPHONE"
ROCK_PI_S = "ROCK_PI_S"
GREATFET_ONE = "GREATFET_ONE"
# Udoo boards
UDOO_BOLT_V3 = "UDOO_BOLT_V3"
UDOO_BOLT_V8 = "UDOO_BOLT_V8"
UDOO_X86 = "UDOO_X86"
# pylint: enable=bad-whitespace
# Asus Tinkerboard
_ASUS_TINKER_BOARD_IDS = (ASUS_TINKER_BOARD,)
_ASUS_TINKER_BOARD_IDS = ASUS_TINKER_BOARD
# STM32MP1
_STM32MP1_IDS = (STM32MP157C_DK2,)
# OrangePI
_ORANGE_PI_IDS = (
@ -117,34 +129,62 @@ _ORANGE_PI_IDS = (
ORANGE_PI_PC_PLUS,
ORANGE_PI_PLUS_2E,
ORANGE_PI_2,
ORANGE_PI_ZERO_PLUS_2H5,
)
# BananaPI
_BANANA_PI_IDS = (BANANA_PI_M2_ZERO,)
_CORAL_IDS = (CORAL_EDGE_TPU_DEV,)
_PYNQ_IDS = (
PYNQ_Z1,
PYNQ_Z2,
)
_PYNQ_IDS = (PYNQ_Z1, PYNQ_Z2)
_JETSON_IDS = {
JETSON_TX1: ("nvidia,p2371-2180", "nvidia,jetson-cv",),
JETSON_TX2: (
"nvidia,p2771-0000",
"nvidia,p2771-0888",
"nvidia,p3489-0000",
"nvidia,lightning",
"nvidia,quill",
"nvidia,storm",
_JETSON_IDS = (
(
JETSON_TX1,
(
"nvidia,p2371-2180",
"nvidia,jetson-cv",
),
),
JETSON_XAVIER: ("nvidia,p2972-0000", "nvidia,p2972-0006", "nvidia,jetson-xavier",),
JETSON_NANO: ("nvidia,p3450-0000", "nvidia,p3450-0002", "nvidia,jetson-nano",),
JETSON_NX: (
"nvidia,p3509-0000+p3668-0000",
"nvidia,p3509-0000+p3668-0001",
"nvidia,p3449-0000+p3668-0000",
"nvidia,p3449-0000+p3668-0001",
(
JETSON_TX2,
(
"nvidia,p2771-0000",
"nvidia,p2771-0888",
"nvidia,p3489-0000",
"nvidia,lightning",
"nvidia,quill",
"nvidia,storm",
),
),
}
(CLARA_AGX_XAVIER, ("nvidia,e3900-0000+p2888-0004",)),
(
JETSON_XAVIER,
(
"nvidia,p2972-0000",
"nvidia,p2972-0006",
"nvidia,jetson-xavier",
),
),
(
JETSON_NANO,
(
"nvidia,p3450-0000",
"nvidia,p3450-0002",
"nvidia,jetson-nano",
),
),
(
JETSON_NX,
(
"nvidia,p3509-0000+p3668-0000",
"nvidia,p3509-0000+p3668-0001",
"nvidia,p3449-0000+p3668-0000",
"nvidia,p3449-0000+p3668-0001",
),
),
)
_RASPBERRY_PI_40_PIN_IDS = (
RASPBERRY_PI_B_PLUS,
@ -178,6 +218,7 @@ _BEAGLEBONE_IDS = (
BEAGLEBONE_POCKETBEAGLE,
BEAGLEBONE_GREEN,
BEAGLEBONE_GREEN_WIRELESS,
BEAGLEBONE_GREEN_GATEWAY,
BEAGLEBONE_BLACK_INDUSTRIAL,
BEAGLEBONE_ENHANCED,
BEAGLEBONE_USOMIQ,
@ -218,8 +259,9 @@ _BEAGLEBONE_BOARD_IDS = {
BEAGLEBONE_BLUE: (("A2", "A335BNLTBLA2"),),
BEAGLEBONE_BLACK_WIRELESS: (("A5", "A335BNLTBWA5"),),
BEAGLEBONE_POCKETBEAGLE: (("A2", "A335PBGL00A2"),),
BEAGLEBONE_GREEN: (("1A", "A335BNLT...."), ("UNKNOWN", "A335BNLTBBG1"),),
BEAGLEBONE_GREEN: (("1A", "A335BNLT...."), ("UNKNOWN", "A335BNLTBBG1")),
BEAGLEBONE_GREEN_WIRELESS: (("W1A", "A335BNLTGW1A"),),
BEAGLEBONE_GREEN_GATEWAY: (("GA1", "A335BNLTGG1A"),),
BEAGLEBONE_BLACK_INDUSTRIAL: (
("A0", "A335BNLTAIA0"), # Arrow
("A0", "A335BNLTEIA0"), # Element14
@ -262,10 +304,10 @@ _PI_REV_CODES = {
"100000e",
"100000f",
),
RASPBERRY_PI_B_PLUS: ("0010", "0013", "900032", "1000010", "1000013", "1900032",),
RASPBERRY_PI_A: ("0007", "0008", "0009", "1000007", "1000008", "1000009",),
RASPBERRY_PI_A_PLUS: ("0012", "0015", "900021", "1000012", "1000015", "1900021",),
RASPBERRY_PI_CM1: ("0011", "0014", "10000011", "10000014",),
RASPBERRY_PI_B_PLUS: ("0010", "0013", "900032", "1000010", "1000013", "1900032"),
RASPBERRY_PI_A: ("0007", "0008", "0009", "1000007", "1000008", "1000009"),
RASPBERRY_PI_A_PLUS: ("0012", "0015", "900021", "1000012", "1000015", "1900021"),
RASPBERRY_PI_CM1: ("0011", "0014", "10000011", "10000014"),
RASPBERRY_PI_ZERO: (
"900092",
"920092",
@ -280,22 +322,26 @@ _PI_REV_CODES = {
"2900093",
"2920093", # warranty bit 25
),
RASPBERRY_PI_ZERO_W: ("9000c1", "19000c1", "29000c1",), # warranty bits
RASPBERRY_PI_ZERO_W: ("9000c1", "19000c1", "29000c1"), # warranty bits
RASPBERRY_PI_2B: (
"a01040",
"a01041",
"a02042",
"a21041",
"a22042",
"1a01040",
"1a01041",
"1a02042",
"1a21041",
"1a22042", # warranty bit 24
"2a01040",
"2a01041",
"2a02042",
"2a21041",
"2a22042", # warranty bit 25
"3a01040",
"3a01041",
"3a02042",
"3a21041",
"3a22042",
),
@ -313,7 +359,7 @@ _PI_REV_CODES = {
"2a32082",
"2a52082", # warranty bit 25
),
RASPBERRY_PI_3B_PLUS: ("a020d3", "1a020d3", "2a020d3",), # warranty bits
RASPBERRY_PI_3B_PLUS: ("a020d3", "1a020d3", "2a020d3"), # warranty bits
RASPBERRY_PI_AVNET_IIOT_GW: ("60a220b0",),
RASPBERRY_PI_CM3: (
"a020a0",
@ -323,8 +369,8 @@ _PI_REV_CODES = {
"1a220a0",
"2a220a0",
),
RASPBERRY_PI_3A_PLUS: ("9020e0", "19020e0", "29020e0",), # warranty bits
RASPBERRY_PI_CM3_PLUS: ("a02100", "1a02100", "2a02100",), # warranty bits
RASPBERRY_PI_3A_PLUS: ("9020e0", "19020e0", "29020e0"), # warranty bits
RASPBERRY_PI_CM3_PLUS: ("a02100", "1a02100", "2a02100"), # warranty bits
RASPBERRY_PI_4B: (
"a03111",
"b03111",
@ -332,6 +378,7 @@ _PI_REV_CODES = {
"a03112",
"b03112",
"c03112",
"b03114",
"d03114",
"1a03111",
"2a03111",
@ -349,16 +396,10 @@ _PI_REV_CODES = {
}
# Onion omega boards
_ONION_OMEGA_BOARD_IDS = (
ONION_OMEGA,
ONION_OMEGA2,
)
_ONION_OMEGA_BOARD_IDS = (ONION_OMEGA, ONION_OMEGA2)
# Pine64 boards and devices
_PINE64_DEV_IDS = (PINE64, PINEH64, PINEBOOK, PINEPHONE)
# ASUS Tinker Board
_ASUS_TINKER_BOARD_DEV_IDS = ASUS_TINKER_BOARD
# UDOO
_UDOO_BOARD_IDS = {UDOO_BOLT_V8: ("SC40-2000-0000-C0|C",)}
_UDOO_BOARD_IDS = {UDOO_BOLT_V8: ("SC40-2000-0000-C0|C",), UDOO_X86: ("dummy",)}

View file

@ -7,7 +7,6 @@ EXYNOS5422 = "EXYNOS5422"
RYZEN_V1202B = "RYZEN_V1202B"
RYZEN_V1605B = "RYZEN_V1605B"
SAMD21 = "SAMD21"
STM32 = "STM32"
SUN8I = "SUN8I"
S805 = "S805"
S905 = "S905"
@ -29,8 +28,12 @@ ZYNQ7000 = "ZYNQ7000"
A64 = "A64"
H6 = "H6"
A33 = "A33"
H5 = "H5"
RK3308 = "RK3308"
LPC4330 = "LPC4330"
RK3288 = "RK3288"
PENTIUM_N3710 = "PENTIUM_N3710" # SOC Braswell core
STM32F405 = "STM32F405"
STM32MP157 = "STM32MP157"
BCM_RANGE = {"BCM2708", "BCM2709", "BCM2711", "BCM2835", "BCM2837"}

View file

@ -25,6 +25,7 @@ print("Is this an embedded Linux system?", detector.board.any_embedded_linux)
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