exelban / stats

macOS system monitor in your menu bar
MIT License
26.4k stars 871 forks source link

No sensors - Apple Silicon #210

Closed ChasingDopamine closed 3 years ago

ChasingDopamine commented 4 years ago

Sensors not properly displaying. I originally got them to work on first install, but upon starting the system the following day the temperature sensors were no longer displaying.

What I've tried:

Information:

johnalanwoods commented 4 years ago

Same issue built from src with current head.

exelban commented 4 years ago

Hi. Thanks for opening the issue. This problem was described here. TL;DR: Computers with Apple Silicon has different sensors key that Intel based. And for now, there is no mapping of these keys.

@lucasaf04 nope. There are no relations between these issues.

thebitstick commented 3 years ago

I have access to the Sensei app which has a very rich list of sensors. image image image

Originally posted by @thebitstick in https://github.com/exelban/stats/issues/181#issuecomment-738955290

exelban commented 3 years ago

@thebitstick Hi. Thanks for the screenshots. This app just shows the keys, not sensor names. So it's not really helpful(

johnalanwoods commented 3 years ago

Can you clarify what "keys" and "names" are?

exelban commented 3 years ago

Yeap.

In the SMC there are only key-value pairs. So I can receive all possible keys + values presenting in the system. This list will contain sensors, some system specs, and some data (timestamp of last boot), etc. Key it's 4 chars. When the list is received I must filter it. To have the list with interesting key-value pairs. It's pretty easy. Because normally the first char shows the type of value. TC0D - means the temperature on the core. So I can filter only interesting pairs by first letter (T,V,P,A). After filtering I don't want to see the list of key values. I want to see the name of the sensor and its value. To do this, I need a dictionary. Which can translate the key to sensor name.

TL.DR: You could see an example of the key and name here.

johnalanwoods commented 3 years ago

@exelban OK that makes sense, so you need help mapping the key (TC0D), to the actual sensor name?

I wonder where other apps got their mapping, I guess I could try and reverse engineer in Ghidra.

exelban commented 3 years ago

Yes.

I don't see any app that has a dictionary for Apple Silicon (or maybe there is some, I don't have Apple Silicon). Unfortunately, it's not public information. If even some company has the dictionary for m1. They will not share. Because they it give them an advantage. I suppose the only one which can have the good dictionary it's iStat Menus.

Fun fact. There is no complete list even for intel based mac(

andreialecu commented 3 years ago

Perhaps this helps? https://github.com/fermion-star/apple_sensors

exelban commented 3 years ago

Thanks. It could be helpful. If I understand correctly, someone must run this tool on m1 and post the output.

lucasaf04 commented 3 years ago

~A bit weird output:~

./temp_sensor

PMU tdie7, PMU2 TR4b, PMU tdev4, PMU tdev7, PMU tdie5, PMU tdev1, gas gauge battery, NAND CH0 temp, PMU2 TR3d, PMU2 TR6b, gas gauge battery, PMU2 TR8b, PMU tdie8, PMU TP3w, PMU tdev5, PMU2 TR1l, gas gauge battery, PMU tdie1, PMU2 TR0Z, pACC MTR Temp Sensor4, PMU tdev8, PMU2 TR3b, PMU tdev2, PMU tdie4, SOC MTR Temp Sensor0, PMU tdie2, PMU tcal, gas gauge battery, PMU2 TR2d, pACC MTR Temp Sensor2, PMU2 TR5d, PMU2 TR5b, ANE MTR Temp Sensor1, eACC MTR Temp Sensor0, PMGR SOC Die Temp Sensor2, PMU2 TR4d, PMU tdev6, eACC MTR Temp Sensor3, GPU MTR Temp Sensor1, PMU2 TR7b, pACC MTR Temp Sensor9, PMU tdie6, SOC MTR Temp Sensor2, ISP MTR Temp Sensor5, PMGR SOC Die Temp Sensor1, PMU tdev3, PMGR SOC Die Temp Sensor0, gas gauge battery, pACC MTR Temp Sensor7, pACC MTR Temp Sensor8, SOC MTR Temp Sensor1, pACC MTR Temp Sensor3, PMU2 TR2l, pACC MTR Temp Sensor5, gas gauge battery, PMU2 TR1d, GPU MTR Temp Sensor4, 
33.1, 34.8, -21.4, 29.8, 33.4, 30.4, 27.9, 28.0, 29.7, 35.6, 27.9, 36.0, 32.7, 35.8, -21.5, 36.0, 27.9, 36.4, 51.9, 28.9, 31.1, 33.9, 29.6, 34.8, 27.3, 32.1, 51.9, 27.0, 29.8, 27.4, 28.8, 36.0, 30.0, 27.0, 27.9, 29.0, 30.1, 24.8, 30.0, 34.8, 29.0, 34.7, 30.7, 30.0, 28.0, 29.8, 28.0, 27.0, 28.9, 26.9, 26.5, 28.8, 35.9, 27.3, 27.7, 29.9, 30.0,

./temp_sensor | ./monitor

ANE MTR Temp Sensor1       | 30.0
GPU MTR Temp Sensor1       | 30.0
GPU MTR Temp Sensor4       | 30.0
ISP MTR Temp Sensor5       | 30.0
NAND CH0 temp              | 33.0
PMGR SOC Die Temp Sensor0  | 35.9
PMGR SOC Die Temp Sensor1  | 35.8
PMGR SOC Die Temp Sensor2  | 35.7
PMU TP3w                   | 43.5
PMU tcal                   | 51.9
PMU tdev1                  | 37.4
PMU tdev2                  | 37.2
PMU tdev3                  | 37.4
PMU tdev4                  | -21.4
PMU tdev5                  | -21.4
PMU tdev6                  | 36.3
PMU tdev7                  | 37.7
PMU tdev8                  | 39.1
PMU tdie1                  | 43.8
PMU tdie2                  | 39.5
PMU tdie4                  | 42.9
PMU tdie5                  | 42.3
PMU tdie6                  | 42.5
PMU tdie7                  | 43.1
PMU tdie8                  | 41.2
PMU2 TR0Z                  | 51.9
PMU2 TR1d                  | 37.1
PMU2 TR1l                  | 43.0
PMU2 TR2d                  | 36.1
PMU2 TR2l                  | 42.9
PMU2 TR3b                  | 41.7
PMU2 TR3d                  | 36.2
PMU2 TR4b                  | 42.4
PMU2 TR4d                  | 34.6
PMU2 TR5b                  | 42.9
PMU2 TR5d                  | 34.0
PMU2 TR6b                  | 42.1
PMU2 TR7b                  | 42.4
PMU2 TR8b                  | 42.4
SOC MTR Temp Sensor0       | 36.1
SOC MTR Temp Sensor1       | 34.1
SOC MTR Temp Sensor2       | 38.7
eACC MTR Temp Sensor0      | 35.5
eACC MTR Temp Sensor3      | 33.8
gas gauge battery          | 31.6
gas gauge battery          | 31.6
gas gauge battery          | 31.6
gas gauge battery          | 31.0
gas gauge battery          | 31.0
gas gauge battery          | 31.3
pACC MTR Temp Sensor2      | 35.7
pACC MTR Temp Sensor3      | 37.0
pACC MTR Temp Sensor4      | 36.6
pACC MTR Temp Sensor5      | 35.0
pACC MTR Temp Sensor7      | 36.5
pACC MTR Temp Sensor8      | 37.7
pACC MTR Temp Sensor9      | 37.7
exelban commented 3 years ago

Yeap, the output is a little bit strange. Also the keys are missing( But I see some sensors which could be added to the Stats. I will try to make a few changes to this temp_sensor app to show key - name.

andreialecu commented 3 years ago

Here's the output on my Mac Mini M1:

apple_sensors on  master [?] took 37s 
➜ ./temp_sensor | ./monitor
ANE MTR Temp Sensor1       | 30.0
GPU MTR Temp Sensor1       | 27.0
GPU MTR Temp Sensor4       | 27.6
ISP MTR Temp Sensor5       | 30.0
NAND CH0 temp              | 28.0
PMGR SOC Die Temp Sensor0  | 29.0
PMGR SOC Die Temp Sensor1  | 28.7
PMGR SOC Die Temp Sensor2  | 28.5
PMU TP3w                   | 37.1
PMU tcal                   | 51.9
PMU tdev1                  | 29.9
PMU tdev2                  | 30.3
PMU tdev3                  | 30.5
PMU tdev4                  | -21.5
PMU tdev5                  | -21.5
PMU tdev6                  | 29.5
PMU tdev7                  | 33.4
PMU tdev8                  | 31.3
PMU tdie1                  | 37.3
PMU tdie2                  | 34.3
PMU tdie4                  | 36.5
PMU tdie5                  | 36.2
PMU tdie6                  | 36.0
PMU tdie7                  | 35.9
PMU tdie8                  | 34.4
PMU2 TR0Z                  | 51.9
PMU2 TR1d                  | 31.2
PMU2 TR1l                  | 37.1
PMU2 TR2d                  | 29.2
PMU2 TR2l                  | 38.0
PMU2 TR3b                  | 36.8
PMU2 TR3d                  | 29.4
PMU2 TR4b                  | 37.4
PMU2 TR4d                  | 29.6
PMU2 TR5b                  | 37.8
PMU2 TR5d                  | 31.2
PMU2 TR6b                  | 37.0
PMU2 TR7b                  | 38.2
PMU2 TR8b                  | 36.8
SOC MTR Temp Sensor0       | 26.9
SOC MTR Temp Sensor1       | 28.0
SOC MTR Temp Sensor2       | 28.6
eACC MTR Temp Sensor0      | 27.0
eACC MTR Temp Sensor3      | 26.7
pACC MTR Temp Sensor2      | 30.8
pACC MTR Temp Sensor3      | 26.4
pACC MTR Temp Sensor4      | 27.1
pACC MTR Temp Sensor5      | 29.0
pACC MTR Temp Sensor7      | 27.7
pACC MTR Temp Sensor8      | 27.5
pACC MTR Temp Sensor9      | 26.6

@lucasaf04 I noticed that if you run it with a terminal window size that is not High enough, it can glitch, like your output. Make sure to resize the terminal and run it again and everything should line up.

lucasaf04 commented 3 years ago

@andreialecu Thanks, I have updated my comment.

andreialecu commented 3 years ago

I've been running https://www.tunabellysoftware.com/cpu_stress_test/ to see how the numbers change, and after a few minutes here are the results:

➜ ./temp_sensor | ./monitor
ANE MTR Temp Sensor1       | 30.0
GPU MTR Temp Sensor1       | 42.1
GPU MTR Temp Sensor4       | 45.9
ISP MTR Temp Sensor5       | 30.0
NAND CH0 temp              | 35.0
PMGR SOC Die Temp Sensor0  | 43.0
PMGR SOC Die Temp Sensor1  | 46.4
PMGR SOC Die Temp Sensor2  | 54.5
PMU TP3w                   | 57.9
PMU tcal                   | 51.9
PMU tdev1                  | 42.6
PMU tdev2                  | 51.8
PMU tdev3                  | 32.8
PMU tdev4                  | -21.7
PMU tdev5                  | -21.6
PMU tdev6                  | 31.7
PMU tdev7                  | 39.6
PMU tdev8                  | 48.6
PMU tdie1                  | 58.2
PMU tdie2                  | 66.6
PMU tdie4                  | 59.6
PMU tdie5                  | 63.5
PMU tdie6                  | 59.4
PMU tdie7                  | 65.1
PMU tdie8                  | 59.7
PMU2 TR0Z                  | 51.9
PMU2 TR1d                  | 34.7
PMU2 TR1l                  | 45.6
PMU2 TR2d                  | 30.7
PMU2 TR2l                  | 46.0
PMU2 TR3b                  | 44.7
PMU2 TR3d                  | 34.9
PMU2 TR4b                  | 45.6
PMU2 TR4d                  | 35.1
PMU2 TR5b                  | 44.8
PMU2 TR5d                  | 38.5
PMU2 TR6b                  | 45.6
PMU2 TR7b                  | 45.7
PMU2 TR8b                  | 44.7
SOC MTR Temp Sensor0       | 42.3
SOC MTR Temp Sensor1       | 47.3
SOC MTR Temp Sensor2       | 55.2
eACC MTR Temp Sensor0      | 49.5
eACC MTR Temp Sensor3      | 46.2
pACC MTR Temp Sensor2      | 67.5
pACC MTR Temp Sensor3      | 71.5
pACC MTR Temp Sensor4      | 67.3
pACC MTR Temp Sensor5      | 56.2
pACC MTR Temp Sensor7      | 64.8
pACC MTR Temp Sensor8      | 64.1
pACC MTR Temp Sensor9      | 61.1

Seems like most of the impact is on the PMU tdie* (perhaps temp for each core?) and pACC MTR Temp Sensor* values.

exelban commented 3 years ago

There is one big problem for me with this output. There are no SMC keys( Only a few of them TRxb.

andreialecu commented 3 years ago

@exelban I'm not sure if I'm understanding exactly how this works. But from what I can tell Apple Silicon does not use (?) SMC for these, but you need to use the HID apis instead.

Based on the output above I think that eACC MTR Temp Sensor* is the temperature of the efficiency cores, and pACC MTR Temp Sensor* is for the performance cores. It seems to correlate with what other apps that display temperatures show.

exelban commented 3 years ago

What do you mean Apple Silicon does not use SMC?

andreialecu commented 3 years ago

Not sure if this is relevant, but the repo above mentions running ioreg -lfx. I'm attaching the output that seems related to sensors here:

https://pastebin.com/raw/BywBmuFP

Perhaps this helps.

Regarding SMC, I'm not sure what I mean. I remember reading somewhere that the sensors are not available via SMC, or it makes it too complicated.

Why would the SMC keys be necessary when the code here seems to work without them? https://github.com/fermion-star/apple_sensors/blob/master/temp_sensor.m

exelban commented 3 years ago

How access to the sensors via ioreg solve the problem?

andreialecu commented 3 years ago

I don't claim to know anything about this really, it's just something in the readme:

https://github.com/fermion-star/apple_sensors

Only test with my Mac mini with M1. Please check your mac's ioreg -lfx output to make changes in temp_sensor.m if needed.

exelban commented 3 years ago

Read the next line please: For better names (e.g. what is PMU TP3w ?) for the sensors, please refer to...

andreialecu commented 3 years ago

I see, but I don't think anyone really figured out what they mean. Everyone is just guessing. See: https://forums.macrumors.com/threads/istat-menus-now-sort-of-supports-temperature-sensors-on-m1.2276062/

exelban commented 3 years ago

I saw this thread. I still do not understand what do you propose?

andreialecu commented 3 years ago

I guess I don't even understand what the problem is. Care to elaborate? :)

andreialecu commented 3 years ago

If the problem is not being able to associate the "raw" names with more user-friendly names, then I don't think there's much that can be done about that at the moment.

Other temperature apps seem to either display the raw names, or they're guessing that eACC = efficiency packages, and pACC = performance package.

Might still be useful to display them in their raw form, and update it later to more friendly names, after it can be figured out exactly what they mean.

exelban commented 3 years ago

I prefer to wait till some dictionary will be ready. Then show raw names. For you maybe it's ok to see PMU TP3w = 24C. Because you know the problem. But for most people, it will look like a bug.

exelban commented 3 years ago

Hi. I have an ask. Could maybe someone who have m1 macbook share one internal library. In theory it must be the same for all macs. But maybe m1 have a different one. This lib has the naming of sensors. Which will be really helpfull to this issue)

I'm talking about libSMC.dylib. Which you can find here: /usr/lib/libSMC.dylib.

Wilkolicious commented 3 years ago

@exelban Don't have that unfortunately

❯ l /usr/lib
total 4672
drwxr-xr-x  37 root  wheel   1.2K  1 Jan  2020 .
drwxr-xr-x@ 11 root  wheel   352B  1 Jan  2020 ..
-r--r--r--   1 root  wheel   198B  1 Jan  2020 charset.alias
lrwxr-xr-x   1 root  wheel    12B  1 Jan  2020 cron -> ../../var/at
-rwxr-xr-x   1 root  wheel   539K  1 Jan  2020 dsc_extractor.bundle
drwxr-xr-x  15 root  wheel   480B  1 Jan  2020 dtrace
-rwxr-xr-x   1 root  wheel   2.4M  1 Jan  2020 dyld
drwxr-xr-x   4 root  wheel   128B  1 Jan  2020 groff
-rwxr-xr-x   1 root  wheel   135K  1 Jan  2020 libLeaksAtExit.dylib
-rwxr-xr-x   1 root  wheel   2.7M  1 Jan  2020 libMTLCapture.dylib
-rwxr-xr-x   1 root  wheel   102K  1 Jan  2020 libffi-trampolines.dylib
-rwxr-xr-x   1 root  wheel   173K  1 Jan  2020 libgmalloc.dylib
lrwxr-xr-x   1 root  wheel    27B  1 Jan  2020 libhunspell-1.2.0.dylib -> libhunspell-1.2.0.0.0.dylib
lrwxr-xr-x   1 root  wheel    27B  1 Jan  2020 libhunspell-1.2.dylib -> libhunspell-1.2.0.0.0.dylib
lrwxr-xr-x   1 root  wheel    21B  1 Jan  2020 libiodbc.2.dylib -> libiodbc.2.1.18.dylib
lrwxr-xr-x   1 root  wheel    21B  1 Jan  2020 libiodbc.dylib -> libiodbc.2.1.18.dylib
lrwxr-xr-x   1 root  wheel    25B  1 Jan  2020 libiodbcinst.2.dylib -> libiodbcinst.2.1.18.dylib
lrwxr-xr-x   1 root  wheel    25B  1 Jan  2020 libiodbcinst.dylib -> libiodbcinst.2.1.18.dylib
-rwxr-xr-x   1 root  wheel   262K  1 Jan  2020 libobjc-trampolines.dylib
lrwxr-xr-x   1 root  wheel    18B  1 Jan  2020 libpython.dylib -> libpython2.7.dylib
lrwxr-xr-x   1 root  wheel    68B  1 Jan  2020 libpython2.7.dylib -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/Python
lrwxr-xr-x   1 root  wheel    21B  1 Jan  2020 libstdc++.6.dylib -> libstdc++.6.0.9.dylib
lrwxr-xr-x   1 root  wheel    17B  1 Jan  2020 libstdc++.dylib -> libstdc++.6.dylib
drwxr-xr-x   2 root  wheel    64B  1 Jan  2020 log
drwxr-xr-x  20 root  wheel   640B  1 Jan  2020 pam
drwxr-xr-x   4 root  wheel   128B  1 Jan  2020 php
drwxr-xr-x   7 root  wheel   224B  1 Jan  2020 pkgconfig
lrwxr-xr-x   1 root  wheel    75B  1 Jan  2020 python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
drwxr-xr-x   9 root  wheel   288B  1 Jan  2020 rpcsvc
lrwxr-xr-x   1 root  wheel    76B  1 Jan  2020 ruby -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/lib/ruby
drwxr-xr-x  22 root  wheel   704B  1 Jan  2020 sasl2
lrwxr-xr-x   1 root  wheel    27B  1 Jan  2020 sqlite3 -> /System/Library/Tcl/sqlite3
drwxr-xr-x   7 root  wheel   224B  1 Jan  2020 swift
drwxr-xr-x   7 root  wheel   224B  1 Jan  2020 system
drwxr-xr-x   2 root  wheel    64B  1 Jan  2020 updaters
drwxr-xr-x   3 root  wheel    96B  1 Jan  2020 xpc
drwxr-xr-x   3 root  wheel    96B  1 Jan  2020 zsh
rajtslegr commented 3 years ago

Libraries are not present in file system in Big Sur. They have moved to shared cache.

agido-malter commented 3 years ago

Could it be possible to have as a minimum the actual Fan speed? FNum (number of Fans) and F0Ac (Fan 0 Actual speed) is working on Apple Silicon

nik27 commented 3 years ago

Hi. I have an ask. Could maybe someone who have m1 macbook share one internal library. In theory it must be the same for all macs. But maybe m1 have a different one. This lib has the naming of sensors. Which will be really helpfull to this issue)

I'm talking about libSMC.dylib. Which you can find here: /usr/lib/libSMC.dylib.

I just checked and there is libSMC.dylib but as @RajceP pointed out location was changed in BigSur. After extracting shared cache with dyld_shared_cache_util I found it in /usr/lib/libSMC.dylib.

oneElectron commented 3 years ago
Screen Shot 2021-03-04 at 1 22 18 PM

-sudo spindump -cat /tmp/spindump.txt | grep "Fan speed"

I am Running an m1 MBP (I used tg pro to set the fan speed)

exelban commented 3 years ago

@FireLite4 Thanks for the proposal. But it requires sudo.

IamTheLoki commented 3 years ago

Is this Issue closed forever or is there a chance this feature can be implement in a future version?

exelban commented 3 years ago

Hi. Yes, it will be implemented. I need an M1 device to do it. I have only intel-based. And there is a difference in fetching sensors. Or someone with m1 and knowledge in swift could help.

cristiansori2 commented 3 years ago

Hi. Yes, it will be implemented. I need an M1 device to do it. I have only intel-based. And there is a difference in fetching sensors. Or someone with m1 and knowledge in swift could help.

I have a MP with M1,and I can help.Best regards.

exelban commented 3 years ago

@cristiansori2 thanks. Do you have experience with swift?

cristiansori2 commented 3 years ago

@cristiansori2 thanks. Do you have experience with swift?

Yes,what do you need?

exelban commented 3 years ago

Ok. I have already tried to port this and this. But I receive an empty list on intel. So, I'm stuck a little bit.

I will put all my tests to the swift playground and create a separate repo for it. I will try to make it later today. And post here a link. So everyone could help.

cristiansori2 commented 3 years ago

Ok. I have already tried to port this and this. But I receive an empty list on intel. So, I'm stuck a little bit.

I will put all my tests to the swift playground and create a separate repo for it. I will try to make it later today. And post here a link. So everyone could help.

Ok pls let me know when you do it.

exelban commented 3 years ago

I will try to rent an M1 (mac mini) as a Service. I don't think that creating a separate repo for this it's a good idea. And don't see a better way to work with this. But it will only if I can't rent M1.

oneElectron commented 3 years ago

it seems to be working

Screen Shot 2021-03-25 at 11 16 05 AM

however the sensors tab and the fans tab has been deactivated in the apple silicon version so the only way to get the readout is to run it with rosetta.

there is also a small problem when the fan RPM goes to Zero the widget does not update and stays on the last update

Screen Shot 2021-03-25 at 11 15 12 AM

edit: the update fan rpm bug seems to have gone away after recompiling

exelban commented 3 years ago

@FireLite4 yes. It works with rosetta. Because rosetta simulates some intel-based methods (SMC). But it does not work natively.

IamTheLoki commented 3 years ago

Maybe you can mark this feature as experimental until a native solution is ready?

exelban commented 3 years ago

Can someone run this console app? It will create a file log.txt in the Documents. There must be thermal sensors. And share the log file after.

m1_sensors.zip

IamTheLoki commented 3 years ago

Yes

log.txt

exelban commented 3 years ago

@IamTheLoki Thanks for this. It looks like I have a list of sensors. Now I need to figured out with values.

exelban commented 3 years ago

A small fix. It must have values or give info on why there are no values.

m1_sensors.zip

IamTheLoki commented 3 years ago

log.txt