Posted 23 September 2013 - 10:52 PM

Mieze

Giant Cat

Developers

1,238 posts

Gender:Female

Location:Germany

Interests:Cats

Although the BCM57781 which can be found on some of Asrock's 7 series boards is fully compatible to the BCM57765 in recent iMacs or Mac minis (with the exception that the BCM57781 lacks the integrated card reader), Apple's driver refuses to work with this chip but the driver can be easily patched in order to add support for the BCM57781. Unfortunately adding the BCM57781's ID to the drivers match list in Info.plist is not enough because it checks the NIC's device-id, subsystem-id and subsystem-vendor-id reading the corresponding registers in it's PCI configuration space in order to verify that the chip is one of the officially supported ones.

In principle this method should work with all members of the BCM57785 family:

BCM57781 = 0x16B1

BCM57785 = 0x16B5

BCM57785X = 0x16B5

BCM57761 = 0x16B0

BCM57791 = 0x16B2

BCM57795 = 0x16B6

BCM57795X = 0x16B6 ​​

The basic idea of this patch is to make the driver believe it's got a BCM57765 instead of a BCM57781 so that it will work with this NIC too. In order to read the registers in PCI configuration space the driver calls a subroutine which does the actual work and return the values in a certain CPU register. Therefore I located the subroutine calls in the drivers binary and replaced them with instructions that return the corresponding values of the BCM57765. That's the reason why your BCM57781 will show up as BCM57765 in System profiler.

Let's start with the trivial part. We have to add the BCM57781's ID ("pci14e4,16b1") to the kext's match list in it's Info.plist file in order make the driver load. Locate the following text and add the line "<string>pci14e4,16b1</string>" as shown in the code below.

Now comes the tricky part. You'll have to locate 3 instructions which call the subroutine to read the NIC's subsystem-vendor-id, subsystem-id and device-id registers in PCI configuration space and replace them with instructions that return the required values making the driver believe it's working on a BCM57765 instead of a BCM57781. Use your favorite binary editor to apply the patch. It's also possible to create a script for Clover letting the boot loader do the hard work for you. As the locations and the opcodes of the instructions to replace will probably change with every new build of the driver it virtually impossible to create a binary patch that works for different versions of the driver but with a basic understanding of x86 assembler it should be quite easy to find these 3 instructions to patch in coming releases of the driver an adapt the patch to them. The instructions below are for 10.8.3. In case you are looking for the instructions to patch the 10.8.5 driver please see post #15 (http://www.insanelym...1085/?p=1952049) of this thread. Of course don't forget to repair permissions after you applied the patch. Modified instructions for the latest Mavericks beta will follow soon.

Posted 23 September 2013 - 11:49 PM

Mieze

Giant Cat

Developers

1,238 posts

Gender:Female

Location:Germany

Interests:Cats

Here are the instructions for patching the latest 10.9 beta. They are slightly different but you'll recognize soon that the overall structure remains the same. Modifications of the driver's Info.plist are identical.

Posted 06 October 2013 - 03:37 AM

Posted 06 October 2013 - 08:05 PM

Huberer

InsanelyMac Protégé

Members

14 posts

Hello Mieze,

today I finally found the time to try to do your patches but I stuck at the "tricky part". You say that ii's necessary to patch the pci configuration space. But this is the problem. Where can I find it. It tried to hexedit IONetworkingFamily and IOPCIFamiliy.kext but I can't find the correct place to edit.

Would you be so kind to show me the way to find this "pci configuration space"

Posted 06 October 2013 - 08:08 PM

Mieze

Giant Cat

Developers

1,238 posts

Gender:Female

Location:Germany

Interests:Cats

Hello Mieze,

today I finally found the time to try to do your patches but I stuck at the "tricky part". You say that ii's necessary to patch the pci configuration space. But this is the problem. Where can I find it. It tried to hexedit IONetworkingFamily and IOPCIFamiliy.kext but I can't find the correct place to edit.

Would you be so kind to show me the way to find this "pci configuration space"

Thanks in advance

Huberer

No, you don't need to patch any other kexts. What you have to do is to patch the instructions where the driver calls the functions which read the configuration registers.

Posted 06 October 2013 - 08:20 PM

Huberer

InsanelyMac Protégé

Members

14 posts

Sorry, but this is too high for me. Where do I find these instructions? I think I've opened every single data file within the IONetworkingFamily.kext with hexedit but can't find the right place to patch

Posted 06 October 2013 - 08:28 PM

Mieze

Giant Cat

Developers

1,238 posts

Gender:Female

Location:Germany

Interests:Cats

Sorry, but this is too high for me. Where do I find these instructions? I think I've opened every single data file within the IONetworkingFamily.kext with hexedit but can't find the right place to patch

Posted 06 October 2013 - 08:54 PM

Huberer

InsanelyMac Protégé

Members

14 posts

Thanks, I thought that these are the files to edit. But the next problem is that I don't find the strings. Either with hexfind nor with hexedit. They only show me 8 figures instead of 10 you posted above. Which binary editor do you use?

Posted 06 October 2013 - 08:56 PM

Mieze

Giant Cat

Developers

1,238 posts

Gender:Female

Location:Germany

Interests:Cats

Thanks, I thought that these are the files to edit. But the next problem is that I don't find the strings. Either with hexfind nor with hexedit. They only show me 8 figures instead of 10 you posted above. Which binary editor do you use?

I use 0xED but any other hex editor should work too. By the way, which version of the driver do you try to patch?

Posted 07 October 2013 - 10:54 PM

Do you have any news? I think your above mentioned describtion is not compatible with the 10.8.5 kext. See my post above.

The patch has been confirmed to work with 10.8.3. Before I stated that it should work with 10.8.5 too I only check the version of the kext. Maybe they have changed something without increasing the version number. I will disassemble the 10.8.5 kext from my iMac in order to verify my instructions. In case I find something new I will post an update.

Posted 07 October 2013 - 11:45 PM

Mieze

Giant Cat

Developers

1,238 posts

Gender:Female

Location:Germany

Interests:Cats

I'm sorry but I have to correct one of my former posts. It's true that Apple changed the Broadcom driver in 10.8.5, at least they included a new build which requires new patch instructions. Therefore you'll have to follow these instructions in order to patch 10.8.5's Broadcom driver:

Posted 08 October 2013 - 04:12 AM

Col. Steve Austin

InsanelyMac Protégé

Members

7 posts

Gender:Male

Hi Mieze, I have a BCM57781 on my Asrock 77E-ITX which worked fine with 10.8. I had already gathered that the locations would be different for 10.8.5 & I'm using 0xED too. your correction above is actually identical to the original patch since in both cases, it's the middle 5 bytes that are being replaced with (mov $0x14e4,%eax) and (mov $0x16b4,%eax) twice, is that right? Anyway applying the patch to info.plist + AppleBCM5701Ethernet binary of a virgin 10.8.5 IONetworkingFamily.kext still refuses to work. in fact it's not even recognised in SystemInfo which is strange. I have triple checked the files with 0xED and both addresses and contents match your last post. Is there anything else that needs to be done?

Posted 08 October 2013 - 04:27 AM

Mieze

Giant Cat

Developers

1,238 posts

Gender:Female

Location:Germany

Interests:Cats

Hi Mieze, I have a BCM57781 on my Asrock 77E-ITX which worked fine with 10.8. I had already gathered that the locations would be different for 10.8.5 & I'm using 0xED too. your correction above is actually identical to the original patch since in both cases, it's the middle 5 bytes that are being replaced with (mov $0x14e4,%eax) and (mov $0x16b4,%eax) twice, is that right? Anyway applying the patch to info.plist + AppleBCM5701Ethernet binary of a virgin 10.8.5 IONetworkingFamily.kext still refuses to work. in fact it's not even recognised in SystemInfo which is strange. I have triple checked the files with 0xED and both addresses and contents match your last post. Is there anything else that needs to be done?

Thanks for your help

Serge

If the kext doesn't load at all the Info.plist is not correct. Use "kextstat" in Terminal to verify it has been loaded. If it loads but refuses to work you'll find the reason why in your kernel logs.

Posted 08 October 2013 - 02:29 PM

Col. Steve Austin

InsanelyMac Protégé

Members

7 posts

Gender:Male

Thanks for the quick reply. I had switch to the old non functioning 10.8 version (169.254.xxx.xxx) which at least loads.

kextstat | grep BCM

confirmed it, so I switched back to the 10.8.5 patched version and the same command shows that it's not loaded. I edited a new info.plist using nano this time. still not loading. I'm at a loss as to why??

I've attached a patched copy, if it's ok. I'd appreciate if you could have a look, to check that I'm not going blind or crazy.

Attached Files

Posted 08 October 2013 - 03:01 PM

Thanks for the quick reply. I had switch to the old non functioning 10.8 version (169.254.xxx.xxx) which at least loads.

kextstat | grep BCM

confirmed it, so I switched back to the 10.8.5 patched version and the same command shows that it's not loaded. I edited a new info.plist using nano this time. still not loading. I'm at a loss as to why??

I've attached a patched copy, if it's ok. I'd appreciate if you could have a look, to check that I'm not going blind or crazy.