How To Control The Fan Behavior Manually

  • Operation confirmed with testing in our Ubuntu Minimal on kernel 4.14.32.
  • This guide helps from our forum[1][2].

ODROID XU4 supports 3 cooling levels for thermal control, 0, 1, 2.
Level 0, which is the lowest level for thermal control and comes with the slowest fan speed.
And level 2, which is the highest level for thermal control and comes with the fastest fan speed.

Refer to this table.

Trip point - 0 1 2
Temperature 0 60°C 70°C 80°C
Fan speed 0 120 180 240

This tables shows the default values that how the fan behaves. As this table shows, 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).
In the same vein, the target trip point will be level 3 and the fan runs at 240 PWM value when the temperature reaches to 80°C.

You can adjust the target trip points and its each fan speed as you want.
And even you can fix the fan speed at the constant speed you set.

You can check current trip points.

$ 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 there're the other trip points named 3, 4, 5. But you can ignore them that we don't use. Same on thermal_zone4.
As we can see, each trip point at each thermal zone has same value 60000, 70000, 80000. That means each trip point is activated on 60°C, 70°C, 80°C.

Each trip point is editable by writing a custom value to the each trip point files set.
For example, if you want to set trip point 1 to be activated at 30°C, you can just write a value on them.

$ 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 the following codes and paste.

# 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 check if the changes applied.

  • You always have to reboot to apply the changed fan speed for now.

You can check current fan speed scaling.

$ cat /sys/devices/platform/pwm-fan/hwmon/hwmon0/fan_speed
# results
0 120 180 240

You can adjust these values by writing value set to the file.
If you want to make your fan more aggressively, you can write like below.

$ echo "0 204 220 240" | sudo tee /sys/devices/platform/pwm-fan/hwmon/hwmon0/fan_speed
# results
0 204 220 240

This makes fan turns on to 80% (204 == 80 * 255 * 0.01) when the temperature reaches to trip point 0.

And when the fan speed is set newly, its kernel message shows up and you can find out by dmesg command.

$ dmesg
# results
...
[ 1998.019631] hwmon hwmon0: fan_speeds : set_fan_speed [0 204 220 240]

If you want to do that automatically, write some code in the /etc/rc.local file.
Copy below and paste.

# 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 applied.

You don't have to stress your ODROID out to test the new settings.

Check 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 can set the any temperature value to cover the real temperature on the board and finally it makes the fan runs by the settings.

If you want to set to 85°C, just write to them.

$ echo 85000 | sudo tee /sys/devices/virtual/thermal/thermal_zone{0,1,2,3}/emul_temp
# results
85000

And check if the changes affect.

$ cat /sys/devices/virtual/thermal/thermal_zone{0,1,2,3}/temp
# results
85000
85000
85000
85000

So easy. If you want to get back to normal, write 0 on them.

$ echo 0 | sudo tee /sys/devices/virtual/thermal/thermal_zone{0,1,2,3}/emul_temp
# results
0

And check.

$ 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 settings you've just set both the trip points and the fan speed scaling.

  • This requires kernel 4.14.20 or higher.

Most programmatically method to adjust fan speed in totally 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

Then the fan ignores written scaling files(trip points and fan speed) and runs constantly at the same speed.

You can do that automatically too. Edit /etc/rc.local file and reboot to check if the changes applied.
This example makes the fan always runs in 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

Or you can write an application using the fan.