OpenCore-Legacy-Patcher icon indicating copy to clipboard operation
OpenCore-Legacy-Patcher copied to clipboard

Hibernation Issues with OpenCore

Open khronokernel opened this issue 4 years ago • 150 comments

For some machines, hibernation is broken resulting in Sleep Wake Failure when waking. Currently we recommend users disable hibernation until a more suitable solution is found:

sudo pmset -a hibernatemode 0

Note: Please only reply with possible solutions. This issue is not a discussion thread

khronokernel avatar Mar 02 '21 15:03 khronokernel

I hope this is helpful. This post by @traviswparker indicates there was a fix in a custom plist: https://github.com/dortania/Opencore-Legacy-Patcher/issues/19#issuecomment-782900468 I am using an adopted version of that config on a Macbook Pro 10,2 with no hibernation issues AFAIK. Many thanks

houser42 avatar Mar 04 '21 15:03 houser42

@houser42 Their configuration breaks OpenCore spec and removes a lot of what the patcher uses to ensure a stable system when SMBIOS is changed such as WhateverGreen and AirportFixup. They haven't responded to the thread about what they actually changed and diffing between it and the patcher's plist is more confusing than anything.

Assuming logically what could've fixed hibernation with their build is the removal of OpenRuntime.efi. Problem is we require this driver for RequestBootVarRouting functionality to ensure macOS doesn't try to boot without OpenCore when blessing an update volume. Additionally this is only a theory, so we're unsure if their other changes had any logical affects on the setup

khronokernel avatar Mar 04 '21 15:03 khronokernel

I see, appreciate the heads-up. I guess I should really go back to the main config.plist and wait for a real fix. Many thanks!

houser42 avatar Mar 04 '21 15:03 houser42

@houser42 To test this theory, can you try to see if this branch works with hibernation?:

https://github.com/dortania/Opencore-Legacy-Patcher/tree/hibernation

khronokernel avatar Mar 04 '21 15:03 khronokernel

@khronokernel
Yes, in fact, I just updated to that versions, and it appears so, so far. YMMV. At least short sessions. Meaning close the lid, or select sleep and wait for 30 secs and open again. No issues so far at least.

houser42 avatar Mar 04 '21 15:03 houser42

Awesome, can you test if it wakes correctly after setting sudo pmset -a hibernatemode 25. This will make the Mac enter hibernation directly when told to sleep

khronokernel avatar Mar 04 '21 15:03 khronokernel

Sure. You mean just run sudo pmset -a hibernatemode 25 in the terminal and then invoke start again manually?

houser42 avatar Mar 04 '21 15:03 houser42

Yeah

khronokernel avatar Mar 04 '21 15:03 khronokernel

Yes, that appears to work. BTW. I am on Big Sur 11.2.2 if that matters.

houser42 avatar Mar 04 '21 15:03 houser42

Awesome, I actually have 1 more test I just pushed to that branch. It re-enables OpenRuntime as well as DiscardHibernateMap. I'm curious if that last quirk is what we're missing for hibernation support

khronokernel avatar Mar 04 '21 16:03 khronokernel

Ok. You mean load same link: https://github.com/dortania/Opencore-Legacy-Patcher/archive/hibernation.zip again now and just run the patcher again?

houser42 avatar Mar 04 '21 16:03 houser42

Yeah

khronokernel avatar Mar 04 '21 16:03 khronokernel

Yes, still appears to work as expected. No issues so far..

houser42 avatar Mar 04 '21 16:03 houser42

Awesome! I'm going to merge the changes however will keep this issue open for the day. If there aren't any reports of it still being broken then I'll close it. Thanks so much for your help!

khronokernel avatar Mar 04 '21 16:03 khronokernel

My pleasure. I just hope I am doing it right then ..;) Possibly unrelated, but tried removing the verbose boot and got some errors: It looks like I need to update something python. Would appreciate a comment if you have a sec? This was quick so did not check the docs properly... Many thanks for any hints

####################
# Copying OpenCore #
####################
- Coping OpenCore onto EFI partition
Removing preexisting EFI folder
Traceback (most recent call last):
  File "/Users/user/Desktop/Opencore-Legacy-Patcher-hibernation/OpenCore-Patcher.command", line 93, in <module>
    OpenCoreLegacyPatcher().main_menu()
  File "/Users/user/Desktop/Opencore-Legacy-Patcher-hibernation/OpenCore-Patcher.command", line 87, in main_menu
    response = menu.start()
  File "/Users/user/Desktop/Opencore-Legacy-Patcher-hibernation/Resources/utilities.py", line 102, in start
    self.options[keys.index(selected.upper())][3]() if self.options[keys.index(selected.upper())][3] else None
  File "/Users/user/Desktop/Opencore-Legacy-Patcher-hibernation/OpenCore-Patcher.command", line 26, in install_opencore
    build.BuildOpenCore(self.constants.custom_model or self.current_model, self.constants).copy_efi()
  File "/Users/user/Desktop/Opencore-Legacy-Patcher-hibernation/Resources/build.py", line 466, in copy_efi
    shutil.copytree(self.constants.opencore_release_folder / Path("EFI"), mount_path / Path("EFI"))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/shutil.py", line 557, in copytree
    return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/shutil.py", line 513, in _copytree
    raise Error(errors)
shutil.Error: [('/Users/user/Desktop/Opencore-Legacy-Patcher-hibernation/Build-Folder/OpenCore-v0.6.7/EFI/OC/config.plist', '/Volumes/EFI/EFI/OC/config.plist', "[Errno 22] Invalid argument: '/Volumes/EFI/EFI/OC/config.plist'")]

houser42 avatar Mar 04 '21 16:03 houser42

Can you try using the binary? We actually converted the patcher to a .app on releases. Here's the latest binary:

https://github.com/dortania/Opencore-Legacy-Patcher/suites/2179614486/artifacts/44846509

This doesn't require any python installs or updates

khronokernel avatar Mar 04 '21 16:03 khronokernel

Both the command file and the binary work fine with regards to the install and the actual hibernation issue. It just will not allow me to edit out the -v from line 859 after boot-args. But I can live with that for now.

houser42 avatar Mar 04 '21 16:03 houser42

We're planning to add DEBUG toggles for the patcher, however our current plan will take some work. So as a work around, you can simply set self.verbose_debug to false as a work-around till we implement it in user-menu:

https://github.com/dortania/Opencore-Legacy-Patcher/blob/main/Resources/Constants.py#L43

khronokernel avatar Mar 04 '21 16:03 khronokernel

Ok. I will test longer hibernation over night also. Thanks again.

houser42 avatar Mar 04 '21 17:03 houser42

I still getting Sleep Wake Failure on my MacBookPro9,2 when ThirdPartyDrives quirk is enabled. Even when hibernation is disabled (hibernatemode 0), my Mac restarts when waking and I still getting this error. When I disable this quirk in the config.plist, the issue goes away.

P.S. Apple broke hibernation on old Macs with third-party SATA SSDs on 10.15+ and now we need the ThirdPartyDrives quirk. More details https://github.com/acidanthera/bugtracker/issues/484#issuecomment-558506255

family1232009 avatar Mar 04 '21 18:03 family1232009

@family1232009 Sorry a bit confused, we don't enable ThirdPartyDrives in our patcher. Are you trying to say you need ThirdPartyDrives for hibernation? Confused how you'd get sleep issues with the patcher currently otherwise

khronokernel avatar Mar 04 '21 18:03 khronokernel

still seeing hibernation issues on MacBookPro10,1. When waking from hibernate I see the backlight come on, then go off, then come on and reboot.

to ensure the Mac actually hibernates and attempts to wake from EFI, you need to do the following:

sudo pmset -a hibernatemode 25
sudo pmset -a standby 1
sudo pmset -a standbydelaylow 1
sudo pmset -a standbydelayhigh 1

then pmset sleepnow or close the lid and wait at least 1 minute before waking the machine.

traviswparker avatar Mar 04 '21 18:03 traviswparker

@traviswparker Are you able to verify if this build works?: https://github.com/dortania/Opencore-Legacy-Patcher/suites/2179361359/artifacts/44839491

khronokernel avatar Mar 04 '21 18:03 khronokernel

Are you trying to say you need ThirdPartyDrives for hibernation?

Yes, I need ThirdPartyDrives for working hibernation (Safe Sleep) on my MBP9,2. Otherwise, hibernation behaves like normal sleep and I get battery drains.

family1232009 avatar Mar 04 '21 18:03 family1232009

FWIW, using the commands @traviswparker gave, my Macbook Pro 10,2 also crashes at wake using that build. Assuming that is the best way to test this, I am sorry to report that my reports of success were probably incorrect and premature.., but there it is...:(

houser42 avatar Mar 04 '21 18:03 houser42

@family1232009 Ah thank you, will integrate that patch into the patcher. However still confusing as traviswparker's config doesn't include the patch at all yet works fine. So unfortunately can't say this issue is resolved yet

khronokernel avatar Mar 04 '21 18:03 khronokernel

@traviswparker Are you able to verify if this build works?: https://github.com/dortania/Opencore-Legacy-Patcher/suites/2179361359/artifacts/44839491

That seems to have fixed it for me. I can tell when it is resuming from hibernate because the display will wake up but mouse pointer will be frozen for about 10 seconds while it actually reloads RAM.

I see you removed OpenRuntime. That seems to be at the root of the issue. If I remove it manually from config.plist on any OpenCore build, hibernate works.

traviswparker avatar Mar 04 '21 19:03 traviswparker

@khronokernel Not sure about MacBookPro10,1 (Early 2013, Retina), but it's a fairly common issue on MacBookPro9,2 (Mid 2012, non-Retina) with third-party SATA SSDs on Catalina and Big Sur. https://discussions.apple.com/thread/251076418 https://forums.macrumors.com/threads/macbook-pro-not-hibernating.2216855/

family1232009 avatar Mar 04 '21 19:03 family1232009

@family1232009 Ah thank you, will integrate that patch into the patcher. However still confusing as traviswparker's config doesn't include the patch at all yet works fine. So unfortunately can't say this issue is resolved yet

My stripped down config removes all kernel extensions, all EFI drivers (no OpenCanopy/OpenRuntime), and all ACPI patches except for the USB3 controller renames. That's all a MBP10,1 needs. RequestBootVarRouting is not effective. When I do upgrades/reinstalls it does not auto-boot until I clear NVRAM.

traviswparker avatar Mar 04 '21 19:03 traviswparker

@traviswparker Can you see if this build works? https://github.com/dortania/Opencore-Legacy-Patcher/suites/2181069639/artifacts/44888605

khronokernel avatar Mar 04 '21 19:03 khronokernel