Showing posts with label G1 Hacks. Show all posts
Showing posts with label G1 Hacks. Show all posts

Thursday, June 11, 2009

Tweak Android for Performance, and increase battery by Saving Power Usage with Sysctl!

For the last couple of days I have been looking at the android os and am trying to find a few ways to optimize performance and increase battery life on the G1. I have found a few sysctl commands that you can expiriment with and let me know the results.

When echoing in the following sysctl settings they do not remain after reboot, so we can adb remount then create a sysctl.conf file on our pc's with these settings, then ./adb push sysctl.conf /etc/ then the kernel should apply the settings every reboot

For examples of a sysctl.conf use google: Sysctl.conf Examples

Open a Terminal and Execute these commands as root

Tweak virtual memory to conserve power when running on battery:
echo 0 > /proc/sys/vm/swappiness #can be ignored if you dont use swap
echo 0 > /proc/sys/vm/dirty_expire_centisecs #can be ignored if you dont use swap
echo 0 > /proc/sys/vm/dirty_writeback_centisecs #can be ignored if you dont use swap
echo 60 > /proc/sys/vm/dirty_background_ratio
echo 95 > /proc/sys/vm/dirty_ratio


Tweak virtual memory for running on Charger:
echo 0 > /proc/sys/vm/swappiness #can be ignored if you dont use swap
echo 3000 > /proc/sys/vm/dirty_expire_centisecs #can be ignored if you dont use swap
echo 500 > /proc/sys/vm/dirty_writeback_centisecs #can be ignored if you dont use swap
echo 10 > /proc/sys/vm/dirty_background_ratio
echo 40 > /proc/sys/vm/dirty_ratio


Detecting apps/services that hog the battery/cpu:
Also while on battery, you should stop all applications that don't really stay idle when you're not using them, if you want to find which apps arent really staying idle you can:
strace -p $(pidof yourapp) # for all your running applications
ps aux | awk '{print$10,$11}' | sort -n # will list all running softs sorted by used cpu time


Additional Tweaks:
By default when Linux runs out of memory it goes through the process list and starts killing off processes that it thinks are using too much memory. This sysctl makes Linux kill the runaway process that made the system run out of memory instead, which is usually what you want.(this will also reduce cpu time and increase battery usage).
sysctl -w vm.oom_kill_allocating_task=1

vfs_cache_pressure to 10 , gives more mem to cache fs dentry and inode to save cpu
At the default value of vfs_cache_pressure = 100 the kernel will attempt to reclaim dentries and inodes at a "fair" rate with respect to pagecache and swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer to retain dentry and inode caches. Increasing vfs_cache_pressure beyond 100 causes the kernel to prefer to reclaim dentries and inodes.
sysctl -w vm.vfs_cache_pressure=10
You may also try setting this to 200 and see if you notice a difference with battery life and app startup times.

There is an in depth discussion over these tweaks over at XDA, feel free to join in if you have any comments or suggestions Here

Saturday, January 3, 2009

JF1.3.1 RC30, RC8, and ADP1 Firmware for your G1

JesusFreke from xda developers has just released is famous custom firmware for the Android G1:
Here is the topic quoted from the forums:

Update (01-03-09)
v1.31 is out! This is a minor bugfix release to fix a few issues that had cropped up in v1.3.

The changes from v1.3 include:
  • Fixed the nandroid backup so that it works on sdcards with a raw fat32 filesystem (with no partition)
  • Added the telnetd binary from RC28
  • Fixed an issue with SuperUser where it was displaying the wrong processes in the su request popup
  • SuperUser should allow root to use su without displaying the popup (though there's not much point.. )
  • Added /system/modules and /system/xbin to fstab in normal and recovery mode
  • Minor fix for the update-script, so the progress bar acts more sanely


I have the usual RC30 and RC8 versions, and new for v1.3 is an ADP1 version.

ADP1: (md5: 96b2abd9a1da2852bc33b2052ea51b2a)

http://android-dls.com/forum/index.p...rb_v=viewtopic
http://www.gotontheinter.net/content/new-images-jf (at bottom of page)

RC30: (md5: 0f2e6a4244410e00028db55b4fbf808c)
http://jf.nyquil.org/v1.31/JFv1.31_RC30.zip
http://android-dls.com/forum/index.p...rb_v=viewtopic
http://www.gotontheinter.net/content/new-images-jf (at bottom of page)

RC8: (md5: e008bbe1d93abd0c2e5e6218f012f20d)

http://android-dls.com/forum/index.p...rb_v=viewtopic
http://www.gotontheinter.net/content/new-images-jf (at bottom of page)


These updates are installed the normal way. Save them to your sdcard named update.zip, boot into recovery mode (home + power), and then press alt+l and alt+s. If you are switch between versions, e.g. from RC30 to ADP1, then it's usually a good idea to perform a wipe. You can try booting up without a wipe, but if it doesn't boot, or you get strange errors once it boots up, go back into recovery and perform a wipe (alt+w)

Note: To install these updates, you need to have a recovery image that uses test keys. If any of the following are true, you most likely have a recovery image that uses test keys
- you have installed my modified recovery image in the past
- you have an ADP1
- you currently have one of my modified firmwares installed



What's new?

The coolest new functionality in v1.3 is a new backup utility that allows you to perform a backup directly from recovery mode with alt+B. This is done using infernix's and brainaid's nandroid script, which they kindly modified to work in recovery mode. Let them know what you think . The backups are stored in a subfolder in the nandroid folder on your sdcard. To restore them, you have to copy them to your computer, and then flash them with the fastboot tool (sorry, no integrated restore yet).

If you get errors when making a backup, first make sure you have enough free space on the sdcard. it needs around 85-90mb. If you have enough space, then try reformatting the sdcard (fat32 is your best bet).

Other changes of note include
  • This version includes a new busybox binary that I compiled against uclibc, making it much smaller (1.8mb vs 700kb).
  • All busybox applets are linked at /system/xbin/bb, which is also in the path. So there are many more standard unix commands available in the terminal.
  • Many more modules and binaries are included in /system/xbin and /system/modules. They were also optimized for size, so even though there are more modules and binaries, they actually take up much less space than they did on v1.2
  • I added the terminal emulator application to /system/app. (don't worry, it won't, or at least shouldn't , cause any problems if you already have it installed)
  • got rid of the normal su binary, in favor of koush's su and SuperUser application. See details here
  • when you boot up into recovery, it will automatically show the text. You can press alt+L to turn off the text and ogle the background. (did I mention there's a new background? shhh. it's a secret )
  • fixed the annoying uptime bug, where the uptime is shown incorrectly in the settings
  • added /data/local/bin to the path. Feel free to add your own binaries/scripts here.
  • includes the /dev/mtd/mtd6 and /dev/mtd/mtd6ro devices, which allow access to the entire flash chip (other than certain restricted areas used by the radio)
  • new "ro.modversion" property, that is set to "JFv1.3". The intent of this property is so you can know you are running a modified version, as well as identify which version
  • added a modified /system/etc/security/cacerts.bks file, which contains additional certificates for cacert.org (courtesy of Disconnect)
  • added a /system/etc/resolv.conf file with the 4.2.2 family of DNS servers, to allow busybox's ping, wget, etc. to resolve host names

See the attached change logs for a complete list of changes with respect to the corresponding "official" firmware.



---------------
Update (01-03-09): Updated the links to point to the v1.31 versions

In addition to the updates themselves, I am also releasing a build environment that can use to build each update from scratch. You can use these to easily make your own custom updates. It includes some utilities that were built from git source. The binaries are for 32bit x86 linux. If you want to run it on a different platform, you're on your own.

NOTE: You don't need these to use my update. Just download one of the updates from above and install it. The build environments are only if you want to make your own customized update.

The general idea of the build environment is that it extracts the original files from the official update (or from my original ADP1 update), and then copies over anything from the various ModifiedFiles folders, then packages it all back up into a ready-to-be-applied update.zip. It does this for the boot image, recovery image and system folder. You can also specify files to delete in the various OriginalFilesToDelete.mk files.

Consider anything new that I created for the build environments (the makefiles, etc.) to be in the public domain. Everything else retains its original license of course.

Instructions:
- extract the build environment into a folder
- download the official update that the update is based on, and put it in the root of the build environment. (note: use my original ADP1 update for the ADP1 build environment. available on this page)
- run make as root. yes, it has to be with root, because the binaries in the 2 cramfs images should be owned by root. (note: I plan on using fakeroot in the future, to workaround the need to be root)
- after make finishes, assuming there are no errors, the update should be in Workspace/update.zip.

Download the build environments here:

ADP1: (md5: 2d116b334515d4d702776b9d74d2e658)
http://jf.nyquil.org/v1.31/JFv1.31AD...ronment.tar.gz
http://android-dls.com/forum/index.p...rb_v=viewtopic
http://www.gotontheinter.net/content/new-images-jf (at bottom of page)

RC30: (md5: 29ced6e7601bac47252e51e5ac4f0ca4)

http://android-dls.com/forum/index.p...rb_v=viewtopic
http://www.gotontheinter.net/content/new-images-jf (at bottom of page)

RC8: (md5: b26f3cd244da9b8662766db69734000e)
http://jf.nyquil.org/v1.31/JFv1.31RC...ronment.tar.gz
http://android-dls.com/forum/index.p...rb_v=viewtopic
http://www.gotontheinter.net/content/new-images-jf (at bottom of page)
Attached Files
File Type: txt ChangeLog-RC30.txt (7.2 KB, 157 views)
File Type: txt ChangeLog-RC8.txt (7.5 KB, 34 views)
File Type: txt ChangeLog-ADP1.txt (7.3 KB, 125 views)