-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathread_temp.py
More file actions
executable file
·69 lines (53 loc) · 1.72 KB
/
Copy pathread_temp.py
File metadata and controls
executable file
·69 lines (53 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
#!/usr/bin/env python3
"""
ASRock BC-250 GDDR6 temperature monitor.
Reads the JEDEC MR3 temperature readout from all 8 GDDR6 memory chips
on the ASRock BC-250 and displays the temperature of each chip.
Temperature conversion follows the JEDEC MR3 encoding:
temperature (°C) = (temperature_code * 2) - 40
The script also calculates:
Average - average temperature across all 8 GDDR6 chips
Hotspot - highest temperature and the corresponding chip
Usage:
sudo python3 read_temp.py
"""
import os
import sys
import time
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from bc250_smu import Bc250Smu, SmuError
from unlock import unlock
from tabulate import tabulate
def main():
if os.geteuid() != 0:
sys.exit("needs root")
smu = Bc250Smu()
try:
rows = []
temperatures = []
for chip in range(8):
temp_readout = smu.send_message(3, 0x5, [chip])[1]
temp_c = ((temp_readout & 0xff) * 2) - 40
temperatures.append(temp_c)
rows.append([
chip,
f"0x{temp_readout:08X}",
f"0x{temp_readout & 0xFF:02X}",
f"{temp_c:.1f} °C"
])
print(tabulate(
rows,
headers=["Chip", "MR3 raw", "Temp code", "Temperature"],
tablefmt="grid"
))
average = sum(temperatures) / len(temperatures)
hotspot = max(temperatures)
hotspot_chip = temperatures.index(hotspot)
print()
print(f"Average : {average:.1f} °C")
print(f"Hotspot : {hotspot:.1f} °C (Chip {hotspot_chip})")
finally:
smu.close()
if __name__ == "__main__":
main()