Using tasker to SETCPU (Change CPU settings/speed)

1,344 views
Skip to first unread message

Mark

unread,
Mar 13, 2011, 9:56:23 PM3/13/11
to Tasker
Basically, exactly the title.
I would like to use tasker to change my CPU settings based on
conditions (eg. Underclock when the battery is low and at night).
I'm having problems with what to type in the Locale Execute plug-in

Here is the guide I followed how:
''I used to use SetCPU and decided to use tasker to change the speeds:
1) download "Locate Execute" for locale
http://www.appbrain.com/app/locale-execute-plug-in/de.elmicha.app.LocaleExecute
2) down this script: http://forum.cyanogenmod.com/topic/595-alternative-setcpu-script/
3) copy it to /data/local/bin (It HAS to be in the phone and not the
SD card)
4) chmod 755 /data/local/bin/setcpu
5) create multiple tasks (CPU-LOW, CPU-MED, CPU-HI) with the Locale
Execute plugin to execute /data/local/bin/setcpu <parameters>
for CPU-LOW (for instance) I run /data/local/bin/setcpu 245000 460800
ondemand
6) create a Profile where when app X is running, run task "CPU-HI"
etc.
I have it setup so when my phone it off, it executes a task called CPU-
LOW. When it is on, it runs CPU-MED, and for certain apps, it runs CPU-
HI''

The script is here: ''http://forum.cyanogenmod.com/topic/595-
alternative-setcpu-script/''

I have followed it all to the letter. If i use a normal terminal and
type:
su
setcpu 100000 800000 ondemand (or any other combination) then my
settings change (as confirmed through CM7's performance settings and
running a script to check).

BUT
If i try and use the Locale execute plug in to reproduce what i have
done in terminal then nothing happens, i do get the toast for the
plugin being granted superuser permissions but the nothing else
happens.

The problem i have is i don't actually know EXACTLY what to type in
the terminal/plugin's box..????

I'm new scripts and things so don't know what to type.

More info:
Phone: Samsung GT-I9000
ROM: CM7 2.3.3 (latest build)
Compatible kernel

PLEASE SOMEONE HELP WITH WHAT TO TYPE IN THE LOCALE EXECUTE PLUGIN'S
BOX


(and please don't respond with 'use setcpu app', as i want to use
tasker end of).

enotar

unread,
Mar 13, 2011, 11:27:23 PM3/13/11
to Tasker
cant you try to run directly the script from inside tasker without
Locale or use SL4A?
I am very interested on your mod, that could open a door to great
stuff.

On Mar 13, 7:56 pm, Mark <boarder....@gmail.com> wrote:
> Basically, exactly the title.
> I would like to use tasker to change my CPU settings based on
> conditions (eg. Underclock when the battery is low and at night).
> I'm having problems with what to type in the Locale Execute plug-in
>
> Here is the guide I followed how:
> ''I used to use SetCPU and decided to use tasker to change the speeds:
> 1) download "Locate Execute" for localehttp://www.appbrain.com/app/locale-execute-plug-in/de.elmicha.app.Loc...

Dave McIntosh

unread,
Mar 13, 2011, 10:39:30 PM3/13/11
to Tasker
Try typing "@/data/local/bin/setcpu 100000 800000" without the quotes
into the plugin box.
Works for me using the exact same script!! :-)
If you get tired of seeing the toast change it to "@!/data/local/bin/
setcpu 100000 800000" :-)

On Mar 13, 9:56 pm, Mark <boarder....@gmail.com> wrote:
> Basically, exactly the title.
> I would like to use tasker to change my CPU settings based on
> conditions (eg. Underclock when the battery is low and at night).
> I'm having problems with what to type in the Locale Execute plug-in
>
> Here is the guide I followed how:
> ''I used to use SetCPU and decided to use tasker to change the speeds:
> 1) download "Locate Execute" for localehttp://www.appbrain.com/app/locale-execute-plug-in/de.elmicha.app.Loc...

gm

unread,
Mar 14, 2011, 6:56:52 AM3/14/11
to Tasker
After a lot of experimentation with setCPU & Tasker with the locale
execute plugin I found that simple is good.

Switching governors can cause significant lag as the kernel tries to
load the necessary modules etc whilst trying to execute whatever
happens to be going on with your phone at the time.
I found it a lot less laggy to stick with the stock ondemand governor
and just switch the scaling_max_freq based on various profiles.

you can get the available frequencies that your kernel supports by
entering in a shell:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies

from there I created several tasks: (note: the numeric values are
specific to you device)
CPUHIGH - execute @! echo 768000 > /sys/devices/system/cpu/cpu0/
cpufreq/scaling_max_freq
- 768000 is about the highest stable frequency that my device supports
(you will need to experiment as to how high you can push your own
device)

CPUMED - execute @! echo 600000 > /sys/devices/system/cpu/cpu0/cpufreq/
scaling_max_freq
- this is the stock clock speed of my device

CPULOW - execute @! echo 248000 > /sys/devices/system/cpu/cpu0/cpufreq/
scaling_max_freq
- don't make this too low if used in a screen off/on context as when
you get an incoming call it will take forever for the phone app to
load

I'm not too sure, feel free to put me straight, but, going about it
this way could maybe slightly faster than using the script? one less
process to start?
Tasker starts the locale plugin, which executes its commands in the
shell it opens... if you then point it to another script, which opens
another shell, is that not another step in the process?
I may be well off track in my understanding, maybe someone with more
knowledge than me can shed some light....

a couple of my gems using Tasker & locale execute:
mount the sdcard automatically on usb connect without disabling access
to the sd on the phone - replaces dual mount sd widget
activating swap on boot - replaces swapper

I'd really like Tasker to be able to natively read a lot of these
configuration files rather than just being limited to the sdcard...
would this be a possibility in future Pent?

GM

On Mar 14, 2:56 pm, Mark <boarder....@gmail.com> wrote:
> Basically, exactly the title.
> I would like to use tasker to change my CPU settings based on
> conditions (eg. Underclock when the battery is low and at night).
> I'm having problems with what to type in the Locale Execute plug-in
>
> Here is the guide I followed how:
> ''I used to use SetCPU and decided to use tasker to change the speeds:
> 1) download "Locate Execute" for localehttp://www.appbrain.com/app/locale-execute-plug-in/de.elmicha.app.Loc...

Doug Catiller

unread,
Mar 14, 2011, 9:29:17 AM3/14/11
to Tasker
I was just playing with the Locale plugin the other day, and I could
only get a script to run if I have the script contents directly into
the Locale configurarion, rather than call the script. I would make a
task called CPUlow, etc in tasker, then add to each profile.

At first I was wondering why in the world you'd want to separate this
from SetCPU, but now I can see where you get lots of control by
scaling for different apps and other conditions. Gonna do this myself.

Doug

On Mar 13, 5:56 pm, Mark <boarder....@gmail.com> wrote:
> Basically, exactly the title.
> I would like to use tasker to change my CPU settings based on
> conditions (eg. Underclock when the battery is low and at night).
> I'm having problems with what to type in the Locale Execute plug-in
>
> Here is the guide I followed how:
> ''I used to use SetCPU and decided to use tasker to change the speeds:
> 1) download "Locate Execute" for localehttp://www.appbrain.com/app/locale-execute-plug-in/de.elmicha.app.Loc...

Mark

unread,
Mar 14, 2011, 3:04:44 PM3/14/11
to Tasker
Thanks so much to all of you for replys, it never ceases to amaze me
how helpful some people are. Thankyou.

Basically, i tried and tried with that script (from origional post)
and could not get tasker to change the cpu frequency (although i could
with a normal terminal??) strange. BUT, dave your method worked
perfectly. I spent so many hours trying to get this to work and yours
is so simple and perfect. I only want to reduce the max frequency so
this is perfect, i would not (at this stage) want to change the
governor or the min frequency.
A million thankyou, may you win the lottery tonight!

If i did want to change the governor or min frequency how would i go
about it,

Would min frequency be:
''@! echo ??(ENTER FREQUENCY)?? > /sys/devices/system/cpu/cpu0/cpufreq/
scaling_min_freq''??

And how would you change the governor?

(I'm fascinated by this)

Mark

unread,
Mar 14, 2011, 3:06:00 PM3/14/11
to Tasker
Sorry about my previous post, it was aimed at GM. thankyou sooo much!

Mark

unread,
Mar 14, 2011, 3:32:56 PM3/14/11
to Tasker
Tested and scaling_min_freq works for changing minimum frequency :D

I wonder how to change the governor...?

On Mar 14, 10:56 am, gm <greasemonke...@gmail.com> wrote:

fubaya

unread,
Mar 14, 2011, 6:26:31 PM3/14/11
to Tasker
The reason a script doesn't work in /data/local/bin is that the locale
execute plugin's path is set to:

/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin

In other words, it only looks in those directories for things to
execute and doesn't look in /data/local/bin. If it works in a
terminal, the terminal's path must be set to include /data/local/bin.
I checked and my terminal includes it although I don't even have that
directory.

On unix/linux, it's usually easy to add a directory to the user's
path. But on android, every app is a separate user and has to have
it's own path set up to access the command line, and there's really no
telling where, or if, it can be changed for that app. I personally
always put scripts in /system/bin, everything finds them there.

Anyway, maybe that shed a little light on that particular mystery. gm
is probably right that typing them directly into the plugin may be
slightly faster.

Scott Miller

unread,
Mar 14, 2011, 6:33:32 PM3/14/11
to tas...@googlegroups.com

I run my scripts from Locale Execute like this:

sh /sdcard/scripts/n.sh

Works every time for me.

Scott

gm

unread,
Mar 14, 2011, 10:06:42 PM3/14/11
to Tasker
you can find the governors that your kernel supports by:

cat /sys/devices/system/cpu/cpu0/cpu0/cpufreq/
scaling_available_governors

then to change your governor eg powersave

echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/
scaling_governor (prefix @! if you use locale execute)

Each governor has its own config files which can be manipulated the
same way, you can explore the contents of the cpufreq directory to get
an idea what is supported

Most roms will have ondemand, powersave & performance

performance is basically the same as setting scaling_min_speed to that
of scaling_max_speed in ondemand
powersave is the reverse

the others that I know of
userspace- will do nothing, no scaling governor loaded,
conservative - haven't had a good play as its not in my kernel, but,
potential battery savings as it doesn't ramp the CPU straight up to
max when under load
interactive - is being used in a number of custom roms, its supposedly
more responsive than ondemand at the expense of battery
smartass - written specifically for smart devices, it watches screen
state, battery and a few other things natively and scales your cpu
accordingly... only found in custom roms I think, but, sounds pretty
cool nonetheless...

Hope that helps?

GM

hope that helps

fubaya

unread,
Mar 14, 2011, 11:10:00 PM3/14/11
to Tasker
On Mar 14, 6:33 pm, Scott Miller <sjmiller.1...@gmail.com> wrote:
> I run my scripts from Locale Execute like this:
>
> sh /sdcard/scripts/n.sh
>
> Works every time for me.
>
> Scott

Yeah, and that's probably the only option on unrooted phones as you
can't put the scripts anywhere in the executable directories like /
system/bin. The only advantage to sticking them there is that you can
just type "n.sh" in a terminal, in the execute plugin, over ssh or
with any other app that accesses the command line, but "sh /sdcard/
scripts/n.sh" should work anywhere too.

gm

unread,
Mar 15, 2011, 3:07:01 AM3/15/11
to Tasker
oops sorry, saw a typo

cat /sys/devices/system/cpu/cpu0/cpu0/cpufreq/
scaling_available_governors

should have been

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

Pent

unread,
Mar 15, 2011, 6:57:57 AM3/15/11
to Tasker
> you can find the governors that your kernel supports by:
>
> cat /sys/devices/system/cpu/cpu0/cpu0/cpufreq/
> scaling_available_governors
>
> then to change your governor eg powersave
>
> echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/
> scaling_governor   (prefix @! if you use locale execute)
>
> Each governor has its own config files which can be manipulated the
> same way, you can explore the contents of the cpufreq directory to get
> an idea what is supported

Great info, thanks. This would be reasonably simple to add to Tasker
and a really
useful feature.

Pent

gm

unread,
Mar 15, 2011, 6:17:36 PM3/15/11
to Tasker
> Great info, thanks. This would be reasonably simple to add to Tasker
> and a really
> useful feature.
>
> Pent

Thats great news, will look forward to it in a future update!

could the ability to read files from the root filesystem be a
possibility too?

currently, eg. to query the current max clock speed I run in locale
execute:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq > /sdcard/
tmp

Then a read file action on tmp which loads the file contents to a
variable for use in Tasker...

Thoughts on this?

gm

Pent

unread,
Mar 16, 2011, 3:49:39 AM3/16/11
to Tasker
> could the ability to read files from the root filesystem be a
> possibility too?
>
> currently, eg. to query the current max clock speed I run in locale
> execute:
>
> cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq > /sdcard/
> tmp
>
> Then a read file action on tmp which loads the file contents to a
> variable for use in Tasker...
>
> Thoughts on this?

I guess I could say something like 'if the path starts with / treat it
as absolute, otherwise as relative to the SD root'.
OK, I'll put that on the todo list.

Pent

Mark

unread,
Mar 17, 2011, 6:12:35 PM3/17/11
to Tasker
@ GM, Thanks dude for all your help, you've been sooooo clear and
concise on how to do everything i needed. absolutely perfect mate. Got
some awesome clocking profiles set up now (hopefully will see some
battery improvements :D). Am tempted to try an OC kernel now to use
with emulators (now i know how thanks to you) :D
@ Pent, that would be an awesome feature to be able to over/underclock
your CPU through tasker's features.

Apostol Apostolov

unread,
Mar 18, 2011, 5:32:01 PM3/18/11
to tas...@googlegroups.com
Pent, I am really looking forward SetCPU support action in Tasker - any hopes for 1.0.20?
Is it possible to change the governor as well within a separate Tasker action?

Pent

unread,
Mar 18, 2011, 5:57:12 PM3/18/11
to Tasker
> Pent, I am really looking forward SetCPU support action in Tasker -

I've on intention of supporting SetCPU (the app). At some point I'll
investigate writing
to the governer files is all.

> any
> hopes for 1.0.20?

No, too much else to do.

> Is it possible to change the governor as well within a separate Tasker
> action?

No idea, it's just a vague idea right now :-)

Pent

Pent

unread,
Mar 20, 2011, 2:30:47 PM3/20/11
to Tasker
> > any
> > hopes for 1.0.20?
>
> No, too much else to do.

I changed my mind (because it appears very simple), I intend to allow
selection of a governor (not userspace) and the min/max scaling
frequency with a new action for 1.0.20. I havn't tested it yet, so
maybe I will encounter difficulties which stop me getting it into
1.0.20.

Pent

enotar

unread,
Mar 20, 2011, 4:04:57 PM3/20/11
to Tasker
would we need CM7 if it works?
or it will be for all.

Pent

unread,
Mar 21, 2011, 4:55:24 AM3/21/11
to Tasker
> would we need CM7 if it works?
> or it will be for all.

It just needs root. To detect that, I decided to look for 'modversion'
in /system/build.prop

Pent

gm

unread,
Mar 21, 2011, 4:06:54 PM3/21/11
to Tasker
Pent,

If it helps, here's a link to some docs that go into a bit more detail
about cpufreq

http://publib.boulder.ibm.com/infocenter/lnxinfo/v3r0m0/index.jsp?topic=/liaai/cpufreq/liaai-cpufreq.htm

the other thing to bear in mind is the influx of phones that will be
coming with dual core processors... each core can be controlled
seperately and their scaling options should be found at:

/sys/devices/system/cpu/cpu0
/sys/devices/system/cpu/cpu1

HTH

gm

Pent

unread,
Mar 22, 2011, 6:20:49 AM3/22/11
to Tasker
> the other thing to bear in mind is the influx of phones that will be
> coming with dual core processors...  each core can be controlled
> seperately and their scaling options should be found at:

Yes... I had been kindof deiberately not thinking about that but I may
as well
put a CPU selector in now I guess.

Here's the help page if you want to pick nits:

http://tasker.dinglisch.net/userguide/en/cpu.html

Pent
Reply all
Reply to author
Forward
0 new messages