From db19a142d79698453f54aa114ddc77f4083b848a Mon Sep 17 00:00:00 2001 From: Hyeonki Hong Date: Mon, 20 Apr 2020 13:39:09 +0900 Subject: [PATCH] ODROID-C4: modify detection through 'compatible' --- adafruit_platformdetect/chip.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/adafruit_platformdetect/chip.py b/adafruit_platformdetect/chip.py index 4e2d2307..21b46f83 100644 --- a/adafruit_platformdetect/chip.py +++ b/adafruit_platformdetect/chip.py @@ -27,7 +27,7 @@ def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return- # look for it based on PID/VID count = len(UsbTools.find_all([(0x0403, 0x6014)])) if count == 0: - raise RuntimeError('BLINKA_FT232H environment variable ' + \ + raise RuntimeError('BLINKA_FT232H environment variable ' + 'set, but no FT232H device found') return chips.FT232H if os.environ.get('BLINKA_MCP2221'): @@ -36,7 +36,7 @@ def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return- for dev in hid.enumerate(): if dev['vendor_id'] == 0x04D8 and dev['product_id'] == 0x00DD: return chips.MCP2221 - raise RuntimeError('BLINKA_MCP2221 environment variable ' + \ + raise RuntimeError('BLINKA_MCP2221 environment variable ' + 'set, but no MCP2221 device found') if os.environ.get('BLINKA_NOVA'): return chips.BINHO @@ -55,7 +55,9 @@ def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return- # pylint: enable=invalid-name - def _linux_id(self): # pylint: disable=too-many-branches,too-many-statements + def _linux_id(self): + # pylint: disable=too-many-branches,too-many-statements + # pylint: disable=too-many-return-statements """Attempt to detect the CPU on a computer running the Linux kernel.""" if self.detector.check_dt_compatible_value('qcom,apq8016'): @@ -88,10 +90,16 @@ def _linux_id(self): # pylint: disable=too-many-branches,too-many-statements linux_id = chips.IMX8MX if compatible and 'odroid-c2' in compatible: linux_id = chips.S905 - if compatible and 'amlogic, g12a' in compatible: - linux_id = chips.S905X3 - if compatible and 'amlogic, g12b' in compatible: - linux_id = chips.S922X + if compatible and 'amlogic' in compatible: + compatible_list = compatible.replace('\x00', ',') \ + .replace(' ', '').split(',') + if 'g12a' in compatible_list: + # 'sm1' is correct for S905X3, but some kernels use 'g12a' + return chips.S905X3 + if 'g12b' in compatible_list: + return chips.S922X + if 'sm1' in compatible_list: + return chips.S905X3 if compatible and 'sun50i-a64' in compatible: linux_id = chips.A64