Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Apple Silicon #137

Merged
merged 7 commits into from
Dec 3, 2022
Merged

Conversation

RaafatAkkad
Copy link
Contributor

@RaafatAkkad RaafatAkkad commented Apr 5, 2022

closes #126 Add support for Apple Silicon
-Updated classes to read correct Apple Silicon CPU sensor
-On Apple Silicon set the fan to Auto before sleeping. systemDidWakeFromSleep will set the previous selection on wake
-Updated the project to compile a Universal 2 binary. Upgraded Sparkle to 2.1.0 as that was the latest and supports ARM64.
-Add MacBookPro18,1 to Machines.plist

This has only been tested on a Macbook Pro 16" M1 Pro. Please test that this still works on Intel.

It's also worth merging #133 as that allows printing of temperatures using smc -t. It's not required for the Mac MenuBar app to function which is why I haven't cherry-picked that commit.

Known Issues:
-[FIXED] When a user sets the fan speed, the fans remain on when the Macbook is put to sleep. I'm unsure if this is Mac ARM specific.
-[FIXED] Use IOHID private API for MacBook Pro M1 as SMC is unavailable.

Note: XCode warns that Sparkle wasn't built for MacOS 10.7, but I have left the MACOSX_DEPLOYMENT_TARGET unchanged to maintain backwards compatibility.
Dylib (./Sparkle.framework/Sparkle) was built for newer macOS version (10.13) than being linked (10.7)

I also noticed these Sparkle errors. Given that https://www.eidac.de/smcfancontrol/smcfancontrol.xml is down, these can be addressed at a later date.

2022-04-05 20:44:07.214425+0100 smcFanControl[41957:179479] [Sparkle] Error: Serving updates without an EdDSA key and only using Apple Code Signing is deprecated and may be unsupported in a future release. Visit Sparkle's documentation for more information: https://sparkle-project.org/documentation/#3-segue-for-security-concerns 2022-04-05 20:44:07.388922+0100 smcFanControl[41957:179479] Metal API Validation Enabled 2022-04-05 20:44:09.937719+0100 smcFanControl[41957:180407] [boringssl] boringssl_context_handle_fatal_alert(1967) [C1.1:2][0x1226438a0] write alert, level: fatal, description: protocol version 2022-04-05 20:44:09.938141+0100 smcFanControl[41957:180407] [boringssl] boringssl_context_error_print(1957) [C1.1:2][0x1226438a0] Error: 4651506696:error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER:/AppleInternal/Library/BuildRoots/66382bca-8bca-11ec-aade-6613bcf0e2ee/Library/Caches/com.apple.xbs/Sources/boringssl/ssl/tls_record.cc:242: 2022-04-05 20:44:09.942152+0100 smcFanControl[41957:180407] [boringssl] boringssl_session_handshake_incomplete(86) [C1.1:2][0x1226438a0] SSL library error 2022-04-05 20:44:09.942268+0100 smcFanControl[41957:180407] [boringssl] boringssl_session_handshake_error_print(41) [C1.1:2][0x1226438a0] Error: 4651506696:error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER:/AppleInternal/Library/BuildRoots/66382bca-8bca-11ec-aade-6613bcf0e2ee/Library/Caches/com.apple.xbs/Sources/boringssl/ssl/tls_record.cc:242: 2022-04-05 20:44:09.942324+0100 smcFanControl[41957:180407] [boringssl] nw_protocol_boringssl_handshake_negotiate_proceed(757) [C1.1:2][0x1226438a0] handshake failed at state 12288: not completed 2022-04-05 20:44:09.943019+0100 smcFanControl[41957:180407] Connection 1: received failure notification 2022-04-05 20:44:09.943151+0100 smcFanControl[41957:180407] Connection 1: failed to connect 3:-9836, reason -1 2022-04-05 20:44:09.943298+0100 smcFanControl[41957:180407] Connection 1: encountered error(3:-9836) 2022-04-05 20:44:09.944149+0100 smcFanControl[41957:180407] Task <009ABA47-B061-4115-A235-4815B7427E43>.<1> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9836]) 2022-04-05 20:44:09.946416+0100 smcFanControl[41957:180443] Task <009ABA47-B061-4115-A235-4815B7427E43>.<1> finished with error [-1200] Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSErrorFailingURLStringKey=https://www.eidac.de/smcfancontrol/smcfancontrol.xml, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <009ABA47-B061-4115-A235-4815B7427E43>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDownloadTask <009ABA47-B061-4115-A235-4815B7427E43>.<1>" ), NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://www.eidac.de/smcfancontrol/smcfancontrol.xml, NSUnderlyingError=0x60000155a400 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9836, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9836, _NSURLErrorNWPathKey=satisfied (Path is satisfied), viable, interface: en0, ipv4, dns}}, _kCFStreamErrorCodeKey=-9836} 2022-04-05 20:44:09.947148+0100 smcFanControl[41957:179479] [Sparkle] Encountered download feed error: Error Domain=SUSparkleErrorDomain Code=2001 "An error occurred while downloading the update. Please try again later." UserInfo={NSErrorFailingURLKey=https://www.eidac.de/smcfancontrol/smcfancontrol.xml, NSLocalizedDescription=An error occurred while downloading the update. Please try again later., NSUnderlyingError=0x60000155bae0 {Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSErrorFailingURLStringKey=https://www.eidac.de/smcfancontrol/smcfancontrol.xml, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <009ABA47-B061-4115-A235-4815B7427E43>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDownloadTask <009ABA47-B061-4115-A235-4815B7427E43>.<1>" ), NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://www.eidac.de/smcfancontrol/smcfancontrol.xml, NSUnderlyingError=0x60000155a400 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9836, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9836, _NSURLErrorNWPathKey=satisfied (Path is satisfied), viable, interface: en0, ipv4, dns}}, _kCFStreamErrorCodeKey=-9836}}} 2022-04-05 20:44:09.947566+0100 smcFanControl[41957:179479] [Sparkle] Error: An error occurred in retrieving update information. Please try again later. (null) (URL (null)) 2022-04-05 20:44:09.947605+0100 smcFanControl[41957:179479] [Sparkle] Error: An error occurred while downloading the update. Please try again later. (null) (URL https://www.eidac.de/smcfancontrol/smcfancontrol.xml) 2022-04-05 20:44:09.947633+0100 smcFanControl[41957:179479] [Sparkle] Error: An SSL error has occurred and a secure connection to the server cannot be made. (null) (URL https://www.eidac.de/smcfancontrol/smcfancontrol.xml) 2022-04-05 20:44:09.949028+0100 smcFanControl[41957:179479] [Sparkle] Error: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1200.) (null) (URL (null))

-Update classes to read correct Apple Silicon CPU sensor
-Update project to compile a Universal 2 binary. Upgraded Sparkle to 2.1.0 as that was the latest and supports ARM64.
-Add MacBookPro18,1 to Machines.plist
@RaafatAkkad RaafatAkkad marked this pull request as draft April 6, 2022 22:22
…omSleep will set the previous selection on wake
@RaafatAkkad RaafatAkkad marked this pull request as ready for review April 7, 2022 22:26
@J-charles-C
Copy link

I,

can you compile a test version on your fork ?

best

@georgedimac
Copy link

georgedimac commented Oct 13, 2022

i am interested in this also, i did a Fork and will try to update. what is notice in my Monterey M1 MacBookPro17,1 13" 2020 is that it does not read well the max-speed , so the slider for speed has random values like 5 digits or so, and if i enter let's say 2000 it says it's not good value.

I think it's not reading good data from SMC.
output:
2022-10-17 19:09:00.619441+0300 smcFanControl[57321:1166066] Unknown val: size-0
2022-10-17 19:09:00.619713+0300 smcFanControl[57321:1166066] Unknown val: size-0

on ./smc -f it gets ok:
Total fans in system: 1

Fan #0:
Current speed : 0
Minimum speed: 1199
Maximum speed: 7199
Safe speed : 0
Target speed : 0
Mode : auto

also the Temperature does not read at all from SMC.
found some info for the M1 temp sensors here

[2022-10-17 19:47:50:196] [thread 1194274] [TempSensorProvider.cpp#68] TemperatureSensorProvider::loadAvailableSensors
[2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: ANE MTR Temp Sensor1
[2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: GPU MTR Temp Sensor1
[2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: GPU MTR Temp Sensor4
[2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: ISP MTR Temp Sensor5
[2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: NAND CH0 temp
[2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMGR SOC Die Temp Sensor0
[2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMGR SOC Die Temp Sensor1
[2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMGR SOC Die Temp Sensor2
[2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU TP3w
[2022-10-17 19:47:50:203] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tcal
[2022-10-17 19:47:50:204] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev1
[2022-10-17 19:47:50:206] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev2
[2022-10-17 19:47:50:207] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev3
[2022-10-17 19:47:50:209] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev4
[2022-10-17 19:47:50:210] [thread 1194274] [TempSensorIOKit.mm#152] Skipped incorrect temperature [-21.8641]
[2022-10-17 19:47:50:210] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev5
[2022-10-17 19:47:50:212] [thread 1194274] [TempSensorIOKit.mm#152] Skipped incorrect temperature [-21.9086]
[2022-10-17 19:47:50:212] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev6
[2022-10-17 19:47:50:213] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev7
[2022-10-17 19:47:50:215] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev8
[2022-10-17 19:47:50:217] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie1
[2022-10-17 19:47:50:217] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie2
[2022-10-17 19:47:50:218] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie4
[2022-10-17 19:47:50:219] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie5
[2022-10-17 19:47:50:219] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie6
[2022-10-17 19:47:50:220] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie7
[2022-10-17 19:47:50:221] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie8
[2022-10-17 19:47:50:222] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR0Z
[2022-10-17 19:47:50:222] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR1d
[2022-10-17 19:47:50:224] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR1l
[2022-10-17 19:47:50:226] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR2d
[2022-10-17 19:47:50:227] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR2l
[2022-10-17 19:47:50:228] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR3b
[2022-10-17 19:47:50:229] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR3d
[2022-10-17 19:47:50:230] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR4b
[2022-10-17 19:47:50:231] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR4d
[2022-10-17 19:47:50:232] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR5b
[2022-10-17 19:47:50:233] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR5d
[2022-10-17 19:47:50:234] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR6b
[2022-10-17 19:47:50:236] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR7b
[2022-10-17 19:47:50:237] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR8b
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: SOC MTR Temp Sensor0
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: SOC MTR Temp Sensor1
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: SOC MTR Temp Sensor2
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: eACC MTR Temp Sensor0
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: eACC MTR Temp Sensor3
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: gas gauge battery
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor2
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor3
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor4
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor5
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor7
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor8
[2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor9
[2022-10-17 19:47:50:239] [thread 1194274] [Service.cpp#62] getSMCKeysCount: 117833728 1543
[2022-10-17 19:47:50:244] [thread 1194274] [Service.cpp#564] Locating temperature SMC keys
[2022-10-17 19:47:50:290] [thread 1194274] [Service.cpp#610] 142 keys found
[2022-10-17 19:47:50:293] [thread 1194274] [Provider_mac_arm.mm#46] addGPU Apple M1
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using GPU MTR Temp Sensor1 sensor for GPU Proximity
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using GPU MTR Temp Sensor4 sensor for GPU Proximity
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMGR SOC Die Temp Sensor0 sensor for Power Manager SOC Die Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMGR SOC Die Temp Sensor1 sensor for Power Manager SOC Die Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMGR SOC Die Temp Sensor2 sensor for Power Manager SOC Die Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie1 sensor for Power Manager Die Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie2 sensor for Power Manager Die Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie4 sensor for Power Manager Die Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie5 sensor for Power Manager Die Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie6 sensor for Power Manager Die Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie7 sensor for Power Manager Die Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie8 sensor for Power Manager Die Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using eACC MTR Temp Sensor0 sensor for CPU Efficiency Cores Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using eACC MTR Temp Sensor3 sensor for CPU Efficiency Cores Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor2 sensor for CPU Performance Cores Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor3 sensor for CPU Performance Cores Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor4 sensor for CPU Performance Cores Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor5 sensor for CPU Performance Cores Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor7 sensor for CPU Performance Cores Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor8 sensor for CPU Performance Cores Average
[2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor9 sensor for CPU Performance Cores Average

@RaafatAkkad
Copy link
Contributor Author

i am interested in this also, i did a Fork and will try to update. what is notice in my Monterey M1 MacBookPro17,1 13" 2020 is that it does not read well the max-speed , so the slider for speed has random values like 5 digits or so, and if i enter let's say 2000 it says it's not good value.

I think it's not reading good data from SMC. output: 2022-10-17 19:09:00.619441+0300 smcFanControl[57321:1166066] Unknown val: size-0 2022-10-17 19:09:00.619713+0300 smcFanControl[57321:1166066] Unknown val: size-0

on ./smc -f it gets ok: Total fans in system: 1

Fan #0: Current speed : 0 Minimum speed: 1199 Maximum speed: 7199 Safe speed : 0 Target speed : 0 Mode : auto

also the Temperature does not read at all from SMC. found some info for the M1 temp sensors here

[2022-10-17 19:47:50:196] [thread 1194274] [TempSensorProvider.cpp#68] TemperatureSensorProvider::loadAvailableSensors [2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: ANE MTR Temp Sensor1 [2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: GPU MTR Temp Sensor1 [2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: GPU MTR Temp Sensor4 [2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: ISP MTR Temp Sensor5 [2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: NAND CH0 temp [2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMGR SOC Die Temp Sensor0 [2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMGR SOC Die Temp Sensor1 [2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMGR SOC Die Temp Sensor2 [2022-10-17 19:47:50:202] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU TP3w [2022-10-17 19:47:50:203] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tcal [2022-10-17 19:47:50:204] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev1 [2022-10-17 19:47:50:206] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev2 [2022-10-17 19:47:50:207] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev3 [2022-10-17 19:47:50:209] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev4 [2022-10-17 19:47:50:210] [thread 1194274] [TempSensorIOKit.mm#152] Skipped incorrect temperature [-21.8641] [2022-10-17 19:47:50:210] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev5 [2022-10-17 19:47:50:212] [thread 1194274] [TempSensorIOKit.mm#152] Skipped incorrect temperature [-21.9086] [2022-10-17 19:47:50:212] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev6 [2022-10-17 19:47:50:213] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev7 [2022-10-17 19:47:50:215] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdev8 [2022-10-17 19:47:50:217] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie1 [2022-10-17 19:47:50:217] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie2 [2022-10-17 19:47:50:218] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie4 [2022-10-17 19:47:50:219] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie5 [2022-10-17 19:47:50:219] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie6 [2022-10-17 19:47:50:220] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie7 [2022-10-17 19:47:50:221] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU tdie8 [2022-10-17 19:47:50:222] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR0Z [2022-10-17 19:47:50:222] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR1d [2022-10-17 19:47:50:224] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR1l [2022-10-17 19:47:50:226] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR2d [2022-10-17 19:47:50:227] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR2l [2022-10-17 19:47:50:228] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR3b [2022-10-17 19:47:50:229] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR3d [2022-10-17 19:47:50:230] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR4b [2022-10-17 19:47:50:231] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR4d [2022-10-17 19:47:50:232] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR5b [2022-10-17 19:47:50:233] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR5d [2022-10-17 19:47:50:234] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR6b [2022-10-17 19:47:50:236] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR7b [2022-10-17 19:47:50:237] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: PMU2 TR8b [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: SOC MTR Temp Sensor0 [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: SOC MTR Temp Sensor1 [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: SOC MTR Temp Sensor2 [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: eACC MTR Temp Sensor0 [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: eACC MTR Temp Sensor3 [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: gas gauge battery [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor2 [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor3 [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor4 [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor5 [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor7 [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor8 [2022-10-17 19:47:50:238] [thread 1194274] [TempSensorIOKit.mm#127] IOKit sensor: pACC MTR Temp Sensor9 [2022-10-17 19:47:50:239] [thread 1194274] [Service.cpp#62] getSMCKeysCount: 117833728 1543 [2022-10-17 19:47:50:244] [thread 1194274] [Service.cpp#564] Locating temperature SMC keys [2022-10-17 19:47:50:290] [thread 1194274] [Service.cpp#610] 142 keys found [2022-10-17 19:47:50:293] [thread 1194274] [Provider_mac_arm.mm#46] addGPU Apple M1 [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using GPU MTR Temp Sensor1 sensor for GPU Proximity [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using GPU MTR Temp Sensor4 sensor for GPU Proximity [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMGR SOC Die Temp Sensor0 sensor for Power Manager SOC Die Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMGR SOC Die Temp Sensor1 sensor for Power Manager SOC Die Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMGR SOC Die Temp Sensor2 sensor for Power Manager SOC Die Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie1 sensor for Power Manager Die Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie2 sensor for Power Manager Die Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie4 sensor for Power Manager Die Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie5 sensor for Power Manager Die Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie6 sensor for Power Manager Die Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie7 sensor for Power Manager Die Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using PMU tdie8 sensor for Power Manager Die Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using eACC MTR Temp Sensor0 sensor for CPU Efficiency Cores Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using eACC MTR Temp Sensor3 sensor for CPU Efficiency Cores Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor2 sensor for CPU Performance Cores Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor3 sensor for CPU Performance Cores Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor4 sensor for CPU Performance Cores Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor5 sensor for CPU Performance Cores Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor7 sensor for CPU Performance Cores Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor8 sensor for CPU Performance Cores Average [2022-10-17 19:47:50:294] [thread 1194274] [TempSensorProvider.cpp#37] Using pACC MTR Temp Sensor9 sensor for CPU Performance Cores Average

@georgedimac Can you download https://crystalidea.com/macs-fan-control/download and check what the Maximum speed is?

The values look correct on my "MacBookPro18,1"

image

Screenshot 2022-12-01 at 9 01 26 pm

It might be worth changing the temperature sensor from 'Tp0D' to 'TCXC' to see if that helps.

diff --git a/Classes/FanControl.m b/Classes/FanControl.m
index cc2f715..e999bf1 100755
--- a/Classes/FanControl.m
+++ b/Classes/FanControl.m
@@ -150,7 +150,7 @@ NSUserDefaults *defaults;
                        @0, PREF_AC_SELECTION,
                        @0, PREF_CHARGING_SELECTION,
                        @0, PREF_MENU_DISPLAYMODE,
-                       [MachineDefaults isAppleSilicon] ? @"Tp0D" : @"TC0D", PREF_TEMPERATURE_SENSOR,
+                       [MachineDefaults isAppleSilicon] ? @"TCXC" : @"TC0D", PREF_TEMPERATURE_SENSOR,
             @0, PREF_NUMBEROF_LAUNCHES,
             @NO,PREF_DONATIONMESSAGE_DISPLAY,
                        [NSArchiver archivedDataWithRootObject:[NSColor blackColor]],PREF_MENU_TEXTCOLOR,
diff --git a/Classes/smcWrapper.m b/Classes/smcWrapper.m
index 4f4573f..83320d3 100755
--- a/Classes/smcWrapper.m
+++ b/Classes/smcWrapper.m
@@ -71,7 +71,7 @@ NSArray *allSensors;
     SMCReadKey2((char*)[sensor UTF8String], &val,conn);
     retValue = [self convertToNumber:val];
     if ([MachineDefaults isAppleSilicon]) {
-        allSensors = [NSArray arrayWithObjects:@"Tp0D",@"Tp0P",nil];
+        allSensors = [NSArray arrayWithObjects:@"TCXC",@"TCXc",nil];
     } else {
         allSensors = [NSArray arrayWithObjects:@"TC0D",@"TC0P",@"TCAD",@"TC0H",@"TC0F",@"TCAH",@"TCBH",nil];
     }

@RaafatAkkad
Copy link
Contributor Author

RaafatAkkad commented Dec 1, 2022

I,

can you compile a test version on your fork ?

best

Added to the PR description.

Update: Removed now that this is merged

@georgedimac
Copy link

georgedimac commented Dec 2, 2022

@georgedimac Can you download https://crystalidea.com/macs-fan-control/download and check what the Maximum speed is?

yes, that app gets the speed right 7199, the same as ./smc , but the smcFanControl does not get it right

look how are the values on mine:
Screenshot 2022-12-02 at 12 01 41
Screenshot 2022-12-02 at 12 01 34

It might be worth changing the temperature sensor from 'Tp0D' to 'TCXC' to see if that helps.

i tried but it doesn't work. as you can see from the previous post the sensors on M1 are different names.

the problem is described here : "Yeah, the issue is that the older code is using the SMC to get temperatures and M1 Macs don't have a SMC. They share the sensor layout with iOS devices for things like the CPU. This means you need to talk to IOKit to get the info."
Macs Fan Control that you mentioned and gets the values right is using IOKit.

@RaafatAkkad
Copy link
Contributor Author

@georgedimac It might be worth resetting the app. "Info & Support" -> "Reset..." as that will delete these 2 files which might have been generated using an older smcFanControl app?

~/Library/Preferences/com.eidac.smcFanControl2.plist
~/Library/Application\ Support/smcFanControl/Machines.plist

Interesting info regarding the temperature. I ran "smc -l" and found a sensor which roughly matches the 46 degree temperature that "Macs Fan Control" displayed

smc -l
  #KEY  [ui32]  1905 (bytes 00 00 07 71)
...
  Tp0D  [flt ]  46 (bytes 66 ba 38 42)

@georgedimac
Copy link

georgedimac commented Dec 2, 2022

thanks. the reset helped the Fan min_max value to read proper now.

as for the temp it still does not read it , if i do "./smc -t" , it shows blank . on "./smc -l" i don't have any Tp0D , maybe my machine (MacBookPro17,1 13" Pro 2020) is different.

i attach the output from apple_sensors

Screenshot 2022-12-02 at 13 12 53

yeah, it seems that on your 18,1 (16" m1 pro 2021) there are different sensor names, that's why it works with Tp0d on your case. on mine there isn't that sensor.

@RaafatAkkad
Copy link
Contributor Author

RaafatAkkad commented Dec 2, 2022

@georgedimac Nice one!

I've changed the code to use a private IOKIT API for the temperatures. Can you recompile and try it? The IOKIT Temperature readings seem about 10°C lower than https://crystalidea.com/macs-fan-control & https://github.com/exelban/stats.

The temperature is similar to https://github.com/macmade/Hot though.

Screenshot 2022-12-02 at 11 41 40 pm

@georgedimac
Copy link

georgedimac commented Dec 3, 2022

yes, but the implementation that you did averages around 20 sensors.

what i saw that other programs do is : calculate a 'SOC Die Average' using this 3 values/sensors: PMGR SOC Die Temp : 0,1,2 . I replaced in 'CFSTR("PMU"))' : PMU with PMGR and works perfect now.

thanks for your work.

@RaafatAkkad
Copy link
Contributor Author

@georgedimac Thanks! My "MacBookPro18,1" doesn't have "PMGR" sensors.

Sensor output:

gas gauge battery
NAND CH0 temp
PMU tcal
PMU tdev1
PMU tdev2
PMU tdev3
PMU tdev4
PMU tdev5
PMU tdev5 
PMU tdev6
PMU tdev7
PMU tdev8
PMU tdie0
PMU tdie1
PMU tdie10
PMU tdie2
PMU tdie3
PMU tdie4
PMU tdie5
PMU tdie6
PMU tdie7
PMU tdie8
PMU tdie9
PMU TP0s
PMU TP1g
PMU TP1s
PMU TP2g
PMU TP2s
PMU TP3g

@RaafatAkkad
Copy link
Contributor Author

RaafatAkkad commented Dec 3, 2022

@georgedimac Can you please confirm if the CPU temp reading from https://github.com/exelban/stats is correct for you? Thanks

Screenshot 2022-12-03 at 12 10 48 pm

Looking through the code the temperature is read from the smc
exelban/stats@8d64644

EDIT: I've updated the code to only use IOHID based on a whitelist. Can you please test that out? Thanks

@hholtmann hholtmann merged commit c065120 into hholtmann:master Dec 3, 2022
@georgedimac
Copy link

georgedimac commented Dec 4, 2022

@georgedimac Can you please confirm if the CPU temp reading from https://github.com/exelban/stats is correct for you? Thanks

Looking through the code the temperature is read from the smc exelban/stats@8d64644

EDIT: I've updated the code to only use IOHID based on a whitelist. Can you please test that out? Thanks

if you look in exelban README it says that for M1 (only) you have to enable IOHID to display them and that's only how it works on this M1, it also states that it consumes energy for polling HID i guess. So i think that for M1 to IOKIT is a better choice instead of SMC.

the implementantion was good like you did it in first place with IOKIT but with PMGR instead of PMU , and with selection on all M1 (mac mini,air,imac) i guess not only Pro. IOHID is not needed.

@RaafatAkkad
Copy link
Contributor Author

@georgedimac It's the same implementation. It's actually the IOHID api that is being called. For now, users will need to add these devices to the OHID whitelist.
A better approach would be to attempt to read the SMC keys and fallback to IOHID if they're not available (ARM only).

@RaafatAkkad
Copy link
Contributor Author

@hholtmann Thanks for merging. Do you have a release date planned for the next version of this app? Thanks

@hholtmann
Copy link
Owner

I will try to find some timer over the new year to test the app on Apple Silicon. Also I think there are some adjustments necessary to the UI for machines where the fan speed is forced (= no minimum fan speed can be set, when the fan is not active).

@iDevPro
Copy link

iDevPro commented Jul 2, 2023

Great work, thanks for this patches.

MacBookPro18,3 @ Sonoma
with change Deployment target to: $(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)
because can't build for 10.6, 10.7 with Xcode 15b2

The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.7, but the range of supported deployment target versions is 10.13 to 14.0.99.
...
ld: file not found: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a

Also this better than TGPro, because support fan speed control, not only off and go fast :)

@RaafatAkkad
Copy link
Contributor Author

RaafatAkkad commented Jul 5, 2023

Thanks @iDevPro
I also had to use $(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET) for it to build with Github Actions.
PR: #144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When would you support M1 Macs?
5 participants