FORUMS
Remove All Ads from XDA

[KERNEL] Undervolt driver for the stock HTC kernel for Desire and others (2.6.32.15)

64 posts
Thanks Meter: 15
 
By iscaela, Member on 6th September 2010, 09:06 AM
Post Reply Email Thread
This kernel module allows you to run any official Froyo kernel image from HTC with reduced CPU voltages at each frequency. Reducing voltage decreases the power consumed by the CPU (dissipated as heat).

INSTALL:
You need root or an unrestricted recovery image (e.g ClockworkMod) to install this. The default settings decrease voltage by 75-100 mV which seems stable on my device. Just download the attached file and select it from recovery or ROM Manager.

I've built "update.zip" files for the Desire with Linux kernel versions 2.6.32.15-gf9c0527, 2.6.32.15-gd96f2c0, and 2.6.32.15-g6a358a9. You can check your kernel version in Settings->About phone->Software information.

Other HTC devices running Froyo are supported. If you have a different device, please give me the full version number and I can add an update.zip for it.


Undervolt driver for the EVO 4G



Added undervolt-2.6.32.15-gd96f2c0-20100907.zip.
Added undervolt-2.6.32.15-g6a358a9-20100907.zip.
Added undervolt-2.6.32.15-gf5a401c-20100907.zip.


USAGE:
Read the instructions above first. If you are happy with the default settings, you don't need to read this unless you're curious


To load the driver, use an init script like this one (included):
Code:
#!/system/bin/sh
#
# Load undervolt for htc-kernel
addr=`awk '$3 == "acpuclk_set_rate" { print "0x"$1; }' /proc/kallsyms`
if [ -n "$addr" ]; then
        insmod /system/lib/modules/undervolt.ko "acpuclk_set_rate_addr=$addr"
        if [ $? -eq 0 ]; then
                echo '-75' > /proc/undervolt
                echo '1225 1125' > /proc/undervolt
                echo '1250 1150' > /proc/undervolt
                echo '1275 1175' > /proc/undervolt
                echo '1300 1200' > /proc/undervolt
                echo '1' > /proc/undervolt
                echo "+++ undervolt enabled"
                exit 0
        fi      
fi
echo "+++ undervolt could not be enabled
The driver adds a "/proc/undervolt" knob to make voltage changes, reading from it prints the current default and adjusted voltages in mV for every CPU frequency, e.g.:
Code:
cat /proc/undervolt
1050  975    19200
1050  975   128000
...
1300 1200   960000
1300 1200   998400
Write a space-separated pair of default and adjusted voltages in mV to change the values in the table, e.g. to undervolt stock freqs using 1500 mV to 1000mV):
Code:
echo '1050 1000' > /proc/undervolt
.
Write '+' or '-' followed by a single number to adjust *all* voltages by that amount in mV:
Code:
echo '-25' > /proc/undervolt
The changes are NOT applied until you write the number 1:
Code:
echo '1' > /proc/undervolt
Writing the number 0 reverts all voltages to the default. This also happens when you unload the module with rmmod.

BACKGROUND:
I figured it would be possible to locate and modify acpu_freq_tbl on the stock HTC kernel with a LKM (since /dev/kmem isn't available), and I was right, although it involved peeking at the ARM opcodes. The method should also work for other HTC kernel images on recent devices (anything with a "Scorpion" CPU): Nexus One, Droid Incredible, EVO 4G. Overclocking will be possible with a bit more work.

This also disables the voltage constraints set by the board-specific configuration (e.g. in board-bravo.c or board-incrediblec.c). This was done by y patching the regulator_set_voltage function to simply ignore the constraints. The remaining limits are imposed by the driver for the regulator IC. The TPS65023 driver defines these for VDCDC1: min_uV = 800000, max_uV = 1600000.

KNOWN BUGS:
There is a vdd_undervolt parameter to set the default undervolt, but it is ignored (by insmod?), use +/- instead.
The Following User Says Thank You to iscaela For This Useful Post: [ View ] Gift iscaela Ad-Free
 
 
6th September 2010, 10:30 AM |#2  
Senior Member
Thanks Meter: 218
 
More
Very nice work!
6th September 2010, 10:33 AM |#3  
Retired Recognized Developer
Thanks Meter: 1,773
 
Donate to Me
More
That is, in fact, fantastic work :)

Of course it will be obsoleted when HTC decides to release their source but you know that

I assume you verified these actually work?
6th September 2010, 10:45 AM |#4  
Senior Member
Flag Lisboa
Thanks Meter: 73
 
More
ok...this is nice i think!

i don't know much about kernel so...can i use the update.zip to install this kernel in my actual sense rom ?
just, install this and that's it? it starts working undervolted?
6th September 2010, 11:52 AM |#5  
Retired Recognized Developer
Thanks Meter: 1,773
 
Donate to Me
More
Did you account for the fact the stock kernel has board files to constrain the minimum
and maximum voltage?

eg, board-bravo.c:
.min_uV = 1000000
.max_uV = 1300000

The same goes for overclocking, the upper limit for the clock is set, hardcoded,
so you would need to change that as well.
6th September 2010, 12:02 PM |#6  
Junior Member
Flag Seoul
Thanks Meter: 10
 
More
Thumbs up
sounds interesting!! I`ll try it very soon.
6th September 2010, 05:21 PM |#7  
OP Member
Thanks Meter: 15
 
More
Quote:
Originally Posted by ieftm

Did you account for the fact the stock kernel has board files to constrain the minimum
and maximum voltage?

eg, board-bravo.c:
.min_uV = 1000000
.max_uV = 1300000

The same goes for overclocking, the upper limit for the clock is set, hardcoded,
so you would need to change that as well.

Yikes, I didn't know about that, is that in bravo_fixup (which I hope is in the .init section like acpu_freq_tbl_fixup)? Is board-bravo.c in the incrediblec or vanilla Android kernel trees? I'm using the supersonic source atm.

Thanks!

-Albert
6th September 2010, 05:47 PM |#8  
OP Member
Thanks Meter: 15
 
More
Quote:
Originally Posted by ieftm

That is, in fact, fantastic work :)

Of course it will be obsoleted when HTC decides to release their source but you know that

I assume you verified these actually work?

Thanks, I haven't hacked on the Linux kernel in ages and wasted a lot of time targeting acpu_freq_tbl_fixup originally (as you might have noticed in the comments).

The idea is that this should work with the stock kernel images of multiple devices without reflashing, and in future releases with only minor changes.

I didn't take a multimeter to the board, if that's what you mean... but acpu_freq_tbl is canonical list of voltages (unless something in board-bravo.c rewrites it after initialisation, which seems unlikely) and this is able to read and write to the table. The actual CPU frequencies are duplicated in another structure (which is why I haven't tried overclocking yet) but the voltages are read directly from the table and scaled to microvolts for the governor.
6th September 2010, 08:23 PM |#9  
Senior Member
Thanks Meter: 0
 
More
Thanks alot for your work. Does anybody have ' proof ' this script works on a Desire running standard HTC Froyo ?

There is no way to check is there, except having better battery life?
What kind of energy saving is possible with this method?

Thanks
6th September 2010, 08:31 PM |#10  
NeoPhyTe.x360's Avatar
Retired Recognized Developer
Flag oυτ oƒ иoωнєяє
Thanks Meter: 1,868
 
Donate to Me
More
Seems to work....but not below 1000mV, so like you say, isn't there ways to check it....
6th September 2010, 08:34 PM |#11  
Senior Member
Thanks Meter: 0
 
More
Ne0, you are on the Dutch television as we speak (the matrix revolutions)

At what mV is the desire standard doing ? Going to flash you 7.6 now
Post Reply Subscribe to Thread

Tags
kernel, stock, undervolt

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes