From 77cff8a6f309d41425a9eec06e983c4e234fdbe6 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Wed, 21 Apr 2021 15:23:43 -0600 Subject: [PATCH 1/4] Initial Sandy Bridge test --- Resources/Build.py | 20 ++++++++++++++++++++ Resources/ModelArray.py | 10 ++++++++++ payloads/Config/config.plist | 30 ++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/Resources/Build.py b/Resources/Build.py index af3651209..5ff590d2d 100644 --- a/Resources/Build.py +++ b/Resources/Build.py @@ -507,6 +507,26 @@ class BuildOpenCore: plistlib.dump(agpm_config, Path(new_agpm_ls).open("wb"), sort_keys=True) plistlib.dump(amc_config, Path(new_amc_ls).open("wb"), sort_keys=True) + if self.model in ModelArray.SandyIGPU: + print("- Adding AppleIntelSNBGraphicsFB patch") + if self.model == "MacBookPro8,1": + x = b'Mac-94245B3640C91C81' + elif self.model == "MacBookPro8,2": + x = b'Mac-94245A3940C91C80' + elif self.model == "MacBookPro8,3": + x = b'Mac-942459F5819B171B' + elif self.model == "MacBookAir4,1": + x = b'Mac-C08A6BB70A942AC2' + elif self.model == "MacBookAir4,2": + x = b'Mac-742912EFDBEE19B3' + elif self.model == "Macmini5,1": + x = b'Mac-8ED6AF5B48C039E1' + elif self.model == "Macmini5,3": + x = b'Mac-7BA5B2794B2CDB12' + self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleIntelSNBGraphicsFB")["Enabled"] = True + self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleIntelSNBGraphicsFB")["Find"] = binascii.unhexlify(str(binascii.hexlify(x),'ascii')) + self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleIntelSNBGraphicsFB")["Replace"] = binascii.unhexlify(str(binascii.hexlify(self.spoofed_board.encode()),'ascii')) + @staticmethod def get_item_by_kv(iterable, key, value): item = None diff --git a/Resources/ModelArray.py b/Resources/ModelArray.py index c8b3343d8..b68569a03 100644 --- a/Resources/ModelArray.py +++ b/Resources/ModelArray.py @@ -872,6 +872,16 @@ NoExFat = [ "Dortania1,1" ] +SandyIGPU = [ + "MacBookAir4,1", + "MacBookAir4,2", + "MacBookPro8,1", + "MacBookPro8,2", + "MacBookPro8,3", + "Macmini5,1", + "Macmini5,3", +] + DeleteNvidiaAccel11 = [ "AMDRadeonX4000.kext", "AMDRadeonX4000HWServices.kext", diff --git a/payloads/Config/config.plist b/payloads/Config/config.plist index 8b6a93449..25ac5a87e 100644 --- a/payloads/Config/config.plist +++ b/payloads/Config/config.plist @@ -848,6 +848,36 @@ Skip 0 + + Arch + x86_64 + Base + + Comment + Patch AppleIntelSNBGraphicsFB + Count + 0 + Enabled + + Find + + Identifier + com.apple.driver.AppleIntelSNBGraphicsFB + Limit + 0 + Mask + + MaxKernel + + MinKernel + 20.0.0 + Replace + + ReplaceMask + + Skip + 0 + Quirks From d4b55ad0e408c043b54a216345fe884d2248af12 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Wed, 21 Apr 2021 17:47:51 -0600 Subject: [PATCH 2/4] Fix build crashing when no wifi card is present --- CHANGELOG.md | 1 + Resources/Build.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5c79feef..7b80d9198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Add public beta support for Legacy GPU Acceleration (v0.0.3) - Note ATI/AMD TeraScale 2 unsupported (HD 5/6000) - Add better kmutil crash handling +- Fix build crashing when no wifi card is present ## 0.1.0 - Fix crash on iMacs with Metal GPUs diff --git a/Resources/Build.py b/Resources/Build.py index 5ff590d2d..9bf8f821d 100644 --- a/Resources/Build.py +++ b/Resources/Build.py @@ -166,11 +166,14 @@ class BuildOpenCore: vendor_atheros = binascii.unhexlify("E4140000") vendor_broadcom = binascii.unhexlify("8C160000") wifi_devices = [i for i in wifi_devices if i["vendor-id"] == vendor_atheros or i["vendor-id"] == vendor_broadcom and i["class-code"] == binascii.unhexlify("00800200")] - wifi_vendor = self.hexswap(binascii.hexlify(wifi_devices[0]["vendor-id"]).decode()[:4]) - wifi_device = self.hexswap(binascii.hexlify(wifi_devices[0]["device-id"]).decode()[:4]) - wifi_ioname = wifi_devices[0]["IOName"] - if not self.constants.custom_model: - print(f"- Detected Wifi Card: {wifi_vendor}:{wifi_device}") + try: + wifi_vendor = self.hexswap(binascii.hexlify(wifi_devices[0]["vendor-id"]).decode()[:4]) + wifi_device = self.hexswap(binascii.hexlify(wifi_devices[0]["device-id"]).decode()[:4]) + wifi_ioname = wifi_devices[0]["IOName"] + if not self.constants.custom_model: + print(f"- Detected Wifi Card: {wifi_vendor}:{wifi_device}") + except IndexError: + wifi_devices = "" else: wifi_devices = "" From d482443f0e5aa27b61ef70d62e8e767e48b6dece Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Wed, 21 Apr 2021 18:13:02 -0600 Subject: [PATCH 3/4] Allow Legacy Acceleration Patches on Mac Pros and Xserves --- CHANGELOG.md | 1 + OpenCore-Patcher.command | 1 + Resources/CliMenu.py | 17 +++++++++++++++++ Resources/Constants.py | 1 + Resources/SysPatch.py | 4 ++-- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b80d9198..52e7cd9e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Note ATI/AMD TeraScale 2 unsupported (HD 5/6000) - Add better kmutil crash handling - Fix build crashing when no wifi card is present +- Allow Legacy Acceleration Patches on Mac Pros and Xserves ## 0.1.0 - Fix crash on iMacs with Metal GPUs diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index 6bbe5689e..1781584b5 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -93,6 +93,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier' [f"DRM Preferences:\t\t\tCurrently {self.constants.drm_support}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).drm_setting], [f"Set Generic Bootstrap:\t\t{self.constants.boot_efi}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).bootstrap_setting], [f"Set Accleration Patches:\t\t{self.constants.legacy_acceleration_patch}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).accel_setting], + [f"Assume Legacy GPU:\t\t\t{self.constants.assume_legacy}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).force_accel_setting], ] for option in options: diff --git a/Resources/CliMenu.py b/Resources/CliMenu.py index 41cfa074f..e447412eb 100644 --- a/Resources/CliMenu.py +++ b/Resources/CliMenu.py @@ -293,5 +293,22 @@ important data backed up in case of emergencies self.constants.legacy_acceleration_patch = True elif change_menu in {"n", "N", "no", "No"}: self.constants.legacy_acceleration_patch = False + else: + print("Invalid option") + + + def force_accel_setting(self): + Utilities.cls() + Utilities.header(["Assume Legacy GPU"]) + print("""Allows any model to force install Legacy Acceleration +patches. Only required for Mac Pro and Xserve users. + +DO NOT RUN IF METAL GPU IS INSTALLED + """) + change_menu = input("Enable Beta Acceleration Patches(y/n): ") + if change_menu in {"y", "Y", "yes", "Yes"}: + self.constants.assume_legacy = True + elif change_menu in {"n", "N", "no", "No"}: + self.constants.assume_legacy = False else: print("Invalid option") \ No newline at end of file diff --git a/Resources/Constants.py b/Resources/Constants.py index 5f732a046..8902f4bb9 100644 --- a/Resources/Constants.py +++ b/Resources/Constants.py @@ -71,6 +71,7 @@ class Constants: self.boot_efi = False self.drm_support = False self.legacy_acceleration_patch = False + self.assume_legacy = False # OS Versions self.tiger = 8 diff --git a/Resources/SysPatch.py b/Resources/SysPatch.py index 59d7525a7..edb0386d8 100644 --- a/Resources/SysPatch.py +++ b/Resources/SysPatch.py @@ -205,7 +205,7 @@ class PatchSysVolume: print("- Preparing Files") subprocess.run(f"sudo find {self.constants.payload_apple_root_path} -name '.DS_Store' -delete".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode() - if self.model in ModelArray.LegacyGPU: + if self.model in ModelArray.LegacyGPU or self.constants.assume_legacy is True: self.check_pciid() if self.dgpu_devices and self.dgpu_vendor == self.constants.pci_amd_ati and self.dgpu_device in ModelArray.AMDMXMGPUs: print("- Detected Metal-based AMD GPU, skipping legacy patches") @@ -351,7 +351,7 @@ class PatchSysVolume: # Check SIP if self.constants.custom_model is not None: print("Root Patching must be done on target machine!") - elif self.model in ModelArray.NoRootPatch11: + elif self.model in ModelArray.NoRootPatch11 and self.constants.assume_legacy is False: print("Root Patching not required for this machine!") elif self.model not in ModelArray.SupportedSMBIOS: print("Cannot run on this machine, model is unsupported!") From b83495702b64ca8de8efeef71ae93dd996afc918 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Wed, 21 Apr 2021 18:13:54 -0600 Subject: [PATCH 4/4] Disable HD3000 work-around --- Resources/Build.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Resources/Build.py b/Resources/Build.py index 9bf8f821d..7e2513765 100644 --- a/Resources/Build.py +++ b/Resources/Build.py @@ -510,25 +510,25 @@ class BuildOpenCore: plistlib.dump(agpm_config, Path(new_agpm_ls).open("wb"), sort_keys=True) plistlib.dump(amc_config, Path(new_amc_ls).open("wb"), sort_keys=True) - if self.model in ModelArray.SandyIGPU: - print("- Adding AppleIntelSNBGraphicsFB patch") - if self.model == "MacBookPro8,1": - x = b'Mac-94245B3640C91C81' - elif self.model == "MacBookPro8,2": - x = b'Mac-94245A3940C91C80' - elif self.model == "MacBookPro8,3": - x = b'Mac-942459F5819B171B' - elif self.model == "MacBookAir4,1": - x = b'Mac-C08A6BB70A942AC2' - elif self.model == "MacBookAir4,2": - x = b'Mac-742912EFDBEE19B3' - elif self.model == "Macmini5,1": - x = b'Mac-8ED6AF5B48C039E1' - elif self.model == "Macmini5,3": - x = b'Mac-7BA5B2794B2CDB12' - self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleIntelSNBGraphicsFB")["Enabled"] = True - self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleIntelSNBGraphicsFB")["Find"] = binascii.unhexlify(str(binascii.hexlify(x),'ascii')) - self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleIntelSNBGraphicsFB")["Replace"] = binascii.unhexlify(str(binascii.hexlify(self.spoofed_board.encode()),'ascii')) + #if self.model in ModelArray.SandyIGPU: + # print("- Adding AppleIntelSNBGraphicsFB patch") + # if self.model == "MacBookPro8,1": + # x = b'Mac-94245B3640C91C81' + # elif self.model == "MacBookPro8,2": + # x = b'Mac-94245A3940C91C80' + # elif self.model == "MacBookPro8,3": + # x = b'Mac-942459F5819B171B' + # elif self.model == "MacBookAir4,1": + # x = b'Mac-C08A6BB70A942AC2' + # elif self.model == "MacBookAir4,2": + # x = b'Mac-742912EFDBEE19B3' + # elif self.model == "Macmini5,1": + # x = b'Mac-8ED6AF5B48C039E1' + # elif self.model == "Macmini5,3": + # x = b'Mac-7BA5B2794B2CDB12' + # self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleIntelSNBGraphicsFB")["Enabled"] = True + # self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleIntelSNBGraphicsFB")["Find"] = binascii.unhexlify(str(binascii.hexlify(x),'ascii')) + # self.get_item_by_kv(self.config["Kernel"]["Patch"], "Identifier", "com.apple.driver.AppleIntelSNBGraphicsFB")["Replace"] = binascii.unhexlify(str(binascii.hexlify(self.spoofed_board.encode()),'ascii')) @staticmethod def get_item_by_kv(iterable, key, value):