Resolved Disable a failed AMD GPU on a 2011 MacBook Pro [GRUB solution]

nate922

macrumors newbie
Aug 2, 2010
16
1
Can I use terminal to install Grub on an external backup HDD via USB, or do I have to do it in Single User?

And how?
Just create the EFI partition (FAT32)

Follow instructions in section 3 from brainshutdown's github:

https://gist.github.com/blackgate/17ac402e35d2f7e0f1c9708db3dc7a44
[doublepost=1511400748][/doublepost]@brainshutdown:

I did a little digging and I don't think it's possible with MacbookPro10,1s yet:

https://wiki.archlinux.org/index.ph..._not_work_.28early_August_2013.2C_3.10.3-1.29

Notice the "power down" dGPU outb numbers don't work (just crashes my machine)

Which is consistent with this post:

https://www.kevxu.net/2014/05/force-intel-graphics-on-2012-retina/

Do you think there's away around it brainshutdown?
 

xanderx007

macrumors regular
Nov 7, 2017
137
28
Just create the EFI partition (FAT32)

Follow instructions in section 3 from brainshutdown's github:

https://gist.github.com/blackgate/17ac402e35d2f7e0f1c9708db3dc7a44
If I got it right, that step lists the root drive and its available partitions, not the external drive/s. I'm talking about installing the grub to an external HDD (connected via USB), not a USB stick drive, just in case I need to boot to it.

I did an ls command to list the external drives.

Code:
ls -l /Volumes

Screen Shot 2017-11-23 at 10.12.51.png

Or, I just didn't understand what you're trying to say.
 

nsgr

macrumors 6502
May 22, 2017
317
115
The GRUB outb command is just the outb assembly instruction. You can see it in the AMDGPUWakeHandler source code.

The thing is, the GPU needs to be disabled before the kernel loads, because macOS will gather the info about the pci devices before loading the kexts, and by that time is already too late to disable the GPU, because it already saw the GPU and will try to load the kexts for it.



If the AMDGPUWakeHandler is unloaded, does it make any difference in the voltage when waking up?
You can unload it running this form terminal:
Code:
sudo kextunload /Library/Extensions/AMDGPUWakeHandler.kext
The GRUB outb command is just the outb assembly instruction. You can see it in the AMDGPUWakeHandler source code.

The thing is, the GPU needs to be disabled before the kernel loads, because macOS will gather the info about the pci devices before loading the kexts, and by that time is already too late to disable the GPU, because it already saw the GPU and will try to load the kexts for it.



If the AMDGPUWakeHandler is unloaded, does it make any difference in the voltage when waking up?
You can unload it running this form terminal:
Code:
sudo kextunload /Library/Extensions/AMDGPUWakeHandler.kext
Yes, I was looking at your source code on Github.

I tested the GRUB on a pendrive / USB Stick and worked with High Sierra with APFS (Encrypted - FileVault).

The temperature of the system was 37 degrees Celsius in idle. Only Terminal and Active Monitor open.

In 2015 the user mtsq posted in the forum tonymacx86.com this GRUB method to disable the AMD GPU.

In 2017 I started using Macbook Pro Early 2011 and saw the mtsq post but I did not go any further. Soon after that, AppleMacFinder's method appeared. And the mtsq user was having some problems. At that time he was using the Mavericks.


https://www.tonymacx86.com/threads/help-macbook-pro-disable-radeon-gpu-via-dsdt.164458/

So far in my testing the videos on Youtube the temperature is lower with the GRUB method.

Luckily GRUB has the internal command outb that makes things much easier.

I followed your GRUB tutorial on Github and it worked fine. Next step is to make the GRUB permanent on the SSD. Thank you.
 
Last edited:

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
Yes, I was looking at your source code on Github.

I tested the GRUB on a pendrive / USB Stick and worked with High Sierra with APFS (Encrypted - FileVault).

The temperature of the system was 37 degrees Celsius in idle. Only Terminal and Active Monitor open.

In 2015 the user mtsq posted in the forum tonymacx86.com this GRUB method to disable the AMD GPU.

In 2017 I started using Macbook Pro Early 2011 and saw the mtsq post but I did not go any further. Soon after that, AppleMacFinder's method appeared. And the mtsq user was having some problems. At that time he was using the Mavericks.


https://www.tonymacx86.com/threads/help-macbook-pro-disable-radeon-gpu-via-dsdt.164458/

So far in my testing the videos on Youtube the temperature is lower with the GRUB method.

Luckily GRUB has the internal command outb that makes things much easier.

I followed your GRUB tutorial on Github and it worked fine. Next step is to make the GRUB permanent on the SSD. Thank you.
Yes, he uses the same method I used to boot linux. It works ok to boot linux, but to boot macOS it was the combination of the EFI variable plus the GRUB menu entry that made it work in my case.
I also tried changing the DSDT, and it works, but had problems with the battery indicator.

If I got it right, that step lists the root drive and its available partitions, not the external drive/s. I'm talking about installing the grub to an external HDD (connected via USB), not a USB stick drive, just in case I need to boot to it.

I did an ls command to list the external drives.

Code:
ls -l /Volumes

View attachment 737728

Or, I just didn't understand what you're trying to say.
I'm saying you need to mount your disk, which in your case is disk4, so you need to run this:
Code:
mkdir /tmp/ubuntu
mount -t cd9660 /dev/disk4 /tmp/ubuntu/
open /tmp/ubuntu/
Just create the EFI partition (FAT32)

Follow instructions in section 3 from brainshutdown's github:

https://gist.github.com/blackgate/17ac402e35d2f7e0f1c9708db3dc7a44
[doublepost=1511400748][/doublepost]@brainshutdown:

I did a little digging and I don't think it's possible with MacbookPro10,1s yet:

https://wiki.archlinux.org/index.ph..._not_work_.28early_August_2013.2C_3.10.3-1.29

Notice the "power down" dGPU outb numbers don't work (just crashes my machine)

Which is consistent with this post:

https://www.kevxu.net/2014/05/force-intel-graphics-on-2012-retina/

Do you think there's away around it brainshutdown?
I don't know about your case, but for the MacBookPro9,1, which has an NVidia GPU, the same procedure is used to boot debian:
https://wiki.debian.org/InstallingDebianOn/Apple/MacBookPro/9-1
 
Last edited:

xanderx007

macrumors regular
Nov 7, 2017
137
28
I'm saying you need to mount your disk, in you case is disk4, so you need to run this:
Code:
mkdir /tmp/ubuntu
mount -t cd9660 /dev/disk4 /tmp/ubuntu/
open /tmp/ubuntu/
That comment was for Nate re Step 3 of the Grub solution. Isn't /dev/disk4 my main startup drive/EFI partition? I already have the grub installed on that.

My backup drive, with the backup OS X, to which I want to install grub on is Raptor Delta. Or, would that matter at all, since it would still start up on grub regardless of the startup disk? (Just trying to understand).

disk4s2 (EFI partition?)

Screen Shot 2017-11-23 at 21.38.17.png

disk2s2 (external Backup partition with OS X)

Screen Shot 2017-11-23 at 21.38.30.png

disk1 (Main drive)

Screen Shot 2017-11-23 at 21.38.40.png
 
Last edited:

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
That comment was for Nate re Step 3 of the Grub solution. Isn't /dev/disk4 my main startup drive/EFI partition? I already have the grub installed on that.

My backup drive, with the backup OS X, to which I want to install grub on is Raptor Delta. Or, would that matter at all, since it would still start up on grub regardless of the startup disk? (Just trying to understand).

disk4s2 (EFI partition?)

View attachment 737837

disk2s2 (external Backup partition with OS X)

View attachment 737838

disk1 (Main drive)

View attachment 737839
When you mounted the iso, on your screenshot the the disk was /dev/disk4. You should change the /dev/disk4 for whatever the "hdiutil attach" returns first.
 

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
Just create the EFI partition (FAT32)

Follow instructions in section 3 from brainshutdown's github:

https://gist.github.com/blackgate/17ac402e35d2f7e0f1c9708db3dc7a44
[doublepost=1511400748][/doublepost]@brainshutdown:

I did a little digging and I don't think it's possible with MacbookPro10,1s yet:

https://wiki.archlinux.org/index.ph..._not_work_.28early_August_2013.2C_3.10.3-1.29

Notice the "power down" dGPU outb numbers don't work (just crashes my machine)

Which is consistent with this post:

https://www.kevxu.net/2014/05/force-intel-graphics-on-2012-retina/

Do you think there's away around it brainshutdown?
I've found the DSDT for your model and the GMUX IO port range is the same as mine (from 0x700 to 0x7FF).
So the method should be the same. But I've found in the linux kernel source code that they power off the GPU in two steps.

You can try to do the same by using this grub menu entry:
Code:
menuentry "macOS" {
   insmod hfsplus
   outb 0x728 1
   outb 0x710 2
   outb 0x740 2
   outb 0x750 1
   outb 0x750 0
   search --set=root --file /System/Library/CoreServices/boot.efi
   chainloader /System/Library/CoreServices/boot.efi
}
[doublepost=1511445895][/doublepost]
Got it! Will try that now.

EDIT:

Got a "permission denied" error. Should I start up from the backup disk? I may have done it wrong.

View attachment 737840
It's /dev/disk4 not /dev/disk2s2.
 
Last edited:

nate922

macrumors newbie
Aug 2, 2010
16
1
Thanks for all the help guys, really appreciate @brainshutdown for all the work on the thread.
[doublepost=1511446584][/doublepost]@brainshutdown: those outb numbers don't work right.
Are you looking at the correct DSDT? I'm on a MacBookPro10,1 (2012 retina with GT 650m)
 

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
Thanks for all the help guys, really appreciate @brainshutdown for all the work on the thread.
[doublepost=1511446584][/doublepost]@brainshutdown: those outb numbers don't work right.
Are you looking at the correct DSDT? I'm on a MacBookPro10,1 (2012 retina with GT 650m)
Yes, I downloaded it from here:
https://applelife.ru/threads/darwindumper-dampy-nastojaschix-macov.39174/

If that didn't work either, then I don't know. I have no way to test it, but if you understand the code for the apple_gmux I posted earlier, then you can try the other things they do there.
 

nate922

macrumors newbie
Aug 2, 2010
16
1
Thanks brainshutdown. Yeh, it didn't work either. I will poke around and see if I can make it work.

Thanks for all the help bud.
 

xanderx007

macrumors regular
Nov 7, 2017
137
28
It's /dev/disk4 not /dev/disk2s2.
/dev/disk4 (Raptor X Prime) is my startup or main drive. I've mounted the Ubuntu ISO thenafter.

I want to install grub on /dev/disk2s2 (Raptor Delta, a secondary partition of an external) which is my backup/startup drive so I can start up from it as needed.

And this is what I'm having a hard time to understand. Do I need to create an EFI partition on that drive (disk2s2) via Disk Utility(?) and transfer the same files as with the USB so it loads the grub when I choose it as the start up disk?

I've tried copying the grub files onto the backup disk using the terminal commands, and that actually got me into trouble earlier (I shant bother you with the details).

I've googled "how to install grub on external drive Mac OS X," but everything I found requires Ubuntu to be installed in some form, which is also what I'm trying to avoid. What I want to know if installing grub on the backup drive is as simple as the steps for the main startup in your gist.
 
Last edited:

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
@xanderx007 You aren't installing anything, just mounting the iso to copy the files. After the "hdiutil attach" command, your screenshot shows that the iso was attached to /dev/disk4, so you need to mount that with the mount command in order to open the iso. If you can't understand that, I can't help you, sorry.
 

nate922

macrumors newbie
Aug 2, 2010
16
1
hey @@brainshutdown
I got it to work, woohoo, using:
Code:
outb 0x7c2 1
outb 0x7d4 0x28
outb 0x7c2 2
outb 0x7d4 0x10
outb 0x7c2 2
outb 0x7d4 0x40

outb 0x7c2 1
outb 0x7d4 0x50
outb 0x7c2 0
outb 0x7d4 0x50
Now the the dGPU is not showing in the profiler, however upon sleep & wake the dGPU is then powered back on.

I've tried your kext and it's showing:

Code:
2017-11-23 21:23:38.002846+0000 0x24fa     Default     0x0                  0      kernel: (AMDGPUWakeHandler) Waking up

2017-11-23 21:23:38.002849+0000 0x24fa     Default     0x0                  0      kernel: (AMDGPUWakeHandler) Disabling GPU
However it doesn't seem to work, does the kext work with those outb numbers ?

Thanks mate.
 
  • Like
Reactions: brainshutdown

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
hey @@brainshutdown
I got it to work, woohoo, using:
Code:
outb 0x7c2 1
outb 0x7d4 0x28
outb 0x7c2 2
outb 0x7d4 0x10
outb 0x7c2 2
outb 0x7d4 0x40

outb 0x7c2 1
outb 0x7d4 0x50
outb 0x7c2 0
outb 0x7d4 0x50
Now the the dGPU is not showing in the profiler, however upon sleep & wake the dGPU is then powered back on.

I've tried your kext and it's showing:

Code:
2017-11-23 21:23:38.002846+0000 0x24fa     Default     0x0                  0      kernel: (AMDGPUWakeHandler) Waking up

2017-11-23 21:23:38.002849+0000 0x24fa     Default     0x0                  0      kernel: (AMDGPUWakeHandler) Disabling GPU
However it doesn't seem to work, does the kext work with those outb numbers ?

Thanks mate.
I'm glad you found a way. You can clone the git repository and change this outb instructions with yours.
 

nate922

macrumors newbie
Aug 2, 2010
16
1
Cheers,

I've modified the code, however I can't seem to compile it:

Code:
bash-3.2# make AMDGPUWakeHandler

c++     AMDGPUWakeHandler.cpp   -o AMDGPUWakeHandler

AMDGPUWakeHandler.cpp:2:10: fatal error: 'IOKit/IOLib.h' file not found

#include <IOKit/IOLib.h>

        ^~~~~~~~~~~~~~~

1 error generated.

make: *** [AMDGPUWakeHandler] Error 1

bash-3.2#
Do I need special libraries for IOKIT?

Thanks mate.
 

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
Cheers,

I've modified the code, however I can't seem to compile it:

Code:
bash-3.2# make AMDGPUWakeHandler

c++     AMDGPUWakeHandler.cpp   -o AMDGPUWakeHandler

AMDGPUWakeHandler.cpp:2:10: fatal error: 'IOKit/IOLib.h' file not found

#include <IOKit/IOLib.h>

        ^~~~~~~~~~~~~~~

1 error generated.

make: *** [AMDGPUWakeHandler] Error 1

bash-3.2#
Do I need special libraries for IOKIT?

Thanks mate.
Open the project with Xcode and compile it there.
 

xanderx007

macrumors regular
Nov 7, 2017
137
28
@xanderx007 You aren't installing anything, just mounting the iso to copy the files. After the "hdiutil attach" command, your screenshot shows that the iso was attached to /dev/disk4, so you need to mount that with the mount command in order to open the iso. If you can't understand that, I can't help you, sorry.
Yes. I understand that that simply mounts the ISO from where it is located on the HD, so I could copy the necessary files from the ISO to the USB RESCUE Drive, as per the steps, but that process is for the MAIN drive. I've done that before for the MAIN drive.

What I've been asking is, how to do the same with an External HDD so I can start up from there. I've tried copying the files from the ISO to the backup drive, and it doesn't work.
 

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
Yes. I understand that that simply mounts the ISO from where it is located on the HD, so I could copy the necessary files from the ISO to the USB RESCUE Drive, as per the steps, but that process is for the MAIN drive. I've done that before for the MAIN drive.

What I've been asking is, how to do the same with an External HDD so I can start up from there. I've tried copying the files from the ISO to the backup drive, and it doesn't work.
This has nothing to do with the fact that you already have this on the MAIN drive. The process is the same. You can run the step 3 as many times as you want for any external HDD/flash drive.
 

xanderx007

macrumors regular
Nov 7, 2017
137
28
This has nothing to do with the fact that you already have this on the MAIN drive. The process is the same. You can run the step 3 as many times as you want for any external HDD/flash drive.
So, I have to set my backup as my start up disk, boot into the USB to disable the dGPU, and do the Terminal commands (Step 4) from there?

I apologize for not getting it, especially since step 3 is about creating the USB boot disk, which has to be formatted FAT32. My Backup drive already has Mac OS X installed (El Capitan).
 
Last edited:

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
So, I have to set my backup as my start up disk, boot into the USB to disable the dGPU, and do the Terminal commands (Step 4) from there?

I apologize for not getting it, especially since step 3 is about creating the USB boot disk, which has to be formatted FAT32. My Backup drive already has Mac OS X installed (El Capitan).
If what you want is to boot the OS X on the external HDD, then no, you don't need to do the step 4. The step 4 is only to copy GRUB to the internal HDD and bless it. You don't need that on the external HDD. You just need to press and hold "option (alt)" and choose the EFI partition(the one you created) on the external HDD.
 

xanderx007

macrumors regular
Nov 7, 2017
137
28
If what you want is to boot the OS X on the external HDD, then no, you don't need to do the step 4. The step 4 is only to copy GRUB to the internal HDD and bless it. You don't need that on the external HDD. You just need to press and hold "option (alt)" and choose the EFI partition(the one you created) on the external HDD.
So, I do need to create an additional partition on the external HD first (which I mentioned earlier, as suggested by Nate, which got me confused) and transfer the necessary files from the ISO into it, and boot into that, instead of the USB.
 

nsgr

macrumors 6502
May 22, 2017
317
115
Yes, he uses the same method I used to boot linux. It works ok to boot linux, but to boot macOS it was the combination of the EFI variable plus the GRUB menu entry that made it work in my case.
I also tried changing the DSDT, and it works, but had problems with the battery indicator.


I'm saying you need to mount your disk, which in your case is disk4, so you need to run this:
Code:
mkdir /tmp/ubuntu
mount -t cd9660 /dev/disk4 /tmp/ubuntu/
open /tmp/ubuntu/


I don't know about your case, but for the MacBookPro9,1, which has an NVidia GPU, the same procedure is used to boot debian:
https://wiki.debian.org/InstallingDebianOn/Apple/MacBookPro/9-1
HighSierra 10.13.1

Yes, if you do not use nvram fa4ce ...:gpu-power-prefs=%01%00%00%00, then HighSierra goes to a black screen after GRUB with the outb command.

HighSierra 10.13.1 has a problem with GRUB in the brightness adjustment on the screen:

Brightness: F1 and F2 keys do not work.

Keyboard light: F5 and F6 keys work correctly.

Also does not appear the slider of the brightness adjustment -> System Preferences -> Displays.


SystemPreferences-Displays-Grub-without-Brightness.png

https://imgur.com/a/cEXEZ




SystemPreferences-Displays-AMDgpu-with-Brightness.png

https://imgur.com/a/qS9qB


If you need to adjust the brightness with GRUB:

1 - You must first enter Safe Mode (press SHIFT key at boot).

2 - Login to your user.

3 - System Preferences -> Displays -> adjust the brightness slider.

4 - Reboot.

5 - Boot with GRUB.



I also noticed that there is difference in configuration files in the brightness adjustment because they are independent.

1 - Boot Safe Mode -> Brightness setting in Safe Mode.

2 - Boot normal without GRUB and AMDRadeonX3000.kext moved from /System/Library/Extensions -> there is another configuration (file config) for the brightness.

I have not found the configuration file yet. I set to a brightness level in Safe Mode and another brightness to normal boot without GRUB (AMD GPU recognized) and the brightness levels remain independent.

I tried to make the brightness adjustment only by the sudo nvram backlight-level but it did not work. I think it's a kext that makes the instant change by sliding the brightness adjustment.

I made an adjustment in my grub.cfg to be able to test GRUB with or without the outb command. The AMDRadeonX3000.kext moved out /System/Library/Extensions .

HighSierra 10.13.1

grub.cfg

Code:
menuentry "macOS with outb" {
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    exit
}
menuentry "macOS without outb" {
    exit
}
 

Attachments

Last edited:

nate922

macrumors newbie
Aug 2, 2010
16
1
@brainshutdown is there a binary that i could run on OSX to power down the GPU ? I believe there's a linux source floating around.

I modifed the AMDGPUWakeHandler.kext and it works around 50% of the time. Sometimes upon wake it still powers up the GPU.

Is there a way to manually execute the AMDGPUWakeHandler binary from cli?

Thanks for all your help brainshutdown.
 

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
HighSierra 10.13.1

Yes, if you do not use nvram fa4ce ...:gpu-power-prefs=%01%00%00%00, then HighSierra goes to a black screen after GRUB with the outb command.

HighSierra 10.13.1 has a problem with GRUB in the brightness adjustment on the screen:

Brightness: F1 and F2 keys do not work.

Keyboard light: F5 and F6 keys work correctly.

Also does not appear the slider of the brightness adjustment -> System Preferences -> Displays.


SystemPreferences-Displays-Grub-without-Brightness.png

https://imgur.com/a/cEXEZ




SystemPreferences-Displays-AMDgpu-with-Brightness.png

https://imgur.com/a/qS9qB


If you need to adjust the brightness with GRUB:

1 - You must first enter Safe Mode (press SHIFT key at boot).

2 - Login to your user.

3 - System Preferences -> Displays -> adjust the brightness slider.

4 - Reboot.

5 - Boot with GRUB.



I also noticed that there is difference in configuration files in the brightness adjustment because they are independent.

1 - Boot Safe Mode -> Brightness setting in Safe Mode.

2 - Boot normal without GRUB and AMDRadeonX3000.kext moved from /System/Library/Extensions -> there is another configuration (file config) for the brightness.

I have not found the configuration file yet. I set to a brightness level in Safe Mode and another brightness to normal boot without GRUB (AMD GPU recognized) and the brightness levels remain independent.

I tried to make the brightness adjustment only by the sudo nvram backlight-level but it did not work. I think it's a kext that makes the instant change by sliding the brightness adjustment.

I made an adjustment in my grub.cfg to be able to test GRUB with or without the outb command. The AMDRadeonX3000.kext moved out /System/Library/Extensions .

HighSierra 10.13.1

grub.cfg

Code:
menuentry "macOS with outb" {
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    exit
}
menuentry "macOS without outb" {
    exit
}
Yes, as mentioned in the guide, there are problems with High Sierra.
It seems to me that the GMUX is disabled in High Sierra when using the grub menu entry.
You can confirm this by running:

Code:
system_profiler SPDisplaysDataType | grep gMux
If nothing appears then its probably disabled.
I don't know if this works, but you can enable the GMUX interrupts by doing an "outb 0x714 0xFF" on the menuentry like this:

Code:
menuentry "macOS with outb" {
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    outb 0x714 0xFF
    exit
}

@brainshutdown is there a binary that i could run on OSX to power down the GPU ? I believe there's a linux source floating around.

I modifed the AMDGPUWakeHandler.kext and it works around 50% of the time. Sometimes upon wake it still powers up the GPU.

Is there a way to manually execute the AMDGPUWakeHandler binary from cli?

Thanks for all your help brainshutdown.
Unfortunately in macOS it's not possible to run binaries that perform low level I/O directly, because they will run in the "user space" and not the "kernel space". The only way to run code in "kernel space" is in kexts.
But you can reload the kext by running the following commands on the terminal:

Code:
sudo kextunload /Library/Extensions/AMDGPUWakeHandler.kext
sudo kextload /Library/Extensions/AMDGPUWakeHandler.kext
The code that powers down the GPU is also executed when loading, so you don't need to put it to sleep.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.