[MOD] Collin_ph Battery Tweak

for the next person who fails to heed the warning in the op....

so after i unchecked and rebooted the mod was still installed and i could run through the script but the changes weren't being applied. so i ran batt.rm-sh to remove the script. rebooted now the cm7 cpu setting were acting weird, i set it to over clock it wasn't(i set to 787 but it wouldn't run over 600 and current cpu setting was showing odd numbers that weren't even choices...622). rebooted again after setting set on boot(at this point i was just trying to get cm7 cpu settings to work again) still acting wierd rebooted again. cm7 cpu settings finally work normally, unchecked set on boot with default settings for speed. rebooted into recovery flashed script, booted, went into batt-cfg set everything up agian and it seems to be working.

long story short...heed the warning...
The weird numbers are normal but not to worry. The way this tweak works is it gradually scales down (or up) the CPU a certain percent based off battery percent (or other variables). So while it may boot at 748 (it actually boots higher), when the battery hits 97% it may be at 744MHz. The way the processor works is it tries to find the closest MHz to the number, without going over the number (think the price is right lol). So if it's showing 744MHz, the closest we have without going over is 729MHz so it will be running at 729MHz until it gets down to 728MHz then it will be running at 600MHZ. To keep phones running at the highest CPU speed possible, I've actually adjusted the top levels of each preconfigured setting. For example, when you select 748000 it really sets it to 767999. This means the phone uses 748 for a longer period of time before it goes down to the next level. Prior to me making this adjustment if you selected 748MHz literally within minutes the CPU was UC'ing and putting you to 729. I wanted people to enjoy the OC a little bit prior to it starting it's scale down process.

Even with all the above said, running this while using any form of app that controls the CPU is going to cause bad, undesirable, just generally crappy things to happen :p
 
These are my results with cm7 and cputuner

EDIT: Still considering trying this script to see differences/benefits.
 
Last edited:
Ah. I thought that the scaling back was only happening over the last portion of the battery not the whole time the battery is discharging.

So actually the only time I would see the Max set freq on my CPU monitor widget would be when I'm on some sort of external power and the first...say..15% of battery at which point it will slowly reduce to 25% of Max(if that's what I set that last question in the script to)?

Do I have that right now?

and how does the set min freg come in because i'm not seeing that show up at all. I see it idle down to 480 which is where i have it set for external power sources but on battery it should be going to 320 and it isn't.

should add that i had set it to power save rather than underclock. i changed it now
 
Last edited:
I can't get it work right. i've tried going back to my nand and reinstalling with out the set on boot ever being set before i even flashed the zip. it won't switch power source profiles even though the script is aware that the source has changed from usb to batt. when i reboot on battery and enable the script it flat doesn't work. i have a log of the batt-diag that i can post in the morning to show it not switched from usb to batt when i'm on batt.
 
I flashed ath3no's CM build this morning and gave it a go. It's working just fine. Starts on boot, decreases with battery use, switches profiles on USB and AC, then switches back seamlessly after unplugging. I changed gov, changed percentage of UC, yadd yadda ... no issues what so ever.

I'd be curious how you came to the conclusion it's not working on your device?
 
ATH3NOSCM7 with stock kernal.

In the log you can see under tweakables that it knows its on battery but the set frequently is still my external power set. This log was after about 30min on battery

$ export PATH=/data/local/bin:$PATH
$su
# batt-diag
Collin_ph Battery diagnostic utility
batt-diag -v for verbose diagnostics
Checking if batt.sh service is running
pidof batt.sh: 8173

Checking dependencies. If any dependency is blank the battery tweak may not function and should be disabled
sleep: /system/bin/sleep
mount: /system/xbin/mount
expr : /system/xbin/expr
log : /system/bin/log

Checking tweak files and permissions
Checking batt.sh service
-rwxr-xr-x 1 root shell 8538 Aug 1 2008 /system/bin/batt.sh

Checking batt.conf configuration file
-rwxr-xr-x 1 root shell 473 Jul 12 23:44 /system/etc/batt.conf

Checking batt-cfg configuration utility
-rwxr-xr-x 1 root shell 14075 Aug 1 2008 /system/bin/batt-cfg

Checking batt-rm.sh service
-rwxr-xr-x 1 root shell 1293 Aug 1 2008 /system/bin/batt-rm.sh

Checking Configuration
----batt.conf file contents----
audio_fix=0
CFStweaks=0
MOUNToptions=0
enabled=1
MaxTemp=450
MaxTempEnable=n
MaxFreqOverride=767999
MinFreqOverride=245760
cpu_limiting_method=2
min_freq_on_battery=320000
max_freq_on_battery=787200
min_freq_on_USBpower=480000
max_freq_on_USBpower=787200
min_freq_on_power=480000
max_freq_on_power=787200
polling_interval_on_battery=75
polling_interval_on_power=15
polling_interval_on_USBpower=15
cpu_max_underclock_perc=15
scaling_governor=interactive
cpu_scheduler=noop
----end of batt.conf----
----Mount points----
rootfs on / type rootfs (ro,relatime)
tmpfs on /dev type tmpfs (rw,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /mnt/asec type tmpfs (rw,relatime,mode=755,gid=1000)
tmpfs on /mnt/obb type tmpfs (rw,relatime,mode=755,gid=1000)
/dev/block/mtdblock5 on /system type yaffs2 (ro,relatime)
/dev/block/mtdblock6 on /data type yaffs2 (rw,nosuid,nodev,relatime)
/dev/block/mtdblock1 on /cache type yaffs2 (rw,nosuid,nodev,relatime)
/dev/block/mtdblock1 on /data/dalvik-cache type yaffs2 (rw,nosuid,nodev,relatime)
/dev/block/vold/179:1 on /mnt/sdcard type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/block/vold/179:1 on /mnt/secure/asec type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
tmpfs on /mnt/sdcard/.android_secure type tmpfs (ro,relatime,size=0k,mode=000)
/proc/mounts/
/proc/mounts/: Not a directory


Displaying CFS tweaks.----
mount: mounting none on /sys/kernel/debug failed: No such file or directory
/sys/kernel/debug/sched_features
/sys/kernel/debug/sched_features: No such file or directory
/proc/sys/kernel/sched_latency_ns
/proc/sys/kernel/sched_latency_ns: No such file or directory
/proc/sys/kernel/sched_min_granularity_ns
/proc/sys/kernel/sched_min_granularity_ns: No such file or directory
/proc/sys/kernel/sched_wakeup_granularity_ns
/proc/sys/kernel/sched_wakeup_granularity_ns: No such file or directory
umount: can't umount /sys/kernel/debug: No such file or directory



Displaying Current CPU scheduler and Scaling Governor
Scaling Governor:
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
interactive
CPU scheduler:
/sys/block/mtdblock3/queue/scheduler
[noop]



Displaying Batt.sh tweakables.----
/proc/sys/vm/swappiness
30
/proc/sys/vm/dirty_expire_centisecs
3000
/proc/sys/vm/dirty_writeback_centisecs
500
/proc/sys/vm/dirty_background_ratio
10
/proc/sys/vm/dirty_ratio
40
/proc/sys/vm/vfs_cache_pressure
10
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
787200
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
480000
/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold: No such file or directory
/sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
/sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias: No such file or directory
Current charging source: 0=Battery 1=AC
/sys/class/power_supply/ac/online
0
Current charging source: 0=Battery 1=USB
/sys/class/power_supply/usb/online
0
Current battery capacity
/sys/class/power_supply/battery/capacity
91
/sys/class/power_supply/battery/health
Good

----Current Battery Temp----
/sys/class/power_supply/battery/temp: No such file or directory
expr: non-numeric argument
expr: non-numeric argument
expr: non-numeric argument
expr: non-numeric argument
F / C
----End of Battery Temp----

----ROM Version----
Linux version 2.6.32.33-Xionia_014 (zefie@selena) (gcc version 4.5.1 (Buildroot 2010.11-rc2) ) #1 PREEMPT Sun Mar 27 19:21:47 EDT 2011
----End of ROM Version ----

---CPU Time in each Frequency---
122880 0
245760 13862
320000 294
480000 461750
600000 27135
729600 5095
748800 822
768000 720
787200 42668
806400 0
825600 0
844800 0
864000 0
---End of CPU Time in each Frequency----

#
 
Try doing the following ....

It's important to follow each step, in order. Even if you just did one of these 5 minutes before reading this, humor me and do it again because i took the time to type it out :p

1) Ensure "set on boot" is not checked in Menu>settings>cyanogenmod settings>Performance>CPU Settings
2) Thoroughly go through all installed apps to ensure you have nothing that can control the CPU. There are too many for me to name so i couldn't possibly list them all but double check.
3) Place the mod tweak zip and ath3nos CM zip on the root of your SD card
4) Mount /system as r/w.
5) open terminal emulator and do the following
Code:
su
batt-rm.sh
y
reboot recovery
6) Wipe dalvik (don't wipe data)
7) Wipe cache (don't wipe data)
8) Flash the ROM
9) Flash the tweak

Ok so assuming you've done all the steps, you've now removed yourself from being part the problem. Sorry but I've worked on Android long enough to know 99.99% of the time it's user error :)

Now do the following
10) open terminal and type
Code:
su
pidof batt.sh
If you get a numeric reply that's good.
11) Now I'm going to suggest you do something i said absolutely not to do and that's download and install SetCPU. Let me explain why, if you install SetCPU and don't touch anything, I mean ANYTHING, when you open SetCPU it opens to the main tab, you can watch in real time when the phone scales up or down. You can watch freq's change as it's plugged in or unplugged, you can watch as it slowly underclocks the CPU based on battery percentage (this will help you figure out which percentage might be best for your needs). Remember, the polling interval for on battery is 75 seconds so when you plug the phone in it could take 74 seconds theoretically for the script to identify the phone is plugged in. Polling on USB/AC is 15 seconds so you'll see that change fairly quickly after unplugging.

If you touch anything in SetCPU, you've blown it. Don't use SetCPU for anything except a real time window into what the script is doing for the freq's. Good luck!
 
Trying it out know.

I was working on the assumption it was some sort of self induced issue...software usually does exactly what its told ...by the user weather they realize it or not...
 
My batt-diag looks similar to 8616v's. What says that its not working. I don't have setcpu to look at it...
 
Been messing with it and I've narrowed down what seems to be my problem ...everything works as advertised with the default profiles as far as I can tell. When I make a manual setup it still isn't making the switch from AC to Batt or USB To batt. AC to USB gets changed.

I'm not totally sure that this isn't happening with the presets too though. The first time after the dirty flash(I did that process on battery) no CPU settings were changed from stock untill I plugged in my charger, than it overclocked. But the CPU stayed at 600 until the phone was plugged in.
 
After a couple hours on battery its definately underclocking as the battery goes down but its still on USB profile ...


I'm just gonna set one of the preset profiles and forget it....

If anyone has any ideas ill be glad to test them out though.
 
Last edited:
After a couple hours on battery its definately underclocking as the battery goes down but its still on USB profile ...


I'm just gonna set one of the preset profiles and forget it....

If anyone has any ideas ill be glad to test them out though.

I'm gonna be busy for a few days with non-android related stuff but when i get some free time I'll set a custom profile and see how it behaves. If i can duplicate it on a custom profile that will help me out. In the interim use the presets (min/max usb, ac, battery) because i can guarantee those work without a hitch. You can physically watch them work with the way i told you before :) (it's quite interesting). We tested the tweak on reborn, CM, and shell and everything passed so the defaults will work for now.

The only bugs logged are the batt.sh not starting on boot for reborn and shell but nick has that fixed up and will be releasing an update soon.

Cheers!
 
pretty impressed...between ath3nos cm7 and this mod i've almost doubled my battery life...
 
While I've only been using it for several hours now, this mod is really seeming to help my battery life with Reborn 2.2.3! (I'm using preset #4, btw, which looks to be similar to what I had my setcpu profiles set to anyway).
 
Cool cool, glad to hear people are enjoying it. I'm back from vacation and need to wrap up some personal stuff but will check out the custom profiles soon, 8616v. Reborn 2.2.3 was released thanks to Nick7 to allow the batt.sh to survive a reboot. I don't think he's adjusted shell ROM yet but I'm sure it's coming. Any other dev's (Non-CM based) please see post #2 of this thread on how to allow the service to start of boot.

Dev's, for now please don't include this mod in your ROM until I've finished tweaking it. I know a couple of you have written me about it, but It's complex and not straight forward so I'd like to make sure any issues associated with it don't get mixed in with ROM bugs. This helps me help continue improving the script and you continue improving your ROM. Thanks :)
 
Last edited:

Trending Posts

Forum statistics

Threads
956,588
Messages
6,968,978
Members
3,163,579
Latest member
DigiMob app