diff --git a/adafruit_platformdetect/__init__.py b/adafruit_platformdetect/__init__.py index 2b465b3d..3e7090df 100644 --- a/adafruit_platformdetect/__init__.py +++ b/adafruit_platformdetect/__init__.py @@ -75,6 +75,7 @@ def get_armbian_release_field(self, field): value, if found, otherwise None. """ field_value = None + pattern = r"^" + field + r"=(.*)" try: with open("/etc/armbian-release", "r") as release_file: @@ -93,20 +94,41 @@ def get_device_model(self): Search /proc/device-tree/model for the device model and return its value, if found, otherwise None. """ + model = None + try: with open("/proc/device-tree/model", "r") as model_file: model = model_file.read() - return model except FileNotFoundError: pass + return model + def get_device_compatible(self): """ Search /proc/device-tree/compatible for the compatible chip name. """ + model = None + try: with open("/proc/device-tree/compatible", "r") as model_file: model = model_file.read() - return model except FileNotFoundError: pass + + return model + + def check_board_asset_tag_value(self): + """ + Search /proc/device-tree/model for the device model and return its value, if found, + otherwise None. + """ + tag = None + + try: + with open("/sys/devices/virtual/dmi/id/board_asset_tag", "r") as tag_file: + tag = tag_file.read() + except FileNotFoundError: + pass + + return tag diff --git a/adafruit_platformdetect/board.py b/adafruit_platformdetect/board.py index 29c4edad..eae2868c 100644 --- a/adafruit_platformdetect/board.py +++ b/adafruit_platformdetect/board.py @@ -117,6 +117,9 @@ def id(self): board_id = self._clockwork_pi_id() elif chip_id == chips.RK3308: board_id = self._rock_pi_id() + elif chip_id == chips.RYZEN_V1605B: + board_id = boards.UDOO_BOLT + return board_id # pylint: enable=invalid-name diff --git a/adafruit_platformdetect/chip.py b/adafruit_platformdetect/chip.py index afbde2a3..485629ba 100644 --- a/adafruit_platformdetect/chip.py +++ b/adafruit_platformdetect/chip.py @@ -135,7 +135,13 @@ def _linux_id(self): if hardware is None: vendor_id = self.detector.get_cpuinfo_field("vendor_id") - if vendor_id in ("GenuineIntel", "AuthenticAMD"): + if vendor_id == "AuthenticAMD": + model_name = self.detector.get_cpuinfo_field("model name").upper() + if "RYZEN EMBEDDED V1605B" in model_name: + linux_id = chips.RYZEN_V1605B + else: + linux_id = chips.GENERIC_X86 + elif vendor_id == "GenuineIntel": linux_id = chips.GENERIC_X86 compatible = self.detector.get_device_compatible() diff --git a/adafruit_platformdetect/constants/boards.py b/adafruit_platformdetect/constants/boards.py index 1282e869..bf9b947f 100644 --- a/adafruit_platformdetect/constants/boards.py +++ b/adafruit_platformdetect/constants/boards.py @@ -95,6 +95,8 @@ GREATFET_ONE = "GREATFET_ONE" +UDOO_BOLT = "UDOO_BOLT" + # pylint: enable=bad-whitespace # OrangePI diff --git a/adafruit_platformdetect/constants/chips.py b/adafruit_platformdetect/constants/chips.py index eb0c74bd..59fdc7be 100644 --- a/adafruit_platformdetect/constants/chips.py +++ b/adafruit_platformdetect/constants/chips.py @@ -3,6 +3,7 @@ IMX8MX = "IMX8MX" BCM2XXX = "BCM2XXX" ESP8266 = "ESP8266" +RYZEN_V1605B = "RYZEN_V1605B" SAMD21 = "SAMD21" STM32 = "STM32" SUN8I = "SUN8I"