Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,807,458 Members 48,068 Now Online
XDA Developers Android and Mobile Development Forum

[KERNEL] 1497MHz Permanent overclock kernel with intermediate speeds!

Tip us?
 
coolbho3000
Old
(Last edited by coolbho3000; 12th November 2010 at 02:47 AM.)
#1  
Senior Recognized Developer - OP
Thanks Meter 761
Posts: 886
Join Date: Dec 2008
Exclamation [KERNEL] 1497MHz Permanent overclock kernel with intermediate speeds!

Now that we have permanent root, we can have even more fun with overclocking. This is an actual kernel, not a module, meaning that there are no scripts to run every time you restart the device, and there are a lot more speeds to choose from, from 806MHz all the way up to 1497MHz.

Just run SetCPU (set on boot will work if you have permanent root!) and set the speed to whatever you want. This is purely an overclocking kernel and is not undervolted, but undervolting is easy for other devs. Just tweak the frequency tables and recompile.

We can now properly changes voltages! With voltage increases, it is possible to push the G2 to absolutely ludicrous speeds. I've limited this kernel to 1497MHz, but I've seen speeds as high as 1.7GHz (!!!) at 1400mV. It scales remarkably in most benchmarks, too. The MSM7x30 chipset is a true overclocking champion.

For safety, this kernel defaults to 806MHz at boot (like overclocking kernels on most other devices). Use SetCPU (in my sig or on the Market) to tweak speeds precisely. (Devs: the max frequency on boot can also be adjusted in the modified cpufreq.c file).

I am not responsible for any damage these instructions or this software may cause!

Installation

I recommend flashing Cyanogen's BaconBits which contains this, more CPU governors, a newer kernel, no wifi bug, and other goodies: http://forum.xda-developers.com/showthread.php?t=834565. The binaries below are not necessary if you flash BaconBits. You'll get the overclock anyway!

Github: https://github.com/coolbho3k/vision_oc_kernel
Binaries: http://pokedev.com/setcpu/vision_oc_kernel_2.zip
Mirror: http://dl.dropbox.com/u/36553/vision_oc_kernel_2.zip

If you want to install using the old method and the binaries I posted above:

Boot into fastboot. Using the fastboot utility, run:

fastboot flash zimage zImage

Where "zImage" is the path to the zImage posted in the zip above.

You'll notice at first that your wifi doesn't work. Don't worry! In Android:

adb push bcm4329.ko /sdcard/bcm4329.ko
adb shell
su
mount -o remount,rw /dev/block/mmcblk0p25 /system
cat /sdcard/bcm4329.ko > /system/lib/modules/bcm4329.ko

EDIT: argh, I keep forgetting our ro.secure is still 1. Fixed the instructions.

Where "bcm4329.ko" is the path to the wifi module posted in the zip above. Then reboot and enjoy.

Have fun guys. This was a lot less of a pain to make than the module and I only had to actually write like three lines of code.

Developers: customizing the overclocked speeds and voltages
Just add lines to the struct acpu_freq_tbl. There are no L values to worry about unlike the 8x50 platform (this time, we automatically detect the required L value), but remember that each speed must be a multiple of 19200. The only thing you need to worry about is the voltage and the VDD_RAW:
Code:
...
{ 1017600, PLL_2,   3, 0,  192000, 1200, VDD_RAW(1200) },
{ 1113600, PLL_2,   3, 0,  192000, 1200, VDD_RAW(1200) },
{ 1209600, PLL_2,   3, 0,  192000, 1200, VDD_RAW(1200) },
{ 1305600, PLL_2,   3, 0,  192000, 1200, VDD_RAW(1200) },
{ 1401600, PLL_2,   3, 0,  192000, 1300, VDD_RAW(1300) },
{ 1497600, PLL_2,   3, 0,  192000, 1300, VDD_RAW(1300) },
...
For a lower voltage, in this case 1100mV, at 1017.6MHz:
Code:
{ 1017600, PLL_2,   3, 0,  192000, 1100, VDD_RAW(1100) },
For 1.7GHz @1400mV (warning: only tested once, and the phone got very hot. I would not recommend this ) edit: actually, 1350mV is the max you can go, I don't know what I was thinking, but this works anyway:
Code:
{ 1708800, PLL_2,   3, 0,  192000, 1400, VDD_RAW(1400) },
Then add the speeds you actually want to use to the freq_table struct, remembering to keep incrementing the first column as you go down.
Code:
...
{ 4, 1017600 },
{ 5, 1113600 },
{ 6, 1209600 },
{ 7, 1305600 },
{ 8, 1401600 },
{ 9, 1497600 },
...
How it works
The G2's CPU speeds are based on the clock output of one of several PLLs. In the default MSM7x30 configuration, the 806.4MHz speed is based on PLL2, which also runs at 806.4MHz by default. (the MSM8x55 is an identical SoC, but runs PLL2 at 1017.6MHz. There is also a 1.2GHz version of the 8x55 floating around somewhere! The stock kernel for the 8x55 reports 1024MHz as the speed, but I think this is off by a few MHz).

So to overclock, we have to change the output of PLL2. The output of PLL2 is based on the speed of TCXO, which runs at 19.2MHz. The output of PLL2 is defined as 19.2 multiplied by an integer at the address MSM_CLK_CTL_BASE + 0x33c, called the L value. By manipulating this multiplier, we can also safely manipulate the output of PLL2, and as a result, safely manipulate the CPU speed when cpufreq switches us to a speed that uses PLL2. I was able to figure out the location of the PLL2 L value using this commit on Code Aurora. Turns out the address is the same as it is on the MSM7200 platform!

My previous kernel module hack that we used did this kind of inelegantly. It wrote a new multiplier to PLL2 and basically corrected cpufreq so that it (correctly) thought that this speed was no longer 806.4MHz. It required the addresses of several data structures in the kernel because it needed to know where to manipulate cpufreq. However, since our module could only change PLL2 once and not every time there is a frequency switch, we could only have one overclocked speed. If we overclocked to 1.42GHz, we lost 806.4MHz and everything in between.

The ability to flash kernels, however, makes our lives a lot easier. Without the need to hack kernel memory to get it to do what we want, overclocking practically requires only four lines of code:

From there, changes to the frequency table to define speeds/voltages is rather trivial.

Code:
#define PLL2_L_VAL_ADDR  (MSM_CLK_CTL_BASE + 0x33)
...
/* Program PLL2 L val for overclocked speeds. */
	if(s->src == PLL_2) {
		writel(s->acpu_clk_khz/19200, PLL2_L_VAL_ADDR);
	}
The above runs during frequency switching. It basically checks if the speed we're switching to runs on PLL2, and if it does, we write the value equal to (clock speed we want)/19200 to the L value address. A much simpler solution, and much more flexible, than the kernel module method. Thank god for permaroot (or just scotty and #g2root)
Galaxy Nexus (GSM)
Control your Android phone's CPU! SetCPU for Root Users
Follow me on Twitter!

Like my work? Buy SetCPU on the market or buy me some [insert drink here].
 
ChiefzReloaded
Old
#2  
ChiefzReloaded's Avatar
Recognized Developer
Thanks Meter 216
Posts: 237
Join Date: Jan 2010
Location: Lebanon, OR

 
DONATE TO ME
Ahhh... first post lol.... Thanks man, flashed and works great +1


On June 16th of this year, I was diagnosed with a life threatening condition called "necrotizing fasciitis" and have been in the hospital most of the last 3 months. Sadly this has basically ruined our family financially and continues to dig us deeper. I have medical bills my wife and I can't pay upwards of $50k and growing weekly. If you like my work please consider making a donation towards my medical bills if you can help in any way. Any amount is greatly appreciated. If you cannot, please take a sec to hit the thanks button. Thank you for your continued support of my Android work over the last 3 years. It is greatly appreciated.
 
TL24
Old
(Last edited by TL24; 9th November 2010 at 08:02 PM.)
#3  
TL24's Avatar
Senior Member
Thanks Meter 17
Posts: 554
Join Date: Oct 2010
Location: Minneapolis, MN
Excuse a NOOB - but how do you boot into fastboot? Is that Volume Down + Power Button?

EDIT:

Nevermind I got it, but when I do "adb push bcm4329.ko /system/lib/modules/bcm4329.ko" I get the following:

failed to copy 'bcm4329.ko' to '/system/lib/modules/bcm4329.ko': Permission denied

However I am fully rooted, any ideas?

HTC One

"real recognize real"
 
k0mpresd
Old
#4  
Senior Member
Thanks Meter 25
Posts: 263
Join Date: Mar 2009
thanks for the post.
 
k0mpresd
Old
#5  
Senior Member
Thanks Meter 25
Posts: 263
Join Date: Mar 2009
Quote:
Originally Posted by TL24 View Post
Nevermind I got it, but when I do "adb push bcm4329.ko /system/lib/modules/bcm4329.ko" I get the following:

failed to copy 'bcm4329.ko' to '/system/lib/modules/bcm4329.ko': Permission denied

However I am fully rooted, any ideas?
i get read-only file system. i tried to chmod the modules folder but i get the same error.
 
coolbho3000
Old
#6  
Senior Recognized Developer - OP
Thanks Meter 761
Posts: 886
Join Date: Dec 2008
Ah oops, you'll have to remount system as rw first. Adding to topic.
Galaxy Nexus (GSM)
Control your Android phone's CPU! SetCPU for Root Users
Follow me on Twitter!

Like my work? Buy SetCPU on the market or buy me some [insert drink here].
 
TL24
Old
(Last edited by TL24; 9th November 2010 at 08:18 PM.)
#7  
TL24's Avatar
Senior Member
Thanks Meter 17
Posts: 554
Join Date: Oct 2010
Location: Minneapolis, MN
Quote:
Originally Posted by coolbho3000 View Post
Ah oops, you'll have to remount system as rw first. Adding to topic.
Is that while we're still in fastboot?

HTC One

"real recognize real"
 
wilnotdie
Old
#8  
Senior Member
Thanks Meter 24
Posts: 404
Join Date: Sep 2009
Works great, thanks!

fastboot just for the zImage

adb push or Root Explorer or Terminal Emulator to cp the wifi file.

I used terminal emulator...

Code:
su
mount -o remount,rw /dev/block/mmcblk0p25 /system
cp /sdcard/bcm4329.ko /system/lib/modules/bcm4329.ko
mount -o remount,ro /dev/block/mmcblk0p25 /system
WiFi is working fine now...
 
milenko11
Old
#9  
Senior Member
Thanks Meter 6
Posts: 183
Join Date: Aug 2009
Quote:
Originally Posted by TL24 View Post
Is that while we're stillin fastboot?
I can't get mount to work in adb
 
coolbho3000
Old
#10  
Senior Recognized Developer - OP
Thanks Meter 761
Posts: 886
Join Date: Dec 2008
Heh, whoops, did I get the system mount command wrong? Fixed it.
Galaxy Nexus (GSM)
Control your Android phone's CPU! SetCPU for Root Users
Follow me on Twitter!

Like my work? Buy SetCPU on the market or buy me some [insert drink here].

THREAD CLOSED
Subscribe
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes