[HOWTO] Control automatic fan settings on XU3/XU4

Moderators: odroid, meveric, mdrjr

[HOWTO] Control automatic fan settings on XU3/XU4

Unread postby Grotus » Tue Sep 22, 2015 7:29 am

There are a lot of postings about the fan in the forums and some workarounds like a script that slows it down. I don't think that the workarounds are all that necessary, if the proper configuration is done. So, this is my attempt to document the fan settings.

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. 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 XU4 this is under /sys/devices/odroid_fan.13, while on the XU3 it is /sys/devices/odroid_fan.14.
The settings are:
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 Celcius temperature values, in ascending order (default "57 63 68")

There are two places to get the CPU temperature in sysfs, /sys/devices/10060000.tmu/temp and /sys/devices/virtual/thermal/thermal_zone0/temp. The first is readable only by root or a user in group root. It shows the temperatures of five sensors. The second is readable by all and gives a single temperature. In both cases, the temperatures are in milli-degrees Celsius (so divide by 1000 to get Celsius). The highest of the values in /sys/devices/10060000.tmu/temp is used to control the fan speed.

The fan speed settings are specified in percent, so should be in the range 0-100. The PWM duty cycle is specified in the range 0-255, and in automatic mode is calculated by multiplying the fan speed setting by 255 and dividing by 100. For example, in the default case, when the temperature hits 57 degrees it turns the fan on to 51%, which equals a PWM duty cycle of 51*255/100 = 130.

The fan-control script works by setting the fan_mode to manual and changing the pwm_duty to the desired value based on the temperature. The script has 9 fan levels defined as opposed to the 4 in the odroid-fan driver.

In order to configure the automatic mode for the fan, you can echo new settings to the fan_speeds and temp_levels settings. These settings will take effect immediately.

Here is an example to make the fan turn on to 20% at 50C, go up to 50% at 70C, and up to 95% at 80C on the Odroid XU4
Code: Select all
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


Setting the values in this way will not persist over a reboot. To get your settings applied at boot time, you can set a rule for udev, by creating a file in /etc/udev/rules.d with the desired settings, I used 60-odroid_fan.rules as the name on my system. The following should work on either an XU3 or XU4 as it matches based on the driver name of odroid-fan rather than the kernel name which is different in the two versions:
Code: Select all
DRIVER=="odroid-fan", ACTION=="add", ATTR{fan_speeds}="1 20 50 95", ATTR{temp_levels}="50 70 80"
Grotus
 
Posts: 2
Joined: Tue Sep 22, 2015 5:55 am
languages_spoken: english
ODROIDs: XU4

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby mdrjr » Wed Sep 23, 2015 6:59 pm

That's Amazing. Thanks for sharing...
mdrjr
Site Admin
 
Posts: 11695
Joined: Fri Feb 22, 2013 11:34 pm
Location: Brazil
languages_spoken: english, portuguese
ODROIDs: -

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby mad_ady » Tue Sep 29, 2015 2:03 am

I need to try this on, but at what speed is the fan still inaudible?
User avatar
mad_ady
 
Posts: 4931
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby gripped » Tue Sep 29, 2015 2:16 am

@Grotus
I missed this when you first posted it and I'm glad to have seen it now.
That is one hell of a first post and I'm looking forward to your 2nd. :)
gripped
 
Posts: 691
Joined: Tue May 21, 2013 11:34 pm
languages_spoken: english
ODROIDs: U2 XU U3 XU3

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby Grotus » Tue Oct 06, 2015 1:14 am

@mad_ady: How audible it is depends on you and your setting. So, you should try out settings by echo'ing them to /sys/devices/odroid_fan.13/fan_speeds until you find what works for you. The second setting is the most important for quiet during mostly idle times. If you end up setting it too low, the fan won't be able to overcome static friction and will make an awful whining sound. Just bump the setting back up so that it can spin.

My fan seems to stick at a settings below 27%, but each fan probably will have its own sticking point. Mine will spin from 27 to 29, but starts with a little chirp, much like a smoke detector with a low battery. So, I have my second fan_speed setting at 30.

You could follow two strategies, start low and go up to find the minimum setting where the fan doesn't stick or chirp, or start high and go down until the fan no longer bothers you. Once you find the setting you like, stick it in the .rules file to make it persistent.

Next up for me is experimenting with the governor to see how that effects temperatures at idle.
Grotus
 
Posts: 2
Joined: Tue Sep 22, 2015 5:55 am
languages_spoken: english
ODROIDs: XU4

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby mad_ady » Tue Oct 06, 2015 2:08 am

Thanks. I noticed the whining sound at low RPM as well. Keep us posted on what you find about governors/max frequencies. With powersave and max frequency of 600MHz I managed to keep the system aroud 55 degrees while idle. Also, fan didn't start too often with your thresholds while compiling.
User avatar
mad_ady
 
Posts: 4931
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby marndra » Sat Oct 31, 2015 4:20 pm

Hello,

yes all nice explained, but why catching all the Linux user and leaving the Androids'?

I have the hardkernel Android 4.4.4 installed and for that your totorial do not help.
I do not have the fan_speed file and also not the temp_levels.

How can we manage and change that anoying spinning sound?
marndra
 
Posts: 10
Joined: Wed Oct 21, 2015 2:39 pm
languages_spoken: german, english
ODROIDs: XU4, eMMC64GB
Android 4.4.4
all from Pollin Germany

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby thachnb » Sun Nov 01, 2015 11:25 pm

This topic must be pinned or added to the Must-Read guide.

Here is my setting for avoiding smoke detector sound

DRIVER=="odroid-fan",
ACTION=="add", ATTR{fan_speeds}="1 2 30 50 95",
ATTR{temp_levels}="40 70 80"

Basically the fan wil always spinning due to my odroid tem is 45-55, i dont want the fan restart too often
thachnb
 
Posts: 11
Joined: Fri Jul 17, 2015 4:31 pm
languages_spoken: english
ODROIDs: C1 XU3

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby ddloeb » Tue Nov 03, 2015 1:52 am

Dear Sir,

Thank you with respect for excellent tutorial to control fan speed and audible sound based on speed. It is very helpful in my location. I found this post because of the excellent article in October 2015 Odroid Magazine written by yourself. Thank you very much for the same.

May I respectfully bring to notice that there is small error in Odroid Magazine. Because "/sys/devices/ODROID_ fan.13" is wrong misprint and I could not find it until I see this very helpful forum post that the correct directory is "/sys/devices/odroid_fan.13". I am weak in Odroid, but maybe others will find the same confusion as me, so can the wrong directory misprint in Odroid Magazine be considered for correction.

Sincerely, with best wishes,
Dan
ddloeb
 
Posts: 21
Joined: Wed Oct 14, 2015 1:07 am
Location: New Orleans
languages_spoken: english, mandarin chinese, french, vietnamese
ODROIDs: odroid xu4

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby DavidTangye » Thu Nov 12, 2015 12:41 am

The key temperature in the 'ATTR{temp_levels}="40 60 80"' is the first one, since the fan should normally come on and drop the temperature to just below this point.

So my question is "What is the recommended temperature to run an XU4 at?" Presumably they will die quicker the higher temperature they are run at?
User avatar
DavidTangye
 
Posts: 56
Joined: Thu May 16, 2013 10:50 pm
Location: Gold Coast, Queensland, Australia
languages_spoken: english
ODROIDs: Currently running XU4 as my desktop
Also had a U2, U3, XU3-Lite (it broke), and 10 * C1's in the past.

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby tk501 » Thu Dec 17, 2015 8:13 am

Great thread, thanks.

Is there also information somewhere on how to control the fan manually?

The reason is I would like to turn the fan on just prior to starting the high load portion of my application even before the temp rises.

I can do this via a script or a c++ program, whatever is recommended.
tk501
 
Posts: 124
Joined: Thu Dec 26, 2013 3:57 am
languages_spoken: english
ODROIDs: C1+

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby mad_ady » Thu Dec 17, 2015 4:18 pm

There's a script and a support thread that manually takes over your FAN settings and controls RPM: https://github.com/nthx/odroid-xu3-fan- ... control.sh
User avatar
mad_ady
 
Posts: 4931
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby tk501 » Thu Dec 17, 2015 8:38 pm

Thank you for the link to the manual program.

My default settings were different in tow areas:

pwm_duty 2 - a number this low does not make sense to me given the initial post - any comments to assist as planning to change to default noted in post?

temp_levels 68 73 85 - this seems much higher than normal default - why? any feedback?
tk501
 
Posts: 124
Joined: Thu Dec 26, 2013 3:57 am
languages_spoken: english
ODROIDs: C1+

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby mad_ady » Thu Dec 17, 2015 9:57 pm

I guess it depends on the usual operating temperature. My XU3 is 53C when idle, and I try to keep the load limited so it doesn't go over 65. Over 65 it starts the fan.
User avatar
mad_ady
 
Posts: 4931
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby tk501 » Thu Dec 17, 2015 11:13 pm

I think I get now why pwm_duty is 2 as I looked at it when the fan was off so I take the 1 setting in the four element list as representing the number when below the lowest temperature setting and with the formula 1 would = 2 which makes sense.

As for the default temp_levels 68 73 85, that is just what it is and without this thread I would have never even know it.

With the immediacy of the adjustment, I will try leaving it on auto and using an echo statement to change the temp_levels based on experiments.

Thanks again for this thread...a very useful tool set for temperature management.
tk501
 
Posts: 124
Joined: Thu Dec 26, 2013 3:57 am
languages_spoken: english
ODROIDs: C1+

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby paran-o-droid » Mon Jan 11, 2016 1:08 am

Owning an XU4 for a weekend now the noise level and the frequent automatic turning on and off of the CPU fan is (as of now) the only downer, 'cause it can be rather annoying.
Thus I'd like to thank all of you for the remedies and suggestions here!

FYI:
I tweaked the fan settings to:
- fan speeds: 19,51,71,91
- temperatures: 61,73,85
As you can see I only changed the 1st values.

19% as the min. fan speed works for me reliably (no high pitched tone from the fan) only if the fan did spin on a higher percentage before (i.e at boot time or when above 60°C).
With these settings the CPU reaches only 49°C when idle.

I will probably also try that PWM control script when the fan bothers me again. But for now I prefer not to employ more software to keep the CPU cool. ;-)
paran-o-droid
 
Posts: 1
Joined: Sat Jan 09, 2016 4:33 pm
languages_spoken: english, german
ODROIDs: XU4

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby Eni-od » Wed May 25, 2016 12:20 pm

hello,
I am newbie and I am tired to hear the fan of my Xu4 every 10-15 sec I rather prefer to hear him at low speed continuously and of course speeder if needer.
I did :
sudo echo "1 20 50 95" > /sys/devices/odroid_fan.14/fan_speeds
sudo echo "50 70 80" > /sys/devices/odroid_fan.14/temp_levels

But it seems not working like I would like, it stops to spins and when it's going to spin it's at lower speed.
Am I right ?
And by the way I hear a fucking whistle.

Someone can give me the solution for a permanent low speed (faster if needed) ?
Thanks by advance !
Eni-od
 
Posts: 14
Joined: Wed May 18, 2016 11:11 pm
languages_spoken: english french dutch
ODROIDs: XU4

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby Scarpia » Thu May 26, 2016 5:41 am

Hi eni-od.

You should have read the whole thread, both the stalling fan and the whistle are addressed in the posts above. TL;DR: just use a higher fan speed for the second level, like 30:

"1 30 50 95"
Scarpia
 
Posts: 25
Joined: Wed Jan 20, 2016 12:33 am
Location: Sweden
languages_spoken: english, danish, swedish
ODROIDs: ODROID-XU4

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby Emilien » Wed Jul 06, 2016 5:51 pm

Thank you for clarifying how this works, You may also need to add in the documentation that for some reason it is not allowed to set non increasing values of fan speeds:

Code: Select all
root@odroid:/etc/udev/rules.d# cat /sys/devices/odroid_fan.14/fan_speeds1 2 3 90
root@odroid:/etc/udev/rules.d# echo "1 1 1 90" > /sys/devices/odroid_fan.14/fan_speeds
root@odroid:/etc/udev/rules.d# cat /sys/devices/odroid_fan.14/fan_speeds1 2 3 90
root@odroid:/etc/udev/rules.d# echo "1 2 4 90" > /sys/devices/odroid_fan.14/fan_speeds
root@odroid:/etc/udev/rules.d# cat /sys/devices/odroid_fan.14/fan_speeds1 2 4 90


For some reason I wanted a setup where it only turns on at high temperatures, but is off most of the time. There might also be restrictions on the other files.
Emilien
 
Posts: 1
Joined: Wed Jul 06, 2016 5:48 pm
languages_spoken: english, french
ODROIDs: XU3

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby jalcaid001 » Mon Nov 28, 2016 2:47 am

This is what I have after reload. What am I doing wrong?

odroid@odroid:~/Desktop$ cat /etc/udev/rules.d/60-odroid_fan.rules
DRIVER=="odroid-fan", ACTION=="add", ATTR[fan_speeds]="1 10 50 95", ATTR[temp_levels]="50 75 80"


odroid@odroid:~/Desktop$ cat /sys/devices/odroid_fan.14/fan_speeds
1 51 71 91
odroid@odroid:~/Desktop$ cat /sys/devices/odroid_fan.14/temp_levels
68 73 85
odroid@odroid:~/Desktop$
jalcaid001
 
Posts: 50
Joined: Mon Nov 28, 2016 2:43 am
languages_spoken: english spanish
ODROIDs: XU4

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby meveric » Mon Nov 28, 2016 3:12 am

did you restart after you created the udev rule?
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.
User avatar
meveric
 
Posts: 9454
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby jalcaid001 » Wed Nov 30, 2016 8:26 pm

YEs, I restarted

After reboot, the values on cat /sys/devices/odroid_fan.14/ are the ones displayed

Is it supposed to work on XU4?
jalcaid001
 
Posts: 50
Joined: Mon Nov 28, 2016 2:43 am
languages_spoken: english spanish
ODROIDs: XU4

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby meveric » Wed Nov 30, 2016 9:52 pm

yep this should work fine on the XU4 I used it quite often already (with similar settings as yours).

You can also try to directly push these values into the control device:
Code: Select all
echo "1 10 50 95" > /sys/devices/odroid_fan.*/fan_speeds
echo "50 75 80" > /sys/devices/odroid_fan.*/temp_levels

You could add these lines to /etc/rc.local so it's set each time on reboot as well.
Not as nice as the udev rule, but it should work as well.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.
User avatar
meveric
 
Posts: 9454
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby jalcaid001 » Thu Dec 01, 2016 10:02 pm

I was hoping to use the more elegant way

/etc/rc.local for some reason is not working

These lines are not executed, nor are executed all the commands below those lines (the commands above are)

Is there any place I can look at logs to see what is the problem?
When I execute those lines from a shell, they work fine
jalcaid001
 
Posts: 50
Joined: Mon Nov 28, 2016 2:43 am
languages_spoken: english spanish
ODROIDs: XU4

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby mad_ady » Thu Dec 01, 2016 10:08 pm

rc.local stops executing once any command inside returns non-zero.
You can do sudo bash -x /etc/rc.local to see what command fails
User avatar
mad_ady
 
Posts: 4931
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby meveric » Fri Dec 02, 2016 2:12 am

also make sure you put these line BEFORE the exit 0 ;)
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.
User avatar
meveric
 
Posts: 9454
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby jalcaid001 » Fri Dec 02, 2016 5:36 am

What I meant is that it seems that the lines for chaning the paramenters of the fan seem the ones with errors. In the example below, I'm creating file temp_x1 but not file temp_x2

odroid@odroid:~$ tail /etc/rc.local

touch ~odroid/temp_x1

touch ~odroid/PROBE/REBOOT_"`date`"

echo "1 10 50 95" > /sys/devices/odroid_fan.*/fan_speeds
echo "50 70 80" > /sys/devices/odroid_fan.*/temp_levels


touch /home/odroid/temp_x2
odroid@odroid:~$
odroid@odroid:~$ sudo bash -x /etc/rc.local
[sudo] password for odroid:
+ '[' -f /aafirstboot ']'
+ touch /home/odroid/temp_x1
++ date
+ touch '/home/odroid/PROBE/REBOOT_Thu Dec 1 20:26:03 UTC 2016'
+ echo '1 10 50 95'
+ echo '50 70 80'
+ touch /home/odroid/temp_x2



odroid@odroid:~/Desktop$ cd ..
odroid@odroid:~$ ls -la | grep temp
-rw-r--r-- 1 root root 0 Dec 1 20:24 temp_x1
jalcaid001
 
Posts: 50
Joined: Mon Nov 28, 2016 2:43 am
languages_spoken: english spanish
ODROIDs: XU4

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby jalcaid001 » Fri Dec 09, 2016 8:49 am

Any ideas? Why I cannot write those files while system is rebooting (via /etc/rc.local). The other files are being created as user root, so I would think I have enough privileges

Is somebody else facing the same problem?
jalcaid001
 
Posts: 50
Joined: Mon Nov 28, 2016 2:43 am
languages_spoken: english spanish
ODROIDs: XU4

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby odroid alc » Fri Mar 24, 2017 3:52 am

Helo all

Noob hear so I got a litel lazy for the momint to many other projects in the air so I thout I wuld try this.. I saw it on anuther site. :


WARNING
Please be careful when using the fan control features of your mainboard, in addition to the risk of burning your CPU, at higher temperatures there will be a higher wearout of your other hardware components, too. So if you plan to use these components in 50 years, maybe you shouldn't use fancontrol at all. Also please keep in mind most fans aren't designed to be powered by a PWMed voltage. In practice it doesn't seem to be a major issue, the fans will get slightly warmer, just be sure to have a temperature alarm and/or shutdown call, in case some fan fails, because you probably won't hear it anymore ;)

How to use Fancontrol

First install fancontrol

sudo apt-get install fancontrol

Use pwmconfig, an script to manage fancontrol

pwmconfig

Now follow the instructions to configure your fan speed.


Any idea if this will work on arm(odroid xu4) ubuntu mate ???
odroid alc
 
Posts: 74
Joined: Sun Feb 26, 2017 9:11 am
languages_spoken: english
ODROIDs: xu4
pi ZERO

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby mad_ady » Fri Mar 24, 2017 4:26 pm

It should work for kernel 3.10, but probably not with 4.9
User avatar
mad_ady
 
Posts: 4931
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby moon.linux » Mon May 08, 2017 1:50 pm

On 4.x kernel as we have mapped the pwm-fan module with the thermal zone to support Active cooling of CPU/GPU.

Code: Select all
Cooling Device list
-------------------
cooling_device0
- pwm-fan
cooling_device1
- thermal-cpufreq-0
cooling_device2
- thermal-cpufreq-1


cooling_device0
- pwm-fan

so we could change the #cooling-level of pwm-fan and possible find drop of temperature of the CPU, this help in active cooling of cpu.

Code: Select all
root@odroid:~# cat /sys/devices/platform/pwm-fan:/hwmon/hwmon0/fan_speed
0 150 190 252
root@odroid:~#
root@odroid:~# echo "0 150 195 245" > /sys/devices/platform/pwm-fan:/hwmon/hwmon0/fan_speed
root@odroid:~# cat /sys/devices/platform/pwm-fan:/hwmon/hwmon0/fan_speed
0 150 195 245
root@odroid:~#
root@odroid:~# echo "0 170 210 255" > /sys/devices/platform/pwm-fan:/hwmon/hwmon0/fan_speed
root@odroid:~# cat /sys/devices/platform/pwm-fan:/hwmon/hwmon0/fan_speed
0 170 210 255
root@odroid:~#


The #cooling-level have 4 setting range of is between [0~255] the change helps in active cooling of Odroid XU4.

Code: Select all
cooling_device1
- thermal-cpufreq-0
cooling_device2
- thermal-cpufreq-1


Second part of thermal cooling is the scaling of cpufreq. As the temperature rise and it passes the trip point
in the dts the cpufreq will scale down the cpu frequency to lower level.

Possible the the Power State Coordination Interface (PSCI) (cpu idle) of the cpu is control power and clk for CPU.
moon.linux
 
Posts: 1161
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby mad_ady » Mon May 08, 2017 2:39 pm

Great @moon.linux. Starting from what kernel version is this implemented?
User avatar
mad_ady
 
Posts: 4931
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby moon.linux » Mon May 08, 2017 2:59 pm

Linux kernel version 4.9.25-29 should have integrated the change.
moon.linux
 
Posts: 1161
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby sratent » Mon May 08, 2017 5:45 pm

Is there a way to use a udev rule with the new 'pwm-fan' ?

Both DRIVER=="odroid-fan" and DRIVER=="pwm-fan" don't seem to click.
sratent
 
Posts: 2
Joined: Thu May 04, 2017 1:11 pm
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby moon.linux » Mon May 08, 2017 8:12 pm

Using udev we will not control the fan like the old version.
As the pmw-fan is registers/mapped to thermal zone via dts.
So as soon as the temperature crosses the trip point it triggers change
in state of pwm-fan the #cooling-level will pick up the appropriate value to control the temperature.
moon.linux
 
Posts: 1161
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby sratent » Wed May 10, 2017 6:34 am

Thanks @moon.linux for the clarification.

So is it correct that the only way to control the fan speed myself from 4.9 kernel on is to "echo" the desired levels to /sys/devices/platform/pwm-fan:/hwmon/hwmon0/fan_speed after boot? If I understand correctly I can't manipulate the dtb blob without recompiling the dts source? How can I specify the temperature trip points myself if they are specified in the dts?
sratent
 
Posts: 2
Joined: Thu May 04, 2017 1:11 pm
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby moon.linux » Wed May 10, 2017 2:48 pm

Hi sratent

We can modify the trip temp via sys file.
Code: Select all
root@odroid:~# ls -la /sys/class/thermal/thermal_zone0/
total 0
drwxr-xr-x  3 root root    0 May 10 05:42 .
drwxr-xr-x 10 root root    0 May 10 02:29 ..
-r--r--r--  1 root root 4096 May 10 05:42 available_policies
lrwxrwxrwx  1 root root    0 May 10 05:42 cdev0 -> ../cooling_device0
-r--r--r--  1 root root 4096 May 10 05:42 cdev0_trip_point
-rw-r--r--  1 root root 4096 May 10 05:42 cdev0_weight
lrwxrwxrwx  1 root root    0 May 10 05:42 cdev1 -> ../cooling_device0
-r--r--r--  1 root root 4096 May 10 05:42 cdev1_trip_point
-rw-r--r--  1 root root 4096 May 10 05:42 cdev1_weight
lrwxrwxrwx  1 root root    0 May 10 05:42 cdev2 -> ../cooling_device0
-r--r--r--  1 root root 4096 May 10 05:42 cdev2_trip_point
-rw-r--r--  1 root root 4096 May 10 05:42 cdev2_weight
lrwxrwxrwx  1 root root    0 May 10 05:42 cdev3 -> ../cooling_device1
-r--r--r--  1 root root 4096 May 10 05:42 cdev3_trip_point
-rw-r--r--  1 root root 4096 May 10 05:42 cdev3_weight
lrwxrwxrwx  1 root root    0 May 10 05:42 cdev4 -> ../cooling_device2
-r--r--r--  1 root root 4096 May 10 05:42 cdev4_trip_point
-rw-r--r--  1 root root 4096 May 10 05:42 cdev4_weight
lrwxrwxrwx  1 root root    0 May 10 05:42 cdev5 -> ../cooling_device2
-r--r--r--  1 root root 4096 May 10 05:42 cdev5_trip_point
-rw-r--r--  1 root root 4096 May 10 05:42 cdev5_weight
lrwxrwxrwx  1 root root    0 May 10 05:42 cdev6 -> ../cooling_device2
-r--r--r--  1 root root 4096 May 10 05:42 cdev6_trip_point
-rw-r--r--  1 root root 4096 May 10 05:42 cdev6_weight
--w-------  1 root root 4096 May 10 05:42 emul_temp
-rw-r--r--  1 root root 4096 May 10 05:42 integral_cutoff
-rw-r--r--  1 root root 4096 May 10 05:42 k_d
-rw-r--r--  1 root root 4096 May 10 05:42 k_i
-rw-r--r--  1 root root 4096 May 10 05:42 k_po
-rw-r--r--  1 root root 4096 May 10 05:42 k_pu
-rw-r--r--  1 root root 4096 May 10 05:42 mode
-rw-r--r--  1 root root 4096 May 10 05:42 offset
-rw-r--r--  1 root root 4096 May 10 05:42 policy
drwxr-xr-x  2 root root    0 May 10 05:42 power
-rw-r--r--  1 root root 4096 May 10 05:42 slope
lrwxrwxrwx  1 root root    0 May 10 02:29 subsystem -> ../../../../class/thermal
-rw-r--r--  1 root root 4096 May 10 05:42 sustainable_power
-r--r--r--  1 root root 4096 May 10 05:42 temp
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_0_hyst
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_0_temp
-r--r--r--  1 root root 4096 May 10 05:42 trip_point_0_type
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_1_hyst
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_1_temp
-r--r--r--  1 root root 4096 May 10 05:42 trip_point_1_type
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_2_hyst
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_2_temp
-r--r--r--  1 root root 4096 May 10 05:42 trip_point_2_type
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_3_hyst
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_3_temp
-r--r--r--  1 root root 4096 May 10 05:42 trip_point_3_type
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_4_hyst
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_4_temp
-r--r--r--  1 root root 4096 May 10 05:42 trip_point_4_type
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_5_hyst
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_5_temp
-r--r--r--  1 root root 4096 May 10 05:42 trip_point_5_type
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_6_hyst
-rw-r--r--  1 root root 4096 May 10 05:42 trip_point_6_temp
-r--r--r--  1 root root 4096 May 10 05:42 trip_point_6_type
-r--r--r--  1 root root 4096 May 10 05:42 type
-rw-r--r--  1 root root 4096 May 10 02:29 uevent
root@odroid:~# cat /sys/class/thermal/thermal_zone0/trip_point_1_temp
75000
root@odroid:~#
root@odroid:~#
root@odroid:~# ls -la /sys/class/thermal/thermal_zone0/trip_point_1_temp
-rw-r--r-- 1 root root 4096 May 10 05:42 /sys/class/thermal/thermal_zone0/trip_point_1_temp
root@odroid:~# echo 65000 > /sys/class/thermal/thermal_zone0/trip_point_1_temp
root@odroid:~# cat /sys/class/thermal/thermal_zone0/trip_point_1_temp
65000
root@odroid:~#


Temperature monitor.
Code: Select all
     TMON v1.0

lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqTHERMAL ZONES(SENSORS)qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
xThermal Zones:                 cpu0-ther00 cpu1-ther01 cpu2-ther02 cpu3-ther03 gpu-therm04                                                                  x
xTrip Points:                   PPPCAAA     PPPCAAA     PPPCAAA     PPPCAAA     CAAA                                                                         x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq COOLING DEVICES qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
xID  Cooling Dev   Cur    Max   Thermal Zone Binding                                                                                                         x
x00      pwm-fan     0      3   xxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxxx                                                                 x
x01 thermal-cpuf     0     11   xxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxxx                                                                 x
x02 thermal-cpuf     0     18   ***xxxxxxxx ***xxxxxxxx ***xxxxxxxx ***xxxxxxxx xxxxxxxxxxxx                                                                 x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x                         10        20        30        40        50        60        70        80        90        100       110       120                  x
xcpu0-t 0:[ 64][>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>A65  A70       A80  P85  P90  P95                 C115      ]               x
xcpu1-t 1:[ 65][>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    A70  A75  A80  P85  P90  P95                 C115      ]               x
xcpu2-t 2:[ 68][>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> A70  A75  A80  P85  P90  P95                 C115      ]               x
xcpu3-t 3:[ 65][>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    A70  A75  A80  P85  P90  P95                 C115      ]               x
xgpu-th 4:[ 64][>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                    A85               A103   A110      C120 ]               x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq CONTROLS qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
xPID gain: kp=0.36 ki=5.00 kd=0.19 Output -14.82                                                                                                             x
xTarget Temp: 65.0C, Zone: 0, Control Device: None                                                                                                           x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj


moon.linux
 
Posts: 1161
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby rupy » Tue May 30, 2017 9:30 pm

echo 35000 > /sys/class/thermal/thermal_zone0/trip_point_1_temp

Does not start my fan... what is wrong?

What does 0 150 190 252 mean when you run:

cat /sys/devices/platform/pwm-fan\:/hwmon/hwmon0/fan_speed
rupy
 
Posts: 47
Joined: Fri Mar 04, 2016 7:38 am
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby meveric » Tue May 30, 2017 10:15 pm

rupy wrote:What does 0 150 190 252 mean when you run:

cat /sys/devices/platform/pwm-fan\:/hwmon/hwmon0/fan_speed

That are the power values for the fan.
values are from 0 to 255 and means the level of power it should use to spin the fan.
where 0 = 0% and 255 = 100%
so 150 = 150 / 255 * 100 ~ 58.8% of maximal spinning power and 190 ~ 74.5%.
User avatar
meveric
 
Posts: 9454
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby rupy » Tue May 30, 2017 10:33 pm

ok thx now I get it but why are there 6 trip point files and only 4 % numbers?!?!

I now set:

echo 10000 > trip_point_0_temp

and

echo "25 150 190 252" > fan_speed

And the fan goes up and down all the time?! Why?

Ok, setting:

echo 60000 > trip_point_0_temp

and

echo "25 150 190 252" > fan_speed

Seems to work like I want it = slow fan all the time... but this is more woodoo magic than science...
rupy
 
Posts: 47
Joined: Fri Mar 04, 2016 7:38 am
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby moon.linux » Tue May 30, 2017 11:25 pm

Their are 5 TMU sensors used by the driver. 4 sensor control active cooling and 1 sensor control GPU cooling.
as the temperature cross the tip point it activates the PWM-FAN module.

You are correct the minimal point should be lowered.

Code: Select all
echo 60000 > trip_point_0_temp


I will check this again.
moon.linux
 
Posts: 1161
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby rupy » Wed May 31, 2017 5:42 am

ok so I had to set echo 10000 > trip_point_1_temp and wait a long while on my other XU4... this seems random and I would like to understand how this is supposed to work...

So the way to get my fan working is really weird now... set 25 on the first fan_speed, then set both trip 0 and 1 to 10000 then when I hear the fan blow I set the trip back to 65000 and 70000 then it "works" and the fan runs silently constantly without going up and down all the time...
rupy
 
Posts: 47
Joined: Fri Mar 04, 2016 7:38 am
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby rupy » Mon Jun 12, 2017 2:46 am

@moon.linux Did you have time to look into this?
rupy
 
Posts: 47
Joined: Fri Mar 04, 2016 7:38 am
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby rupy » Mon Jun 12, 2017 7:23 pm

The fan is going up and down like crazy can the official Odroid team please post a configuration that makes the fan silent and constant?

When the CPU is working hard the fan spins up randomly no matter which config it has... I think these commands don't really control everything:

echo "25 25 25 25" > /sys/devices/platform/pwm-fan:/hwmon/hwmon0/fan_speed
echo 90000 > /sys/class/thermal/thermal_zone0/trip_point_0_temp
echo 90000 > /sys/class/thermal/thermal_zone0/trip_point_1_temp
echo 90000 > /sys/class/thermal/thermal_zone0/trip_point_2_temp

Because no matter what I set them to the fan goes up and down... and the CPU is cool so it's not my heatsink shim or anything...
rupy
 
Posts: 47
Joined: Fri Mar 04, 2016 7:38 am
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby moon.linux » Mon Jun 12, 2017 7:33 pm

I will check this and let you know more on this.
moon.linux
 
Posts: 1161
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby rupy » Mon Jun 12, 2017 7:40 pm

echo 100000 > /sys/class/thermal/thermal_zone0/trip_point_0_temp
echo 100000 > /sys/class/thermal/thermal_zone0/trip_point_1_temp
echo 100000 > /sys/class/thermal/thermal_zone0/trip_point_2_temp

worked... this is soo fishy. the cpu is barely warm... like 40C max...

nope again it turned on...

What are these:

root@stad:~# cat /sys/class/thermal/thermal_zone0/trip_point_4_temp
85000
root@stad:~# cat /sys/class/thermal/thermal_zone0/trip_point_5_temp
90000
root@stad:~# cat /sys/class/thermal/thermal_zone0/trip_point_6_temp
95000

why is there only 4 values in this:

echo "25 25 25 25" > /sys/devices/platform/pwm-fan:/hwmon/hwmon0/fan_speed

but 7 trip values?!

tried echo "25 25 25 25 25 25 25" > /sys/devices/platform/pwm-fan:/hwmon/hwmon0/fan_speed

seems to work so far... nope... you have until after lunch then I'm going back to the old version where this works:

echo 0 > /sys/devices/odroid_fan.13/fan_mode
echo 20 > /sys/devices/odroid_fan.13/pwm_duty

I really regret buying these Odroid... complete garbage...
rupy
 
Posts: 47
Joined: Fri Mar 04, 2016 7:38 am
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby moon.linux » Mon Jun 12, 2017 8:04 pm

echo "25 25 25 25" > /sys/devices/platform/pwm-fan:/hwmon/hwmon0/fan_speed

seen no correct value it's too low to generate valid PMW signal to trigger active fan control on 4.9.x
We can increase the number of inputs as long as we update this via dts changes.

If you are using 3.10.x then their is another parameter to control the fan speed.

Code: Select all
sudo echo "1 20 50 95" > /sys/devices/odroid_fan.14/fan_speeds
sudo echo "50 70 80" > /sys/devices/odroid_fan.14/temp_levels
moon.linux
 
Posts: 1161
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby rupy » Mon Jun 12, 2017 8:33 pm

ok, I'm going back to whatever:

echo 0 > /sys/devices/odroid_fan.13/fan_mode
echo 20 > /sys/devices/odroid_fan.13/pwm_duty

was then, you don't know how to make the fan just spin silently permanently on 4.9.x?
rupy
 
Posts: 47
Joined: Fri Mar 04, 2016 7:38 am
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby rupy » Mon Jun 12, 2017 8:36 pm

do you need to edit all thermal zones?

/sys/class/thermal/thermal_zone1/
/sys/class/thermal/thermal_zone2/
/sys/class/thermal/thermal_zone3/
rupy
 
Posts: 47
Joined: Fri Mar 04, 2016 7:38 am
languages_spoken: english

Re: [HOWTO] Control automatic fan settings on XU3/XU4

Unread postby moon.linux » Mon Jun 12, 2017 8:46 pm

on Odroid products fan is controlled by variation of temperature and adjust of pwm_duty.
We don't need to edit any thermal zone.

You want to fan run silently then we need to lower the tip point so that the PWM signal is generated at low temperature.
moon.linux
 
Posts: 1161
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english

Next

Return to Ubuntu (All Linux'es)

Who is online

Users browsing this forum: No registered users and 1 guest