Solved Getting CPU temperature on AMD Ryzen Zen 5 CPUs

Is there some way to display the CPU temperature of AMDs ryzen zen 5 CPUs ?

I tried to load amdtemp by issuing as root:
Code:
kldload -v amdtemp

and checking whether the module is loaded through issuing:
Code:
kldstat | grep amdtemp
the module seems to be loaded.

Next I tried both commands:
1) sysctl -a | grep temperature
2) sysctl dev.cpu | grep temperature
resulting in a blank output line for both.

In linux I remember that I used lm_sensors to scan the mainboard for CPU temps for my zen 4 CPU back then.
Is there some alternative for FreeBSD ?
 
I tested out hwstat.
Here is my output when issuing hwstat both as user and as root:
Code:
hwstat
                    Current                Unit
[Coretemp]
    CPU0:                Cannot get temperature
    CPU1:                Cannot get temperature
    CPU2:                Cannot get temperature
    CPU3:                Cannot get temperature
    CPU4:                Cannot get temperature
    CPU5:                Cannot get temperature
    CPU6:                Cannot get temperature
    CPU7:                Cannot get temperature
    CPU8:                Cannot get temperature
    CPU9:                Cannot get temperature
    CPU10:               Cannot get temperature
    CPU11:               Cannot get temperature

I tried to load coretemp together with amdtemp, too, but the output is the same.
I am using a AMD Ryzen 9900X if it helps.

Neville, RhfUsQnPbC which ryzen CPUs do you have ?
 
Could it be something related to Zen5 only? so far I didn't find anything yet.
I am still on Zen4 so I can't tell.
Wait a bit if people on Zen5 can confirm what you say and may be make a report on Bugzilla.
 
I do not know since I started to use FreeBSD recently on my Zen 5 CPU, but I believe that OS tools like sysctl or external tools like hwstat do not have support for zen 5, yet.
 
I do not know since I started to use FreeBSD recently on my Zen 5 CPU, but I believe that OS tools like sysctl or external tools like hwstat do not have support for zen 5, yet.
FreeBSD tends to have better support for hardware that is not "too new".
Your CPU came out 7 months ago, so do not expect an immediate full support, but at least it works ;)
IMO the best thing to do in this situation is making reports and wait, may be someone will come by and give you a hint here or in Bugzilla.

PS: I am not a pro but in your situation, I would just set my CPU fan via the motherboard and lower a bit more the threshold to avoid the heat, just to be sure.
 
FreeBSD tends to have better support for hardware that is not "too new".
Your CPU came out 7 months ago, so do not expect an immediate full support, but at least it works ;)
IMO the best thing to do in this situation is making reports and wait, may be someone will come by and give you a hint here or in Bugzilla.
It works very well considered being a "new" CPU.
I think it has something to do with having all cores being the same, instead of having E-, and P-Cores.
In this regard, thank you AMD.

PS: I am not a pro but in your situation, I would just set my CPU fan via the motherboard and lower a bit more the threshold to avoid the heat, just to be sure.
This is usually the first thing I do after buying a new CPU.
I see whether I can lower the V-Core voltage without getting instability issues.
In this case, I could set it from 1.1V to 0.915V without problems.

Next I set the C-State to enabled so that cores can go to sleep, if I do not need all of them.
After that I adjust the fan speed, and do benchmarks to see the temperature on all cores at 100%.

These values are from my test in Windows 10 under Prime95:
-> 32 to 35 in idle
-> 40 to 48 under load
-> 50 to 61 at 100%

It is just that I want to see which temps I get under FreeBSD in idle, and under load.
I have powerd enabled in high adaptive mode so that the CPU switch contexts more frequently.
It makes FreeBSD more responsive and games work without hiccups.
So I am curious whether the CPU cores match the temps I get under windows, or whether they are lower than that.
After all Windows tends to be more resource hungry.

Probably easy to fix if AMD updated the CPU reference manuals.
I see.
So AMD needs to be contacted then first ?
 
I will mark this thread as solved, after the problem is fixed with zen 5 CPUs.
If it will ever get fixed of course as my motivations are not so high to look into it myself.
 
Then void-linux would be a good option.
But as it is now, I do not have any spare drive left for another OS.
Well since it is more curiosity than actual necessity, I will wait for now.
 
The support was added for 15.0-CURRENT if I am not wrong.
Thank you for providing the link to the bugfix.
Now, I only need to know how to apply that patch to my current 14.2-RELEASE version 😄
Is it actually possible to down-patch without breaking stuff ?

Its in the stable/14 branch. You can check out src via git, switch to the stable/14 branch and make buildkernel. But I have not tested this
 
Its in the stable/14 branch. You can check out src via git, switch to the stable/14 branch and make buildkernel. But I have not tested this
I have edited the amdsmn.c file accordingly, and are going to compile a custom kernel.
Throwing a lot of unnecessary things like axge, and and wifi out of the kernel was something I wanted to do now for some time.
I will report back, if everything works.
 
Today I looked up the zen5 patch file again, and noticed that both amdsmn.c, and amdtemp.c need to be edited.

I deleted my /usr/src directory content, and issued as root:
Code:
git clone -o freebsd https://git.FreeBSD.org/src.git /usr/src
to get the latest FreeBSD OS sources.

After that I looked up the patched amdsmn.c and amdtemp.c, and pasted their content into /usr/src/sys/dev/amdsmn/amdsmn.c[/code] and [cmd]/usr/src/sys/dev/amdtemp/amdtemp.c, replacing the old content of these files.

Issuing as root:
Code:
git checkout releng/14.2
I confirmed that I am on the 14.2-RELEASE branch, and amdsmn.c and amdtemp.c are indeed modified.

Next I compiled a custom kernel, named it MYKERNEL with only the drivers I need for my system, throwing everything unneeded out.
For compiling the GENERIC kernel with applied patches to amdsmn.c and amdtemp.c you need to issue as root from /usr/src:
Code:
make buildkernel KERNCONF=GENERIC
make installkernel KERNCONF=GENERIC
Reboot, and load amdtemp as root with kldload -v amdtemp or put the module inside your kld_list in your /etc/rc.conf file.

With issuing the following command:
Code:
sysctl dev.cpu | grep dev.cpu.0.temperature | awk '{print $2}'
42.6C
I could verify that the patched files also work under FreeBSD 14.2-RELEASE, although added in 14-STABLE recently.

Hopefully this thread helps users out, who want to stay on the RELEASE branch, but still get temperature output for their zen 5 CPU.
 
Back
Top