Browse Source

Merge branch 'db410c' of https://github.com/ric96/Adafruit_Python_PlatformDetect into ric96-db410c

Additional fixes a syntax error and (I'm pretty sure) a logic bug.
96boards
Brennen Bearnes 6 years ago
parent
commit
9c861c637f
3 changed files with 27 additions and 1 deletions
  1. +11
    -0
      adafruit_platformdetect/__init__.py
  2. +10
    -0
      adafruit_platformdetect/board.py
  3. +6
    -1
      adafruit_platformdetect/chip.py

+ 11
- 0
adafruit_platformdetect/__init__.py View File

@ -55,6 +55,17 @@ class Detector:
return None
def get_dt_compatible_field(self, field):
"""
Search /proc/device-tree/compatible for a field and return True, if found,
otherwise False.
"""
# Match a value like 'qcom,apq8016-sbc':
if field in open('/proc/device-tree/compatible').read():
return True
return False
def get_armbian_release_field(self, field):
"""
Search /etc/armbian-release, if it exists, for a field and return its


+ 10
- 0
adafruit_platformdetect/board.py View File

@ -46,6 +46,8 @@ ODROID_C1_PLUS = "ODROID_C1_PLUS"
ODROID_C2 = "ODROID_C2"
FTDI_FT232H = "FT232H"
# XXX: naming
_96BOARDS = "96BOARDS"
# pylint: enable=bad-whitespace
_RASPBERRY_PI_40_PIN_IDS = (
@ -253,6 +255,9 @@ class Board:
board_id = ODROID_C2
elif chip_id == ap_chip.FT232H:
board_id = FTDI_FT232H
else:
board_id = self._is_96boards()
return board_id
# pylint: enable=invalid-name
@ -298,6 +303,11 @@ class Board:
return None
# pylint: enable=no-self-use
def _is_96Boards(self):
if self.detector.get_dt_compatible_field("qcom,apq8016-sbc") or self.detector.get_dt_compatible_field("hisilicon,hi3660-hikey960") or self.detector.get_dt_compatible_field("hisilicon,hi6220-hikey"):
return _96BOARDS
return None
def _armbian_id(self):
"""Check whether the current board is an OrangePi PC."""
board_value = self.detector.get_armbian_release_field('BOARD')


+ 6
- 1
adafruit_platformdetect/chip.py View File

@ -10,6 +10,7 @@ STM32 = "STM32"
SUN8I = "SUN8I"
S805 = "S805"
S905 = "S905"
APQ8016 = "APQ8016"
GENERIC_X86 = "GENERIC_X86"
FT232H = "FT232H"
@ -72,11 +73,15 @@ class Chip:
hardware = self.detector.get_cpuinfo_field("Hardware")
if self.detector.get_dt_compatible_field("qcom,apq8016"):
linux_id = APQ8016
return linux_id
if hardware is None:
vendor_id = self.detector.get_cpuinfo_field("vendor_id")
if vendor_id in ("GenuineIntel", "AuthenticAMD"):
linux_id = GENERIC_X86
elif hardware in ("BCM2708", "BCM2709", "BCM2835"):
elif hardware in ("BCM2708", "BCM2708", "BCM2835"):
linux_id = BCM2XXX
elif "AM33XX" in hardware:
linux_id = AM33XX


|||||||
x
 
000:0
Loading…
Cancel
Save