Add basic hardware detection

This commit is contained in:
Mykola Grymalyuk
2021-09-16 12:21:14 -06:00
parent 1da93b1ca0
commit 986878055f
2 changed files with 26 additions and 10 deletions

View File

@@ -582,6 +582,21 @@ class BuildOpenCore:
self.config["DeviceProperties"]["Add"][tb_device_path] = {"class-code": binascii.unhexlify("FFFFFFFF"), "device-id": binascii.unhexlify("FFFF0000")} self.config["DeviceProperties"]["Add"][tb_device_path] = {"class-code": binascii.unhexlify("FFFFFFFF"), "device-id": binascii.unhexlify("FFFF0000")}
# Bluetooth Detection
if not self.constants.custom_model and self.computer.bluetooth:
if self.computer.bluetooth == "BRCM2070 Hub":
print("- Enabling Bluetooth BRCM2070 for macOS Monterey")
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.brcm2070_path)
elif self.computer.bluetooth == "BRCM2046 Hub":
print("- Enabling Bluetooth BRCM2046 for macOS Mojave")
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.brcm2046_path)
elif self.model in ModelArray.Bluetooth_BRCM2070:
print("- Enabling Bluetooth BRCM2070 for macOS Monterey")
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.brcm2070_path)
elif self.model in ModelArray.Bluetooth_BRCM2046:
print("- Enabling Bluetooth BRCM2046 for macOS Monterey")
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.brcm2046_path)
# Add XhciDxe if firmware doesn't have XHCI controller support and XCHI controller detected # Add XhciDxe if firmware doesn't have XHCI controller support and XCHI controller detected
# TODO: Fix XhciDxe to work on pre UEFI 2.0 Macs # TODO: Fix XhciDxe to work on pre UEFI 2.0 Macs
# Ref: https://github.com/acidanthera/bugtracker/issues/1663 # Ref: https://github.com/acidanthera/bugtracker/issues/1663
@@ -692,15 +707,6 @@ class BuildOpenCore:
# Note this function was added in 11.3 (20E232, 20.4), older builds do not support this (ie. 11.2.3) # Note this function was added in 11.3 (20E232, 20.4), older builds do not support this (ie. 11.2.3)
print("- Allowing FileVault on Root Patched systems") print("- Allowing FileVault on Root Patched systems")
self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.filesystems.apfs")["Enabled"] = True self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.filesystems.apfs")["Enabled"] = True
if self.model in ModelArray.Bluetooth_BRCM2070:
print("- Enabling Bluetooth BRCM2070 for macOS Monterey")
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.brcm2070_path)
elif self.model in ModelArray.Bluetooth_BRCM2046:
print("- Enabling Bluetooth BRCM2046 for macOS Monterey")
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.brcm2046_path)
def set_smbios(self): def set_smbios(self):
spoofed_model = self.model spoofed_model = self.model
@@ -851,7 +857,6 @@ class BuildOpenCore:
print(f"- Could not find {efi_type}: {bundle_path}!") print(f"- Could not find {efi_type}: {bundle_path}!")
raise IndexError raise IndexError
return efi_binary return efi_binary
def enable_kext(self, kext_name, kext_version, kext_path, check=False): def enable_kext(self, kext_name, kext_version, kext_path, check=False):
kext = self.get_kext_by_bundle_path(kext_name) kext = self.get_kext_by_bundle_path(kext_name)

View File

@@ -313,6 +313,7 @@ class Computer:
cpu: Optional[CPU] = None cpu: Optional[CPU] = None
oclp_version: Optional[str] = None oclp_version: Optional[str] = None
opencore_version: Optional[str] = None opencore_version: Optional[str] = None
bluetooth_chipset: Optional[str] = None
@staticmethod @staticmethod
def probe(): def probe():
@@ -324,6 +325,7 @@ class Computer:
computer.storage_probe() computer.storage_probe()
computer.smbios_probe() computer.smbios_probe()
computer.cpu_probe() computer.cpu_probe()
computer.bluetooth()
return computer return computer
def gpu_probe(self): def gpu_probe(self):
@@ -437,3 +439,12 @@ class Computer:
subprocess.run("sysctl machdep.cpu.brand_string".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip(), subprocess.run("sysctl machdep.cpu.brand_string".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip(),
subprocess.run("sysctl machdep.cpu.features".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip().split(" "), subprocess.run("sysctl machdep.cpu.features".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip().split(" "),
) )
def bluetooth(self):
usb_data: str = subprocess.run("system_profiler SPUSBDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
if "BRCM2070 Hub" in usb_data:
self.bluetooth_chipset = "BRCM2070 Hub"
elif "BRCM2046 Hub" in usb_data:
self.bluetooth_chipset = "BRCM2046 Hub"
elif "Bluetooth":
self.bluetooth_chipset = "Generic"