Jump to content

2 Sleep issues - resume immediately & reboot when wake


Go to solution Solved by monto,
59 posts in this topic

Recommended Posts

I've got a perfectly working Sierra on Gigabyte B150M-HD3 DDR3, using SMBIOS 17,1, except two sleeping issues:

1. Resume immediately: When I put Sierra to sleep, it takes about 20 seconds to power everything down and becomes quiet. A couple of seconds later, the power light goes back on again. The system just wakes up all by itself. At this point, if I don't press a key on the keyboard to wake up the monitor, the machine would go into a "black screen" state - appears waken but black screen. How do I know? Apple Watch would tell me it has unlocked Sierra successfully.

At this stage, I can't use the machine without the screen, and the only way to fix this state is to press the reset button on the PC case. If I press a key within a few seconds of automatically resuming from sleep, the system wakes up correctly without going into the black screen state. 

What's interesting is, the first time after booting into Sierra, I always get a proper sleep. On the second time of sleep, I always get this problem. The next sleep is always working again, while the following attempt of sleep always fails. It seems to be alternating a state of working and failing.

Tried all the different settings of darkwake (yes, no, 0-10), no perceived differences.
Tried unplug all the USB devices, no differences.
Tried disabled bluetooth prior to sleep, no differences.

Tried disable wake by bluetooth, and wake by network, no differences.

Any other suggestions would be appreciated.

2. Reboot when wake: On those successful sleeps, if I leave the machine in standby state for over 10 minutes or so, when I press a key on the keyboard to wake it up, it would reboot the machine. In fact, I should probably say, the machine seems to be in an off state rather than low power state, as pressing a key seems to power it up. It powers up immediately and goes through the usual BIOS power up cycle, similar to pressing the power button on the PC case.

Not much was logged in the system logs. As per the logs below. Sleep was triggered manually at 20:42 and it went to sleep successfully. When I woke it up at 20:54 by pressing a key, it rebooted.

Oct  9 20:42:07 MyMac logd[56]: Flushing contents to disk due to sleep event

Oct  9 20:42:08 MyMac com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.user.505): Service "com.apple.xpc.launchd.unmanaged.loginwindow.98" tried to hijack endpoint "com.apple.tsm.uiserver" from owner: com.apple.SystemUIServer.agent

Oct  9 20:42:38 --- last message repeated 1 time ---

Oct  9 20:54:38 localhost bootlog[0]: BOOT_TIME 1476017678 0


I am eager to solve this last sleep issue of my otherwise 99% working system - with full suite of Sierra continuity and iMessage/Facetime all working correctly. 

Do anyone else encounter these problems on Skylake systems? Or do anyone else who doesn't share these problems on Skylake systems? Anyone with a working sleep system in Sierra?

--------------------------------- Below Edited 10/19/2016 -------------------------------
[sOLVED partially] - This is probably a workaround rather than a fix:

Problem 1 is no longer exhibited, if instead of pressing a key on keyboard/trackpad/mouse, the power button on the case is used to wake the system. I am still puzzled as why this is the case.

Problem 2 is no longer occurring with some workarounds. See post #10 below for details.
The workaround was short-lived. Prolong sleep still caused reboot randomly.
 
---------------------------------- Below Edited 12/22/2016 ------------------------------
Both problems still persist and behave exactly the same, even after changing of motherboard recently. 
The motherboard was changed from Gigabyte B150M-HD3 DDR3 to Gigabyate H170-Gaming 3 DDR3. After ssdt for USB was remapped and uia_excluded, sound and network kexts loaded, nothing is changed.
Edited by monto

*Update 3*

[sOLVED] Edited USBInject.kext and changed ID to 255 to make the port where the Bluetooth device is plugged in appear as "internal". Now sleep and wake work perfectly  :D

 

 

Similar problems here :(
http://www.insanelymac.com/forum/topic/316428-asus-z170m-plus-nvidia/?p=2292423

 

*Update* I guess the problem is caused by the Broadcom Wifi/Bluetooth-card I installed...

Problem solved! Now everything works  :) 

*Update 2* Ok, only force sleep works and you have to wake up by power button. It doesn't sleep on his own... Can anyone please assist me with patching the dsdt? Thank you so much in advance! 

  • Like 1

*Update 3*

[sOLVED] Edited USBInject.kext and changed ID to 255 to make the port where the Bluetooth device is plugged in appear as "internal". Now sleep and wake work perfectly  :D

 

 

Similar problems here :(

http://www.insanelymac.com/forum/topic/316428-asus-z170m-plus-nvidia/?p=2292423

 

*Update* I guess the problem is caused by the Broadcom Wifi/Bluetooth-card I installed...

Problem solved! Now everything works  :) 

*Update 2* Ok, only force sleep works and you have to wake up by power button. It doesn't sleep on his own... Can anyone please assist me with patching the dsdt? Thank you so much in advance! 

Would you be kind enough to describe the steps in more details on how you resolved this issue. Specifically, where do I find USBInject.kext (can only find USBInjectAll.kext online) and which ID to change to 255.

Thanks.

Would you be kind enough to describe the steps in more details on how you resolved this issue. Specifically, where do I find USBInject.kext (can only find USBInjectAll.kext online) and which ID to change to 255.

Thanks.

I meant USBInject*ALL* of course, sorry ;)

Right click on it and "Show package contents". Inside you have a config.plist (similar to Clover's). Open it with Textedit (or any other editor you might use). Scroll down until you reach the desired port. My example:

Under my specific mainboard config
 
<key>Configuration</key>
<dict>
 
<key>8086_a12f</key> <<-- Yours can be different!
......
<key>ports</key>
<dict>
......
<key>HS12</key> <<-- Yours can be different!
<dict>
<key>UsbConnector</key>
<integer>255</integer>  <<--- in this field standard is "3" and I changed it to "255"
<key>port</key>
<data>
DAAAAA==
</data>

</dict> 

 

I searched for the correct port via the app "IORegistryExplorer". I found that my bluetooth device is plugged in port HS12 (that is my second USB2 mainboard connector near the PCIe-Slots). Yours may be different.  

Thanks for the detailed instruction. Still no dice unfortunately.

The BT from my BCM94360 is also connected to USB2 on mainboard. IORegistryExplorer showed the BRCM20702 BT on HS08 of 8086_a12f, so I changed UsbConnector from 3 to 255 under HS08 as per your instruction. Then I used KCPM to install USBInjectAll.kext to /Library/Extension, followed by reboot.

First thing I noticed after reboot, was the external USB drive icon is now orange, instead of the same internal hard disk icon. This indicated USBInjectAll.kext was installed properly.

Put the system to sleep for 5 minutes or so. Hit a key on keyboard, system rebooted! Same as before.

Did I miss anything in the steps?
 

This is a problem with Sierra I think. Both my systems exhibit this reboot problem on wake. Where one is a Z97 system with 4790K and no BCRM94360 the other Z170 with 6700K with BCRM94360. Both slept/woke well in 10.11.6 and both are broken now. Will probably have to wait for 10.12.1.

Anyone on the Beta will need to check this out.

I get failures as 

 

Drivers Failure during wake due to XHC(XHC),SAT0(),RP05(AirPort_Brcm4360),GLAN(IntelMausi)

or

 

Darkwake Exit Failure during wake due to 0x34053000000032:

 

This is when I run in terminal

 

sudo pmset -g log | grep -i failure

Interesting! With the lack of response, I was under the impression most people don't have this problem. Now I am seeing similar failures like yours too.

Notification Failure during wake due to 0x3403A004000024:

 

Drivers Failure during wake due to 0x01000027:

First I recommend cleaning up the USB injector, deleting all unnessecary stuff. And DO NOT install it in your extensions folder! Put these kexts on your efi partition in Clover/kexts. That is why we use Clover, to keep the system clean (else you may have to reinstall kexts after updates/kexts causing kernel panics etc. It is easier to remove "bad kexts" from Clover folder). Delete USBInjectALL.kext from Library/Extensions, edit it as you please and put it in Clover folder.  

Interestingly, I have successfully slept and woken up the machine at least 5 times without any reboot or other issues. The system hasn't been rebooted for over a day now.

What I did was applied the USBInjectAll.kext and changed ID from 3 to 255 as per the above instruction, AND removed darkwake=no from the boot parameter. Also, the power button was used to wake up the system, instead of pressing a key on keyboard. Power management was set to never automatically sleep the system. Always manually set the system to sleep, as automatic sleep seems to cause problem.

It's still not perfect, but the workaround is good enough for now.

If you still have time there a several things you could do ;) Simply deactivate bluetooth wake for example, or deactivate network sharing, delete your sleep file. This could be a "non-hack" problem in the end. That activating darkwake helped is strange, should be the other way around ;) By the way: Using the command "pmset -g assertions" in terminal should give you an idea of what is preventing auto sleep.

If you still have time there a several things you could do ;) Simply deactivate bluetooth wake for example, or deactivate network sharing, delete your sleep file. This could be a "non-hack" problem in the end. That activating darkwake helped is strange, should be the other way around ;) By the way: Using the command "pmset -g assertions" in terminal should give you an idea of what is preventing auto sleep.

Thanks for the tips. I was puzzled about the removal of darkwake=no too!

Both bluetooth wake and network wake were already disabled long ago, before I started to try all the exotic workarounds. 

 

I think auto sleep actually works - in the sense that it sleeps the system successfully. The problem seems to be, if it's set to for example 15 minutes to sleep, and I manually sleep the machine, it would cause a reboot if I leave the system in sleep state for longer than 15 minutes. It's like the 15 minutes auto sleep would still get triggered while during sleep and cause problem upon next reboot. That's why I set sleep to never, and only manually trigger the sleep as a workaround for now.

 

It's been 1d17h since the last reboot, with many manual sleeps during this period. The workaround is working good so far.

 

How do I delete the sleep file? I'd like to try that...

I see at least one problem with this approach. What if for some reason the system comes on there is no autosleep to put it back to sleep and it remains on all through. I think there's "PleaseSleep" for that but I've never used it.

@monto — please could you see if this works okay?

One thing I forgot monto: Do you have hibernation activated? That could cause the reboot, at least it appears as if it was a reboot...

 

Hibernation is disabled.

 

$ pmset -g

Currently in use:

 hibernatemode        0

 womp                 0

 networkoversleep     0

 sleep                0

 Sleep On Power Button 1

 ttyskeepawake        1

 hibernatefile        /var/vm/sleepimage

 disksleep            10

 displaysleep         10

I see at least one problem with this approach. What if for some reason the system comes on there is no autosleep to put it back to sleep and it remains on all through. I think there's "PleaseSleep" for that but I've never used it.

@monto — please could you see if this works okay?

I agree the workaround is not optimal. Unfortunately I haven't found a better solution yet.

 

PleaseSleep seems to stop updating since 2013. Without specifically catering for newer OSX, I didn't bother to try it.

Don't know if this related to your problem, but: After changing my graphics card to a GTX680 and therefore being able to use Apple stock drivers the machine now sleeps in seconds and even power nap is working at the moment. Never heard that nVidia web drivers are responsible for sleep issues, but in my case they were somehow ;)

Don't know if this related to your problem, but: After changing my graphics card to a GTX680 and therefore being able to use Apple stock drivers the machine now sleeps in seconds and even power nap is working at the moment. Never heard that nVidia web drivers are responsible for sleep issues, but in my case they were somehow ;)

That's interesting. Wondering if anyone using nVidia web driver is able to get sleep working properly? By the way, which SMBIOS do you use?

 

The workaround has failed suddenly this morning and the reboot upon wake comes back again. The only change I've made is I have many programs opened before going to sleep, while previously I've closed most programs prior to sleep. I'm suspecting if one of the built-in programs may be the culprit.

Further program isolation seems to suggest the built-in Mail is the culprit here!

Sleep & Wake worked fine without Mail open. Once it's opened, it rebooted at wake, after 5 minutes of sleep. Curiously, sleeping for 3 minutes doesn't cause a reboot at wake, but 5 minutes would cause the failure.

 

Could you folks please try this and verify if Mail is causing reboot at wake on your system after 5 minutes? Thanks

 

 

Hey monto, it gets even stranger: seems that the Clover patch to raise USB ports was responsible for my instant wakes, it even gave me kernel panics at some occasions. So I removed the patch. After all, everything is working fine for me now. I use USBinjectAll, removed all unnecessary ports and defined the port where my bluetooth card is plugged in as internal. Have no sleep or wake problems anymore. Hope, you came up with a solution for your problems too!

  • Like 1

@macinsane do you mean you use the usbinjectall kext after making the edits you describe to it. Could you please attach it so I may refer to it and edit mine. Thank you.

I leave the kext untouched and use a custom Ssdt instead, you can find it at the bottom of my guide

http://www.insanelymac.com/forum/topic/316428-asus-z170m-plus-installpost-install-for-sierra-1012-and-10121/

Hope that helps, but it only applies to my configuration of course.

Hey monto, it gets even stranger: seems that the Clover patch to raise USB ports was responsible for my instant wakes, it even gave me kernel panics at some occasions. So I removed the patch. After all, everything is working fine for me now. I use USBinjectAll, removed all unnecessary ports and defined the port where my bluetooth card is plugged in as internal. Have no sleep or wake problems anymore. Hope, you came up with a solution for your problems too!

 

How do I easily determine what ports to remove from USBinjectall? 

I leave the kext untouched and use a custom Ssdt instead, you can find it at the bottom of my guide

http://www.insanelymac.com/forum/topic/316428-asus-z170m-plus-installpost-install-for-sierra-1012-and-10121/

Hope that helps, but it only applies to my configuration of course.

 

The ZIP seems to be corrupt, unable to expand. Tried in Mac Windows and Android. Please check and re upload. Thank you.

After trying so many different things, the "reboot at wake" problem seems mostly fixed. While I can't be 100% certain what exactly fixed the problem, I suspect the followings have something to do:

1. removed USBInjectAll.kext (doesn't seem required with latest clover)
2. Install latest clover r3882 (most likely the real contributor of the fix, but can't confirm either way)

3. darkwake = no

4. disable BT to wake & network to wake

5. remove ssdt.aml generated by ssdtPRgen.sh (doesn't seem required with latest clover)

6. Run following commands
sudo pmset -a standby 0 && sudo pmset -a autopoweroff 0

sudo nvram -c
sudo kextcache -system-prelinked-kernel
sudo kextcache -system-caches

Make sure the system is cold reboot when you finish all the changes. 

  • Like 2
×
×
  • Create New...