Overclocking

=Overclocking=

This page is about overclocking the N900. For the N8x0 see this


 * 1) WORK IN PROGRESS, HELP IF YOU WANT

Overclocking is discussed in this thread. Benchmark results can be found here. If you're more interested in power saving read this.

=Warnings=

- Overclocking WILL VOID YOUR WARRANTY - The lifetime of your device will get reduced - You could lose the data in your device (file system corruption) - Every device is an individual, what is stable for others might not be for you - If you encounter ANY unusual problems, lower your clock frequency - You do it at your own responsibility. No whining afterwards. If you're unsure, don't do it. - Nokia's overclocking warning: 500MHz is the normal frequency. Everything above is not good for your device, even with the stock kernel. - Igor Stoppa's warning and comment - chip vendors specs

=Available kernels=

Overclocking requires installation of a custom kernel. There are two types of kernels:
 * 1) modified PR1.1 kernels by Lehto and others. The only difference to the stock Nokia kernel is that the change the available hardcoded frequencies.
 * 2) enhanced kernels by titan. They are compatible with PR1.2 (!), contain lots of additional features (IPv6, NAT etc) and bugfixes. In addition they include a large set of possible frequencies (125MHz-1.2GHz) which you manually set an try out without flashing a new kernel. The defaults are set to the standard 250-600MHz range. The kernel can be installed via HAM from the extras-devel catalouge.

Installation of Lehto's PR1.1 kernels
Lehto's Kernels

talk.maemo.org: Jakiman's Overclock Guide / Summary

Installation of titan's enhanced kernels
This kernel makes it possible dynamically change the maximum frequency up to 1.15GHz (supported frequencies are 125,250,500,550,600,700,750,805,850,900,950,1000,1100,1150MHz). WARNING: Overclocking may damage your device and is at your own risk! It may void your warranty and destroy your data. You have been warned.

talk.maemo.org: Discussion of the enhanded kernel

Note: all commands on this page must be run as root in X Terminal (install rootsh package and enter "sudo gainroot")

Installation of the more stable kernel (maemo24) from extras-testing
With this kernel you can change the frequency limits, the voltages and DSP frequencies online. It requires firmware PR1.1 or newer. [Configuring_the_kernel_settings read this for configuration]
 * 1) Install the package kernel-power-settings (section system in HAM). It will automatically also install kernel-power-flasher.
 * 2) shutdown and boot again. There's no need for reflashing etc.

Installation of the experimental kernel (maemo25) from extras-devel
This kernel version contains additional experimental features and patches. Changelogs are posted here. Read the instructions for the stable kernel for more information.
 * 1) Install the package "Enhanced kernel for power users" (section system in HAM).
 * 2) shutdown and boot again. There's no need for reflashing etc.

Upgrade from older versions (< maemo24)
The package was previously called kernel-flasher-maemo. If you have one of the older packages installed it it recommended that you upgrade in X Terminal sudo gainroot apt-get install -y kernel-power-flasher apt-get remove kernel-flasher-maemo If the new kernel still doesn't boot up, try apt-get install --reinstall -y kernel-power kernel-power-flasher Also try other hints for deinstalling the old package.

Make sure you reset /etc/pmconfig to the defaults: enable_off_mode 1 sleep_while_idle 1 sr_vdd1_autocomp 0 sr_vdd2_autocomp 0 clocks_off_while_idle 1 voltage_off_while_idle 1 scaling_governor ondemand scaling_max_freq 600000 scaling_min_freq 125000 sleep_ind 1
 * 1) Power management configuration file

Deinstallation
sudo gainroot apt-get install --reinstall -y kernel kernel-flasher apt-get remove kernel-power kernel-power-modules

Configuring the kernel settings
read this for more details. Make sure the package kernel-power-settings is installed. All commands need to be run as root user. If you are normal user in X Terminal either "sudo gainroot" or prepend sudo to every command.

1) to try a configuration (you can replace "ideal" with default, lv, ulv, xlv or specify a file you created based on the template /usr/share/kernel-power-settings/default ) /usr/sbin/kernel-load /usr/share/kernel-power-settings/ideal Note: do NOT modify the files in /usr/share/kernel-power-settings/ instead copy them them as in 3) and then modify the file /etc/default/kernel-power

2) to permanently install a default configuration rm -f /etc/default/kernel-power ln -s /usr/share/kernel-power-settings/ideal /etc/default/kernel-power 3) or your own config rm -f /etc/default/kernel-power cp /etc/default/kernel-power 4) and to immediately apply it sudo /usr/sbin/kernel-load

For beginners: first reboot. then try 1) and check whether the device is stable. then do 2).

To create your own configuration: 1) copy the template to your mydocs (when not in mass storage mode) cp /usr/share/kernel-power-settings/ideal /home/user/MyDocs/kernel.txt 2) USB mount it to edit it on the PC. unmount and unplug USB, and try it with /usr/sbin/kernel-load /home/user/MyDocs/kernel.txt and repeat 2) until you're happy.

To permanently install this new configuration rm -f /etc/default/kernel-power cp /home/user/MyDocs/kernel.txt /etc/default/kernel-power /usr/sbin/kernel-load

to reset the device to the defaults use rm -f /etc/default/kernel-power /usr/sbin/kernel-load /usr/share/kernel-power-settings/default

Temporarly change of the frequency limits
sudo gainroot echo 250000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq echo 599000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq The last line shows which values were actually set. To set 125MHz use 124999, for 600MHz 599999, for everthing else x000 with x=MHz. This setting takes effect immediately and is cleared with the next reboot.

Permanently change of the frequency limits
WARNING: Permanent overclocking is very dangerous!

Install kernel-power-settings and follow those instructions.

Battery
In kernels version >=maemo20 you can read out the current battery info: modprobe bq27x00_battery cat /sys/class/power_supply/bq27200-0/current_now

Holding a kernel version
It your manually installed kernel should be not upgraded to the one in extras* try this: echo kernel-power-flasher hold | dpkg --set-selections echo kernel-power hold | dpkg --set-selections echo kernel-power-modules hold | dpkg --set-selections to unlock the version: echo kernel-power-flasher install | dpkg --set-selections echo kernel-power install | dpkg --set-selections echo kernel-power-modules install | dpkg --set-selections

Remarks

 * 1) The screen calibration in settings crashes immediately. It is a known bug in the calibration app, not in the kernel. It's mentioned in the kernel package description and is due to additional evdev (joystick,mouse) support. Just calibrate once with the stock kernel before you install the fully featured kernel.
 * 2) the 125MHz issue
 * 3) Installing another version of the enhanced kernel will just overwrite the older version. The stock kernel modules are preserved so that you can simply reflash the stock kernel via USB.
 * 4) If you for some reason get errors like this during removal or installation  "rm: cannot remove '/lib/modules/2.6.28.10maemo-lv-omap1/modules.*': No such file or directory".try this workaround. There was a bug in one of the early LV kernels but it should be fixed in more recent versions.
 * 5) This kernel will not conflict with the future PR1.2 upgrade. The upgrade will, however, overwrite this kernel and you'll have to install it again.

=Additional information and hints=


 * 1) the frequencies available in the Nokia kernel are: 250, 500, 550 and 600MHz.
 * 2) Nokia locks the device to 600MHz during phone calls. This may be a bug. It also affects Lehto's kernels.
 * 3) the telephone app is closed-source and broken. After a phone call it sets the maximum to 600Mhz and the minimum to 250MHz (or  125MHz if available) irrespective of what you have set before.
 * 4) when connected via USB the device locks the minimum frequency to 500Mhz.
 * 5) By default the device is configured to use 125MHz as the lowest frequency but it not enabled in the kernel pmconfig bug
 * 6) if enable 125MHz also set  "echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load" hint
 * 7) improving responsiveness
 * 8) safe pmconfig configuration
 * 9) the warning "WARNING: at arch/arm/mach-omap2/clock34xx.c:443 omap3_noncore_dpll_set_rate+0x28c/0x2dc" in the kernel logs (dmesg) only happens if the invalid 800MHz frequency was selected. ignore it.
 * 10) saving more battery power when idle
 * 11) EvilJazz had photoshopped a picture of a device being overclocked 1.7GHz. It's a JOKE!
 * 12) reading one of the temperature sensors "cat /sys/devices/platform/omap34xx_temp/temp1_input"

=Useful stuff=

Show current CPU frequency
awk '{print $1/1000" MHz"}' /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

Set maximum CPU frequency
From root terminal:

rootsh echo 600000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq | echo ""

Replace 600000 with desired maximum frequency. Pay attention to the two exceptions in titan's kernels (124999 and 599000). The list of available frequencies on your device/kernel can be obtained with command:

awk '{print $1/1000" MHz"}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state

Script for analyzing time_in_state (by rooted) - rev6
This script prints percentage of frequencies (states) used and some additional info useful for posting on the forum (debugging). It displays all frequencies, works with all kernels and it is not affected by the bug which resets minimum frequency after phone call.

The script is in active development. I'm adding new features and resolving bugs if they are reported. Please update your script to newest revision and report if something doesn't work properly.

Temperature may not be listed if you don't have module bq27x00_battery installed or enabled. Also kernel-maemo version is not listed if you don't use titan's kernel.

currfreq=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` idlefreq=`awk '{if ($2 > 0) print $1}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state | tail -n 1` tis1=`awk '{sum += $2} END {print sum}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state` tis2=`awk '$1 == "'"$idlefreq"'" {idle = $2} {sum += $2} END {print sum-idle}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state` echo -e " SCRIPT FOR ANALYZING TIME_IN_STATE By rooted (maemo.org) Revision 6 The script is in active development. Update your script to current revision from: wiki.maemo.org/Overclocking FREQUENCY\tUSED\t\tWHEN BUSY\n" awk ' {if ($1 >= 1000000)                printf ("%.0f MHz\t",$1/1000); else printf ("%.0f MHz\t\t",$1/1000)} {if ($2 == 0)                      printf "unused";               else printf ("%.1f %\t\t",($2*100)/"'"$tis1"'")} {if ($2 == 0 || $2/"'"$tis2"'" > 1) printf "\n";                  else printf ("%.1f %\n",($2*100)/"'"$tis2"'")} ' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state echo -e " Current frequency:  $(($currfreq/1000)) MHz Idle frequency:      $(($idlefreq/1000)) MHz Kernel:              `uname -r` kernel-maemo:        `dpkg -l kernel* | awk '/kernel-maemo/ {print $3}'` Uptime:              `uptime | sed -e 's/.*p *//' -e 's/, l.*//' -e 's/  / /'` Load:                `uptime | sed 's/.*e: //'` Boot reason:         `cat /proc/bootreason` Temperature:         `cat /sys/class/power_supply/bq27200-0/temp` °C\n"
 * 1) !/bin/sh

Output example:

SCRIPT FOR ANALYZING TIME_IN_STATE By rooted (maemo.org) Revision 6 The script is in active development. Update your script to current revision from: wiki.maemo.org/Overclocking FREQUENCY      USED            WHEN BUSY 1200 MHz       unused 1100 MHz       unused 1000 MHz       unused 950 MHz        unused 900 MHz        unused 850 MHz        unused 810 MHz        1.6 %           56.7 % 750 MHz        0.0 %           0.8 % 700 MHz        0.1 %           1.9 % 600 MHz        0.0 %           1.5 % 550 MHz        0.0 %           1.2 % 500 MHz        1.0 %           37.8 % 250 MHz        97.3 % 125 MHz        unused Current frequency:  250 MHz Idle frequency:     250 MHz Kernel:             2.6.28.10maemo-ulv-omap1 kernel-maemo:       2.6.28-maemo21 Uptime:             2 days, 2:27 Load:               0.11, 0.04, 0.01 Boot reason:        pwr_key Temperature:        25 °C

Analyzing time in state, including idle mode stats (by ArbitRabbit)
The following script will show the current frequency and statistics for each state, including time spent in idle mode when the CPU is actually sleeping. This script works with the special frequency handling in Titan's kernel.

To run this script as user and be able to set the frequencies you will need to install "rootsh" via apt-get.

scheduler_stats.sh

awk '{print "\nCurrent frequency: "$1/1000" MHz\n"}' /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq awk '{print "Minimum frequency: "$1/1000" MHz\n"}' /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq awk '{print "Maximum frequency: "$1/1000" MHz\n"}' /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq tis1=`awk '{SUM += $2} END {printf("%.0f",SUM/1000)}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state` idle0=`awk '{printf ("%.0f",$1/1000)}' /sys/devices/system/cpu/cpu0/cpuidle/state0/time` idle1=`awk '{printf ("%.0f",$1/1000)}' /sys/devices/system/cpu/cpu0/cpuidle/state1/time` idle2=`awk '{printf ("%.0f",$1/1000)}' /sys/devices/system/cpu/cpu0/cpuidle/state2/time` idle3=`awk '{printf ("%.0f",$1/1000)}' /sys/devices/system/cpu/cpu0/cpuidle/state3/time` totaltime=$(($idle0+$idle1+$idle2+$idle3+$tis1)) echo -e "FREQUENCY\tUSED" SUM=0 awk ' {               printf (($1/1000)" MHz \t"); if ($2 == 0) {                       printf "0 %\n"; }               else { SUM+=$2; printf("%.3f %\n",($2/10)/"'"$totaltime"'"); }       }        END{ printf ("Time spent in idle mode is %2.2f %\n",(1-((SUM/1000)/"'"$totaltime"'"))*100); }' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state echo ""
 * 1) !/bin/sh

Sample Output

Current frequency: 500 MHz Minimum frequency: 500 MHz Maximum frequency: 810 MHz FREQUENCY      USED 1200 MHz       0 % 1100 MHz       0 % 1000 MHz       0 % 950 MHz        0 % 900 MHz        0 % 850 MHz        0 % 810 MHz        0.000 % 750 MHz        0.000 % 700 MHz        0.000 % 600 MHz        0.000 % 550 MHz        0.000 % 500 MHz        0.010 % Time spent in idle mode is 99.99 %

Known Bugs: Requires the Phone to be booted for an hour or so before it results in decent stats.

Combined helper script (by evilJazz)
The following script will show the current frequency and statistics. It also accepts two optional parameters that will set the max and/or min frequencies (in MHz unit). Calling the script without these parameters will not set the new clocking. Instead it will just show the current frequencies and statistics.

This script works with the special frequency handling in Titan's kernel.

To run this script as user and be able to set the frequencies you will need to install "rootsh" via apt-get.

overclock.sh [max freq] [min freq]

max=${1}000 min=${2}000 [ "$max" == "600000" ] && max=599000 [ "$min" == "125000" ] && min=124999 if [ $(id -u) -ne 0 ]; then [ "$max" != "000" ] && echo "echo $max > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" | sudo gainroot [ "$min" != "000" ] && echo "echo $min > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" | sudo gainroot else [ "$max" != "000" ] && echo $max > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq [ "$min" != "000" ] && echo $min > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq fi awk '{printf("\nCurrent frequency: %7s MHz\n", $1/1000)}' /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq awk '{printf("Minimal frequency: %7s MHz\n", $1/1000)}' /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq awk '{printf("Maximal frequency: %7s MHz\n\n", $1/1000)}' /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq sum=$(awk '{SUM += $2} END {print SUM}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state) awk '{printf("%7s MHz: %5.1f % (%8d)\n", ($1/1000), ($2 * 100)/"'"$sum"'", $2)}' /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state echo
 * 1) !/bin/sh
 * 1) Handle and rewrite special cases in Titan's kernel...

Output example:

~ $ ./overclock.sh 600 250

Current frequency:    250 MHz Minimal frequency:    250 MHz Maximal frequency:    599 MHz 1200 MHz:  0.0 % (       0) 1100 MHz:  0.0 % (       0) 1000 MHz:  0.0 % (       0) 950 MHz:  0.0 % (       0) 900 MHz:  0.2 % (     271) 850 MHz:  0.0 % (       0) 810 MHz:  0.0 % (       0) 750 MHz:  0.0 % (       0) 700 MHz:  0.0 % (       0) 600 MHz:  9.0 % (   13663) 550 MHz:  0.5 % (     701) 500 MHz: 15.4 % (   23379) 250 MHz: 75.0 % (  114021) 124.999 MHz:  0.0 % (       0)

=Changing the Kernel=

Flashing using PC
1. Power off the N900 completely.

2. Hold "u" on the N900's keyboard, while holding, connect it to the PC via USB cable.

3. You will see usb icon on top right of white Nokia screen.

4. Now you can let go of "u" on the keyboard.

5. Now use flasher utility with the kernel file located in the same directory.

flasher-3.5 -k image_file_name -f -R

6. It should take about 1-2 seconds then it'll say Done.

7. Now your N900 will show white Nokia screen. (reboot)

8. At this time, you can pull out the USB cable.

9. N900 should finish booting up if all goes well.

10. Test out your phone as usual. (Apps, browser, camera, phone etc etc)

11. If any abnormal events occur frequently (crash, hang, screen corruption etc), turn it off, flash it to a slower kernel and test again. note: For Windows7 64bit users, you may need to use WindowsXP mode. (Youtube Tutorial)

Flashing from N900 xterminal

 * do a backup, have a pc nearby and know you are able to flash the n900 with flasher-3.5 - just in case

0. Launch xterminal app then type sudo gainroot (need rootsh installed)

1. type softupd -vv -s --local (thats double v)

2. open new terminal

3. type flasher --local -f -k 

4. you see the flashing (takes some time)

5. type "sync" to save changes

6. type "reboot" and enter to restart

7. Test out your phone as usual. (Apps, browser, camera, phone etc etc)

8. If any abnormal events occur frequently (crash, hang, screen corruption etc), turn it off, flash it to a slower kernel and test again.

'''You are fully responsible for any damage caused by overclocking. Not anyone else.'''

Reverting to the Original Kernel
If you want to revert to the original kernel, execute:

apt-get install --reinstall kernel kernel-flasher

=Voltage tables=

One factor reducing CPU life time is the current it is running with. The current is proportional to frequency * voltage^2 (source?). By reducing the voltage the damage of overclocking can be reduced and the battery life time extended. According to this calculations the voltage can be varied in steps of 0.0125V so that V=x*0.0125+0.6. The relative currents for different kernel settings can be found here.

Summary
FREQUENCY  Nokia   LV    ULV   XLV   ideal 0 MHz      30      30    25    30    30 125 MHz    30      30    25    20    30 250 MHz    38      38    25    30    30 500 MHz    48      48    33    33    30 550 MHz   *54*     48    38    38    33 600 MHz    60     *54*   38    38    38 700 MHz            54    45    45    45 750 MHz            54    45    45    45 810 MHz            54    48    48    48 850 MHz            54    48    48    48 900 MHz            54   *54*  *54*  *54* 950 MHz            54    54    54    54 1000 MHz           60    60    60    60 1100 MHz           72    72    72    72 1150 MHz           72    72    72    72 1200 MHz           72    72    72    72

Note: Asterisks indicate the first frequency in the kernel which needs overvoltage.

Nokia's kernel
VALUE VOLTAGE   FREQUENCY 30    0.975V    0 MHz 30    0.975V    125 MHz 38    1.075V    250 MHz 48    1.200V    500 MHz 54    1.275V    550 MHz 60    1.350V    600 MHz

titan's LV kernel
VALUE VOLTAGE   FREQUENCY 30    0.975V    0 MHz 30    0.975V    125 MHz 38    1.075V    250 MHz 48    1.200V    500 MHz 48    1.200V    550 MHz 54    1.275V    600 MHz 54    1.275V    700 MHz 54    1.275V    750 MHz 54    1.275V    810 MHz 54    1.275V    850 MHz 54    1.275V    900 MHz 54    1.275V    950 MHz 60    1.350V    1000 MHz 72    1.500V    1100 MHz 72    1.500V    1200 MHz

titan's ULV kernel
VALUE VOLTAGE   FREQUENCY 25    0.912V    0 MHz 25    0.912V    125 MHz 25    0.912V    250 MHz 33    1.012V    500 MHz 38    1.075V    550 MHz 38    1.075V    600 MHz 45    1.163V    700 MHz 45    1.163V    750 MHz 48    1.200V    810 MHz 48    1.200V    850 MHz 54    1.275V    900 MHz 54    1.275V    950 MHz 60    1.350V    1000 MHz 72    1.500V    1100 MHz 72    1.500V    1200 MHz

titan's XLV kernel
VALUE VOLTAGE   FREQUENCY 30    0.975V    0 MHz 20    0.850V    125 MHz 30    0.975V    250 MHz 33    1.012V    500 MHz 38    1.075V    550 MHz 38    1.075V    600 MHz 45    1.163V    700 MHz 45    1.163V    750 MHz 48    1.200V    810 MHz 48    1.200V    850 MHz 54    1.275V    900 MHz 54    1.275V    950 MHz 60    1.350V    1000 MHz 72    1.500V    1100 MHz 72    1.500V    1150 MHz

titan's ideal kernel
VALUE VOLTAGE   FREQUENCY 30    0.975V    0 MHz 30    0.975V    125 MHz 30    0.975V    250 MHz 30    0.975V    500 MHz 33    1.012V    550 MHz 38    1.075V    600 MHz 45    1.163V    700 MHz 45    1.163V    750 MHz 48    1.200V    810 MHz 48    1.200V    850 MHz 54    1.275V    900 MHz 54    1.275V    950 MHz 60    1.350V    1000 MHz 72    1.500V    1100 MHz 72    1.500V    1150 MHz

/sys/power/vdd1_opps_vsel values
LV:     "30 30 38 48 48 54 54 54 54 54 54 54 60 72 72" ULV:    "25 25 25 33 38 38 45 45 48 48 54 54 60 72 72" XLV:    "30 20 30 33 38 38 45 45 48 48 54 54 60 72 72" ideal:  "30 30 30 30 33 38 45 45 48 48 54 54 60 72 72"