Skip to main content

2.4 Thermal and CPU Frequency Management

RDK S100

Temperature Sensors

There are 5 temperature sensors in the RDK S100 chip, used to display the temperatures of the MCU domain/BPU/MAIN domain. Among them, the MAIN domain and MCU each have two temperature sensors, and the BPU has one temperature sensor.

Under /sys/class/hwmon/, the hwmon0 directory contains parameters related to the temperature sensors.

  • temp1_input is the first temperature sensor of the MAIN domain, temp2_input is the second temperature sensor of the MAIN domain,
  • temp3_input is the first temperature sensor of the MCU domain, temp4_input is the second temperature sensor of the MCU domain,
  • temp5_input is the BPU temperature sensor.

The temperature precision is 0.001 degrees Celsius.

root@ubuntu:~# cat /sys/class/hwmon/hwmon0/temp1_input
46837
root@ubuntu:~#

Thermal Mechanism

Linux Thermal is a module related to temperature control under the Linux system, mainly used to control the heat generated by the chip during system operation, keeping the chip temperature and device housing temperature within a safe and comfortable range.

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

  • Temperature acquisition device: Abstracted as Thermal Zone Device in the Thermal framework. There are 5 thermal zones on RDK S100, namely thermal_zone0~thermal_zone4, each bound to 5 temperature sensors;
  • Cooling device: Abstracted as Thermal Cooling Device in the Thermal framework, including CPU, BPU, and fan;
    • CPU/BPU and other devices cool down by frequency scaling;
    • The fan can control its speed to cool down;
  • 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.

Thermal Zone Introduction

To get information about a specific thermal_zone, take thermal_zone0 as an example, the example command is as follows:

root@ubuntu:~# cat /sys/class/thermal/thermal_zone0/type
pvt_cmn_pvtc1_t1

To get the current policy of a specific thermal_zone, take thermal_zone0 as an example, the example command is as follows:

root@ubuntu:~# cat /sys/class/thermal/thermal_zone0/policy
step_wise

To get the supported policies of a specific thermal_zone, take thermal_zone0 as an example, the example command is as follows:

root@ubuntu:~# cat /sys/class/thermal/thermal_zone0/available_policies
user_space step_wise

It can be seen that the policies supported by Thermal are: user_space and step_wise

  • user_space: Reports the current temperature of the thermal zone, temperature control trigger points, and other information to user space via uevent, where user-space software formulates the temperature control strategy.

  • step_wise: Increases the cooling state step by step in each polling cycle, a relatively gentle temperature control strategy.

Customers can choose which strategy to use based on the product. It can be specified at compile time or dynamically switched via sysfs. For example: Dynamically switch the policy of thermal_zone0 to user_space mode

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

There are 4 trip_points in thermal_zone0,

  • trip_point_0_temp: Shutdown temperature, default set to 120 degrees
  • trip_point_1_temp: Used to control fan speed, default is 43 degrees, fan gear range 2~5, meaning above 43 degrees, the fan will adjust from off state to gear 2, and can be increased up to gear 5.
  • trip_point_2_temp: Used to control fan speed, default is 65 degrees, fan gear range 6~10, meaning above 65 degrees, the fan will adjust to gear 6, and can be increased up to gear 10 slow speed.
  • trip_point_3_temp: Used to control CPU Acore frequency, default is 95 degrees, meaning above 95 degrees, CPU Acore will downclock. You can view the corresponding temperature settings via sysfs
root@ubuntu:~# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp
120000

If you want to adjust the corresponding temperature, e.g., start CPU frequency scaling at 85 degrees, use the following command:

echo 85000 > /sys/devices/virtual/thermal/thermal_zone0/trip_point_3_temp
Introduction to thermal_zone1/2/3

There is 1 trip_point in thermal_zone1/2/3, all indicating the shutdown temperature, default is 120 degrees.

There are two trip_points in thermal_zone4, where

  • trip_point_0_temp is the shutdown temperature, default is 120 degrees.
  • trip_point_1_temp is the frequency scaling temperature for BPU, default is 95 degrees.

For example, to start BPU frequency scaling when the junction temperature reaches 85 degrees Celsius:

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

If you want to adjust the shutdown temperature to 105 degrees Celsius, you can do so by modifying the trip_point_0_temp of all thermal_zones:

echo 105000 > /sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp
echo 105000 > /sys/devices/virtual/thermal/thermal_zone1/trip_point_0_temp
echo 105000 > /sys/devices/virtual/thermal/thermal_zone2/trip_point_0_temp
echo 105000 > /sys/devices/virtual/thermal/thermal_zone3/trip_point_0_temp
echo 105000 > /sys/devices/virtual/thermal/thermal_zone4/trip_point_0_temp
info

PS: The above settings are only valid for the current boot, and need to be reset after reboot.

Cooling Devices

There are four cooling devices in RDK S100:

  • cooling_device0: cpu cluster 0, controls temperature by adjusting frequency
  • cooling_device1: cpu cluster 1, controls temperature by adjusting frequency
  • cooling_device2: emc2305 fan, controls temperature by adjusting fan speed gear, gears from 0~10, 0 means off, 10 means full fan speed.
  • cooling_device3: bpu, controls temperature by adjusting frequency

Among them, the cooling devices CPU and fan are associated with thermal_zone0, and the cooling device BPU is associated with thermal_zone4. thermal_zone1/2/3 have no cooling devices bound.

Currently, the default strategy used is step_wise.

Fan Adjustment

For the emc2305 fan controller on the RDK S100 development board, you can obtain basic device information and control speed through device nodes:

  1. Get cooling device information:
    root@ubuntu:~# cat /sys/class/thermal/cooling_device2/type
    emc2305_fan
  2. Get configurable fan gears:
    root@ubuntu:~# cat /sys/class/thermal/cooling_device2/max_state
    10
  3. Get current fan gear:
    root@ubuntu:~# cat /sys/class/thermal/cooling_device2/cur_state
    5
  4. Configure the policy of thermal_zone0 to userspace:
    echo user_space > /sys/class/thermal/thermal_zone0/policy
  5. Set the current fan gear to 10:
    root@ubuntu:~# echo 10 > /sys/class/thermal/cooling_device2/cur_state
info

Note: When the policy of thermal_zone0 is step_wise, the fan gear configured by the user will be automatically adjusted by the system based on the current temperature. If customers need to fix the fan to a specific gear, please refer to the Thermal Zone section and change the policy of thermal_zone0 to user_space.

CPU Frequency Management

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

Enter the directory /sys/devices/system/cpu/cpufreq/policy0, and run ls to see the following files in the directory:

affected_cpus						// CPU cores affected by current control (does not show offline cpus)
cpuinfo_cur_freq // Current CPU frequency (unit: KHz)
cpuinfo_max_freq // Highest available CPU frequency under current scaling policy (unit: KHz)
cpuinfo_min_freq // Lowest available CPU frequency under current scaling policy (unit: KHz)
cpuinfo_transition_latency // Time required for the processor to switch frequency (unit: ns)
related_cpus // CPU cores affected by this control policy (includes all online+offline cpus)
scaling_available_frequencies // List of main frequencies supported by the CPU (unit: KHz)
scaling_available_governors // All governor types supported in the current kernel
scaling_cur_freq // Holds the current CPU frequency cached by the cpufreq module, does not check CPU hardware registers.
scaling_driver // Currently used frequency scaling driver
scaling_governor // Governor (frequency scaling) policy
scaling_max_freq // Highest available CPU frequency under current scaling policy (read from cpufreq module cache)
scaling_min_freq // Lowest available CPU frequency under current scaling policy (read from cpufreq module cache)
scaling_setspeed // Requires switching governor to userspace to use; echoing a value into this file switches the frequency

Currently supported frequencies include:

cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies
1500000 2000000

Note: Supported frequency points may vary across different chip types. The Linux kernel used by the RDK S100 system supports the following types of frequency scaling policies:

  • performance: Always keeps the CPU at the highest power consumption and highest performance state, i.e., the highest frequency supported by the hardware.
  • performance: Executes at the highest frequency
  • ondemand: Adjusts frequency based on load
  • userspace: Frequency set by the user
  • powersave: Executes at the lowest frequency
  • schedutil: Adjusts frequency based on load, used in conjunction with the CPU scheduler
  • conservative: Similar to Ondemand, but frequency adjustments are smoother, avoiding sudden shifts to maximum or minimum values

Users can control the CPU frequency scaling policy by manipulating the corresponding settings in the directory /sys/devices/system/cpu/cpu0/cpufreq/.

For example, to run the CPU in performance mode:

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

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

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

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

RDK S600

Temperature Sensors

There are 19 temperature sensors in the RDK S600 chip, used to display the temperatures of BPU/CPU/DDR. Among them, the BPU has 8 temperature sensors, the CPU has 7 temperature sensors, and the DDR has 4 temperature sensors.

Under /sys/class/hwmon/, the hwmon1 directory contains parameters related to the temperature sensors.

  • temp1_input to temp7_input are the CPU temperature sensors, with corresponding labels CMN0-TS[0~6]
  • temp8_input to temp11_input are the DDR temperature sensors, with corresponding labels DDR[0~3]-TS0
  • temp12_input to temp19_input are the BPU temperature sensors, with corresponding labels BPU[03]-TS0[01]

The temperature precision is one-thousandth of a degree Celsius, with a range of -40 to 125 degrees Celsius.

root@ubuntu:~# cat /sys/class/hwmon/hwmon1/temp1_label
CMN0-TS0
root@ubuntu:~# cat /sys/class/hwmon/hwmon1/temp1_input
56339

Above is an example of the first CPU temperature sensor, named 'CMN0-TS0', with a temperature of 56.339 degrees Celsius.

Thermal Mechanism

Linux Thermal is a module related to temperature control under the Linux system, mainly used to control the heat generated by the chip during system operation, keeping the chip temperature and device housing temperature within a safe and comfortable range.

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

  • Temperature acquisition device: Abstracted as Thermal Zone Device in the Thermal framework. There are 19 thermal zones on RDK S600, namely thermal_zone0~thermal_zone18, each bound to 19 temperature sensors;
  • Cooling device: Abstracted as Thermal Cooling Device in the Thermal framework, including CPU, BPU, and fan;
    • CPU/BPU and other devices cool down by frequency scaling;
    • The fan can control its speed to cool down;
  • 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.

Thermal Zone Introduction

To get information about a specific thermal_zone, take thermal_zone0 as an example, the example command is as follows:

root@ubuntu:~# cat /sys/class/thermal/thermal_zone0/type
pvt_cmn_pvtc1_t1

To get the current policy of a specific thermal_zone, take thermal_zone0 as an example, the example command is as follows:

root@ubuntu:~# cat /sys/class/thermal/thermal_zone0/policy
step_wise

To get the supported policies of a specific thermal_zone, take thermal_zone0 as an example, the example command is as follows:

root@ubuntu:~# cat /sys/class/thermal/thermal_zone0/available_policies
user_space step_wise

It can be seen that the policies supported by Thermal are: user_space and step_wise

  • user_space: Reports the current temperature of the thermal zone, temperature control trigger points, and other information to user space via uevent, where user-space software formulates the temperature control strategy.

  • step_wise: Increases the cooling state step by step in each polling cycle, a relatively gentle temperature control strategy.

Customers can choose which strategy to use based on the product. It can be specified at compile time or dynamically switched via sysfs. For example: Dynamically switch the policy of thermal_zone0 to user_space mode

echo user_space > /sys/class/thermal/thermal_zone0/policy
Introduction to CPU thermal_zone

CPU thermal_zones include thermal_zone0 to thermal_zone6.

There are 5 trip_points in thermal_zone2,

  • trip_point_0_temp: Used to control fan speed, default is 45 degrees, fan gear range 2~5, meaning above 45 degrees, the fan will adjust from off state to gear 2, and can be increased up to gear 5.
  • trip_point_1_temp: Used to control fan speed, default is 65 degrees, fan gear range 6~10, meaning above 65 degrees, the fan will adjust to gear 6, and can be increased up to gear 10 speed.
  • trip_point_2_temp: Used to control CPU Acore frequency, default is 95 degrees, meaning above 95 degrees, CPU Acore will downclock.
  • trip_point_3_temp: hot temperature, default set to 110 degrees, meaning above 110 degrees, the system issues a hot warning.
  • trip_point_4_temp: Shutdown temperature, default set to 115 degrees, meaning above 115 degrees, the system will shut down.

You can view the corresponding temperature settings via sysfs

root@ubuntu:~# cat /sys/class/thermal/thermal_zone2/trip_point_0_temp
45000

If you want to adjust the corresponding temperature, e.g., start CPU frequency scaling at 85 degrees, use the following command:

echo 85000 > /sys/class/thermal/thermal_zone2/trip_point_2_temp

Other thermal_zones have 1 trip_point, all indicating the shutdown temperature, default is 115 degrees.

Introduction to DDR thermal_zone

DDR thermal_zones include thermal_zone7 to thermal_zone10.

There are 2 trip_points in the thermal_zone,

  • trip_point_0_temp: hot temperature, default set to 110 degrees, meaning above 110 degrees, the system issues a hot warning.
  • trip_point_1_temp: Shutdown temperature, default set to 115 degrees, meaning above 115 degrees, the system will shut down.
Introduction to BPU thermal_zone

BPU thermal_zones include thermal_zone11 to thermal_zone18.

There are 5 trip_points in thermal_zone16, where

  • trip_point_0_temp: Used to control fan speed, default is 45 degrees, fan gear range 2~5, meaning above 45 degrees, the fan will adjust from off state to gear 2, and can be increased up to gear 5.
  • trip_point_1_temp: Used to control fan speed, default is 65 degrees, fan gear range 6~10, meaning above 65 degrees, the fan will adjust to gear 6, and can be increased up to gear 10 speed.
  • trip_point_2_temp: Used to control BPU frequency, default is 95 degrees, meaning above 95 degrees, the BPU will downclock.
  • trip_point_3_temp: hot temperature, default set to 110 degrees, meaning above 110 degrees, the system issues a hot warning.
  • trip_point_4_temp: Shutdown temperature, default set to 115 degrees, meaning above 115 degrees, the system will shut down.

For example, to start BPU frequency scaling when the junction temperature reaches 85 degrees Celsius:

echo 85000 > /sys/class/thermal/thermal_zone16/trip_point_2_temp

Other thermal_zones have 1 trip_point, all indicating the shutdown temperature, default is 115 degrees.

If you want to adjust the shutdown temperature to 105 degrees Celsius, you can do so by modifying the trip_point_0_temp of all thermal_zones:

echo 105000 > /sys/class/thermal/thermal_zone0/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone1/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone2/trip_point_4_temp
echo 105000 > /sys/class/thermal/thermal_zone3/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone4/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone5/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone6/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone7/trip_point_1_temp
echo 105000 > /sys/class/thermal/thermal_zone8/trip_point_1_temp
echo 105000 > /sys/class/thermal/thermal_zone9/trip_point_1_temp
echo 105000 > /sys/class/thermal/thermal_zone10/trip_point_1_temp
echo 105000 > /sys/class/thermal/thermal_zone11/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone12/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone13/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone14/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone15/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone16/trip_point_4_temp
echo 105000 > /sys/class/thermal/thermal_zone17/trip_point_0_temp
echo 105000 > /sys/class/thermal/thermal_zone18/trip_point_0_temp
info

PS: The above settings are only valid for the current boot, and need to be reset after reboot.

Cooling Devices

There are 11 cooling devices in RDK S600:

  • cooling_device0: cpu cluster 0, controls temperature by adjusting frequency
  • cooling_device1: cpu cluster 1, controls temperature by adjusting frequency
  • cooling_device2: cpu cluster 2, controls temperature by adjusting frequency
  • cooling_device3: cpu cluster 3, controls temperature by adjusting frequency
  • cooling_device4: cpu cluster 4, controls temperature by adjusting frequency
  • cooling_device5: emc2305 fan, controls temperature by adjusting fan speed gear, gears from 0~10, 0 means off, 10 means full fan speed.
  • cooling_device6: emc2305 fan, controls temperature by adjusting fan speed gear, gears from 0~10, 0 means off, 10 means full fan speed.
  • cooling_device7: bpu core 0, controls temperature by adjusting frequency
  • cooling_device8: bpu core 1, controls temperature by adjusting frequency
  • cooling_device9: bpu core 2, controls temperature by adjusting frequency
  • cooling_device10: bpu core 3, controls temperature by adjusting frequency

Currently, the default strategy used is step_wise.

Fan Adjustment

For the emc2305 fan controller on the RDK S600 development board, you can obtain basic device information and control speed through device nodes:

  1. Get cooling device information:
    root@ubuntu:~# cat /sys/class/thermal/cooling_device5/type
    emc2305_fan
  2. Get configurable fan gears:
    root@ubuntu:~# cat /sys/class/thermal/cooling_device5/max_state
    10
  3. Get current fan gear:
    root@ubuntu:~# cat /sys/class/thermal/cooling_device5/cur_state
    5
  4. Configure the policy of thermal_zone2 to userspace:
    # thermal_zone2 and thermal_zone16 will control the fan
    echo user_space > /sys/class/thermal/thermal_zone2/policy
    echo user_space > /sys/class/thermal/thermal_zone16/policy
  5. Set the current fan gear to 10:
    root@ubuntu:~# echo 10 > /sys/class/thermal/cooling_device5/cur_state
info

Note: When the policy of thermal_zone2 or thermal_zone16 is step_wise, the fan gear configured by the user will be automatically adjusted by the system based on the current temperature. If customers need to fix the fan to a specific gear, please refer to the Thermal Zone section and change the policy of thermal_zone2 and thermal_zone16 to user_space.

CPU Frequency Management

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

Enter the directory /sys/devices/system/cpu/cpufreq/policy0, and run ls to see the following files in the directory:

affected_cpus						// CPU cores affected by current control (does not show offline cpus)
cpuinfo_cur_freq // Current CPU frequency (unit: KHz)
cpuinfo_max_freq // Highest available CPU frequency under current scaling policy (unit: KHz)
cpuinfo_min_freq // Lowest available CPU frequency under current scaling policy (unit: KHz)
cpuinfo_transition_latency // Time required for the processor to switch frequency (unit: ns)
related_cpus // CPU cores affected by this control policy (includes all online+offline cpus)
scaling_available_frequencies // List of main frequencies supported by the CPU (unit: KHz)
scaling_available_governors // All governor types supported in the current kernel
scaling_cur_freq // Holds the current CPU frequency cached by the cpufreq module, does not check CPU hardware registers.
scaling_driver // Currently used frequency scaling driver
scaling_governor // Governor (frequency scaling) policy
scaling_max_freq // Highest available CPU frequency under current scaling policy (read from cpufreq module cache)
scaling_min_freq // Lowest available CPU frequency under current scaling policy (read from cpufreq module cache)
scaling_setspeed // Requires switching governor to userspace to use; echoing a value into this file switches the frequency

Currently supported frequencies include:

cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies
525000 1050000 2100000

Note: Supported frequency points may vary across different chip types. The Linux kernel used by the RDK S600 system supports the following types of frequency scaling policies:

  • performance: Always keeps the CPU at the highest power consumption and highest performance state, i.e., the highest frequency supported by the hardware.
  • performance: Executes at the highest frequency
  • ondemand: Adjusts frequency based on load
  • userspace: Frequency set by the user
  • powersave: Executes at the lowest frequency
  • schedutil: Adjusts frequency based on load, used in conjunction with the CPU scheduler
  • conservative: Similar to Ondemand, but frequency adjustments are smoother, avoiding sudden shifts to maximum or minimum values

Users can control the CPU frequency scaling policy by manipulating the corresponding settings in the directory /sys/devices/system/cpu/cpu0/cpufreq/.

For example, to run the CPU in performance mode:

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

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

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

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