Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
Installing GRUB

Follow the steps described in this guide:
https://gist.github.com/blackgate/17ac402e35d2f7e0f1c9708db3dc7a44

Installing the attached kext to prevent the GPU from waking up from sleep (optional)

WARNING: This kext should only be used with the GRUB solution in place, otherwise it will kernel panic.

The attached kext is unsigned, if you have a kext signing certificate, you can build it yourself and sign it (don't forget to share :)). You can find the source code here.

Mavericks
Copy the kext to /System/Library/Extensions and then run the following commands from terminal:
Code:
sudo chmod -R 755 /System/Library/Extensions/AMDGPUWakeHandler.kext
sudo chown -R root:wheel /System/Library/Extensions/AMDGPUWakeHandler.kext
sudo touch /System/Library/Extensions

Yosemite
Copy the kext to /Library/Extensions and then run the following commands from terminal:
Code:
sudo nvram boot-args="kext-dev-mode=1"
sudo chmod -R 755 /Library/Extensions/AMDGPUWakeHandler.kext
sudo chown -R root:wheel /Library/Extensions/AMDGPUWakeHandler.kext
sudo touch /Library/Extensions

El Capitan and later
You need to have SIP disabled (view the guide to see how you can disable it).
Copy the kext to /Library/Extensions and then run the following commands from terminal:
Code:
sudo chmod -R 755 /Library/Extensions/AMDGPUWakeHandler.kext
sudo chown -R root:wheel /Library/Extensions/AMDGPUWakeHandler.kext
sudo touch /Library/Extensions
 

Attachments

  • AMDGPUWakeHandler.kext.zip
    7.3 KB · Views: 1,879
Last edited:

mcbeej

macrumors member
Jun 7, 2007
77
3
Thanks for this solution. It's not yet working for me - I have got as far as step 3.5, getting the UUID and putting it into the grub config (either during grub boot, or saving it in the cfg file).

In either case, trying to boot MacOS from grub doesn't work, it just goes to a black screen here.

The UUID I'm using is the MacOS partition UUID as listed from grub, but I have tried others with no success either.
Any things I can try to get MacOS booting from grub?

El Capitan BTW
 

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
@mcbeej The problem you describe reminds me of a problem I had when I tried the grub solution without changing the nvram variable (first step in the guide). You can try to reset the NVRAM and repeat the first two steps in the guide.
 
  • Like
Reactions: AppleMacFinder

mcbeej

macrumors member
Jun 7, 2007
77
3
Thanks for the help - I had been resetting the nvram variable (it's the only way my machine will boot) but this time I tried to reset it then *immediately* on the reboot boot into grub, ie:

- boot into single user mode
- reset the nvram gpu prefs
- reboot, while holding option to go into EFI boot for grub

This time the behaviour of grub changes - if I try to launch MacOS from the menu option (the config file already has my uuid in it), the menu goes away from about ten seconds, then I come back to the menu. If I "e" into edit mode, then fn F10 from there to boot, the screen goes away, and then after about ten seconds I get an "error: unknown error" back from grub. (Always the most useful of error reports (!) )...

Will try a full nvram reset and report how I get on, thanks for the tip.

Edit: Ok, after a full nvram reset, I repeated the above procedure exactly and got the same results from grub...
 
Last edited:

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
@mcbeej
Double check the uuid of your macOS partition, and make sure you choose the correct one. If you choose an uuid for a partition that doesn't have macOS it won't boot.

If you are still having trouble booting, you can use the menu entry used for High Sierra. The only "problem" is that you can only boot one macOS partition.
 
Last edited:

carlsson

macrumors 6502a
Jul 18, 2001
581
496
I am thinking; Since I am able to boot on the failed computer with the help of target mode, could I disable SIP that way? That would save a lot of work...
But I guess not. Recovery mode is always performed on the computer that you are starting from, right?

Just a thought.
 

mcbeej

macrumors member
Jun 7, 2007
77
3
@mcbeej
Double check the uuid of your macOS partition, and make sure you choose the correct one. If you choose an uuid for a partition that doesn't have macOS it won't boot.

Yes, it was definitely correct, but still wouldn't work for some reason. Presumably there was something causing the correct partition to fail to be booted from.

If you are still having trouble booting, you can use the menu entry used for High Sierra. The only "problem" is that you can only boot one macOS partition.

I tried this version, and after a little bit of funkiness, i finally got it to boot and the graphics card is hidden, and Photoshop runs without freaking the computer out, which is *major* progress! Thank you - I will continue on with the other steps to get it to boot without the USB stick.

Really grateful for this procedure and the help, thank you!

Edit: Having some problems with the usb-less boot though, and can no longer boot into single user mode. I followed the procedure without problems. Grub has again stopped booting macOS. And I’m not sure if the new boot stuff can be reverted..?
 
Last edited:

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
Are you using the High Sierra menu entry or the one with the UUID? Can you paste the menu entry here? And BTW can you paste here your UUID?
 
  • Like
Reactions: AppleMacFinder

mcbeej

macrumors member
Jun 7, 2007
77
3
Currently using the High Sierra one yes, as that's the only one I got to boot (but it has since stopped working again).

My MacOS UUID is db683969dd679b2c and the previous grub.cfg file I was using was exactly as the example, but with "db683969dd679b2c" in place of the YOUR_UUID placeholder, but I never got it to work.

Current:
(I left the font stuff is as it made it easier to read the ls -l drive listing - with the font stuff taken out, this overran the window a bit.

Version I got to boot once:

Code:
if loadfont /boot/grub/font.pf2 ; then
    set gfxmode=auto
    insmod efi_gop
    insmod efi_uga
    insmod gfxterm
    terminal_output gfxterm
fi

set menu_color_normal=white/black
set menu_color_black/light-gray

menuentry "macOS" {
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    exit
}

Previous version
Code:
if loadfont /boot/grub/font.pf2 ; then
    set gfxmode=auto
    insmod efi_gop
    insmod efi_uga
    insmod gfxterm
    terminal_output gfxterm
fi

set menu_color_normal=white/black
set menu_color_black/light-gray

menuentry "macOS" {
   insmod hfsplus
   outb 0x728 1
   outb 0x710 2
   outb 0x740 2
   outb 0x750 0
   search --no-floppy --fs-uuid --set=root db683969dd679b2c
   chainloader /System/Library/CoreServices/boot.efi
}

By luck I've managed to boot into MacOS normally, so if there is a way to temporarily undo the permanent boot efi changes, that would be useful, as booting from the USB stick is better than nothing, for now..!
 

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
Ok, try this:
Code:
if loadfont /boot/grub/font.pf2 ; then
   set gfxmode=auto
   insmod efi_gop
   insmod efi_uga
   insmod gfxterm
   terminal_output gfxterm
fi

set menu_color_normal=white/black
set menu_color_black/light-gray

menuentry "macOS" {
   insmod hfsplus
   outb 0x728 1
   outb 0x710 2
   outb 0x740 2
   outb 0x750 0
   search --set=root --file /System/Library/CoreServices/boot.efi
   chainloader /System/Library/CoreServices/boot.efi
}

This will try to find the first /System/Library/CoreServices/boot.efi and then boots it.

To remove grub, this should be enough:
Code:
cd /Volumes
sudo mkdir efi
sudo mount -t msdos /dev/disk0s1 /Volumes/efi
sudo rm -rf /Volumes/efi/boot/grub/
sudo rm -rf /Volumes/efi/EFI/grub/
 

mcbeej

macrumors member
Jun 7, 2007
77
3
Thanks, will try this shortly.

Edit, some additional information as I have started to understand the behaviour a bit more:

Firstly, I'm using your modified grub.cfg posted above, but I think the following would work with the previous ones as well. SIP is left disabled here, at least for now. I removed the boot stuff for now with your instructions above.

When I have been booting from grub, and the screen goes black, what's happening here is that the nvram gpu-power-prefs has been reset back to the default (this seems to happen quite a lot, at least while doing boot tests etc). I *know* when gpu-power-prefs has been reset, because if I do a normal boot, I get the same old behaviour - ie, the machine mostly hangs on boot because of the state of the dGPU.

When gpu-power-prefs has been correctly modified, the machine will boot normally (as the boot procss is ignoring the dGPU state) - and also, the grub boot will work correctly (no more black screen, macOS boots, and the dGPU is gone).

What was causing me problems - not being able to get into single user mode (or verbose mode) - is that since originally modifying the USB boot procedure to not use the USB stick, the initial white screen on boot now adds 10-20 seconds *before* the command-S/whatever keys will start to have any effect (I've no idea why). If I literally hold command-S down while turning the machine on and waiting for 20 seconds or so on a white screen, it will eventually go into single user mode - where I can modify the gpu-power-prefs setting, and then whatever boot method I choose will work.

So, I think for now, I'm going to stick with this system - with no USB stick, the machine will do a normal boot and not hang, with the dGPU active, or, I can boot from the USB stick using grub, and disable the dGPU completely (which is obviously how I will be mostly running from now on.)

Maybe I'll play with this some more and give the permanent boot another go, but at least for now, I have a working system, and should a boot fail, I know to go back into single-user mode and reset the nvram gpu-power-prefs (which is just in the command line history state, so no typing involved).

I also have the wake handler kext installed as well.

This has been *immensely* helpful, thanks to everyone who's been investigating this and conjuring up the deep black voodoo to find solutions. I hope some of my observations might be helpful to others in a similar situation.

And thanks for the support - this machine's behaviour over the last month or so has been incredibly frustrating and unproductive, and now I have a genuine workable solution until I get a hardware fix.

Thank you!
 
Last edited:

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
You can use clover, but I don't think is better for this. I've tried changing the DSDT to achieve a similar result with clover and I was able to boot, but I had problems with the battery.
 
Last edited:
  • Like
Reactions: AppleMacFinder

tmanx

macrumors newbie
Nov 1, 2017
22
3
Hi @brainshutdown

Thanks for the revised instructions. Have used the new kext and Maverick code to install. Got the same error as in my other post #1133 - but to the path /System/Library/Extensions. Restarted and it has not popped up again - but on returning from sleep am not convinced it's working (e.g. iStat GPU VCore reading is 1.12V). How can I check for sure?

thanks a lot
 

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
@tmanx The first time the kext is loaded on mavericks, a message is displayed because it's unsigned, but it loads nevertheless. With the kext loaded, the temperature of the GPU die shouldn't increase with respect to the values after booting (You can use iStat or Macs Fan Control to check the temperature), and the battery shouldn't drain faster.
 

tmanx

macrumors newbie
Nov 1, 2017
22
3
@brainshutdown temp has never been a major concern - it's the power loss.

I'm wondering if the kext has loaded though? I'm having basically the same behaviour as before applying AMDGPUWakeHandler/kext

Battery time remaining on istat after restart is about 4 hrs at 56% and GPU VCore is 0.00. But after sleep it seems to be shooting down quite quickly (e.g. then says about 2 hrs) and GPU VCore changes to 1.12V (as if the GPU is waking up / power is being drawn) or have I misunderstood?

Thanks very much
 
  • Like
Reactions: AppleMacFinder

nsgr

macrumors 6502
May 22, 2017
317
117
I am thinking; Since I am able to boot on the failed computer with the help of target mode, could I disable SIP that way? That would save a lot of work...
But I guess not. Recovery mode is always performed on the computer that you are starting from, right?

Just a thought.

Ways to Disable SIP:

1 - Recovery Mode (Graphical Mode): Command + R

2 - Recovery Mode (Text Mode): Command + R + S

3 - Pendrive with the installer of El Capitan, Sierra and High Sierra -> press Option key at boot.

4 - Internet Installer: Option + Command + R

https://support.apple.com/en-us/HT204904


If you have a problem with the Recovery Mode (graphic mode) or pendrive installer Mac OS or Internet Installer Mac OS (AMD gpu freezes on the gray screen), then you have to enter text mode with the command:

sudo nvram fa4ce28d-b62f-4c99-9cc3-6815686e30f9:gpu-power-prefs=%01%00%00%00


The gray screen freezing problem is in the AMD6000Controller.kext and AMDRadeonX3000.kext.

In the Mac OS installer (pendrive, recovery mode, Internet) there is only the AMD6000Controller.kext. This problem with the AMD6000Controller.kext is resolved with the nvram gpu-power-prefs command above.

To get a normal boot with the system installed, just by moving the AMDRadeonX3000.kext to another folder.

AMD6000Controller.kext: full power AMD GPU -> decrease battery life and increase temperature system.

AMDRadeonX3000.kext: Loaded when Intel gpu is as primary gpu. -> low power AMD gpu -> increase battery life and decrease temperature system.

With normal boot and the system running without problem, it is easier to try the grub solution with AMDGPUWakeHandler.kext.


Update:

SIP is stored in the variable nvram csr-active-config. If this variable is listed by Linux (AppleMacFinder method), then SIP can be disabled in ArchLinux or another Linux distribution.

http://osxarena.com/2015/10/guide-details-apples-system-integrity-protection-sip-for-hackintosh/

https://i0.wp.com/osxarena.com/wp-content/uploads/2015/10/csr-active-config.png


SIP enable:

nvram -p

csr-active-config %10%00%00%00


SIP disable:

nvram -p

csr-active-config w%00%00%00
 
Last edited:
  • Like
Reactions: brainshutdown

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
@brainshutdown temp has never been a major concern - it's the power loss.

I'm wondering if the kext has loaded though? I'm having basically the same behaviour as before applying AMDGPUWakeHandler/kext

Battery time remaining on istat after restart is about 4 hrs at 56% and GPU VCore is 0.00. But after sleep it seems to be shooting down quite quickly (e.g. then says about 2 hrs) and GPU VCore changes to 1.12V (as if the GPU is waking up / power is being drawn) or have I misunderstood?

Thanks very much
To check if it's loaded run this on terminal:
Code:
kextstat | grep AMDGPUWakeHandler
If it returns something, then it's loaded.

I haven't really tested on Mavericks directly, but using a VM. I suspect it may be related to the location(/System/Library/Extensions) that is raising it's priority and making it run before the bit of code that triggers the activation of the AMD GPU.

Can you test if reloading the kext by running:
Code:
sudo kextunload /System/Library/Extensions/AMDGPUWakeHandler.kext
sudo kextload /System/Library/Extensions/AMDGPUWakeHandler.kext
and then putting it to sleep and waking it up works?
 
  • Like
Reactions: AppleMacFinder

tmanx

macrumors newbie
Nov 1, 2017
22
3
cheers @brainshutdown

Thanks for your help - I'll give you as much info as I can.

Running
kextstat | grep AMDGPUWakeHandler

didn't return anything (I got the following):

Phoebes-MacBook-Pro:~ phoebe$ kextstat | grep AMDGPUWakeHandler
Phoebes-MacBook-Pro:~ phoebe$


From what you said - that means it isn't loaded. To be sure I tried to unload it and got the following:

Phoebes-MacBook-Pro:~ phoebe$ sudo kextunload /System/Library/Extensions/AMDGPUWakeHandler.kext
Password:
(kernel) Kext io.github.blackgate.AMDGPUWakeHandler not found for unload request.
Failed to unload io.github.blackgate.AMDGPUWakeHandler - (libkern/kext) not found.


I checked and it is in the correct directory:

Screen Shot 2017-11-12 at 21.27.42.png


I then tried to load it and got the following:

Phoebes-MacBook-Pro:~ phoebe$ sudo kextload /System/Library/Extensions/AMDGPUWakeHandler.kext
/System/Library/Extensions/AMDGPUWakeHandler.kext failed to load - (libkern/kext) authentication failure (file ownership/permissions); check the system/kernel logs for errors or try kextutil(8).


Screen Shot 2017-11-12 at 21.23.56.png
Screen Shot 2017-11-12 at 21.24.14.png


I'm assuming that as I've run the following the permissions are OK? - But I'm unsure why it wasn't loaded in the first place? The

sudo chown -R root:wheel /System/Library/Extensions/AMDGPUWakeHandler.kext
sudo touch /System/Library/Extensions


thanks very much
 

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
OK, it must be the permissions. Did you try rerunning the chown and then doing the kextload?
If it still doesn't work try this:
Code:
sudo chmod -R 755 /System/Library/Extensions/AMDGPUWakeHandler.kext
sudo chown -R root:wheel /System/Library/Extensions/AMDGPUWakeHandler.kext
sudo touch /System/Library/Extensions
sudo kextload /System/Library/Extensions/AMDGPUWakeHandler.kext
 

mcbeej

macrumors member
Jun 7, 2007
77
3
The kext isn't working for me either, with similar errors to tmanx above.

('ve done all the suggested procedures above, so permissions etc should be ok.)

If I try to load it manually, I get:
/Library/Extensions/AMDGPUWakeHandler.kext failed to load - (libkern/kext) dependency resolution failure; check the system/kernel logs for errors or try kextutil(8).

I'm on El Cap, perhaps that's an issue..?

Code:
sudo kextutil -v /Library/Extensions/AMDGPUWakeHandler.kext
Defaulting to kernel file '/System/Library/Kernels/kernel'
/Library/Extensions/AMDGPUWakeHandler.kext - no compatible dependency found for com.apple.kpi.mach.
/Library/Extensions/AMDGPUWakeHandler.kext - no compatible dependency found for com.apple.kpi.iokit.
/Library/Extensions/AMDGPUWakeHandler.kext - no compatible dependency found for com.apple.kpi.libkern.
/Library/Extensions/AMDGPUWakeHandler.kext - no compatible dependency found for com.apple.kpi.mach.
/Library/Extensions/AMDGPUWakeHandler.kext - no compatible dependency found for com.apple.kpi.iokit.
/Library/Extensions/AMDGPUWakeHandler.kext - no compatible dependency found for com.apple.kpi.libkern.
/Library/Extensions/AMDGPUWakeHandler.kext - no compatible dependency found for com.apple.kpi.mach.
/Library/Extensions/AMDGPUWakeHandler.kext - no compatible dependency found for com.apple.kpi.iokit.
/Library/Extensions/AMDGPUWakeHandler.kext - no compatible dependency found for com.apple.kpi.libkern.
Diagnostics for /Library/Extensions/AMDGPUWakeHandler.kext:
Dependency Resolution Failures:
    Only incompatible kexts found for these libraries:
        com.apple.kpi.mach
        com.apple.kpi.iokit
        com.apple.kpi.libkern

Code Signing Failure: not code signed

--

Code:
kextlibs -xml /Library/Extensions/AMDGPUWakeHandler.kext
    <key>OSBundleLibraries</key>
    <dict>
        <key>com.apple.kpi.iokit</key>
        <string>15.6</string>
        <key>com.apple.kpi.libkern</key>
        <string>15.6</string>
    </dict>

I'll see if I can build an El Cap compatible version...
 
Last edited:

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
@mcbeej You aren't using this kext version. I known this because your kextutil references a lib that is not used in this version. Please download the version in this thread, because the other I posted in the other thread is only compatible with Sierra.
 
  • Like
Reactions: AppleMacFinder
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.