SOC THERMAL DRAFT: Difference between revisions

From Variscite Wiki
(Initial draft of the SoC Thermal wiki page)
 
No edit summary
Line 1: Line 1:
{{PageHeader|SoC Thermal Temperature}}
<!-- Set release according to "release" parameter in URL and use mx8mp-yocto-hardknott-5.10.72_2.2.1-v1.0 as default
--> {{INIT_RELEASE_PARAM|mx8mp-yocto-hardknott-5.10.72_2.2.1-v1.0}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
 
Set common variables
--> {{#vardefine: MACHINE_PROMPT | root@{{#var:MACHINE_NAME}}}} <!--
--> {{#vardefine: KERNEL_SOURCE | {{#ifeq: {{#pos: {{#var: HARDWARE_NAME}} | MX8 }} | | source code | device tree }}}} <!--
--> {{#vardefine: DEVICE_TREE | {{#replace:{{#var:DEFAULT_DTB}}|dtb|dts}}}} <!--
--> {{#vardefine: DEVICE_TREE_LINK | https://github.com/varigit/{{#var:KERNEL_REPO_NAME}}/blob/{{#var:KERNEL_BRANCH}}/arch/arm64/boot/dts/freescale/{{#var:DEVICE_TREE}}}} <!--
--> {{#vardefine: IMX_THERMAL_LINK | https://github.com/varigit/{{#var:KERNEL_REPO_NAME}}/blob/{{#var:KERNEL_BRANCH}}/drivers/thermal/imx_thermal.c }} <!--
--> {{#vardefine: HEATSINK_LINK |
{{#switch: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6=
[https://www.variscite.com/product/accessories/vhp-mx6/ Heatsink]
 
| DART-MX8M=
[https://www.variscite.com/product/accessories/vhp-dt8mx/ DART-MX8M Heatsink]
 
| DART-MX8M-MINI=
[https://www.variscite.com/product/accessories/vhp-dt8mx/ DART-MX8M-MINI Heatsink]<br>
[https://www.variscite.com/product/accessories/vhp-vs8m/ VAR-SOM-MX8M-MINI Heatsink]
 
| VAR-SOM-MX8M-NANO=
[https://www.variscite.com/product/accessories/vhp-vs8m/ VAR-SOM-MX8M-NANO Heatsink]
 
| DART-MX8M-PLUS=
[https://www.variscite.com/product/accessories/vhp-dt8mx/ DART-MX8M-PLUS Heatsink]<br>
[https://www.variscite.com/product/accessories/vhp-vs8m/ VAR-SOM-MX8M-PLUS Heatsink]
 
| VAR-SOM-MX8=
[https://www.variscite.com/product/accessories/vhp-mx8/ VAR-SOM-MX8 Heatsink]
 
| VAR-SOM-MX8X=
[https://www.variscite.com/product/accessories/vhp-mx8/ VAR-SOM-MX8X Heatsink]
 
|
[https://www.variscite.com/products/accessories/ Acessories] }}}} <!--
 
Define mx6/7 source codes lines needed for changing the trip points
--> {{#vardefine: MX6_7_CHANGE_TRIP | {{#ifexpr: {{#var:KERNEL_VER}} > 4.8 <!--
Kernel version 4.9 or higher -->|<pre>
static void imx_init_temp_grade(struct platform_device *pdev, u32 ocotp_mem0)
{
struct imx_thermal_data *data = platform_get_drvdata(pdev);
 
/* The maximum die temp is specified by the Temperature Grade */
switch ((ocotp_mem0 >> 6) & 0x3) {
case 0: /* Commercial (0 to 95 °C) */
data->temp_grade = "Commercial";
data->temp_max = 95000;
break;
case 1: /* Extended Commercial (-20 °C to 105 °C) */
data->temp_grade = "Extended Commercial";
data->temp_max = 105000;
break;
case 2: /* Industrial (-40 °C to 105 °C) */
data->temp_grade = "Industrial";
data->temp_max = 105000;
break;
case 3: /* Automotive (-40 °C to 125 °C) */
data->temp_grade = "Automotive";
data->temp_max = 125000;
break;
}
 
/*
* Set the critical trip point at 5 °C under max
* Set the passive trip point at 10 °C under max (changeable via sysfs)
*/
data->temp_critical = data->temp_max - (1000 * 5); /* Sets critical trip point temperature, in millidegree Celsius */
data->temp_passive = data->temp_max - (1000 * 10); /* Sets passive trip point temperature, in millidegree Celsius */
}
</pre><!--
Kernel version less than 4.9 -->|<pre>
#define IMX_TEMP_PASSIVE 85000  /* Sets passive trip point temperature, in millidegree Celsius */
 
...
 
/*
* Set the default critical trip point to 20 C higher
* than passive trip point. Can be changed from userspace.
*/
data->temp_critical = IMX_TEMP_PASSIVE + 20 * 1000; /* Sets critical trip point temperature, in millidegree Celsius */
</pre>}}}}
 
 
{{PageHeader|{{#var:HARDWARE_NAME}} SoC Thermal Temperature}} __toc__


__toc__
= Introduction =
= Introduction =


Line 9: Line 94:


{{Note|'''DISCLAIMER:'''<br>
{{Note|'''DISCLAIMER:'''<br>
If there are heat problems, using a heat plate or sink can be considered as an option to manage the temperature of the CPU. Variscite provides the heat sink on the accessories page:
If there are heat problems, using a heat plate or sink can be considered as an option to manage the temperature of the CPU. Variscite provides the heat sink on the accessories page:<br>
* [https://www.variscite.com/products/accessories/ Accessories]
{{#var: HEATSINK_LINK}}
| warning}}
| warning}}


= U-Boot =
= U-Boot =


In the U-Boot, the CPU temperature is also monitored, and if it exceeds the critical temperature, the system waits until the temperature drops below the critical trip point before continuing with the boot process.<br>
The imx_thermal driver is an essential component for ensuring the proper operation of i.MX SoCs, particularly in environments where high temperatures are a concern.
Starting from the [https://github.com/varigit/uboot-imx/tree/imx_v2017.03_4.9.11_1.0.0_ga_var01 imx_v2017.03_4.9.11_1.0.0_ga_var01] branch, the critical temperature is detected automatically and set to the same values as in the newer kernels.
In U-Boot, the CPU temperature is monitored, and if it exceeds the critical temperature, the system waits until the temperature drops below the critical trip point before continuing with the boot process.<br>
<br>
Starting from [https://github.com/varigit/uboot-imx/tree/imx_v2017.03_4.9.11_1.0.0_ga_var01 imx_v2017.03_4.9.11_1.0.0_ga_var01], the critical temperature is set automatically and set to the same values as in the more recent Linux kernel releases. The feature was introduced in the following commit:
* [https://github.com/varigit/uboot-imx/commit/a91db95479e75c70ec49676e9a347787b054d651 thermal: imx_thermal: use CPU temperature grade for trip points]


= Linux Kernel =
= Linux Kernel =


In the User space, the current CPU's temperature sensor can be read as the following:
In the User space, the current CPU's temperature sensor can be read as the following:
  root@machine:~# cat /sys/devices/virtual/thermal/thermal_zone0/temp
  {{#var:MACHINE_PROMPT}}:~# cat /sys/devices/virtual/thermal/thermal_zone0/temp
<br>
<br>
Additionally, there are two '''thermal trip points''' that can be configured to control the behavior of the CPU based on temperature changes:<br>
Additionally, there are two '''thermal trip points''' that can be configured to control the behavior of the CPU based on temperature changes:<br>
<br>
<br>
The first trip point, also known as the '''passive trip point''', is set/read in:
The first trip point, also known as the '''passive trip point''', is set/read in:
  root@machine:~# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp
  {{#var:MACHINE_PROMPT}}:~# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp


When the CPU temperature reaches the passive trip point, the CPU frequency is reduced to minimize heat production, allowing the CPU to cool down.
The passive trip point refers to the temperature at which the kernel starts to reduce the performance of the SoC to prevent it from overheating.
This is done by lowering the CPU frequency and voltage to reduce the heat generated by the processor.
Once the temperature drops '''10 °C''' below the passive trip point, the CPU frequency returns to its normal value.<br>
Once the temperature drops '''10 °C''' below the passive trip point, the CPU frequency returns to its normal value.<br>
<br>
<br>


The second trip point, the '''critical trip point''', is read/set in:
The second trip point, the '''critical trip point''', is read/set in:
  root@machine:~# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_1_temp
  {{#var:MACHINE_PROMPT}}:~# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_1_temp
If the CPU temperature exceeds the critical trip point, the system is shut down by software to avoid damaging the hardware.<br>
The critical trip point is the temperature threshold at which the kernel will initiate an emergency shutdown to prevent damage to the processor due to overheating. This is a last-resort mechanism to protect the system from damaging itself.<br>


== Defining the default trip points values via Linux kernel {{#var: KERNEL_SOURCE}} ==
Starting from kernel [https://github.com/varigit/linux-imx/tree/imx_4.9.11_1.0.0_ga-var01 imx_4.9.11_1.0.0_ga-var01], the temperature grade of the CPU is detected automatically, and the trip points are set accordingly.<br>
* For Commercial CPUs, the operational temperature ranges from 0 to 95 °C.
* For Extended Commercial CPUs, the operational temperature ranges from -20 to 105 °C.
* For Industrial CPUs, the operational temperature ranges from -40 to 105 °C.
The critical trip point is set to '''5 °C''' below the maximum temperature, while the passive trip point is set to '''10 °C''' below the maximum temperature.<br>
<br>
<br>
Starting from kernel version '''4.9.x''', the temperature grade of the CPU is detected automatically, and the trip points are set accordingly.<br>
In older releases, the temperature grade may not be detected automatically, and the trip points must be set manually. However, it is essential to be careful not to set the trip points of a higher-grade CPU on a lower-grade CPU to avoid damage. To manually set the trip points, the appropriate SYSFS file can be written to, but the default value of the passive trip point can not be exceeded without modifying the kernel source code.<br>
For Industrial/Extended Commercial temperature grade CPUs, the maximum temperature is '''105 °C''', and the critical trip point is set '''5 °C''' below the maximum temperature, while the passive trip point is set to '''10 °C''' below the maximum temperature.<br>
To identify which processes are consuming more power, the '''powertop''' software package can be used.
For Commercial grade CPUs, the maximum temperature is '''95 °C''', and the trip points are similarly set.<br>
 
In older kernels, the temperature grade may not be detected automatically, and the trip points must be set manually. However, it is essential to be careful not to set the trip points of a higher-grade CPU on a lower-grade CPU to avoid damage. To manually set the trip points, the appropriate sysfs file can be written to, but the default value of the passive trip point cannot be exceeded without modifying the kernel source code.<br>
<!-- Demonstrate how to change the thermal trip points in the source code -->
To identify which processes are consuming the most power, the powertop software package can be used.
=== {{#var:HARDWARE_NAME}} {{#var:KERNEL_SOURCE}}===
{{Note|'''DISCLAIMER:'''<br>
Be very careful when changing the thermal trip points of your SoC manually. Note that changing the thermal trip points can have serious consequences if not done properly. It is important to understand the thermal characteristics of your device and to make careful modifications to the trip points to avoid causing damage or instability.
| error}}
{{#ifeq: {{#pos: {{#var: HARDWARE_NAME}} | MX8 }} | <!--
i.MX6/7 --> | The {{#var: MACHINE_NAME}} temperature trip points can be changed in the following lines of the [{{#var: IMX_THERMAL_LINK}} imx_thermal {{#var: KERNEL_SOURCE}}]:
{{#var:MX6_7_CHANGE_TRIP}} <!--
i.MX8 --> |  The {{#var: MACHINE_NAME}} temperature trip points can be changed by adding the following to its [{{#var: DEVICE_TREE_LINK}} {{#var: KERNEL_SOURCE}}]:
<pre>
&thermal-zones {
cpu-thermal {
trips {
cpu_alert0: trip0 {
temperature = <85000>;  /* Sets passive trip point temperature, in millidegree Celsius */
hysteresis = <2000>;
type = "passive";
};
 
cpu_crit0: trip1 {
temperature = <95000>; /* Sets the critical trip point temperature, in millidegree Celsius */
hysteresis = <2000>;
type = "critical";
};
};
};
};
</pre>
}}


= Defining the default trip points values via Linux kernel source code/device tree =


The default values of the passive and critical trip points can be changed manually in the Linux kernel source code.


== i.MX6 Family ==
* Passive trip point: https://github.com/varigit/linux-2.6-imx/blob/imx-rel_imx_4.1.15_2.0.0_ga-var03/drivers/thermal/imx_thermal.c#L95
* Critical trip point: https://github.com/varigit/linux-2.6-imx/blob/imx-rel_imx_4.1.15_2.0.0_ga-var03/drivers/thermal/imx_thermal.c#L634


== i.MX8 Family ==
=== i.MX8M ===
* https://github.com/varigit/linux-imx/blob/p9.0.0_2.0.0-ga_var01/arch/arm64/boot/dts/freescale/fsl-imx8mq.dtsi#L416-L427


=== i.MX8M Mini ===
* https://github.com/varigit/linux-imx/blob/5.4-2.1.x-imx_var01/arch/arm64/boot/dts/freescale/imx8mm.dtsi#L349-L361


=== i.MX8M Plus ===
<!-- === i.MX6 Family ===
* https://github.com/varigit/linux-imx/blob/5.4-2.1.x-imx_var01/arch/arm64/boot/dts/freescale/imx8mp.dtsi#L460
* Passive trip point: https://github.com/varigit/linux-2.6-imx/blob/imx-rel_imx_4.1.15_2.0.0_ga-var03/drivers/thermal/imx_thermal.c#L95
* Critical trip point: https://github.com/varigit/linux-2.6-imx/blob/imx-rel_imx_4.1.15_2.0.0_ga-var03/drivers/thermal/imx_thermal.c#L634

Revision as of 05:38, 28 April 2023

Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release mx8mp-yocto-hardknott-5.10.72_2.2.1-v1.0.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release


DART-MX8M-PLUS SoC Thermal Temperature

Introduction

The CPU temperature plays a crucial role in the optimal functioning and reliability of a computer system. As the CPU is the primary processing unit of a computer, it generates a significant amount of heat while executing tasks.
The temperature of the CPU must be within a safe range to ensure that the system operates correctly, without any performance degradation or hardware damage. Therefore, monitoring and managing the CPU temperature is essential to maintaining a stable and efficient computer system.


DISCLAIMER:

If there are heat problems, using a heat plate or sink can be considered as an option to manage the temperature of the CPU. Variscite provides the heat sink on the accessories page:
DART-MX8M-PLUS Heatsink
VAR-SOM-MX8M-PLUS Heatsink

U-Boot

The imx_thermal driver is an essential component for ensuring the proper operation of i.MX SoCs, particularly in environments where high temperatures are a concern. In U-Boot, the CPU temperature is monitored, and if it exceeds the critical temperature, the system waits until the temperature drops below the critical trip point before continuing with the boot process.

Starting from imx_v2017.03_4.9.11_1.0.0_ga_var01, the critical temperature is set automatically and set to the same values as in the more recent Linux kernel releases. The feature was introduced in the following commit:

Linux Kernel

In the User space, the current CPU's temperature sensor can be read as the following:

root@imx8mp-var-dart:~# cat /sys/devices/virtual/thermal/thermal_zone0/temp


Additionally, there are two thermal trip points that can be configured to control the behavior of the CPU based on temperature changes:

The first trip point, also known as the passive trip point, is set/read in:

root@imx8mp-var-dart:~# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp

The passive trip point refers to the temperature at which the kernel starts to reduce the performance of the SoC to prevent it from overheating. This is done by lowering the CPU frequency and voltage to reduce the heat generated by the processor. Once the temperature drops 10 °C below the passive trip point, the CPU frequency returns to its normal value.

The second trip point, the critical trip point, is read/set in:

root@imx8mp-var-dart:~# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_1_temp

The critical trip point is the temperature threshold at which the kernel will initiate an emergency shutdown to prevent damage to the processor due to overheating. This is a last-resort mechanism to protect the system from damaging itself.

Defining the default trip points values via Linux kernel device tree

Starting from kernel imx_4.9.11_1.0.0_ga-var01, the temperature grade of the CPU is detected automatically, and the trip points are set accordingly.

  • For Commercial CPUs, the operational temperature ranges from 0 to 95 °C.
  • For Extended Commercial CPUs, the operational temperature ranges from -20 to 105 °C.
  • For Industrial CPUs, the operational temperature ranges from -40 to 105 °C.

The critical trip point is set to 5 °C below the maximum temperature, while the passive trip point is set to 10 °C below the maximum temperature.

In older releases, the temperature grade may not be detected automatically, and the trip points must be set manually. However, it is essential to be careful not to set the trip points of a higher-grade CPU on a lower-grade CPU to avoid damage. To manually set the trip points, the appropriate SYSFS file can be written to, but the default value of the passive trip point can not be exceeded without modifying the kernel source code.
To identify which processes are consuming more power, the powertop software package can be used.

DART-MX8M-PLUS device tree

DISCLAIMER:

Be very careful when changing the thermal trip points of your SoC manually. Note that changing the thermal trip points can have serious consequences if not done properly. It is important to understand the thermal characteristics of your device and to make careful modifications to the trip points to avoid causing damage or instability.

The imx8mp-var-dart temperature trip points can be changed by adding the following to its device tree:

&thermal-zones {
	cpu-thermal {
		trips {
			cpu_alert0: trip0 {
				temperature = <85000>;  /* Sets passive trip point temperature, in millidegree Celsius */
				hysteresis = <2000>;
				type = "passive";
			};

			cpu_crit0: trip1 {
				temperature = <95000>; /* Sets the critical trip point temperature, in millidegree Celsius */
				hysteresis = <2000>;
				type = "critical";
			};
		};
	};
};