Fan Control: Tailor the ODROID-XU4 To Your Perfect Settings

The ODROID-XU4 supports 3 cooling levels for the thermal control: 0, 1, 2. Level 0 is the lowest level for thermal control and comes with the slowest fan speed. Level 2 is the highest level for thermal control and comes with the fastest fan speed, as shown in the following table:

This table shows the default values for how the fan behaves. When the temperature reaches to 60°C, the target trip point will be changed to level 1 and the fan starts to run at 120 PWM value (0~255). The same idea holds for when the target trip point will be level 3, the fan runs at 240 PWM value when the temperature reaches to 80°C. You can adjust the target trip points and its fan speed to be any values you want. You can even set the fan speed to be constant.

Modify the trip points

You can check current trip points via the command prompt.

$ cat /sys/devices/virtual/thermal/thermal_zone{0,1,2,3}/trip_point_{0,1,2}_temp
# results
60000
70000
80000
60000
70000
80000
60000
70000
80000
60000
70000
80000
Yes, they’re the other trip points named 3, 4, 5. But, you can ignore them as we don’t use them. Same with thermal_zone4. As we can see, each trip point at each thermal zone has the same value 60000, 70000, 80000. That means each trip point is activated at 60°C, 70°C, 80°C. Each trip point is editable by writing a custom values to the each trip point files. For example, if you want to set trip point 1 to be activated at 30°C, you can just write a value for it.
$ echo 30000 | sudo tee /sys/devices/virtual/thermal/thermal_zone{0,1,2,3}/trip_point_0_temp
$ cat /sys/devices/virtual/thermal/thermal_zone{0,1,2,3}/trip_point_0_temp
# results
30000
30000
30000
30000
Then the fan starts spinning up at 30°C. If you want to do that automatically, write some code in the /etc/rc.local file. Copy and paste the following code:
# Target temperature: 30°C, 50°C, 70°C
TRIP_POINT_0=30000
TRIP_POINT_1=50000
TRIP_POINT_2=70000
 
echo $TRIP_POINT_0 > /sys/devices/virtual/thermal/thermal_zone0/trip_point_0_temp
echo $TRIP_POINT_0 > /sys/devices/virtual/thermal/thermal_zone1/trip_point_0_temp
echo $TRIP_POINT_0 > /sys/devices/virtual/thermal/thermal_zone2/trip_point_0_temp
echo $TRIP_POINT_0 > /sys/devices/virtual/thermal/thermal_zone3/trip_point_0_temp
 
echo $TRIP_POINT_1 > /sys/devices/virtual/thermal/thermal_zone0/trip_point_1_temp
echo $TRIP_POINT_1 > /sys/devices/virtual/thermal/thermal_zone1/trip_point_1_temp
echo $TRIP_POINT_1 > /sys/devices/virtual/thermal/thermal_zone2/trip_point_1_temp
echo $TRIP_POINT_1 > /sys/devices/virtual/thermal/thermal_zone3/trip_point_1_temp
 
echo $TRIP_POINT_2 > /sys/devices/virtual/thermal/thermal_zone0/trip_point_2_temp
echo $TRIP_POINT_2 > /sys/devices/virtual/thermal/thermal_zone1/trip_point_2_temp
echo $TRIP_POINT_2 > /sys/devices/virtual/thermal/thermal_zone2/trip_point_2_temp
echo $TRIP_POINT_2 > /sys/devices/virtual/thermal/thermal_zone3/trip_point_2_temp
Reboot and verify that the changes have been applied.

Modify The Fan Speed

You can check current fan speed scaling with the following command:

$ cat /sys/devices/platform/pwm-fan/hwmon/hwmon0/fan_speed
# results
0 120 180 240
You can adjust these values by writing a set value to the file. If you want to make your fan more aggressive, you can use the following command:
$ echo "0 204 220 240" | sudo tee /sys/devices/platform/pwm-fan/hwmon/hwmon0/fan_speed
# results
0 204 220 240
This makes a fan turn on to 80% (204 == 80 * 255 * 0.01) when the temperature reaches to trip point 0. When the fan speed is newly set, its kernel message shows up and you can find out by using the dmesg command:
$ dmesg
# results
...
[ 1998.019631] hwmon hwmon0: fan_speeds : set_fan_speed [0 204 220 240]
If you want to do that automatically, copy and paste the following lines into the /etc/rc.local file:
# Target fan speed (PWM): 0, 204, 220, 240
echo "0 204 220 240" > /sys/devices/platform/pwm-fan/hwmon/hwmon0/fan_speed
Reboot and check if the changes were applied.

Emulate Temperature

You don’t have to stress your ODROID out to test the new settings. The fan settings can be checked with these files.

$ ls -l /sys/devices/virtual/thermal/thermal_zone{0,1,2,3}/emul_temp
# results
--w------- 1 root root 4096 Apr 11 01:55 /sys/devices/virtual/thermal/thermal_zone0/emul_temp
--w------- 1 root root 4096 Apr 11 02:05 /sys/devices/virtual/thermal/thermal_zone1/emul_temp
--w------- 1 root root 4096 Apr 11 02:05 /sys/devices/virtual/thermal/thermal_zone2/emul_temp
--w------- 1 root root 4096 Apr 11 02:05 /sys/devices/virtual/thermal/thermal_zone3/emul_temp
These writable files let us fake any temperature value to cover the real temperature on the board and finally it makes the fan run with the settings. If you want to set to 85°C, just write it.
$ echo 85000 | sudo tee /sys/devices/virtual/thermal/thermal_zone{0,1,2,3}/emul_temp
# results
85000
Verify if the changes took effect:
$ cat /sys/devices/virtual/thermal/thermal_zone{0,1,2,3}/temp
# results
85000
85000
85000
85000
If you want to get back to normal, write 0:
$ echo 0 | sudo tee /sys/devices/virtual/thermal/thermal_zone{0,1,2,3}/emul_temp
# results
0 
$ cat /sys/devices/virtual/thermal/thermal_zone{0,1,2,3}/temp
# results
30000
30000
30000
29000
This would be helpful for you to check the new fan speed and trip point settings you’ve just set.

Fully manual way to control the fan speed

This is the most programmatic method to adjust the fan speed in a manual way:

# Set fan to manual mode
$ echo 0 | sudo tee /sys/devices/platform/pwm-fan/hwmon/hwmon0/automatic
 
# Set speed to 100%
$ echo 255 | sudo tee /sys/devices/platform/pwm-fan/hwmon/hwmon0/pwm1
The fan ignores written scaling files (trip points and fan speed) and runs constantly at the same speed, you can do this automatically too. Edit the /etc/rc.local file and reboot to check if the changes applied. The following example makes the fan always run at full speed:
# Fix fan speed
echo 0 | sudo tee /sys/devices/platform/pwm-fan/hwmon/hwmon0/automatic
echo 255 | sudo tee /sys/devices/platform/pwm-fan/hwmon/hwmon0/pwm1
Additionally, you can write an application using the fan.

Fan control script examples

There are some nice script code examples you have to refer. https://forum.odroid.com/viewtopic.php?f=77&t=30743 https://forum.odroid.com/viewtopic.php?f=146&t=30745

References

https://forum.odroid.com/viewtopic.php?f=52&t=16308 https://forum.odroid.com/viewtopic.php?f=99&t=30675

The original text can be found on the ODROID wiki page for manually controlling the ODROID-XU4 fan at https://wiki.odroid.com/odroid-xu4/application_note/manually_control_the_fan#fully_manual_way_to_control_the_fan_speed.

Be the first to comment

Leave a Reply