odroid-cpu-control

Post Reply
User avatar
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

odroid-cpu-control

Post by mad_ady » Fri Oct 02, 2015 5:55 pm

I put together a small shell script to help people change frequency/governors for their XU3/XU4s.
I will be using it via cron to set the odroid to low power mode during the night so that the fan won't start too often even if it's doing intensive work.

You can get the script on github: https://github.com/mad-ady/odroid-cpu-control

Code: Select all

Usage:

./odroid-cpu-control [options]

Options:
 -l, --list                      List a parameter
 -s, --set                       Set a parameter
 -g, --governor <governor>       Select a governor
                                 (interactive conservative ondemand powersave performance )
 -c, --cpu <number|range>        The CPU to edit/query. Leave blank for all CPUs. Valid syntax:
                                 0; 0,4; 0,4,5-7; 0-7
 -m, --min <number>              The minimum CPU frequency (must be supported by governor and CPU)
 -M, --max <number>              The maximum CPU frequency (must be supported by governor and CPU)
 -f, --frequency                 The current CPU frequency
 -t, --temperature               The current CPU temperature
 -q, --quiet                     Don't display much output when setting a parameter
 -i, --interactive <number>      Keep running the list command every number seconds
 -h, --help                      Show this help screen
 
Examples:
 ./odroid-cpu-control -l                                   Lists current frequency/governor for all cores
 ./odroid-cpu-control -l -g -f                             Lists just governor and current frequency for all cores
 ./odroid-cpu-control -l -c 0,4                            Lists all information only for cores 0 and 4
 ./odroid-cpu-control -l -c 0-4                            Lists all information for cores 0 to 4
 ./odroid-cpu-control -s -g powersave -m 300M -M 600M      Sets governor, minimum and maximum frequency for all cores
 ./odroid-cpu-control -s -M 1.2G -c 0,4                    Sets maximum frequency on cores 0 and 4

Examples:
  • list current settings for all CPUs:
    ./odroid-cpu-control -l
  • list current settings for CPU 3:
    ./odroid-cpu-control -l -c 3
  • list current frequency for CPU 3:
    ./odroid-cpu-control -l -c 3 -f
  • list current governor for CPU 3:
    ./odroid-cpu-control -l -c 3 -g
  • set governor, min, max frequency for all CPUs:
    ./odroid-cpu-control -s -g "powersave" -m 300M -M 1G
  • set governor, min, max frequency for cpus 1, 4, 5 and 6:
    ./odroid-cpu-control -s -g "powersave" -m 400M -M 1.3G -c 1,4-6
Patches and improvements welcome.
Last edited by mad_ady on Mon Dec 14, 2015 11:51 pm, edited 5 times in total.

User avatar
meveric
Posts: 11085
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 42 times
Been thanked: 384 times
Contact:

Re: odroid-xu3/4-cpu-control

Post by meveric » Fri Oct 02, 2015 6:18 pm

Instead of using sudo commands within the script, just check if the script is started as root, and if not quit and tell the user to start with sudo or as root.
Makes things ALOT easier :)

Code: Select all

        if [ $UID -ne 0 ]; then
                echo "You must run this script with root priviledges."
                echo "try sudo $0"
                exit 1
        fi
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
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-xu3/4-cpu-control

Post by mad_ady » Sat Oct 03, 2015 11:05 pm

Thanks for the feedback. This is what I tried first, but when running the cpufreq-set command as root with the correct parameters from within the script it would output an error message. The same command ran just fine in a new root shell. I even looked with strace and when it fails, it didn't even try to open the relevant /proc file (so it wasn't a permission error). When running through sudo it magically works.

This needs more investigation, but probably the best workaround is to skip cpufreq-set alltogether and just echo the values directly into /proc.

Also, there's an aditional problem - the show command shows absolute min/max values for the cores, not the limits you set.

User avatar
meveric
Posts: 11085
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 42 times
Been thanked: 384 times
Contact:

Re: odroid-xu3/4-cpu-control

Post by meveric » Sun Oct 04, 2015 3:33 am

First of all, not all systems work with sudo.
On my image, the default user, does not have sudo permissions, so your entire code would fail to run here :)

Besides all what you said sounds a little strange, in fact, i never checked on your code before and just did it right now.
You're using cpufrequtils to perform most of your operations.
Well I don't see this mentioned in your OP. But without having this installed, your script won't work at all.
And although it "might" be preinstalled on most images, it's not required, and chances are, that it's not present on the image you want to run this on.

I actually wouldn't use cpufrequtils at all, it's not needed, and you probably get less issues, just directly accessing and altering /sys to achive the same.
I think there is even an option to set the system in a way to ignore cpufreq-set commands so i wouldn't rely on it at all.

Here some hints, how to improve your scripts, and get rid of cpufrequtils as well as making sure, that just running the script as root (or with sudo) is more than enough.

Code: Select all

ll /sys/devices/system/cpu/cpu0/cpufreq/
total 0
-r--r--r-- 1 root root 4096 Oct  3 20:31 affected_cpus
-r-------- 1 root root 4096 Oct  3 20:31 cpuinfo_cur_freq
-r--r--r-- 1 root root 4096 Oct  2 14:19 cpuinfo_max_freq
-r--r--r-- 1 root root 4096 Oct  3 20:31 cpuinfo_min_freq
-r--r--r-- 1 root root 4096 Oct  3 20:31 cpuinfo_transition_latency
-r--r--r-- 1 root root 4096 Oct  3 20:31 related_cpus
-r--r--r-- 1 root root 4096 Oct  3 20:31 scaling_available_governors
-r--r--r-- 1 root root 4096 Sep 30 23:26 scaling_cur_freq
-r--r--r-- 1 root root 4096 Oct  3 20:31 scaling_driver
-rw-r--r-- 1 root root 4096 Oct  3 20:24 scaling_governor
-rw-r--r-- 1 root root 4096 Oct  3 20:24 scaling_max_freq
-rw-r--r-- 1 root root 4096 Oct  3 20:24 scaling_min_freq
-rw-r--r-- 1 root root 4096 Oct  3 20:31 scaling_setspeed
drwxr-xr-x 2 root root    0 Oct  3 20:31 stats
If you replace cpu0 with cpu1 you get the second core, cpu2 is the third and so on.
The file name should speak for itself. With cat and echo you can either show the information, or alter the information on the cores.
Another hint: "nproc" gives you back the number of processors, so you don't need to use something like:

Code: Select all

totalCPUs=`grep processor /proc/cpuinfo | wc -l`
to find out how many cores you got ;)

This should work much better than relying on cpufrequtils, also it should fix any issue you have with permissions.
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
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-xu3/4-cpu-control

Post by mad_ady » Mon Oct 05, 2015 4:58 pm

Thank you for your suggestions. I will try to rework the script to access the files directly. Should be faster and more reliable.

In the mean time, here's a screenshot with the temperature variation of the XU3 when limiting CPU performance. The "high" temperature is with the "interactive" governor with maximun frequency, the low values is with powersave governor limited between 200-600MHz. The system was idle the whole time.

Image

I will update the first post when I make more changes.

User avatar
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-xu3/4-cpu-control

Post by mad_ady » Thu Dec 03, 2015 8:07 pm

I finally got the time to rewrite this script (in perl instead of bash), and now it doesn't use cpufreq-tools anymore and operates directly on the pseudo-files in /proc. I updated the first post accordingly. The syntax also allows the user to specify multiple cores, either as a comma separated list (e.g. 1,3,5,7) or using ranges (1-4), or both (1,3-5,7). The values for min/max support a suffix of M or G. Any non-compliant values (lower or higher than the CPU capability) will be automatically converted to the supported limit (this is a feature of the CPU).

Let me know if there are any problems with it or any suggestions for improvement.

Note: setting things on a core from 0-3 or 4-7 usually sets the same thing on adjacent cores from the same group. Check what was set with -l.

User avatar
meveric
Posts: 11085
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 42 times
Been thanked: 384 times
Contact:

Re: odroid-xu3/4-cpu-control

Post by meveric » Thu Dec 03, 2015 10:33 pm

looks good.. Just one more thing.
This is very "universal" it work's just fine on any system. So it can be used on U3 or C1 as well. Maybe you want to rethink the name ;)
All in all, very good and useful tool :)
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
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-xu3/4-cpu-control

Post by mad_ady » Thu Dec 03, 2015 11:38 pm

Thanks for the feedback. If you have those systems, can you check that the script works on them as well? Also, it was designed for XU3/4 because of their FAN noise problems - other devices are passive, so the users might not mind if they run hot. Although it would be useful for low power setups to increase battery life.

Thanks

Edit: project and git files renamed to odroid-cpu-control

User avatar
meveric
Posts: 11085
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 42 times
Been thanked: 384 times
Contact:

Re: odroid-cpu-control

Post by meveric » Thu Dec 03, 2015 11:51 pm

I checked it on my U3 and it's working perfectly fine :)
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
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Mon Dec 14, 2015 11:53 pm

Quick update. I added two more options:

Code: Select all

 -t, --temperature               The current CPU temperature
 -i, --interactive <number>      Keep running the list command every number seconds
With -i you can keep reading the values every x seconds (like top), so you can keep an eye on how the frequency is scaling comparing with load and temperature. Glad to hear it's working on other models as well.

kouchy
Posts: 11
Joined: Sat Oct 03, 2015 3:43 am
languages_spoken: english
ODROIDs: Odroid C1, Odroid XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by kouchy » Tue Dec 29, 2015 6:15 pm

Hi mad_ady,

I tested your script on my Odroid XU4 and it worked perfectly. It is a very nice tool for me, thanks for that.
I also think that your script is even more generic, it could be used for x86 architectures of for other ARM boards based on Linux (except for the temperature option which is very specific to the Odroid I think).

Thanks again and I will tell you if I see some improvments :-).

Perhaps I could be nice to specify the interactive mode in milliseconds instead of in seconds or to accept floating poing number in seconds...

User avatar
XeoSal
Posts: 925
Joined: Sun Aug 30, 2015 11:21 pm
languages_spoken: English
ODROIDs: C1, C1+, C2 & XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by XeoSal » Sun Jan 10, 2016 2:59 pm

Your tool is now available as a Debian package, and it can be run just as "cpuctrl" anywhere on terminal instead of "./odroid-cpu-control" inside one directory only, installation for odrobian users is easy:

Code: Select all

odroid:$ sudo apt-get update && sudo apt-get install odroid-cpu-control
Installation on Ubuntu is also simple:

Code: Select all

odroid:$ wget http://oph.mdrjr.net/odrobian/pool/main/o/odroid-cpu-control/odroid-cpu-control_1.0-4_all.deb
odroid:$ sudo dpkg -i odroid-cpu-control_1.0-4_all.deb
Have fun guys, thank you @mad_ady for such a great tool and your hard work. ;)

My suggestions:
  • Let us change command from "odroid-cpu-control" to "cpuctrl" as it very hard to re-type that long name each time. (I will push an update to my current package if you decide to do so)
  • Include an IF statement for ODROID C1 temperature command so it does work on all ODROIDs. (Find anything specific for s805 as a condition for the if statement)
  • Current ODROID XU4 temprature command can be put under the "else" section of the previous condition.
P.S. Never mind temperature suggestions, I checked my "cpuinfo" scripts that I created for odrobian once again, it's the same for both devices, sorry for some reason I remembered it incorrectly, also I tested your script on ODROID C1 and it's working as expected. :mrgreen:

Edit2: I decided to advertise this on odrobian, I will credit you by a special thanks, my new package version uses this command "cpuctrl" now, thank you again.
Last edited by XeoSal on Fri Mar 11, 2016 11:14 pm, edited 4 times in total.

User avatar
meveric
Posts: 11085
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 42 times
Been thanked: 384 times
Contact:

Re: odroid-cpu-control

Post by meveric » Sun Jan 10, 2016 11:31 pm

XeoSal wrote:
  • Include an IF statement for ODROID C1 temperature command so it does work on all ODROIDs. (Find anything specific for s805 as a condition for the if statement)
What ODROID C1 temperature command do you mean?

On all ODROID (and even regualr x86 PCs) the temperature can be read from /sys/devices/virtual/thermal/thermal_zone0/temp therefore that option is very universal and goes way beyond ODROID C1 or XU4.


What is it you want to change it to?
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
XeoSal
Posts: 925
Joined: Sun Aug 30, 2015 11:21 pm
languages_spoken: English
ODROIDs: C1, C1+, C2 & XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by XeoSal » Mon Jan 11, 2016 12:17 pm

Okay, now I am having your script on odrobian repository and I've done some changes to the version of my package, here's how it's introduced to the user:

Advanced CPU Control
If to have full control over your CPU functions, you should try the ODROID CPU Control (OCC) which is a universal utility developed by @mad_ady that enables advanced customization abilities for CPU covering its clock rate, governors, minimum/maximum frequencies and much more. First of all, this is an optional tool that can be installed directly from our repository so, if the overclock/underclock options available on odrobian by default ain't enough for you then you should absolutely install this.

Code: Select all

Installation for ODROBIAN users:
odroid:$ sudo apt-get install odroid-cpu-control

Installation for UBUNTU users:
odroid:$ wget http://oph.mdrjr.net/odrobian/pool/main/o/odroid-cpu-control/odroid-cpu-control_1.0-4_all.deb
odroid:$ sudo dpkg -i odroid-cpu-control_1.0-4_armhf.deb

Usage/Command:
odroid:$ sudo -s
odroid:# cpuctrl
Here's some examples on how to use OCC:

Code: Select all

cpuctrl [options]

Options:
 -l, --list                      List a parameter
 -s, --set                       Set a parameter
 -g, --governor <governor>       Select a governor
                                 (interactive conservative ondemand powersave performance )
 -c, --cpu <number|range>        The CPU to edit/query. Leave blank for all CPUs. Valid syntax:
                                 0; 0,4; 0,4,5-7; 0-7
 -m, --min <number>              The minimum CPU frequency (must be supported by governor and CPU)
 -M, --max <number>              The maximum CPU frequency (must be supported by governor and CPU)
 -f, --frequency                 The current CPU frequency
 -t, --temperature               The current CPU temperature
 -q, --quiet                     Don't display much output when setting a parameter
 -i, --interactive <number>      Keep running the list command every number seconds
 -h, --help                      Show this help screen
 
Examples:
 cpuctrl -l                                   Lists current frequency/governor for all cores
 cpuctrl -l -t                                Shows current temperature for all cores
 cpuctrl -l -g -f                             Lists just governor and current frequency for all cores
 cpuctrl -l -c 0,4                            Lists all information only for cores 0 and 4
 cpuctrl -l -c 0-4                            Lists all information for cores 0 to 4
 cpuctrl -s -g performance -m 300M -M 600M    Sets governor, minimum and maximum frequency for all cores
 cpuctrl -s -M 1.2G -c 0,4                    Sets maximum frequency on cores 0 and 4
Last edited by XeoSal on Sat Mar 12, 2016 7:44 am, edited 2 times in total.

User avatar
TeHashX
Posts: 171
Joined: Wed Aug 13, 2014 4:14 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by TeHashX » Wed Jan 13, 2016 12:08 am

Thanks for this, I installed on XU4, ubuntu 15.04 and set cpu governor to ondemand but after reboot is set back to performance.
Someone can create an init start script?
Thanks

User avatar
meveric
Posts: 11085
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 42 times
Been thanked: 384 times
Contact:

Re: odroid-cpu-control

Post by meveric » Wed Jan 13, 2016 12:12 am

TeHashX wrote:Thanks for this, I installed on XU4, ubuntu 15.04 and set cpu governor to ondemand but after reboot is set back to performance.
Someone can create an init start script?
Thanks
check /media/boot/boot.ini
the CPU governors are in that file as well, you just need to uncomment the ondemand governor and outcomment the performance governor.
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
TeHashX
Posts: 171
Joined: Wed Aug 13, 2014 4:14 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by TeHashX » Wed Jan 13, 2016 4:17 am

meveric wrote:
TeHashX wrote:Thanks for this, I installed on XU4, ubuntu 15.04 and set cpu governor to ondemand but after reboot is set back to performance.
Someone can create an init start script?
Thanks
check /media/boot/boot.ini
the CPU governors are in that file as well, you just need to uncomment the ondemand governor and outcomment the performance governor.
Thanks but if boot.ini is changed on some kernel update this setting will be lost.
I found another way, through crontab:

Code: Select all

crontab -e
@reboot cpuctrl -s -g ondemand
And it's ok :)

User avatar
TeHashX
Posts: 171
Joined: Wed Aug 13, 2014 4:14 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by TeHashX » Wed Jan 13, 2016 9:46 pm

TeHashX wrote:
meveric wrote:
TeHashX wrote:Thanks for this, I installed on XU4, ubuntu 15.04 and set cpu governor to ondemand but after reboot is set back to performance.
Someone can create an init start script?
Thanks
check /media/boot/boot.ini
the CPU governors are in that file as well, you just need to uncomment the ondemand governor and outcomment the performance governor.
Thanks but if boot.ini is changed on some kernel update this setting will be lost.
I found another way, through crontab:

Code: Select all

crontab -e
@reboot cpuctrl -s -g ondemand
And it's ok :)
Actually is not ok with crontab, after about one minute after reboot is set back to performance :(
I will stick with boot.ini modification, thanks.

User avatar
meveric
Posts: 11085
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 42 times
Been thanked: 384 times
Contact:

Re: odroid-cpu-control

Post by meveric » Wed Jan 13, 2016 11:20 pm

There is a script being started that checks what option is set in the boot.ini and after 60 seconds will set the governor to that value, no matter what you set it before in whatever.

BTW: no one uses crontab -e any longer you should rather stick with /etc/cron.d/

And since you now know this script (for setting governor to what it's set in boot.ini) is started after 60 seconds, if you check every minute IF it has the wrong value and just set it to what you want, should fix the issue as well, although you should prefer the change in the boot.ini, or you could simply remove the script (although it's being recreated ob boot.ini upgrade 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
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Mon Feb 01, 2016 5:55 pm

Sorry guys, I haven't been paying attention to this thread - I thought I was getting email notifies, but I wasn't... Oops...

@kouchy:
Download the newest commit - I added fractional timer for interactive option. Note that if it's too low you'll see a flickering effect. Most likely I need to tweak buffering.

@XeoSal: Thanks for packaging it - it was just a script, I didn't think it was worth the trouble of making a package for it, but if you already did it, great! Regarding the name - I never managed to pick good names, so I don't mind the name change. Also, it seems it mostly works on other platforms as well - such as my Intel desktop:

Code: Select all

adrianp@frost:~/temp$ perl odroid-cpu-control -l
CPU0: governor powersave	current 1.43GHz	min 800.00MHz [800.00MHz]	max 3.00GHz [3.00GHz] 	
CPU1: governor powersave	current 1.40GHz	min 800.00MHz [800.00MHz]	max 3.00GHz [3.00GHz]
@TeHashX: I start it via /etc/rc.local (make sure it's enabled in systemctl). You can start it with a custom delay in the background (since rc.local is no longer the last process to run in systemd):

Code: Select all

(sleep 60; /usr/local/bin/odroid-cpu-control -s -g conservative -M 600M >>/tmp/odroid-cpu-rc.local 2>&1)&
@meveric: Do you know which is the script you mentioned that sets the governor after boot?

User avatar
meveric
Posts: 11085
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 42 times
Been thanked: 384 times
Contact:

Re: odroid-cpu-control

Post by meveric » Mon Feb 01, 2016 6:57 pm

/etc/init.d/ondemand (at least on the Ubuntu Images from HardKernel)
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
TeHashX
Posts: 171
Joined: Wed Aug 13, 2014 4:14 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by TeHashX » Sun Feb 07, 2016 7:13 pm

Installed on Odroid C1+ and I wonder why max cpu freq is only 1.2? I know cpu is 1.5 but 1.73 is overclock?
odroid@odroid:~$ cpuctrl -l
CPU0: governor performance current 1.20GHz min 96.00MHz [24.00MHz] max 1.20GHz [1.73GHz]
CPU1: governor performance current 1.20GHz min 96.00MHz [24.00MHz] max 1.20GHz [1.73GHz]
CPU2: governor performance current 1.20GHz min 96.00MHz [24.00MHz] max 1.20GHz [1.73GHz]
CPU3: governor performance current 1.20GHz min 96.00MHz [24.00MHz] max 1.20GHz [1.73GHz]

User avatar
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Sun Feb 07, 2016 11:21 pm

I don't know... On my C1 I can hardly go below 1500 with ondemand. Performance should have kept it close to maximum. Are you using a custom kernel?

User avatar
TeHashX
Posts: 171
Joined: Wed Aug 13, 2014 4:14 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by TeHashX » Sun Feb 07, 2016 11:23 pm

No, official ubuntu 14.04, all stock

User avatar
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Mon Feb 08, 2016 12:51 am

What does this file say?

Code: Select all

sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

User avatar
TeHashX
Posts: 171
Joined: Wed Aug 13, 2014 4:14 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by TeHashX » Mon Feb 08, 2016 2:02 am

I think max cpu speed is related to cpu temp, plexmediaserver transcoded a media file and temp was 83C, now after finishing temp is 66C and max cpu speed is 1.54
root@odroid:~# cpuctrl -l
CPU0: governor performance current 1.54GHz min 96.00MHz [24.00MHz] max 1.54GHz [1.73GHz]
CPU1: governor performance current 1.54GHz min 96.00MHz [24.00MHz] max 1.54GHz [1.73GHz]
CPU2: governor performance current 1.54GHz min 96.00MHz [24.00MHz] max 1.54GHz [1.73GHz]
CPU3: governor performance current 1.54GHz min 96.00MHz [24.00MHz] max 1.54GHz [1.73GHz]
root@odroid:~# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
1536000
root@odroid:~# cpuctrl -l -t
TEMP: 66C

User avatar
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Mon Feb 08, 2016 3:29 am

That's plausible. Dmesg should say something when you reach thermal throttling.

User avatar
XeoSal
Posts: 925
Joined: Sun Aug 30, 2015 11:21 pm
languages_spoken: English
ODROIDs: C1, C1+, C2 & XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by XeoSal » Mon Feb 08, 2016 5:37 pm

TeHashX wrote:I think max cpu speed is related to cpu temp, plexmediaserver transcoded a media file and temp was 83C, now after finishing temp is 66C and max cpu speed is 1.54
mad_ady wrote:That's plausible. Dmesg should say something when you reach thermal throttling.
I am not having this issue, maybe a thermal throttling action?

Just take a look at the available range:

Code: Select all

odroid:$ sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
You can't clock your CPU out of this range and values, to solve your issue just set slightly higher clock speed to make the value closer to what's available. The OCC script according to the kernel will decide which value in this range is more suitable for your chosen clock rate.

User avatar
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Fri Mar 11, 2016 10:16 pm

Update: I've added support for hotplug (the script was dying when trying to read CPUs that were offline). @XeoSal, could you update your debian package (changes are in git)?

User avatar
XeoSal
Posts: 925
Joined: Sun Aug 30, 2015 11:21 pm
languages_spoken: English
ODROIDs: C1, C1+, C2 & XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by XeoSal » Fri Mar 11, 2016 11:13 pm

mad_ady wrote:Update: I've added support for hotplug (the script was dying when trying to read CPUs that were offline). @XeoSal, could you update your debian package (changes are in git)?
Hey friend, of course I have just upgraded the package on our repository with your changes! :D

User avatar
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Fri Mar 11, 2016 11:40 pm

It works correctly, thanks for updating the package!

User avatar
sputnik1969
Posts: 20
Joined: Mon Mar 30, 2015 6:54 am
languages_spoken: english, german
ODROIDs: C1
C2
XU3 lite
Location: Berlin, Germany
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by sputnik1969 » Thu Jul 28, 2016 7:38 pm

Changing the governor does not work for me :(
Neither using odroid-cpu-control, nor the manual way.
This is the result:

Code: Select all

root@BARDIOC:~# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
performance
root@BARDIOC:~# echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
-su: echo: write error: Invalid argument
root@BARDIOC:~# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
performance
I'm using Ubuntu 16.04.1, kernel version 3.10.72-23 (root@odroid) (gcc version 4.9.2 (Ubuntu/Linaro 4.9.2-10ubuntu13) ) #1 SMP PREEMPT Sat May 23 17:58:14 BRT 2015

User avatar
odroid
Site Admin
Posts: 34586
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 812 times
Been thanked: 704 times
Contact:

Re: odroid-cpu-control

Post by odroid » Thu Jul 28, 2016 7:50 pm

Try this

Code: Select all

echo interactive > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

User avatar
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Fri Jul 29, 2016 12:36 am

Also check that interactive governor is available for your kernel. odroid-cpu-ctrl -h should show you available governors.

For my c2 it works:

Code: Select all

adrianp@bellatrix:~$ sudo cpuctrl -s -g interactiveCPU0: governor conservative -> interactive
CPU1: governor conservative -> interactive
CPU2: governor conservative -> interactive
CPU3: governor conservative -> interactive
adrianp@bellatrix:~$ cpuctrl -l
CPU0: governor interactive      current 2.02GHz min 1
00.00MHz [100.00MHz]    max 2.02GHz [2.02GHz]
CPU1: governor interactive      current 2.02GHz min 1
00.00MHz [100.00MHz]    max 2.02GHz [2.02GHz]
CPU2: governor interactive      current 2.02GHz min 1
00.00MHz [100.00MHz]    max 2.02GHz [2.02GHz]
CPU3: governor interactive      current 2.02GHz min 1
00.00MHz [100.00MHz]    max 2.02GHz [2.02GHz]
adrianp@bellatrix:~$

User avatar
sputnik1969
Posts: 20
Joined: Mon Mar 30, 2015 6:54 am
languages_spoken: english, german
ODROIDs: C1
C2
XU3 lite
Location: Berlin, Germany
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by sputnik1969 » Sun Jul 31, 2016 8:02 am

I got it - there is no other governor in the kernel. how could this be? It's the official Ubuntu for XU3/4 :(
Big faux pas....
on my C2 it's working without problems...

DarkBahamut
Posts: 332
Joined: Tue Jan 19, 2016 10:19 am
languages_spoken: english
ODROIDs: XU4, N1
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by DarkBahamut » Mon Aug 01, 2016 4:01 am

That's an odd one. The stock kernel includes the governors by default. What is your exact kernel version (uname -r)?

User avatar
TeHashX
Posts: 171
Joined: Wed Aug 13, 2014 4:14 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by TeHashX » Mon Aug 01, 2016 7:53 pm

Tried with /etc/rc.local but didn't worked and I still used crontab with a delay, XU4 Ubuntu 16.04

Code: Select all

@reboot (sleep 90; /usr/local/bin/cpuctrl -s -m 200M -M 1.7G  >>/tmp/cpuctrl.tmp 2>&1)&

oversim
Posts: 51
Joined: Wed Feb 18, 2015 7:59 pm
languages_spoken: english
ODROIDs: C1 , XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by oversim » Tue Aug 23, 2016 6:05 pm

Thanks mad_ady, installed on my new XU4 and it's working like a charm...

Giak
Posts: 4
Joined: Sun Nov 13, 2016 8:07 pm
languages_spoken: english
ODROIDs: XU4
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by Giak » Mon Nov 14, 2016 7:29 pm

Make attention in a lot of previous examples you use the governor: "powersafe" but in my odriod with ubuntu the name is "powersave". You can show how governors is available with cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

User avatar
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Mon Nov 14, 2016 8:05 pm

@Glak: I searched the page and I could only find "powersafe" in your post. The correct name is powersave, as you mentioned. If you run the script with -h it will show you available governors for your system.

ulfben
Posts: 112
Joined: Thu Jul 20, 2017 11:56 pm
languages_spoken: english
ODROIDs: XU4Q
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: odroid-cpu-control

Post by ulfben » Mon Jul 24, 2017 7:28 am

XeoSal wrote:Your tool is now available as a Debian package, and it can be run just as "cpuctrl" anywhere on terminal instead of "./odroid-cpu-control" inside one directory only, installation for odrobian users is easy:

[...]

Code: Select all

odroid:$ wget http://oph.mdrjr.net/odrobian/pool/main/o/odroid-cpu-control/odroid-cpu-control_1.0-4_all.deb
odroid:$ sudo dpkg -i odroid-cpu-control_1.0-4_all.deb
Have fun guys, thank you @mad_ady for such a great tool and your hard work. ;)

[...]
This is fantastic. The conservative governor took my system - under load! - from ~58 degrees to ~32-37, with no loss in throughput. Big thanks to both of you!

There was a discussion a few post back about making the setting permanent. I'm a linux-noob, so can anyone suggest (more like; guide) something more long-term / permanent, than editing boot.ini?

I saw mad_ady's
mad_ady wrote:[...] I start it via /etc/rc.local (make sure it's enabled in systemctl). You can start it with a custom delay in the background (since rc.local is no longer the last process to run in systemd):

Code: Select all

(sleep 60; /usr/local/bin/odroid-cpu-control -s -g conservative -M 600M >>/tmp/odroid-cpu-rc.local 2>&1)&


But that line terrifies me. :P

User avatar
meveric
Posts: 11085
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 42 times
Been thanked: 384 times
Contact:

Re: odroid-cpu-control

Post by meveric » Mon Jul 24, 2017 7:32 am

On my images I use my own tools for setting CPU speed and I had to deal with the same topic.
My solution was to create a config file stored on the system which is read by a service on system start. This service uses the values in the config file to recreates the settings you've chosen.
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
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Mon Jul 24, 2017 2:51 pm

There's nothing terrifying (or risky) about that line. It's a quick and dirty way to set it at boot.

ulfben
Posts: 112
Joined: Thu Jul 20, 2017 11:56 pm
languages_spoken: english
ODROIDs: XU4Q
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: odroid-cpu-control

Post by ulfben » Wed Jul 26, 2017 7:22 am

Yeah, what I meant to say was; I don't understand it. :)

But today I learnt about systemd, systemctl and services. So I created a service unit to run at boot, for setting the governor and adjusting its settings. Thread: Tweaking governor up_threshold / down_threshold

A bit more manual labor than your one-liner, for sure, but as a reward I get a bit of handholding from the system. :)

User avatar
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Wed Jul 26, 2017 12:55 pm

That's actually the proper way to do it. Good job. One more thing - disable the execution bit of /etc/init.d/ondemand so it doesn't override governor

leepage@eml.cc
Posts: 19
Joined: Fri Feb 09, 2018 11:20 am
languages_spoken: English, French
ODROIDs: Odroid XU4, N2
Location: Florida, USA
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by leepage@eml.cc » Tue Nov 13, 2018 10:40 pm

I wrote a script that runs as my user and watches the activity of the screensaver. Once the screensaver goes into blanking or lock, it sets a flag that a root-owned process watches, whereupon it changes the cpu performance. It also does a kill -STOP on my web browsers, since those will keep the fan running even in powersave mode.

But, watching the screensaver changes the power management to be more on-demand, rather than just by the clock. Since I work at my home desk, I don't like my home computer (the XU4) whining all day.

If anyone is interested, I could provide it.

User avatar
mad_ady
Posts: 8151
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 567 times
Been thanked: 403 times
Contact:

Re: odroid-cpu-control

Post by mad_ady » Tue Nov 13, 2018 11:36 pm

I hope you set a simple screensaver. The default ones hog the CPU.

leepage@eml.cc
Posts: 19
Joined: Fri Feb 09, 2018 11:20 am
languages_spoken: English, French
ODROIDs: Odroid XU4, N2
Location: Florida, USA
Has thanked: 0
Been thanked: 0
Contact:

Re: odroid-cpu-control

Post by leepage@eml.cc » Wed Nov 14, 2018 12:16 am

You can use a blank page for the screen saver. That doesn't take up much... xscreensaver on my box is now taking up 0.0% CPU.

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 2 guests