# Battery Life By Underclocking



## x13thangelx

Disclaimer: I, nor the developers of either of the apps mentioned below accept responsibility for what you do to your device.

So I've been asked multiple times how I go 12+ hours on the normal battery with average use. I really dont do much so this can easily be increased.

Recommended apps:
SetCPU (free from XDA or paid on the market) - http://forum.xda-dev...ad.php?t=505419
Milestone Overclock - http://milestone-ove...verclock148.apk

Progressive underclock:
This is the single biggest thing I've found to help with battery life. This is relatively easy to understand, you lower the clock speed as the battery reaches certain points. This is done by profiles in SetCPU.

These are my battery level slots:
(with stock speeds, adjust if you modify them)
profile min/max priority
charging 300/1200 70
<40% 300/800 60
<80% 300/1000 50

Screen off underclock:
Another pretty easy to understand one. SetCPU lowers the max clock speed whenever your screen is off. Also done via profiles in SetCPU.

(stock speeds again)
profile min/max priority
Screen Off 300/600 90

Notes about SetCPU:
You should always have a "Temp > xx C" profile. I use 50C which is a tad on the high side but still within safe limits. I would recommend using 46-47C but ultimately is up to you.

profile min/max priority
Temp > 50 C 300/300 100

Governor:
I use Ondemand personally. Its made to do what it says, scales up the processor when its needed but the rest of the time will with at the lowest speed. With that said, smartass is a bit more efficient however it requires setting at a lower speed otherwise it doesnt work right. I prefer not to cripple my device when its not needed. In the end, it is entirely up to you.

SetCPU Advanced tab:
This is a really good explanation and rather than re-typing it all out I'll just link to it: http://forum.xda-dev...304&postcount=1

Here is my values though:
Sampling Rate: 37500
Up Threshold: 75
Ignore Nice Load: 0
Powersave bias: 500

Milestone Overclock:
This really is an amazingly useful app when you start using it. It does two things, 1) has the overclock module and allows you to have it load on boot without having to write a shell script to do so and 2) allows you to easily modify the top frequency speed/voltage. All others require a script to modify however and I'll get into that later in this post.

So when you open the app its pretty straight forward. Load module loads the overclock module, refresh refreshes the values above unload module when it is loaded, apply applies the value from the slider, and the slider allows you to pick which you use. Autoload on boot is also pretty obvious, it loads the overclock module after boot (its either 30 seconds after or 60 seconds after, cant remember). It allows the environment to get booted and sane (not running the boot up processes) and then loads. This is nice because if you set it then your device cant handle the speed it allows you time to deselect autoload.

Now the real prize here is that last slot of the slider, the custom one. When you press the menu button then click settings it allows you to change the clock speed and vsel. These values will differ for every device. For instance, I can run mine up to 1375000 khz (the value is in khz in the settings menu) but Ace can go up to 1395000 khz without problems, mine instantly reboots above 1375 mhz. Vsel is much the same, this will vary by your slot speed though.

My values for reference:
clock speed: 1350
vsel: 66

Finding your speed/voltage:
Be very very very careful when testing to find your speed/voltage. Do NOT rush this, otherwise you can easily bootloop your device and the only way to get out of it is by wiping data. Do not set at boot until you have found a stable speed/voltage.

Using the settings menu and the custom slot bump up your custom rate in small increments. Generally safe way to get a "ball park figure" is to bump it up by 50 mhz at a time, then when it reboots go to 10, when it reboots go to 5, then 1. Always stress test each speed for a minute or two. This is especially important when you start narrowing in your speeds. This is a very handy feature of SetCPU, it has a stress test built in under the info tab of the app.

For vsel, do basically the same thing just in 2/3 increments instead of 50/10/5. Always stress test and when you find the vsel that it reboots at then bump it up by 2 or 3 to be safe.

I'll write up about writing a shell script for all slots later.


----------



## x13thangelx

Finally got off my butt and got around to writing this.....

This is how to write a shell script for underclock/undervolt. I'll try to explain how everything works as I go.

So this is my oc script and there are multiple ways to do it.



Code:


<br />
#!/system/bin/sh<br />
# might cause problems, use at your own risk<br />
# optimized for x13thangelx's D2G<br />
<br />
# sleep so that it allows you time to remove/comment the script if it causes problems on boot<br />
sleep 120<br />
<br />
# voltages<br />
echo 1 300000000 17 > /proc/overclock/mpu_opps<br />
echo 2 645000000 34 > /proc/overclock/mpu_opps<br />
echo 3 886000000 45 > /proc/overclock/mpu_opps<br />
echo 4 1128000000 58> /proc/overclock/mpu_opps<br />
echo 5 1350000000 68 > /proc/overclock/mpu_opps<br />
<br />
# speeds<br />
echo 0 1350000 > /proc/overclock/freq_table<br />
echo 1 1128000 > /proc/overclock/freq_table<br />
echo 2 886000 > /proc/overclock/freq_table<br />
echo 3 645000 > /proc/overclock/freq_table<br />
echo 4 300000 > /proc/overclock/freq_table<br />

Now to dissect it....

Its fairly straight forward as far as a script goes, waits 2 minutes then write some numbers to the overclock module.

Quick overview of a shell script:


Code:


<br />
#!/system/bin/sh<br />

This line tells the script what it gets run as and the path to what runs it, in this case a shell script using sh in /system/bin.



Code:


<br />
#<br />

This symbol is used to comment things out. This can be used for explanations, directions, or removal of lines so it doesnt get run, etc. Commented lines are not executed. Say i used "#sleep 120" instead of "sleep 120", then it would not execute the sleep command.



Code:


<br />
sleep 120<br />

This makes the script wait for 120 seconds before running. This is mostly to allow the environment to be sane before changing values. It also allows you to fix any problems (read reboots) by changing values, deleting the script, or other methods, without having to reflash the system or wipe data.



Code:


<br />
echo<br />

From the echo manpage: "Display message on screen, writes each given STRING to standard output, with a space between each and a newline after the last one."
This command can be used to display text or to write data to a location. In this case it writes the values we use for our clock speeds and our vsel's.

This requires the Overclock module to already be loaded. This can be done by having Milestone Overclock set to load on boot or by insmod'ing the module yourself.

if you have Milestone Overclock installed as well then add this line to the script after "sleep 120"


Code:


<br />
insmod /data/data/pt.com.darksum.milestoneoverclock/files/overclock.ko<br />

Running the script:

Theres several ways to run a script. I personally prefer using Script Manager because I have had init.d not run the script before.

Init.d method:
this requires a rom that supports init.d (which I think is everything but stock and it can with a little work)
Rather simple, name the script 99oc.sh and put it in /system/etc/init.d and make it executable ("chmod +x /system/etc/init.d/99oc.sh" in terminal)

Manual method:
Save the script anywhere you wish and then run it by typing this into terminal emulator: sh /<path/to/saved/script> (obviously replace that with where you saved it including the scripts name).
Downside is that you have to manually run it every boot.

Script Manager method:
Requires Script Manager (free on the market)
Save the script somewhere on your sdcard then point Script manager at it, run as root (and when you know for sure you wont cause problems with it run at boot).


----------



## swirly

good looking yo! I owe you 2 now!


----------



## nailbomb3

Awesome brother thanks !

Sent from my DROID2 GLOBAL using Tapatalk


----------



## Patgt500

Can't wait on the shell script write up!

MIUI!!


----------



## bikedude880

Please note that the current version of smartass is not tuned for our device.


----------



## x13thangelx

bikedude880 said:


> Please note that the current version of smartass is not tuned for our device.


"With that said, smartass is a bit more efficient however it requires setting at a lower speed otherwise it doesnt work right." Close enough.... I'll make a direct note of it in the op later though.


----------



## nailbomb3

Up and running with stock clocks and voltages. Will report back with results.

Sent from my DROID2 GLOBAL using Tapatalk


----------



## phrir1

What's the best way to undervolt?

Sent from my DROID2 GLOBAL using RootzWiki Forums


----------



## x13thangelx

phrir1 said:


> What's the best way to undervolt?
> 
> Sent from my DROID2 GLOBAL using RootzWiki Forums


Shell script. Only way I know tbh.

I'll do a writeup on it soonish.... Been busy with other projects.


----------



## kr3n

Quickclock advanced lets you control voltage too, but its a paid app.


----------



## phrir1

kr3n said:


> Quickclock advanced lets you control voltage too, but its a paid app.


I have used it for about two weeks and let it do the auto calibration and bumbed up the bmv by 3 and didn't do any extreme overclocking and at random points even with my phone just sitting there it would just reboot. I didn't like it. I have haven't had any issues with milestone oc and set up the way 13th explained with setcpu. But I just want to see if I can get a little more life out of the battery while still using milestone oc. I will just wait for 13th's script.

Thanks again for the info x13thangelx

Sent from my DROID2 GLOBAL using RootzWiki Forums


----------



## x13thangelx

2nd part posted. If theres any specific questions or anything I missed let me know


----------



## Patgt500

QWhenever I try to run this with Script manager, i get, "/mnt/sdcard/roms/test.sh: !/system/bin/sh: not found"
: not found
: not found
I uncommented the first line after trying with it commented, and getting the same thing with the addition of the # in front of !/system/bin/sh:

and then
"/mnt/sdcard/roms/test.sh: cannot create /proc/ov: directory nonexistent"
i manually loaded the module from milestone overclock before i tried it. From what it seems, none of the directories in the shell script are in my file system. any ideas?

edit: nvm, fixed my stupidity, but when i run this and then auto detect on setcpu, it shows the custom frequencies, 1350 is selectable, but it still shows 1200 as the max.


----------



## x13thangelx

Yea, it does that just set the slider to 1350 or w/e your highest is.


----------



## nailbomb3

Thanks again 13th.

Sent from my DROID2 GLOBAL using Tapatalk


----------



## phrir1

2 Quick questions.

1. i'm no sure why but after i run the script everything runs fine and smooth but for some reason cpuspy doesn't register any of the new frequencies (setcpu can see them). all that registers is deep sleep and 300 mhz. any reason why that is, and can it be fixed?

2. does anyone know the command to run in terminal emulator that pulls the freq and vsel values that are being ran. I have done it before i just can't remember the command.

EDIT: found the answer to #2, if anyone else wants it here it is.

cat /proc/overclock/mpu_opps


----------



## ldopa

Quickclock advanced is my favorite. It calibrates for you by finding the min and max freq and voltages. No needs to spend all the time doing it manually. Plus, after calibration, you can also fine tune any of the settings.

Absolutely a must have app


----------



## phrir1

ldopa said:


> I have used it for about two weeks and let it do the auto calibration and bumbed up the bmv by 3 and didn't do any extreme overclocking and at random points even with my phone just sitting there it would just reboot. I didn't like it. I have haven't had any issues with milestone oc and set up the way 13th explained with setcpu. But I just want to see if I can get a little more life out of the battery while still using milestone oc. I will just wait for 13th's script.
> 
> Thanks again for the info x13thangelx
> 
> Sent from my DROID2 GLOBAL using RootzWiki Forums


----------



## kevdliu

bummer 300mhz is the lowest it can go


----------



## x13thangelx

kevdliu said:


> bummer 300mhz is the lowest it can go


I had mine running at 250mhz before, was buggy as hell though...


----------



## kevdliu

x13thangelx said:


> I had mine running at 250mhz before, was buggy as hell though...


when i did it it just scaled from the 2nd to 5th step which in my case is 500-1200. but if its buggy as hell then i guess i shouldnt even try


----------



## nailbomb3

Angel I don't know why but going the setcpu route turned my phone into lag city. Having much better luck using smartass at a max clock of 800mhz in cm's settings menu.

Sent from my DROID2 GLOBAL using Tapatalk


----------



## x13thangelx

Did you use the same clock speeds? I've been using SetCPU for months and have never had that happen that I couldnt attribute to other settings


----------



## angryshuna

Setcpu kept getting stuck in screen off for me-lag city. I seem to do a lot better at 300-800 undervolted without any profiles.


----------



## nailbomb3

x13thangelx said:


> Did you use the same clock speeds? I've been using SetCPU for months and have never had that happen that I couldnt attribute to other settings


Yeah stock clocks on the device. Sysctl from jakebites mods and a few prop edits. Nothing crazy I don't think.

Sent from my DROID2 GLOBAL using Tapatalk


----------



## nailbomb3

Angel, brother....

I ditched Jake's and went with your flashable zip of sysctl/prop tweaks last night. Phone was fast and snappy. Was....

Fired up SetCPU and boom, same thing as before laaaaaag city. Scrolling thru menu's, scrolling thru SMS messages, zooming webpages you name it. Slowed it right the hell down. Killed SetCPU and bang nice and fluid and fast again.

Can you confirm that the values you posted in the Advanced section in your OP are the correct ones? I'm wondering if that's what the deal is.

Thanks man









ETA: I suspect "Powersave Bias" is the culprit. According to your OP you set it at "500"?

I just went and read the XDA thread and they indicated lower values are better.


----------



## bikedude880

nailbomb3 said:


> Angel, brother....
> 
> I ditched Jake's and went with your flashable zip of sysctl/prop tweaks last night. Phone was fast and snappy. Was....
> 
> Fired up SetCPU and boom, same thing as before laaaaaag city. Scrolling thru menu's, scrolling thru SMS messages, zooming webpages you name it. Slowed it right the hell down. Killed SetCPU and bang nice and fluid and fast again.
> 
> Can you confirm that the values you posted in the Advanced section in your OP are the correct ones? I'm wondering if that's what the deal is.
> 
> Thanks man
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ETA: I suspect "Powersave Bias" is the culprit. According to your OP you set it at "500"?
> 
> I just went and read the XDA thread and they indicated lower values are better.


Can you post the contents of your /system/lib/egl/egl.cfg ?


----------



## nailbomb3

0 0 android
0 1 POWERVR_SGX530_125

Sent from my DROID2 GLOBAL using Tapatalk


----------



## x13thangelx

nailbomb3 said:


> Angel, brother....
> 
> I ditched Jake's and went with your flashable zip of sysctl/prop tweaks last night. Phone was fast and snappy. Was....
> 
> Fired up SetCPU and boom, same thing as before laaaaaag city. Scrolling thru menu's, scrolling thru SMS messages, zooming webpages you name it. Slowed it right the hell down. Killed SetCPU and bang nice and fluid and fast again.
> 
> Can you confirm that the values you posted in the Advanced section in your OP are the correct ones? I'm wondering if that's what the deal is.
> 
> Thanks man
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ETA: I suspect "Powersave Bias" is the culprit. According to your OP you set it at "500"?
> 
> I just went and read the XDA thread and they indicated lower values are better.


Yes, heres a screenshot of my advanced and of my profiles tabs in SetCPU.

Its personal preference I guess. I've used 500 for a while without problems. Try changing it to 0 and see if that helps.


----------



## nailbomb3

Thanks brother, I will mess around with it a bit. As I said your tweaks .zip file works fan f'ingtastic!


----------



## xfloggingkylex

Just because you couldn't get it working doesn't mean it isn't an excellent app. I have been using quick clock for a while now, have run it at 1.45 ghz and overvolted as well as 900 mhz and seriously undervolted. The setting I used the longest was about 1.2 ghz while still being under stock voltage. Never once had a reboot from Quick Clock. If you are having issues your CPU probably can't handle it.

Either way, how high did you move your stability buffer?

you're honestly the first person I've heard say they couldn't use QCA.


----------



## clouse2013

Right now stable at 1400! just gotta set the voltage. Also i noticed that Quick Clock Advanced has a scripter built into it that was helpful for this. But whenever i try to set the cpu after new values using quick clock, it says max cpu speed is 1200. Is this because of our module?


----------



## ElectroGeek

Used milestone overclock from OP and it messed up gthe hardware qwerty. Every key with a shortcut associated to it would lauch the shortcut instead of typing the letter (b launched the browser etc).

DROID2 GLOBAL CM7GB


----------



## x13thangelx

ElectroGeek said:


> Used milestone overclock from OP and it messed up gthe hardware qwerty. Every key with a shortcut associated to it would lauch the shortcut instead of typing the letter (b launched the browser etc).
> 
> DROID2 GLOBAL CM7GB


There's an option in settings to disable shortcuts. It sometimes randomly turned on for me but a reboot would fix it.

Sent from my D2G


----------



## aceoyame

clouse2013 said:


> Right now stable at 1400! just gotta set the voltage. Also i noticed that Quick Clock Advanced has a scripter built into it that was helpful for this. But whenever i try to set the cpu after new values using quick clock, it says max cpu speed is 1200. Is this because of our module?


congrats if it is stable. You have the fastest cpu of any d2g atm then lol. Mine took 1.395 max, it couldn't give any more.


----------



## ldopa

Same with mine. I can never hit 1.4ghz.


----------



## phrir1

Best I got so far with light/moderate use,

Underclocked, with tweaks from angel and running voltage script. If I tried probably could have got a little more life. Just wanted to share because I was charging my phone twice a day for a while with moderate use.









Sent from my DROID2 GLOBAL using RootzWiki Forums


----------



## nailbomb3

phrir1 said:


> Best I got so far with light/moderate use,
> 
> Underclocked, with tweaks from angel and running voltage script. If I tried probably could have got a little more life. Just wanted to share because I was charging my phone twice a day for a while with moderate use.
> 
> View attachment 11840
> 
> 
> Sent from my DROID2 GLOBAL using RootzWiki Forums


Outstanding!


----------



## clouse2013

aceoyame said:


> congrats if it is stable. You have the fastest cpu of any d2g atm then lol. Mine took 1.395 max, it couldn't give any more.


Thanks. It seems stable there. I may try to go higher but theres not much of a point.


----------



## CrossoverDOC

Angel, I appreciate all of your work, I just have a few questions.
First, I might be missing something, but why should you overclock your device to 1.35 when the highest profile you have is 1.2?
Also, I'm not sure what vsel affects, and what effects do undervolting have on the battery? And would you recommend ondemand or conservative gov?


----------



## x13thangelx

My actual profiles use considerable different values. I was using stock values for the op.

Vsel is basically voltage that is used (not sure the exact definition). Can increase battery life because you use less volts to do the same thing.

Personal preference. I use ondemand.


----------



## CrossoverDOC

x13thangelx said:


> My actual profiles use considerable different values. I was using stock values for the op.
> 
> Vsel is basically voltage that is used (not sure the exact definition). Can increase battery life because you use less volts to do the same thing.
> 
> Personal preference. I use ondemand.


Thank you very much! Care to list those profiles?


----------



## x13thangelx

temp > 50 300/300
screen off 300/645
charging 300/1350 (which also works until it gets to the first battery profile)
Battery > 40 300/886
Battery > 80 300/1128

Same basic profiles, i just oc'd all the slots a little.


----------



## nailbomb3

Quickclock ftw. Undervolting cm really helps

Sent from my DROID2 GLOBAL using Tapatalk


----------



## theskinny

Delete....ever have that "duh" moment? Thanks for the script angel!!


----------



## tRu3_sKiTz0

It's a beautiful thing.

Sent from my DROID2 GLOBAL using Tapatalk


----------



## tRu3_sKiTz0

This is my current batt state after a full day's work and messin around with google searches and youtube and voice sprinkled throughout the day/night. I recently downloaded and installed the latest Angel build(CM7, you can see the little gap where my phone in recovery and then rebooting, thank you so much) and I am also using the settings(exactly, including on demand and everything)that you posted in the OP. I like my batt and performance as is. I was just wondering if you(Angel, since I have seen you mention other governers in other threads) had other suggestions that might increase performance and batt life. Not a big deal, I'm happy, just curious. Thanks again for this.

Sent from my DROID2 GLOBAL using Tapatalk


----------



## x13thangelx

tRu3_sKiTz0 said:


> I was just wondering if you(Angel, since I have seen you mention other governers in other threads) had other suggestions that might increase performance and batt life. Not a big deal, I'm happy, just curious. Thanks again for this.
> 
> Sent from my DROID2 GLOBAL using Tapatalk


I use InteractiveX. Havent noticed much improvement either way but I also tend to leave mine either plugged into my laptop or with the screen off in my pocket for vast amounts of time so it hasnt really had much hard usage to really test with. I like it enough that I included it in my v2 of "tweaks" though (which i havent posted anywhere).


----------



## tRu3_sKiTz0

I will keep that inn mind but since this is working well for me,i will leave it as is for now. Thanks again.

Sent from my DROID2 GLOBAL using Tapatalk


----------



## BMc08GT

x13thangelx said:


> My actual profiles use considerable different values. I was using stock values for the op.
> 
> Vsel is basically voltage that is used (not sure the exact definition). Can increase battery life because you use less volts to do the same thing.
> 
> Personal preference. I use ondemand.


Vsel is the hex #. the conversion for mv @at 1200MHz and say 55vsel is as follows:

so DECIMAL=(5*16^1)+(5*16^0)
DECIMAL=(5*16)+(5)=85

then

mV=(0.6+85)(12)+600=1620.6

heres a way that will auto the conversion from hex to decimal


Code:


<br />
#in this example vsel will equal the 55 from above<br />
# so VSEL=55<br />
hex1=` echo $VSEL | cut -c 1 `<br />
hex2=` echo $VSEL | cut -c 2 `<br />
add1=` dc $hex1 16 \* p `<br />
add2=` dc $hex2 1 \* p `<br />
decimal=` dc $add1 $add2 + p `<br />
echo $mV<br />

it will give you the correct value of 85


----------



## enigmawutashi

nailbomb3 said:


> Thanks brother, I will mess around with it a bit. As I said your tweaks .zip file works fan f'ingtastic!


Hi where can I find those tweaks?
thanks


----------

