How to control ODROID-XU4 Cooling fan

ODROID-XU4 CPU has four 2Ghz big cores and four 1.4Ghz LITTLE cores.

It also has six GPU cores as well as 2GByte DRAM on the SoC with a package on package(PoP) process.

So this tiny SoC power consumption can be up to 10 Watt and it generates a lot of heat.
Therefore, we had to attach a cooling fan to the SoC to minimize the thermal throttling.
Exa_fan_comvec_cmyk_300.jpg
 
Once the system boots, the cooling fan runs at full speed by the u-boot(bootloader) initialization code.
When the Linux Kernel runs, the thermal management driver controls the fan speed automatically.
There are three threshold points 60°C, 70°C and 80°C.

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





The fan speed value is connected to 8bit(0~255) PWM control register.

When the SoC temperature is lower than 60°C, the fan doesn’t rotate.

If you need to adjust the temperature threshold values, just modify the thermal control nodes in sysfs.

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 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 well or not.

If you want to change the fan speed values in trip points, modify this system node.

/sys/devices/platform/pwm-fan/hwmon/hwmon0/fan_speed

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

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

# Target fan speed (PWM): 0, 204, 220, 240
echo "0 204 220 240" > /sys/devices/platform/pwm-fan/hwmon/hwmon0/fan_speed

You can also control the fan speed fully manually.

# 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

 

If you need further information, refer this WiKi page.
https://wiki.odroid.com/odroid-xu4/application_note/manually_control_the_fan#fully_manual_way_to_control_the_fan_speed