From abe865f999031b44aff05cf667ec827933a78127 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Sat, 15 May 2021 17:42:09 -0600 Subject: [PATCH] Fix MacBookPro8,2/3 Hibernation wake --- CHANGELOG.md | 1 + OpenCore-Patcher.command | 9 +++++++++ Resources/Build.py | 10 +++++++--- Resources/Constants.py | 1 + Resources/ModelArray.py | 14 ++++++++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b993450b8..a18babf5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Support space in path when downloading Root Patches - Enable PanicNoKextDump by default - Expand AppleGraphicsPowerManagement and AppleGraphicsDeviceControl Override support +- Fix MacBookPro8,2/3 Hibernation wake ## 0.1.4 - Fix Device Path formatting on 2012+ iMacs diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index 21e004614..15412359b 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -56,6 +56,15 @@ class OpenCoreLegacyPatcher(): self.constants.custom_cpu_model = 1 self.constants.custom_cpu_model_value = custom_cpu_model_value.split("%00")[0] + # Check if running in RecoveryOS + root_partition_info = plistlib.loads(subprocess.run("diskutil info -plist /".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) + if root_partition_info["VolumeName"] == "macOS Base System" and \ + root_partition_info["FilesystemType"] == "apfs" and \ + root_partition_info["BusProtocol"] == "Disk Image": + self.constants.recovery_status = True + else: + self.constants.recovery_status = False + def hexswap(self, input_hex: str): hex_pairs = [input_hex[i:i + 2] for i in range(0, len(input_hex), 2)] hex_rev = hex_pairs[::-1] diff --git a/Resources/Build.py b/Resources/Build.py index ba16e72a1..7419143e2 100644 --- a/Resources/Build.py +++ b/Resources/Build.py @@ -541,6 +541,8 @@ class BuildOpenCore: print("- Adding CPU Name Patch") if self.get_kext_by_bundle_path("RestrictEvents.kext")["Enabled"] is False: self.enable_kext("RestrictEvents.kext", self.constants.restrictevents_version, self.constants.restrictevents_path) + if self.model in ModelArray.AMCSupport: + self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = {"wegnoegpu": binascii.unhexlify("01000000")} def set_smbios(self): spoofed_model = self.model @@ -761,8 +763,10 @@ class BuildOpenCore: zip_file.extractall(self.constants.oc_folder) item.unlink() - for i in self.constants.build_path.rglob("__MACOSX"): - shutil.rmtree(i) + if self.constants.recovery_status == False: + # Crashes in RecoveryOS for unknown reason + for i in self.constants.build_path.rglob("__MACOSX"): + shutil.rmtree(i) Path(self.constants.opencore_zip_copied).unlink() @@ -876,7 +880,7 @@ Please build OpenCore first!""" " without altering line endings", ] - if self.constants.detected_os > self.constants.yosemite: + if self.constants.detected_os > self.constants.yosemite and self.constants.recovery_status == False: result = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: result = subprocess.run(f"diskutil mount {disk_identifier}s{response}".split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) diff --git a/Resources/Constants.py b/Resources/Constants.py index 3e6ec492d..130ecf1cb 100644 --- a/Resources/Constants.py +++ b/Resources/Constants.py @@ -78,6 +78,7 @@ class Constants: self.custom_color = "" self.download_ram = False self.disallow_cpufriend = False + self.recovery_status = False # OS Versions self.tiger = 8 diff --git a/Resources/ModelArray.py b/Resources/ModelArray.py index fa2a3ba12..041a0b6ef 100644 --- a/Resources/ModelArray.py +++ b/Resources/ModelArray.py @@ -883,6 +883,13 @@ AGDPSupport = [ "iMac14,3", ] +AMCSupport = [ + "MacBookPro8,2", + "MacBookPro8,3", + #"MacBookPro9,1", + #"MacBookPro10,1" +] + DeleteNvidiaAccel11 = [ "AMDRadeonX4000.kext", "AMDRadeonX4000HWServices.kext", @@ -1043,4 +1050,11 @@ DeleteVolumeControl = [ "AppleVirtualPlatform.kext", "ApplePVPanic.kext", "AppleVirtIOStorage.kext", +] + +RecoveryIgnore = [ + "Update", + "VM", + "Recovery", + "Preboot" ] \ No newline at end of file