Fan control for Odroid XU4
The odroid fan driver uses pulse width modulation (PWM) to control the speed of the fan, with the PWM duty cycle adjusted based on the temperature of the CPU.
On 3.10.x kernel
The driver has four speed settings, which it selects among based on three temperature settings. So, if the current CPU temp is below the lowest temperature setting it uses the first fan speed, if between the first and second temperature settings it uses the second fan speed, if between the second and third temperature settings it uses the third fan speed, and if greater than the third temperature setting it uses the fourth fan speed.
There are a number of settings in /sysfs for the odroid-fan driver.
On the Odroid-XU4 this is under /sys/devices/odroid_fan.13, while on the Odroid-XU3 it is /sys/devices/odroid_fan.14.
# fan_mode : Auto or Manual (set to 1 for auto and 0 for manual, default Auto) # fan_speeds : Four space delimited fan speed percentage values, in ascending order. (default "1 51 71 91") # pwm_duty : Current setting of the PWM duty cycle (0-255, set dynamically) # pwm_enable : On or off (default on) # temp_levels : Three space delimited CPU Celsius temperature values, in ascending order (default "57 63 68")
Control CPU fan
With the help of temp_level and fan_speed we could update the duty cycle of the PMW for cpu-fan.
sudo echo "1 20 50 95" > /sys/devices/odroid_fan.13/fan_speeds sudo echo "50 70 80" > /sys/devices/odroid_fan.13/temp_levels
Alternate way to create udev rule by creating a file in /etc/udev/rules.d/60-odroid_fan.rules which control pmw-fan.
DRIVER=="odroid-fan", ACTION=="add", ATTR{fan_speeds}="1 20 50 95", ATTR{temp_levels}="50 70 80"
On 4.9.x Kernel
On Odroid 4.x we could control the cpu fan speed and temperature control by registration with themal-zone via dts.
pwm-fan module will update the duty cycle value with variation of temperature as it reaches close to trip point. As the thermal sensors reached the trip point which triggers change in duty cycle.
Odroid dts change cannot be changes so we have modified the driver to change the cooling level.
sudo echo "0 175 210 255" > /sys/class/hwmon/hwmon0/fan_speed
range should be between [0 ~ 255]
Note: for permanent changes you can append the above in /etc/rc.local