I.MX Linux temperature
From Boundary Devices Wiki
Revision as of 15:22, 26 May 2021 by Gary.bisson (talk | contribs)
We have received many requests about temperature monitoring on our NXP i.MX based Nitrogen platforms.
This blog post aims to answer the most common questions and help you get the most out of your Nitrogen device.
Temperature Monitoring principle
All the i.MX processors come with an integrated IP capable of providing the internal temperature of the SoC.
That temperature monitoring IP is not the same across all i.MX CPUs. The older i.MX 6 & 7 used to rely on the TEMPMON IP whereas the newer i.MX 8M (Quad, Mini, Nano & Plus) use the TMU.
How do you read the temperature?
The good news is that no matter which platform you use, the way to read the temperature is always the same:
# cat /sys/devices/virtual/thermal/thermal_zone0/temp 37000
The above means my platform temperature is currently 37 degrees Celsius as the unit is millidegree as described in the kernel documentation:
Behind the scenes, as the IP differs between CPUs, different kernel drivers can be in use:
- imx_thermal.c for i.MX 6 and i.MX 7 processors (TEMPMON)
- imx8mm_thermal.c for i.MX 8M Mini / Nano / Plus processors (TMU)
- qoriq_thermal.c for i.MX 8M Quad processors (TMU)
How accurate is the measurement?
Some of you have tried to compare a case temperature measurement against the one read by the IP which isn't a fair comparison.
First, the internal temperature monitor measures die temp (also called junction temp), with an accuracy of +5C.
Second, the difference between junction and case temperature is linear to the wattage of your platform, so it increases the more power you draw.
In other words the die temperature is what should be used to avoid damaging your platform.
Is there a safety mechanism?
The first question often is: "how do I make sure not to damage my platform in case it gets hot?"
The safety mechanism for that defines 2 thresholds:
- Passive trip point: when reached, the CPU/GPU/VPU throttles to try to reduce the temperature
- Active trip point: when reached, the board reboots immediately to avoid damaging the SoC
Those thresholds are usually 10C apart, like the default values on our 8MP SOM like this:
# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_*temp 85000 95000
How to modify the thresholds?
Depending on the exact version of the CPU you are using, you might need to change the default thresholds.
This is not necessary for i.MX 6 & 7 as the driver checks the temperature grade and adapts temperatures automatically:
For the other processors, like an industrial version of the i.MX 8M Mini CPU that can go from -40C to 105C, you need to update the trip points as follows:
# echo 105000 > /sys/devices/virtual/thermal/thermal_zone0/trip_point_1_temp # echo 95000 > /sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp # cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_*temp 95000 105000
Note that setting those thresholds this way is not persistent across reboot, so you have 2 solutions:
- Modify the device tree directly to have your own values
- i.MX 8M Quad: imx8mq.dtsi
- i.MX 8M Mini: imx8mm.dtsi
- i.MX 8M Nano: imx8mn.dtsi
- i.MX 8M Plus: imx8mp.dtsi
- Create an init script for your OS to do that at bootup