Skip to main content

5.2.4 Thermal & CPU Frequency Management

X5

Thermal

Temperature

There are three temperature sensors on the X5, which are used to display the temperature of the DDR, BPU, and CPU. The hwmon0 directory in /sys/class/hwmon/ contains the relevant parameters of the temperature sensors. temp1_input is the temperature of the DDR, temp2_input is the temperature of the BPU, and temp3_input is the temperature of the CPU. The temperature accuracy is 0.001 degrees Celsius.

cat /sys/class/hwmon/hwmon0/temp1_input
46643

The BPU temperature sensor is located in the BPU subsystem. The BPU subsystem is powered on only when the BPU is running. Therefore, the BPU temperature can be checked only when the BPU is running.

Thermal

Linux Thermal is a temperature control module under Linux system. It is mainly used to control the heat generated by the chip during system operation, so that the chip temperature and device casing temperature are maintained in a safe and comfortable range.

To achieve reasonable control of device temperature, we need to understand the following three modules:

The device that obtains temperature is abstracted as a Thermal Zone Device in the Thermal framework. The X5 has two thermal zones: thermal_zone0 and thermal_zone1.

Devices that require cooling: These are abstracted as Thermal Cooling Devices in the Thermal framework, including CPUs, BPUs, GPUs, and DDRs.

Temperature control strategy: abstracted as Thermal Governor in the Thermal framework;

Information and control of the above modules can be obtained in the /sys/class/thermal directory.

There are four cooling devices in the X5:

  • cooling_device0: cpu
  • cooling_device1: bpu
  • cooling_device2: gpu
  • cooling_device3: ddr

The DDR cooling device is associated with thermal_zone 0, and the CPU/BPU/GPU cooling devices are associated with thermal_zone 1. The default strategy is step_wise, as shown in the following command.

cat /sys/class/thermal/thermal_zone0/policy

The following commands can be used to view the supported strategies: user_space and step_wise.

cat /sys/class/thermal/thermal_zone0/available_policies

User_space reports the current temperature of the temperature zone, temperature control trigger point and other information to the user space through uevent, and the user space software formulates the temperature control strategy.

step_wise is a relatively mild temperature control strategy that gradually improves the cooling state in each polling cycle.

The specific strategy to choose is based on the product needs. It can be specified at compile time or dynamically switched through sysfs. For example: dynamically switch the strategy of thermal_zone0 to user_space mode

echo user_space > /sys/class/thermal/thermal_zone0/policy

There is a trip_point in thermal_zone0, which is used to control the frequency modulation temperature of the cooling device DDR

You can view the DDR frequency modulation temperature through sysfs. The current configuration is 95 degrees.

cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp

If you want to adjust the DDR frequency modulation temperature, such as 85 degrees, you can use the following command:

echo 85000 > /sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp

There are three trip_points in thermal_zone1, of which trip_point_0_temp is reserved. Trip_point_1_temp is the frequency modulation temperature of the thermal zone, which controls the CPU/BPU/GPU frequency and is currently set to 95 degrees. Trip_point_2_temp is the shutdown temperature and is currently set to 105 degrees. For example, if you want the junction temperature to reach 85 degrees Celsius, the CPU/BPU/GPU will start frequency modulation:

echo 85000 > /sys/devices/virtual/thermal/thermal_zone1/trip_point_1_temp

If you want to adjust the shutdown temperature to 105 degrees Celsius:

echo 105000 > /sys/devices/virtual/thermal/thermal_zone1/trip_point_2_temp

The above settings need to be reset after power off and restart

CPU Frequency

In the Linux kernel, there is a built-in cpufreq subsystem to control the CPU frequency and frequency control strategy.

Enter the directory /sys/devices/system/cpu/cpufreq/policy0 and ls you will see the following files in the directory:

Currently supported frequencies include

cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies
300000 600000 1200000 1500000

The Linux kernel used in the RDK X5 system supports the following frequency scaling strategies:

  • Performance: Always put the CPU into the highest energy consumption and highest performance state, that is, the highest frequency supported by the hardware.
  • performance: execute at the highest frequency
  • ondemand: adjust the frequency according to the load
  • Userspace: according to the user's setting frequency
  • powersave: execute at the lowest frequency
  • schedutil: adjusts the frequency according to the load, which is used in conjunction with the CPU scheduler

Users can /sys/devices/system/cpu/cpu0/cpufreq/ control the CPU frequency regulation strategy through the corresponding settings in the control directory.

For example, to run the CPU in performance mode:

echo performance >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

Or control the CPU to run at a fixed frequency (1.2GHz):

echo userspace >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 1200000 >/sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed

CPU

The development board uses the CPU Freq driver to manage the CPU operating state. The default mode is schedutil mode. At this time, the CPU operating frequency will be dynamically adjusted according to the load to save power. The user can change performance the mode to make the CPU always run at the highest frequency. The command is as follows:

echo performance >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

The development board provides an overclocking function in the system, which can increase the maximum CPU frequency from 1.5GHz to 1.8GHz. The configuration command is as follows:

echo 1 >/sys/devices/system/cpu/cpufreq/boost
echo performance >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

The CPU frequency configured using the above command is only effective during the current operation. If the device is restarted, the default configuration will be restored.

You can use sudo hrut_somstatus the command to view the current chip operating frequency, temperature and other status:

image-20240829171934000