Palm Pre Hack To Significantly Extend Battery Life

Okay, we at L337Tech have replace our iPhones out of sheer bordem (had iphone for 2 years and am now bored with it). We now have Palm Pre’s. I love my Palm Pre but was not happy with the battery life. Luckily the Palm Pre is the easiest phone to hack ever. Heck, to access developer mode you type in the konami code, come on thats awesome!! I wrote some code that uses power saving features built into the linux operating system used by the Pre. This has literally increased my battery life by 40%. It is only a matter of time before Palm sees this and writes their own power saving script. But as of right now the Pre has now power saving features so use my code.

This is basically a repost of the work i did in the forums of PreCentral.net

Okay i have been doing extensive testing. I believe i have solved most of the problems related to cpu scaling.

noted problems:
1. Video playback flickers and can be choppy
3. Phone freezes usually in standby or some other low state like listening to pandora in standby.
2. Can force the phone to have a 250mhz minimum instead of 125Mhz minimum

Fixes:
Two new scaling schemes. The first uses 1 second sampling rates and an 11% cpu utilization speed up threshold. The second method uses powersave_bias to turn on the 250mhz minimum (this will cause the phone to quit going down to 125Mhz, it goes down to 250Mhz instead during standby or other lowly states)

The fist scheme fixes video playback and phone freezes during lowly states, but does not fix the 250Mhz minimum problem so you phone will use 125Mhz for its lowly state.

The second scheme fixes phone freezes during lowly states like standby and Pandora, and makes 250Mhz the minimum cpu frequency. This method does not fix video playback flickering issues.

Here is the code:

First scheme (my favorite and the one im currently using)
assumes you are at root@castle:/#

echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 250000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 11 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 1000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate

Second scheme (not my favorite because of video flicker and other reasons i will explain latter but it does utilize the 250mhz low state which is a little snappier than 125Mhz)
assumes you are at root@castle:/#

echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 250000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo 11 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 10000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias

The main problem with the methods people were doing before is that the chip was switching between low and high state several times over the course of a few second no matter if they were playing a video or pandora. The first scheme above fixes that issue. The second scheme still suffers from this but i tried to lessen its severity by changing the sampling rate to 10 seconds (in reality it seems like 2 seconds durring testing). 10 seconds was the lowest i could go without it wanting to change states from low to high several times in a few seconds. There is something wrong with the powersave_bias function that makes it switch states faster than the sampling rate. I am looking into possible workarounds.

I would have liked to make the speed up threshold 5% but the lowest the up_threshold function would let me choose is 11%. 5% is usually low enough to have the phone running full power during pandora. Your phone is almost always lower than 5% during standby or when not doing anything on your phone.

If you want these codes to stick after a reboot then you will need to prepare a script in vi editor inside you pre’s linux system in the format similar to how they did it at pre dev wiki here

scroll down the page till you see how they made it stick. Just change the code to the codes in the post, but you need to change the format slightly. If you dont know how to do this then you do not need to be trying anything mentioned in this post.

And as always i am not responsible for any damage this may cause you. But the consensus is that the ondemand scaling function is pretty harmless to your phone. Freezes are fixed by unplugging you battery. If you want to be extra careful then just run these codes without making a script. That way when you reboot everything goes back to defaults from palm for the cpu.

If anyone can get powersave_bias stable let me know what you did. I was using trans_table in the /cpufreq/stats folder and also time_in_state within the same folder. Another usefull tool is cpuinfo_cur_freq within the /cpufreq folder. Also use top command to monitor your cpu utilization, this command can be executed anywhere within linux.

I have decided to include some code that will help anyone if they decide to do their own testing of cpu scaling and power save bias. Here is the code I use for testing:

current speed
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
time in different frequencies
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
number of switches between power states
cat /sys/devices/system/cpu/cpu0/cpufreq/stats/trans_table
current sampling rate
cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
current up threshold
cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
current power save bias
cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias
current max freq
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
current min freq
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq

turn off power save bias
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias

overclocking
echo 550000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 600000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 1500000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate

good luck

-L337Tech

New iPhone (3rd Generation) with iPhone OS 3.0 Available in June!

From all the different quality sources I have gathered intel from it is almost certain there will be a new iPhone that will come with a new iPhone operating system called iPhone OS 3.0 in June. The new iPhone is reported to have a faster processor boasting speeds of ~600Mhz. This is a good ~200Mhz faster than the latest iteration of the iPhone. The new iphone + iphone OS 3.0 is said to perform background tasks and have up to three applications running at once. Also, there are many who think the new Apple+Adobe version of flash will debut in June on this system. Expect double the ram (256MB) and for the top end model double the storage (32GB). People do not think that “copy and paste” will be included but are optimistic about landscape keyboard. They are previewing the new iPhone OS 3.0 on March 17th.

We here at L337Tech have iPhones and appreciate having a small computer in our pockets. However, we do have to jailbreak our phones to be able to data tether (connect to internet through phone) and record video. So when i caught wind of the new phone + OS i was happy/unhappy. Happy because we finally get multitasking and faster opening closing and running of programs. Unhappy because i know i will have to buy this thing for uber amounts of money and then wait for the jailbreak so i can get back my beloved Cydia programs.

Either way its nice to see continued competition for the Smart Phone market. It will only makes things better in the long run. A war between the Pre, iPhone, G1 and others will lead to lower prices and better hardware. But in all honesty i am really just waiting on all the new android phones coming out mid this year (Android Cupcake available April).

UPDATE: The new iPhone (3rd Generation) will be announced at Apple’s WWDC which takes place June 8-12th. The actual phone will go on sale June 17th. I hate how they always show you their new products then make you wait a month before you can buy it. I guess its never too early to setup a tent in front of your local AT&T store. Also its worth mentioning that iPhone OS 3.0 will be formally introduced at the WWDC and will most likely not be available for download till June 17th.

-L337tech

source for iPhone OS 3.0 preview date = Engadget