stevezhengshiqi / one-key-cpufriend

Generate customized CPUFriendDataProvider.kext for dynamic macOS CPU power management
342 stars 47 forks source link

[REQUEST] add support for MacBookPro15,2 (Mac-827FB448E656EC26) #18

Closed LeeBinder closed 4 years ago

LeeBinder commented 4 years ago

Your board-id is Mac-827FB448E656EC26>

[ ERROR ]: Sorry, your board-id has not been supported yet!

just in case you feel like it, Steve :)

[EDIT]: this might help: https://github.com/daliansky/XiaoMi-Pro-Hackintosh/blob/master/one-key-cpufriend/one-key-cpufriend.sh

stevezhengshiqi commented 4 years ago

@LeeBinder Hi, it seems that the L10 doesn't return correct board-id in your case. It should return Mac-827FB448E656EC26, not Mac-827FB448E656EC26>, which causes the issue.

MBP15,2 is supported in the script. Please make sure the script is not corrupted, or try the command below to check the board-id is valid or not:

ioreg -lw0 | grep -i "board-id" | sed -e '/[^<]*</s///; s/\"//g; s/\>//'
LeeBinder commented 4 years ago

Great, thanks for the hints - here's my conclusive results:

In Mojave and Catalina, the ioreg-command correctly produces Mac-827FB448E656EC26 In High Sierra (which I need to boot for testing every once in a while) it produces Mac-827FB448E656EC26>

I looked at Clover config.plist in a text and code editor - the line is correct, no duplicate >: <string>Mac-827FB448E656EC26</string>

Next I booted into High Sierra with other mac models set via Clover Configurator - same thing, always trailing >. So it's not an issue with this particular mac model but with High Sierra.

Output in Hardware Overview is fine:

click to expand ``` Model Name: MacBook Pro Model Identifier: MacBookPro15,2 Processor Name: Intel Core i5 Processor Speed: 1,6 GHz Number of Processors: 1 Total Number of Cores:4 L2 Cache (per Core): 256 KB L3 Cache: 6 MB Memory: 8 GB Boot ROM Version: 1037.80.41.0.0 Apple ROM Info: Apple ROM Version. BIOS ID: MBP152.88Z.F000.B00.1911080134 Board-ID: Mac-827FB448E656EC26 ⌘ Powered by Clover v2.5k 5104 SMC Version (system): 1.74f4 ```

Also when I only run ioreg -lw0 | grep -i "board-id"the output format is as expected: | "board-id" = <"Mac-827FB448E656EC26">

The solution was to add an extra > into the ioreg command: ioreg -lw0 | grep -i "board-id" | sed -e '/[^<]*</s///; s/\"//g; s/\>>//'

resulting in correct output Mac-827FB448E656EC26 in High Sierra, and your script continuing and producing appropriate kexts.

However, this only works in High Sierrra. When I run the script with an extra > in Mojave & Catalina, the resulting board-ID string is Mac-827FB448E656EC26>.

In other words, the script would either need a function with an algorithm like

if macOS-version <=10.13 then
    BOARD_ID="$(ioreg -lw0 | grep -i "board-id" | sed -e '/[^<]*</s///; s/\"//g; s/\>>//')"
    else
        BOARD_ID="$(ioreg -lw0 | grep -i "board-id" | sed -e '/[^<]*</s///; s/\"//g; s/\>//')"
fi

Daliansky has already implemented a remotely similar function in his mod of your script:

click to expand ``` # default board-id BOARD_ID="Mac-53FDB3D8DB8CA971" # MacBookPro15,4 # Check board-id, only system version >=10.14.6(18G87)(?) supports Mac-53FDB3D8DB8CA971.plist(MBP15,4) function checkPlist() { if [[ ! -f "${X86_PLIST}" ]]; then # Use MBP15,2's plist if no Mac-53FDB3D8DB8CA971.plist BOARD_ID="Mac-827FB448E656EC26" # MacBookPro15,2 X86_PLIST="/System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/X86PlatformPlugin.kext/Contents/Resources/${BOARD_ID}.plist" # check board-id, only system version >=10.13.6(17G2112) supports Mac-827FB448E656EC26.plist(MBP15,2) if [[ ! -f "${X86_PLIST}" ]]; then # Use MBP14,1's plist if no Mac-827FB448E656EC26.plist BOARD_ID="Mac-B4831CEBD52A0C4C" # MacBookPro14,1 X86_PLIST="/System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/X86PlatformPlugin.kext/Contents/Resources/${BOARD_ID}.plist" fi fi } ```

which could be modified and used, too (it's just not a real check for version of macOS).

Or, the other approach would be to make the ioreg function which breaks the string down to the mere board-ID compatible with High Sierra, too.

Any which way, from here on it's a downhill ride :)

LeeBinder commented 4 years ago

Here you go:

detect macOS version - click to expand ``` product_version=$(sw_vers -productVersion) os_vers=( ${product_version//./ } ) #os_vers_major="${os_vers[0]}" os_vers_minor="${os_vers[1]}" #os_vers_patch="${os_vers[2]}" #os_vers_build=$(sw_vers -buildVersion) # Sample output #echo "${os_vers_major}.${os_vers_minor}.${os_vers_patch}+${os_vers_build}" #echo # set board-id according to macOS version if (($os_vers_minor <= 13)) ; then echo "macOS 10.13 or below detected." # Current board-id BOARD_ID="$(ioreg -lw0 | grep -i "board-id" | sed -e '/[^<]*>//')" else echo "macOS 10.14 or higher detected." # Current board-id BOARD_ID="$(ioreg -lw0 | grep -i "board-id" | sed -e '/[^<]*//')" fi echo ```

:)

stevezhengshiqi commented 4 years ago

Thank you for your efforts! The code looks good to me. What about this one, maybe we don't need macOS version detection

ioreg -lw0 | grep -i "board-id" | sed -e '/[^<]*</s///; s/\"//g; s/\>//; s/\>//'
LeeBinder commented 4 years ago

no, same thing in 10.13.6, Mac-827FB448E656EC26> :( ..

but ioreg -lw0 | grep -i "board-id" | sed -e '/[^<]*</s///; s/\"//g; s/\>//; s/\>>//'

produces the correct output without trailing >. Haven't tested in macOS >= 10.14 yet, though.

stevezhengshiqi commented 4 years ago

Great. ioreg -lw0 | grep -i "board-id" | sed -e '/[^<]*</s///; s/\"//g; s/\>//; s/\>>//' works for me in 10.15. I will commit this change, and thank you for your help.

LeeBinder commented 4 years ago

SUCCESS! ioreg -lw0 | grep -i "board-id" | sed -e '/[^<]*</s///; s/\"//g; s/\>//; s/\>>//'

produces the correct output without trailing > in 10.13 AND 10.14! Haven't tested in macOS 10.15 yet, though.

LeeBinder commented 4 years ago

oh, trans-posting LOL. Great, you're welcome, and thanks to you for this neat and helpful script!