Experiments in refit shell to enable 9400M on MBP 5,1

So I've been experimenting with the refit shell to see if its possible to enable the 9400M instead of the 9600M GT.

The refit shell is part of the standard refit installation and you can load it by choosing the little terminal icon from the refit menu when you first boot. The following will walk you through using the shell to try and activate the 9400M on the MBP 5,1.

<disclaimer>Warning: If you are not very familiar with things like hex editors and low level stuff, or if you are just careless, you could mess with your EFI in a bad way, so please proceed with caution (if you are careful and know what you're doing it is perfectly safe).</disclaimer>.

First thing to know if you're using the shell is that most shell commands can take the option -b which means to break each output page. They all also take the option -? which means to show a help page about the command. ie. from the refit shell do:

Code:

help -? -b

to get info about the help command or you can just do

Code:

help -b

which will show you all the different commands the shell supports. The first one to look at is

Code:

pci -b

which will show us that we can see both display controllers (9400 & 9600) with pci id's 00 02 00 00 and 00 03 00 00 respectively.

If we do

Code:

pci 00 02 00 -i

we find that the 9400M just has 0xFF for all values, and so I think is not power up maybe, whereas the 9600M GT has some sane information.

The next thing we can do is get a list of all the efi devices:

Code:

devices -b

Which again lists the 2 video controllers with handles e5 and e7 respectively. You can get some more info by doing:

Code:

dh -b e5

and same for e7 - this seems to show that handle e7 is being used as the active graphics card (which is the 9600M GT from what I can tell).

Next we can see all the EFI variables with

Code:

dmpstore -b

and there are 2 pretty interesting ones there - gpu-power-prefs and LEGACYVGAHANDLE. If you look carefully you'll notice that the value of LEGACYVGAHANDLE (on my machine it is 18 4A 6D 7E 00 00 00 00 - where the first 4 bytes are the same as the handle shown when you do a dh -b e7 - 7E6D4A18 - but just in reverse byte order since it's little endian). The other thing to note is that gpu-power-prefs is stored in NVRAM (indicated by the NV) whereas LEGACYVGAHANDLE is not, and from what I've been able to gather LEGACYVGAHANDLE gets set as a result of the value of gpu-power-prefs. The default value of gpu-power-prefs is 01 00 00 00 (ie 1) and I've been experimenting with different values to see if we can get the 9400M powered up at boot (since I assume it is powered down normally).

You can use dmpstore to save a variable to a file or to load a variable from a file, so we can use this to change the values of these variables. So try something like the following to save the original value of gpu-power-prefs to a file and edit a copy of the file to set a new value from:

now change the 01 00 00 00 and the end of the file to 00 00 00 00 (ie effectively change the value from 1 to 0). You can check that you didn't make any major screwups by doing a:

Code:

comp fs0:\gpu-power-prefs.orig fs0:\gpu-power-prefs

and it should show just a single byte change from 01 to 00.

We can now set the value of gpu-power-prefs to our new value by using dmpstore again:

Code:

dmpstore gpu-power-prefs -l fs0:\gpu-power-prefs

So with this new value you can exit the shell and power on and off the machine. Now go back into the shell and do a dmpstore gpu-power-prefs and you'll see its got your new value of 00 00 00 00 AND if you do a dmpstore legacyvgahandle you can see the handle should now be changed to that of the device e5 (ie the 9400M) instead of the device e7 (the 9600M GT).

So at this point it looks like we've got the 9400M enabled as the legacy mode GPU - YAY - BUT unfortunately though when I then go and boot into Ubuntu it still only lists the 9600M GT and there is still no sign of the 9400M.

So after all that I still can't seem to get it to use the 9400M over the 9600M GT - I've posted the instructions here though in case anyone else can get further with it or wants to experiment more.

Last edited by alexmurray; February 23rd, 2009 at 12:01 AM.
Reason: Added info about refit shell and warning for unfamiliar users

Re: Experiments in refit shell to enable 9400M on MBP 5,1

The commands are in the refit shell - not in Ubuntu - if you've got refit installed, when you power on, instead of selecting Linux to boot, choose the little terminal icon on the second row which will drop you into the refit shell.

Re: Experiments in refit shell to enable 9400M on MBP 5,1

This is what I was thinking too. It may be that the legacy loader ignores these, or even sets them "appropriately" when it is activated.

I bet if you boot from EFI that Alex's method would work. You might at least be able to get to a commandline and do lspci to see if the device is seen in Linux (that is if you have a working keyboard).

Originally Posted by pxwpxw

But thanks for the info on using EFI shell, can use some of that to look at grub.efi booting video and other issues. I have only single video display MBP4,1/iMac8.1, not much help for your topic,

and on that note, I wanted to point out that there is a command to change the resolution in the efi terminal, so you can see a bit more at once.

Originally Posted by alexmurray

The commands are in the refit shell - not in Ubuntu - if you've got refit installed, when you power on, instead of selecting Linux to boot, choose the little terminal icon on the second row which will drop you into the refit shell.

Yes, and I think that a warning is in order to users that do not know what they are doing. If you are not careful, you may be able to change some EFI variable that causes problems with your machine. Happy Hacking.

Re: Experiments in refit shell to enable 9400M on MBP 5,1

Great experiment. Hopefully it will be useful at some point.

Originally Posted by alexmurray

The commands are in the refit shell - not in Ubuntu - if you've got refit installed, when you power on, instead of selecting Linux to boot, choose the little terminal icon on the second row which will drop you into the refit shell.

I can't see any terminal icon!? Out of my memory I have only OSX, Linux and on the bottom row there are 4 icons. The terminal is missing. I 've checked the refit.conf file and there is no disabled shell option or similar.

Re: Experiments in refit shell to enable 9400M on MBP 5,1

[...]
It can support up to 8GB of RAM. It can do on-the-fly GPU switching. And it can work together with the MacBook Pro's discrete 9600M GT. But it doesn't do any of those things. Yet.
[...]
But since it's Apple it's also entirely possible we'll never see any of this to come to pass...
[...]

Imagine that Linux can make the break-through Imagine that Linux will make the break-through

Common, let's set-up a project to attract dev's on it. There are many geeks who like apple-machines out there.

Re: Experiments in refit shell to enable 9400M on MBP 5,1

Hi to all, is there any progress on this problem ?
My experiments finished at the point, when I was starting ubuntu after enabling 9400 GPU through rEfi.
I noticed some interesting things:
1. changing 'gpu-power-prefs' to my 9400 value, after that 'dmpstore legacyvgahandle' shows my 9400 value
a) when I run rEfit shell -> than exit rEfit shell -> than try from menu linux lounch -> it stucks, nothing happens and macbook freeze with rEfit pinguins image.
b) when I run linux from menu, skiping rEfit shell -> than ubuntu starting OK
2. changing 'gpu-power-prefs' to my 9600 value, after that 'dmpstore legacyvgahandle' shows my 9600 value
a) when I run rEfit shell -> than exit rEfit shell -> than try from menu linux lounch -> it stucks, nothing happens, but macbook freeze with black screen, like when we boot linux.
b) when I run linux from menu, skiping rEfit shell -> than ubuntu starting OK

From that results, I'm thinking that rEfit uses another values than our values which we changing through rEfit shell, because in two cases we stuck, and in other two cases we run ubuntu without any problems.
But when we look at cases when we stuck, we can result that in one case was more progress than in other.

I think need to dig in refit startup, when I'll have time, I would look. And for purity of experiment I whant to reinstall rEfit, because I could corrupt something in the past - I must satisfy that linux stucks after we run rEfit shell.