Skip to main content

2.4 Thermal and CPU Frequency Management

RDK S100

Temperature Sensors

The RDK S100 chip contains five temperature sensors to monitor temperatures of the MCU domain, BPU, and MAIN domain. Specifically, both the MAIN domain and the MCU domain each have two temperature sensors, while the BPU has one.

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

  • temp1_input corresponds to the first temperature sensor in the MAIN domain, and temp2_input corresponds to the second temperature sensor in the MAIN domain.
  • temp3_input corresponds to the first temperature sensor in the MCU domain, and temp4_input corresponds to the second temperature sensor in the MCU domain.
  • temp5_input corresponds to the BPU temperature sensor.

Temperature readings have a precision of 0.001 degrees Celsius.

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

Thermal Mechanism

Linux Thermal is a kernel module responsible for temperature control in Linux systems. Its primary purpose is to manage heat generated by the chip during system operation, keeping both chip and device casing temperatures within a safe and comfortable range.

To achieve effective thermal management, we need to understand the following three components:

  • Temperature-sensing devices: Abstracted in the Thermal framework as Thermal Zone Devices. The RDK S100 has five thermal zones (thermal_zone0 to thermal_zone4), each associated with one of the five temperature sensors.
  • Cooling devices: Abstracted in the Thermal framework as Thermal Cooling Devices, which include the CPU, BPU, and fan:
    • Devices like the CPU and BPU reduce temperature by adjusting their operating frequencies.
    • The fan reduces temperature by controlling its rotational speed.
  • Thermal control policies: Abstracted in the Thermal framework as Thermal Governors.

Information and controls for all these components are accessible under the /sys/class/thermal directory.

Introduction to Thermal Zones

To retrieve information about a specific thermal zone (e.g., thermal_zone0), use the following command:

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

To check the current policy of a thermal zone (e.g., thermal_zone0):

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

To view the policies supported by a thermal zone (e.g., thermal_zone0):

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

The supported policies are:

  • user_space: Reports the current zone temperature and trip point information to userspace via uevent, allowing userspace software to implement its own thermal policy.
  • step_wise: Gradually increases cooling levels each polling cycle, providing a relatively gentle thermal control strategy.

Customers can choose the appropriate policy based on their product requirements. Policies can be specified at compile time or dynamically switched via sysfs.
For example, to dynamically switch thermal_zone0 to user_space mode:

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

thermal_zone0 contains four trip points:

  • trip_point_0_temp: Shutdown temperature, defaulting to 120°C.
  • trip_point_1_temp: Controls fan speed, defaulting to 43°C. Fan levels range from 2 to 5—exceeding 43°C causes the fan to switch from off to level 2, with a maximum of level 5.
  • trip_point_2_temp: Controls fan speed, defaulting to 65°C. Fan levels range from 6 to 10—exceeding 65°C sets the fan to level 6, with a maximum of level 10 (lower speed).
  • trip_point_3_temp: Controls CPU A-core frequency, defaulting to 95°C—exceeding this temperature triggers CPU frequency scaling.

You can view these temperature settings via sysfs:

root@ubuntu:~# cat /sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp
120000

To adjust, for example, the CPU frequency scaling threshold to 85°C:

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

Each of thermal_zone1, thermal_zone2, and thermal_zone3 has one trip point, all representing the shutdown temperature (default: 120°C).

thermal_zone4 has two trip points:

  • trip_point_0_temp: Shutdown temperature, defaulting to 120°C.
  • trip_point_1_temp: BPU frequency scaling temperature, defaulting to 95°C.

For example, to start BPU frequency scaling at a junction temperature of 85°C:

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

To change the shutdown temperature to 105°C, update trip_point_0_temp for 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

Note: The above settings are only effective for the current boot session. They must be reapplied after reboot.

Cooling Devices

The RDK S100 includes four cooling devices:

  • cooling_device0: CPU cluster 0, cools by adjusting frequency.
  • cooling_device1: CPU cluster 1, cools by adjusting frequency.
  • cooling_device2: emc2305 fan, cools by adjusting fan speed levels (0–10; 0 = off, 10 = full speed).
  • cooling_device3: BPU, cools by adjusting frequency.

The CPU and fan cooling devices are associated with thermal_zone0, while the BPU cooling device is associated with thermal_zone4. thermal_zone1/2/3 are not bound to any cooling devices.

The default policy currently in use is step_wise.

Fan Control

The emc2305 fan controller on the RDK S100 development board allows retrieval of device information and speed control via device nodes:

  1. Get cooling device type:
    root@ubuntu:~# cat /sys/class/thermal/cooling_device2/type
    emc2305_fan
  2. Check configurable fan levels:
    root@ubuntu:~# cat /sys/class/thermal/cooling_device2/max_state
    10
  3. Check current fan level:
    root@ubuntu:~# cat /sys/class/thermal/cooling_device2/cur_state
    5
  4. Set thermal_zone0 policy to user_space:
    echo user_space > /sys/class/thermal/thermal_zone0/policy
  5. Set current fan level to 10:
    root@ubuntu:~# echo 10 > /sys/class/thermal/cooling_device2/cur_state
info

Note: When thermal_zone0 uses the step_wise policy, the system automatically adjusts the fan level based on temperature. If you need to fix the fan at a specific level, refer to the Thermal Zone section and switch the policy to user_space.

CPU Frequency Management

The Linux kernel includes the cpufreq subsystem to manage CPU frequency and frequency scaling policies.

Navigate to /sys/devices/system/cpu/cpufreq/policy0 and list its contents to see the following files:

affected_cpus						// CPU cores affected by current policy (excludes offline CPUs)
cpuinfo_cur_freq // Current CPU frequency (unit: kHz)
cpuinfo_max_freq // Maximum CPU frequency available under current policy (unit: kHz)
cpuinfo_min_freq // Minimum CPU frequency available under current policy (unit: kHz)
cpuinfo_transition_latency // Time required for the processor to switch frequencies (unit: ns)
related_cpus // All CPU cores affected by this policy (including both online and offline CPUs)
scaling_available_frequencies // List of CPU-supported frequencies (unit: kHz)
scaling_available_governors // All frequency scaling governors supported by the current kernel
scaling_cur_freq // Current CPU frequency cached by the cpufreq module (does not read hardware registers)
scaling_driver // Current frequency scaling driver in use
scaling_governor // Current frequency scaling governor (policy)
scaling_max_freq // Maximum CPU frequency under current policy (read from cpufreq module cache)
scaling_min_freq // Minimum CPU frequency under current policy (read from cpufreq module cache)
scaling_setspeed // Only usable when governor is set to 'userspace'; writing a value here sets the CPU 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 in the RDK S100 system supports the following CPU frequency scaling governors:

  • performance: Always runs the CPU at the highest supported frequency (maximum performance and power consumption).
  • ondemand: Dynamically adjusts frequency based on system load.
  • userspace: Allows users to manually set the CPU frequency.
  • powersave: Runs the CPU at the lowest supported frequency.
  • schedutil: Adjusts frequency based on load, tightly integrated with the CPU scheduler.
  • conservative: Similar to ondemand, but changes frequency more gradually to avoid abrupt jumps between min and max frequencies.

Users can control CPU frequency scaling by modifying settings under /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 lock the CPU to a fixed frequency (e.g., 1.5 GHz):

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 check the current chip's operating frequency, temperature, and other status information: