Skip to content

Commit c47e21d

Browse files
committed
Add Wifi card upgrade detection
Closes #70 Closes #62 Closes #55
1 parent 83df3e3 commit c47e21d

File tree

3 files changed

+44
-35
lines changed

3 files changed

+44
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- WhateverGreen 2e19d1b(1.4.8 release)
1010
- Rework SMBIOS allowing both original and custom serials(Should resolve all iMessage issues)
1111
- Support upgraded GPU detection in iMac10,x-12,x
12+
- Add Wifi card upgrade detection
1213

1314
## 0.0.10
1415
- Increment binaries

Resources/ModelArray.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,19 +743,17 @@
743743
"0x1392",#GTX 860M
744744
"0x1199",#GTX 870M
745745
"0x11a9",#GTX 870M
746-
"0x731f",
747746
]
748747

749748
AMDMXMGPUs = [
750749
"0x67EF",#AMD RX 460
751750
"0x67e8",#AMD WX 4130/WX 4150
752751
"0x67e0",#AMD WX 4170
753752
"0x67c0",#AMD WX 7100
754-
"0x731f",
755753
]
756754

757755
nativeWifi = [
758-
"0x43ba",#BCM43602
759-
"0x43a3",#BCM4350
760-
"0x43a0",#BCM4360
756+
"ba430000",#BCM43602
757+
"a3430000",#BCM4350
758+
"a0430000",#BCM4360
761759
]

Resources/build.py

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ def __init__(self, model, versions):
3434
self.config = None
3535
self.constants: Constants.Constants = versions
3636

37+
def hexswap(self, input_hex: str):
38+
hex_pairs = [input_hex[i:i + 2] for i in range(0, len(input_hex), 2)]
39+
hex_rev = hex_pairs[::-1]
40+
hex_str = "".join(["".join(x) for x in hex_rev])
41+
return hex_str.upper()
42+
3743
def build_efi(self):
3844
utilities.cls()
3945
if not Path(self.constants.build_path).exists():
@@ -87,30 +93,36 @@ def build_efi(self):
8793

8894
# WiFi patches
8995

90-
if self.model in ModelArray.WifiAtheros:
91-
self.enable_kext("IO80211HighSierra.kext", self.constants.io80211high_sierra_version, self.constants.io80211high_sierra_path)
92-
self.get_kext_by_bundle_path("IO80211HighSierra.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
93-
94-
if self.model in ModelArray.WifiBCM94331:
95-
self.enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
96-
self.get_kext_by_bundle_path("AirportBrcmFixup.kext/Contents/PlugIns/AirPortBrcmNIC_Injector.kext")["Enabled"] = True
97-
98-
if self.model in ModelArray.EthernetNvidia:
99-
# Nvidia chipsets all have the same path to ARPT
100-
property_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
101-
if self.model in ("MacBookAir2,1", "MacBookAir3,1", "MacBookAir3,2"):
102-
property_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
103-
elif self.model in ("iMac7,1", "iMac8,1"):
104-
property_path = "PciRoot(0x0)/Pci(0x1C,0x4)/Pci(0x0,0x0)"
105-
elif self.model in ("iMac13,1", "iMac13,2"):
106-
property_path = "PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0)"
107-
elif self.model == "MacPro5,1":
108-
property_path = "PciRoot(0x0)/Pci(0x1C,0x5)/Pci(0x0,0x0)"
109-
else:
110-
# Assumes we have a laptop with Intel chipset
111-
property_path = "PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0)"
112-
print("- Applying fake ID for WiFi")
113-
self.config["DeviceProperties"]["Add"][property_path] = {"device-id": binascii.unhexlify("ba430000"), "compatible": "pci14e4,43ba"}
96+
wifi_devices = plistlib.loads(subprocess.run(f"ioreg -c IOPCIDevice -r -d2 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
97+
wifi_devices = [i for i in wifi_devices if i["vendor-id"] == binascii.unhexlify("E4140000") and i["class-code"] == binascii.unhexlify("00800200")]
98+
wifi_devices = wifi_devices[0]
99+
if (self.constants.custom_model) == "None" & (self.hexswap(binascii.hexlify(wifi_devices["vendor-id"]).decode()[:4]) in ModelArray.nativeWifi):
100+
print("- Skipping wifi patches")
101+
else:
102+
if self.model in ModelArray.WifiAtheros:
103+
self.enable_kext("IO80211HighSierra.kext", self.constants.io80211high_sierra_version, self.constants.io80211high_sierra_path)
104+
self.get_kext_by_bundle_path("IO80211HighSierra.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
105+
106+
if self.model in ModelArray.WifiBCM94331:
107+
self.enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
108+
self.get_kext_by_bundle_path("AirportBrcmFixup.kext/Contents/PlugIns/AirPortBrcmNIC_Injector.kext")["Enabled"] = True
109+
110+
if self.model in ModelArray.EthernetNvidia:
111+
# Nvidia chipsets all have the same path to ARPT
112+
property_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
113+
if self.model in ("MacBookAir2,1", "MacBookAir3,1", "MacBookAir3,2"):
114+
property_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
115+
elif self.model in ("iMac7,1", "iMac8,1"):
116+
property_path = "PciRoot(0x0)/Pci(0x1C,0x4)/Pci(0x0,0x0)"
117+
elif self.model in ("iMac13,1", "iMac13,2"):
118+
property_path = "PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0)"
119+
elif self.model == "MacPro5,1":
120+
property_path = "PciRoot(0x0)/Pci(0x1C,0x5)/Pci(0x0,0x0)"
121+
else:
122+
# Assumes we have a laptop with Intel chipset
123+
property_path = "PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0)"
124+
print("- Applying fake ID for WiFi")
125+
self.config["DeviceProperties"]["Add"][property_path] = {"device-id": binascii.unhexlify("ba430000"), "compatible": "pci14e4,43ba"}
114126

115127
# HID patches
116128
if self.model in ModelArray.LegacyHID:
@@ -139,12 +151,10 @@ def build_efi(self):
139151
self.config["NVRAM"]["Add"]["4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14"]["UIScale"] = binascii.unhexlify("02")
140152

141153
# Check GPU Vendor
142-
if self.constants.custom_model != "None":
143-
#current_gpu: str = subprocess.run("system_profiler SPDisplaysDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
144-
#current_gpuv = [line.strip().split(": ", 1)[1] for line in current_gpu.split("\n") if line.strip().startswith(("Vendor"))][0]
145-
#current_gpud = [line.strip().split(": ", 1)[1] for line in current_gpu.split("\n") if line.strip().startswith(("Device ID"))][0]
146-
current_gpuv = "NVIDIA (0x10de)"
147-
current_gpud = "0x11a9"
154+
if self.constants.custom_model == "None":
155+
current_gpu: str = subprocess.run("system_profiler SPDisplaysDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
156+
current_gpuv = [line.strip().split(": ", 1)[1] for line in current_gpu.split("\n") if line.strip().startswith(("Vendor"))][0]
157+
current_gpud = [line.strip().split(": ", 1)[1] for line in current_gpu.split("\n") if line.strip().startswith(("Device ID"))][0]
148158
print(f"- Detected GPU: {current_gpuv} {current_gpud}")
149159
if (current_gpuv == "AMD (0x1002)") & (current_gpud in ModelArray.AMDMXMGPUs):
150160
self.constants.custom_mxm_gpu = True

0 commit comments

Comments
 (0)