[Tweak] Boost RAM Management - get more free RAM! // [23.03.2011] Fixed Permissions. - Galaxy S I9000 Android Development

Memory Tweak - get more free RAM to use for apps and less lag.
// This was first intended for other ROM chefs, so they can include this tweak in their ROMs. I'm aware that there are apps which can do this. But it's the idea to have it included automatically, so you don't have to annoy your users
However, this is also for normal users. Those just flash the CWM Package thunderteaser made here. Thanks for this.
I made a script which boosts the RAM Management significantly.
You can use this in any ROM - those values have been created from my mind and were being tested for several days in heavy use.
IMHO, it's the perfect combination of RAM Management.
HOW TO IMPLEMENT IT INTO YOUR ROM
Just make a new bash script and place the following code into it.
NOTE: bash files created on Windows don't work. Create them with a UNIX like Linux (Ubuntu, Fedora, whatever) or Mac OS X.
Place the script in /system/etc/init.d so it gets automatically executed at every startup. You have to make this because init.rc (in root dir /) gets executed first and will also set the RAM Management (minfree) on his own.
UPDATE - 20.03.2011
Supercurio said, there is support for init.d in his Voodoo injected kernel for JV1 Gingerbread.
This means, the script is fully working and the Gingerbread JV1 memory leaks are fixed when using those values.
This also means, my current ROM v10.0 Beta 3 already has the Memory Hack integrated.
Code:
#!/system/bin/sh
# DarkyROM 2011 - Joël Staub (darkyy)
# This will stabilize the memory leaks in Gingerbread and other ROMs.
# Adjusting Memory Settings
# The values in MB: 10, 16, 24, 68, 76, 92
if [ -e /sys/module/lowmemorykiller/parameters/minfree ]; then
echo "Modifying minfree parameters"
echo "2560,4096,6144,17408,19456,23552" > /sys/module/lowmemorykiller/parameters/minfree
else
echo "minfree not found"
fi
Permissions
You may want to adjust the permissions of the script when it's on your phone.
You can do it with ADB.
First, connect to your phone.
Code:
adb shell
Get root access.
Code:
su
Set the permissions.
Code:
chmod 777 /system/etc/init.d/ramtweak
Code:
chown root:root /system/etc/init.d/ramtweak
When you're a ROM chef, you can include those permissions either with update(r)-script or with a bash file.
Thanks to zacharias.maladroit for the hint with the permissions.
- darkyy.

Darkyy said:
Ignore the # You're not allowed to use this script without giving proper credits. - EVERYONE IS WELCOME TO IMPLEMENT THIS INTO HIS / HER ROM - I don't need credits.
Click to expand...
Click to collapse
If you don't mean it, take it out

Ok this looks awesome but for the most part of the members can u make a proper tutorial ? I really don't understand how to implement your hack, how to create a bash script init.d ?
sorry for my noobiness
And when you say in every ROM, did you also mean every custom kernel ?

chambo622 said:
If you don't mean it, take it out
Click to expand...
Click to collapse
I will, sorry for this crap
I'm a bit too tired...

touness69 said:
Ok this looks awesome but for the most part of the members can u make a proper tutorial ? I really don't understand how to implement your hack, how to create a bash script init.d ?
sorry for my noobiness
And when you say in every ROM, did you also mean every custom kernel ?
Click to expand...
Click to collapse
You just make a new file on your COMPUTER.
Or it would even work on your SGS (but I'm writing now for the Computer).
Example:
Let's say, you're on Windows - create a NEW text file and remove the .txt extension (you need to have this option activated in the explorer settings).
You can leave it to no extension or just make it end on .sh
You got a file called randomname.sh now.
Now to make it easy, just copy this file to the C: drive in NO subfolder.
Now just ADB push this file to your SGS into:
Code:
adb push /randomname.sh /system/etc/init.d
Or just copy the .sh file to your SGS via USB Storage mount and copy it to the directory with Root Explorer or Super Manager.
Yes, this should work with every kernel (Android 2.2.1) here.

Thanks for doing this testing to find good settings. Forgive me if I'm misinformed, but is there anything particularly innovative about new minfree settings? I do appreciate your testing and finding ones that work well for you.

have a good rest, Darkyy !
thanks for this script
so you noticed improved interactivity with "apps and less lag" ?
gotta try this with CM7
FYI:
the defaults of the CM7 kernel are:
Code:
cat /sys/module/lowmemorykiller/parameters/minfree
2048,3072,4096,6144,7168,8192
edit2:
make sure that you get the right permissions for the file on the phone afterwards
say:
Code:
chmod 750 /system/etc/init.d/99rambooster
chown root:shell /system/etc/init.d/99rambooster

thanks for explanation ! I have done what you say and rebooted my phone after that. I renamed the file to init.d after placing it into the /system/etc/ directory and setted the défault permissions for this file rwxrwxrwx (or something like that)
But how I find if I have the hack succesfuly installed ?

chambo622 said:
Thanks for doing this testing to find good settings. Forgive me if I'm misinformed, but is there anything particularly innovative about new minfree settings? I do appreciate your testing and finding ones that work well for you.
Click to expand...
Click to collapse
Not innovative - this is nothing new.
It's just that many ROM devs aren't aware of this and I thought I could share my script.
zacharias.maladroit said:
have a good rest, Darkyy !
thanks for this script
so you noticed improved interactivity with "apps and less lag" ?
gotta try this with CM7
FYI:
the defaults of the CM7 kernel are:
Code:
cat /sys/module/lowmemorykiller/parameters/minfree
2048,3072,4096,6144,7168,8192
edit2:
make sure that you get the right permissions for the file on the phone afterwards
say:
Code:
chmod 750 /system/etc/init.d/99rambooster
chown root:shell /system/etc/init.d/99rambooster
Click to expand...
Click to collapse
Strange permissions...
This would be rwx r-x --- [Owner, Group, Other]
EDIT:
Ouch, CM7 really has 2048,3072,4096,6144,7168,8192?
That's really not the best value... looks close like JV1 RAM Management at first glance...
I'm gonna check that later.

Darkyy said:
Not innovative - this is nothing new.
It's just that many ROM devs aren't aware of this and I thought I could share my script.
Strange permissions...
This would be rwx r-x --- [Owner, Group, Other]
EDIT:
Ouch, CM7 really has 2048,3072,4096,6144,7168,8192?
That's really not the best value... looks close like JV1 RAM Management at first glance...
I'm gonna check that later.
Click to expand...
Click to collapse
yes,
and those are really the permissions
ls -l
-rwxr-x--- 1 root shell 365 Aug 1 2008 00banner
-rwxr-x--- 1 root shell 27 Aug 1 2008 01sysctl
-rwxr-x--- 1 root shell 229 Aug 1 2008 03firstboot
-rwxr-x--- 1 root shell 201 Aug 1 2008 04modules
-rwxr-x--- 1 root shell 1452 Aug 1 2008 05mountsd
-rwxr-x--- 1 root shell 272 Aug 1 2008 06mountdl
-rwxr-x--- 1 root shell 925 Aug 1 2008 20userinit
-rwxr-x--- 1 root shell 2533 Mar 19 02:20 89system_tweak
-rwxr-x--- 1 root shell 2848 Aug 1 2008 90screenstate_scaling
Click to expand...
Click to collapse
good thing you came up with these improved values,
I'm gonna include these in the next revision of my script / kernel
thanks again

Thanks Darkyy! Once again, you kicketh ass!
I am gonna give this a try.

Nice, some info on min free settings:
http://www.androidcentral.com/fine-tuning-minfree-settings-improving-androids-multi-tasking

while we're at it:
you could include lots of stuff from the
tweak script for the Galaxy Spica
in your next revision of ROM
I'm using some of those
and planning to continually add more after having tested them

DocRambone said:
Nice, some info on min free settings:
http://www.androidcentral.com/fine-tuning-minfree-settings-improving-androids-multi-tasking
Click to expand...
Click to collapse
Thanks Doc, will add it tomorrow in the OP.
zacharias.maladroit said:
while we're at it:
you could include lots of stuff from the
tweak script for the Galaxy Spica
in your next revision of ROM
I'm using some of those
and planning to continually add more after having tested them
Click to expand...
Click to collapse
Nice, but most things are specially for the low-end device Spica.
I'll sure look into it
Thank you

Gah this is such a retarded suggestion. Darky your SGS ROM is really nice and I'm currently running it, but please think about things like this before you post them.
The SGS has, comparatively, RAM out the wazoo. Why do we want more of it sitting idle and unused? RAM is there to be used, not sit there looking unused and pretty like a virgin at an eastern european slave auction in a free -m command. Twatting about with this setting on behalf of the Android Low Memory Killer is essentially like telling the ROM you have less RAM than you actually do since it will always endeavour to keep that much RAM -free- as in -unused- by the GUI itself as well as Android apps.

Darkyy said:
Memory Tweak - get more free RAM to use for apps and less lag.
I made a script which boosts the RAM Management significantly.
You can use this in any ROM - those values have been created from my mind and were being tested for several days in heavy use.
IMHO, it's the perfect combination of RAM Management.
HOW TO IMPLEMENT IT INTO YOUR ROM
Just make a new bash script and place the following code into it.
Place the script in /system/etc/init.d so it gets automatically executed at every startup. You have to make this because init.rc (in root dir /) gets executed first and will also set the RAM Management (minfree) on his own.
This doesn't work on JV1 now because we don't have the kernel sources to implement init.d support.
Code:
#!/system/bin/sh
# DarkyROM 2011 - Joël Staub (darkyy)
# This will stabilize the memory leaks in Gingerbread and other ROMs.
# Adjusting Memory Settings
# Old Hack (you can ignore this, it's just another method of doing it)
#if [ -e /sdcard/darky_tweak/init.rc ]; then
# echo "Copying init.rc to /"
# cp /sdcard/darky_tweak/init.rc /
# else
# echo "No init.rc found"
#fi
# New Method [15.03.2011]
if [ -e /sys/module/lowmemorykiller/parameters/minfree ]; then
echo "Modifying minfree parameters"
echo "2560,4096,6144,17408,19456,23552" > /sys/module/lowmemorykiller/parameters/minfree
else
echo "minfree not found"
fi
- darkyy.
Click to expand...
Click to collapse
How to do it. any video to show us. ??

touness69 said:
thanks for explanation ! I have done what you say and rebooted my phone after that. I renamed the file to init.d after placing it into the /system/etc/ directory and setted the défault permissions for this file rwxrwxrwx (or something like that)
But how I find if I have the hack succesfuly installed ?
Click to expand...
Click to collapse
He said to place it inside init.d not call it init.d. Are you honestly this illiterate?
shaldi said:
How to do it. any video to show us. ??
Click to expand...
Click to collapse
How to create a text file and place it where he says to place it? Are you honestly this illiterate?

Darkyy said:
You just make a new file on your COMPUTER.
Or it would even work on your SGS (but I'm writing now for the Computer).
Example:
Let's say, you're on Windows - create a NEW text file and remove the .txt extension (you need to have this option activated in the explorer settings).
You can leave it to no extension or just make it end on .sh
You got a file called randomname.sh now.
Now to make it easy, just copy this file to the C: drive in NO subfolder.
Now just ADB push this file to your SGS into:
Code:
adb push /randomname.sh /system/etc/init.d
Or just copy the .sh file to your SGS via USB Storage mount and copy it to the directory with Root Explorer or Super Manager.
Yes, this should work with every kernel (Android 2.2.1) here.
Click to expand...
Click to collapse
Darkyy, so I just copy the codes, paste in notepad then save as [anygivenname.sh] then paste into system/ect/init.d using root explorer and reboot my galaxy s?

Darky is this included in your rom? if not is it going to be?

bernard134 said:
Darkyy, so I just copy the codes, paste in notepad then save as [anygivenname.sh] then paste into system/ect/init.d using root explorer and reboot my galaxy s?
Click to expand...
Click to collapse
guys
seriously: read what comes after the 1st ,2nd and 3rd post - or the first 1-3 (or 5 sites) if it's a larger topic
you'll see that you need to change the permissions & owner
you do that via logging in via adb, becoming root (su)
and navigating to /system/etc/init.d/
or do it explicitly from the folder where you are - like I posted
0) prepare file on windows / linux / mac
Code:
#!/system/bin/sh
# DarkyROM 2011 - Joël Staub (darkyy)
# This will stabilize the memory leaks in Gingerbread and other ROMs.
# Adjusting Memory Settings
# Old Hack (you can ignore this, it's just another method of doing it)
#if [ -e /sdcard/darky_tweak/init.rc ]; then
# echo "Copying init.rc to /"
# cp /sdcard/darky_tweak/init.rc /
# else
# echo "No init.rc found"
#fi
# New Method [15.03.2011]
if [ -e /sys/module/lowmemorykiller/parameters/minfree ]; then
echo "Modifying minfree parameters"
echo "2560,4096,6144,17408,19456,23552" > /sys/module/lowmemorykiller/parameters/minfree
else
echo "minfree not found"
fi
e.g. save as:
99rambooster
1) dl & install Android SDK
http://www.talkandroid.com/android-sdk-install-guide/
2) connect phone
navigate to tools folder (or from Linux: launch from terminal via command)
3) put it on the phone
Code:
adb push 99rambooster /sdcard/
4) log in to phone & become root
Code:
adb shell
(now in phone)
Code:
su
5) copy it to init.d folder [you eventually need to remount /system rw]
Code:
cp /sdcard/99rambooster /system/etc/init.d/
6) adjust permissions:
Code:
chmod 750 /system/etc/init.d/99rambooster
chown root:shell /system/etc/init.d/99rambooster

Related

[REF] Startup script speed tweaks

Hi guys,
UPDATE: Over time, I've modified some of these values in my SpeedMod kernel. The values here may not be the best ones.
NOTE: These tweaks are now included in kernels based on sztupy's Universal Lagfix, for example:
http://forum.xda-developers.com/showthread.php?t=822756
But they must be manually activated from the recovery menu.
I've been using Linux kernel tweaks in a startup script to make the phone smoother.
With these tweaks, the phone is quite smooth and fast even without using the filesystem lagfixes.
These settings are only useful for you if you know how to create and modify a startup script. I use the old playlogos hack myself, but I'm sure there are many new ways to do it now.
Code:
# Tweak cfq io scheduler
for i in $(ls -1 /sys/block/stl*) $(ls -1 /sys/block/mmc*) $(ls -1 /sys/block/bml*) $(ls -1 /sys/block/tfsr*)
do echo "0" > $i/queue/rotational
echo "1" > $i/queue/iosched/low_latency
echo "1" > $i/queue/iosched/back_seek_penalty
echo "1000000000" > $i/queue/iosched/back_seek_max
echo "3" > $i/queue/iosched/slice_idle
done
# Remount all partitions with noatime
for k in $(busybox mount | grep relatime | cut -d " " -f3)
do
sync
busybox mount -o remount,noatime $k
done
# Tweak kernel VM management
echo "0" > /proc/sys/vm/swappiness
#echo "10" > /proc/sys/vm/dirty_ratio
#echo "4096" > /proc/sys/vm/min_free_kbytes
# Tweak kernel scheduler, less aggressive settings
echo "18000000" > /proc/sys/kernel/sched_latency_ns
echo "3000000" > /proc/sys/kernel/sched_wakeup_granularity_ns
echo "1500000" > /proc/sys/kernel/sched_min_granularity_ns
# Misc tweaks for battery life
echo "2000" > /proc/sys/vm/dirty_writeback_centisecs
echo "1000" > /proc/sys/vm/dirty_expire_centisecs
EDIT: Explanations:
# Remount all partitions with noatime
atime is a setting where the filesystem updates the access time of a file. This creates a write-after-every-read which slows things down. By default all partitions are mounted with relatime, which is an optimized version of atime. noatime is the fastest, and afaik we don't need atime.
# Tweak cfq io scheduler
Tweaked settings of the disk io scheduler more for flash memory. Defaults are optimized for spinning harddisks. Lowered the idle wait, re-enable the low latency mode of cfq, removed the penalty for back-seeks and explicitly tell the kernel the storage is not a spinning disk.
# Tweak kernel VM management
Set tendency of kernel to swap to minimum, since we don't use swap anyway.
Lower the amount of unwritten write cache to reduce lags when a huge write is required.
Increase tendency of kernel to keep block-cache to help with slower RFS filesystem.
Increase minimum free memory, in theory this should make the kernel less likely to suddenly run out of memory.
# Tweak kernel scheduler
Make the task scheduler more 'fair' when multiple tasks are running. This has a huge effect on UI and App responsiveness. These values (less aggressive settings) are 20% of the Linux defaults, and about half of the Android defaults.
# Miscellaneous tweaks
Increase the write flush timeouts to save some battery life.
___________________________________
EDIT: How to create/use a startup script:
You need root and busybox for this.
This procedure is adapted from the old OCLF which used this method to create a startup script in /system/userinit.sh
Check if the file /system/userinit.sh exists. If it does, u should just edit that file as the startup script and DO NOT do the procedure below.
Here's how to do it manually. Do this only if some other lagfix/patch has not already done the playlogos hack, otherwise u might overwrite the other script!
Create the startup script on your PC. Use adb to push it to /sdcard/userinit.sh
adb push userinit.sh /sdcard/userinit.sh
On your PC, create a file called playlogos1 with this content:
#!/system/bin/sh
sh /data/userinit.sh
playlogosnow
Use adb to push the playlogos1 file to /sdcard/playlogos1
adb push playlogos1 /sdcard/playlogos1
Now use adb shell, su and do this:
busybox mount -o remount,rw /system;
busybox cp /sdcard/userinit.sh /data/userinit.sh;
busybox mv /system/bin/playlogos1 /system/bin/playlogosnow;
busybox cp /sdcard/playlogos1 /system/bin/playlogos1;
chmod 755 /system/bin/playlogos1;
chmod 755 /data/userinit.sh;
The startup script will be /data/userinit.sh
The reason I put the startup script in /data is so that if you mess up the startup script and get stuck during boot, you can do a "clear data" from recovery, and the startup script will be erased.
Could you explain what this actually does for the non linux savvy, also maybe you could make a script/app for this so everyone else can try it ?
hardcore said:
Hi guys,
I've been using Linux kernel tweaks in a startup script to make the phone smoother.
With these tweaks, the phone is quite smooth and fast even without using the filesystem lagfixes.
These settings are only useful for you if you know how to create and modify a startup script. I use the old playlogos hack myself, but I'm sure there are many new ways to do it now.
Code:
# Remount all partitions with noatime
for k in $(mount | cut -d " " -f3)
do
sync
mount -o remount,noatime $k
done
# Tweak cfq io scheduler
for i in $(ls -1 /sys/block/stl*) $(ls -1 /sys/block/mmc*) $(ls -1 /sys/block/bml*) $(ls -1 /sys/block/tfsr*)
do echo "0" > $i/queue/rotational
echo "1" > $i/queue/iosched/low_latency
echo "1" > $i/queue/iosched/back_seek_penalty
echo "1000000000" > $i/queue/iosched/back_seek_max
echo "3" > $i/queue/iosched/slice_idle
done
# Tweak kernel VM management
echo "0" > /proc/sys/vm/swappiness
echo "10" > /proc/sys/vm/dirty_ratio
echo "1000" > /proc/sys/vm/vfs_cache_pressure
echo "4096" > /proc/sys/vm/min_free_kbytes
# Tweak kernel scheduler
echo "2000000" > /proc/sys/kernel/sched_latency_ns
echo "500000" > /proc/sys/kernel/sched_wakeup_granularity_ns
echo "400000" > /proc/sys/kernel/sched_min_granularity_ns
# Miscellaneous tweaks
setprop dalvik.vm.startheapsize 8m
setprop wifi.supplicant_scan_interval 90
setprop windowsmgr.max_events_per_sec 68
Click to expand...
Click to collapse
VERY interesting
EarlZ said:
you could make a script/app for this so everyone else can try it ?
Click to expand...
Click to collapse
+1, pretty plz, also, is this compatible with voodoo?
INeedYourHelp said:
+1, pretty plz, also, is this compatible with voodoo?
Click to expand...
Click to collapse
Should be compatible, although u need to know how to add it into voodoo's startup script.
Hello
Values description for each one and why is welcome
supercurio said:
Hello
Values description for each one and why is welcome
Click to expand...
Click to collapse
Hey supercurio! Great job on Voodoo, I am particularly keen on the Sharpness, Video and future Sound fixes. I think its very cool that you found out how to modify the sharpness (S-AMOLED's PenTile matrix software algorithms?).
Edited the starting post with explanations. Most of them should be documented somewhere in the Linux sources / documents.
I've been using them for a while, tweaking values here n there. I think I've finally reached a stage where I'm confident enough to recommend them to others to try. There could be more optimum values with further testing, but these work well for me with Froyo.
hardcore said:
Hey supercurio! Great job on Voodoo, I am particularly keen on the Sharpness, Video and future Sound fixes. I think its very cool that you found out how to modify the sharpness (S-AMOLED's PenTile matrix software algorithms?).
Edited the starting post with explanations. Most of them should be documented somewhere in the Linux sources / documents.
I've been using them for a while, tweaking values here n there. I think I've finally reached a stage where I'm confident enough to recommend them to others to try. There could be more optimum values with further testing, but these work good for me so far with Froyo.
Click to expand...
Click to collapse
Yeah thank you so much for taking the time and sharing, i'll integrate them after a bit of testing
About the sharpness filter yes this is the main difference between S-AMOLED and AMOLED panel wise.
It's a hardware sharpness filter which is here to fight the fuzziness introduced by the pentile pattern but.. they overdid it a bit.
The "perfect" values are of course closer than the one with the same radius that the one of the blur introduced itself with the pixel pattern.
I feel it can maybe be improved a hair
I'll soon publish a version that allow write to the mDNIe register so you'll be able to play *live* with it too
Nice, could these be modified post-startup? like I go adb and copy paste some of them for testing?
I've tested setprop windowsmgr.max_events_per_sec 68, no difference. Set it to
setprop windowsmgr.max_events_per_sec 10 and still, no difference.
xan said:
Nice, could these be modified post-startup? like I go adb and copy paste some of them for testing?
I've tested setprop windowsmgr.max_events_per_sec 68, no difference. Set it to
setprop windowsmgr.max_events_per_sec 10 and still, no difference.
Click to expand...
Click to collapse
hey xan, you made me remember to add run-parts support.
i'll do that and you'll be able to set it without special hack very soon with voodoo
xan said:
Nice, could these be modified post-startup? like I go adb and copy paste some of them for testing?
I've tested setprop windowsmgr.max_events_per_sec 68, no difference. Set it to
setprop windowsmgr.max_events_per_sec 10 and still, no difference.
Click to expand...
Click to collapse
I don't think the setprop values can be modified post-startup. You can check if the value was modified by doing a getprop. (The default value for that prop is 55.)
The rest of them can be modified post-startup though.
Excuse my noobiness on Android, I would like an explanation on this command:
hardcore said:
# Tweak kernel VM management
echo "0" > /proc/sys/vm/swappiness
Click to expand...
Click to collapse
On my GNU/Linux system I've set vm.swappiness to 10, because I've got plenty MiB of RAM and I don't want my system to swap a lot. Is this swappiness the same as Linux? Because that would mean having the system to use more RAM, and since we don't have much of that available by default, I'm just surprised you didn't set a higher value. (I'm not saying you don't know what you're doing, I just want to learn how it works!)
By the way, this script is going to be a must-have, I think you've put an excellent effort on i9000 Android development! Thanks for sharing!
xan said:
Nice, could these be modified post-startup? like I go adb and copy paste some of them for testing?
I've tested setprop windowsmgr.max_events_per_sec 68, no difference. Set it to
setprop windowsmgr.max_events_per_sec 10 and still, no difference.
Click to expand...
Click to collapse
The aosp windowmanager (android framework) ignores values <35. (Samsung could have changed something here, but that is very unlikely).
That value does not affect the framerate, but how many touch events are reported to the apps; this saves some cpu if the user keeps touching the screen.
Fr4gg0r said:
The aosp windowmanager (android framework) ignores values <35. (Samsung could have changed something here, but that is very unlikely).
That value does not effect the framerate, but how many touch events are reported to the apps; this saves some cpu if the user keeps touching the screen.
Click to expand...
Click to collapse
Yes, i tried on Eclair to set it to 56fps (real fps is 55.5555555555555) but touch scrolling were not smoother.
I hope it can be improved in some way!
Fr4gg0r said:
The aosp windowmanager (android framework) ignores values <35. (Samsung could have changed something here, but that is very unlikely).
That value does not affect the framerate, but how many touch events are reported to the apps; this saves some cpu if the user keeps touching the screen.
Click to expand...
Click to collapse
Thanks for the info. Looks like default settings are best unless we can actually change the refresh rate.
supercurio said:
Yeah thank you so much for taking the time and sharing, i'll integrate them after a bit of testing
Click to expand...
Click to collapse
We are eagerly waiting for it =) I don't know when you manage to sleep since you have so many things to do in voodoo =)
hardcore said:
Hi guys,
I've been using Linux kernel tweaks in a startup script to make the phone smoother.
With these tweaks, the phone is quite smooth and fast even without using the filesystem lagfixes.
These settings are only useful for you if you know how to create and modify a startup script. I use the old playlogos hack myself, but I'm sure there are many new ways to do it now.
Code:
# Remount all partitions with noatime
for k in $(mount | cut -d " " -f3)
do
sync
mount -o remount,noatime $k
done
# Tweak cfq io scheduler
for i in $(ls -1 /sys/block/stl*) $(ls -1 /sys/block/mmc*) $(ls -1 /sys/block/bml*) $(ls -1 /sys/block/tfsr*)
do echo "0" > $i/queue/rotational
echo "1" > $i/queue/iosched/low_latency
echo "1" > $i/queue/iosched/back_seek_penalty
echo "1000000000" > $i/queue/iosched/back_seek_max
echo "3" > $i/queue/iosched/slice_idle
done
# Tweak kernel VM management
echo "0" > /proc/sys/vm/swappiness
echo "10" > /proc/sys/vm/dirty_ratio
echo "1000" > /proc/sys/vm/vfs_cache_pressure
echo "4096" > /proc/sys/vm/min_free_kbytes
# Tweak kernel scheduler
echo "2000000" > /proc/sys/kernel/sched_latency_ns
echo "500000" > /proc/sys/kernel/sched_wakeup_granularity_ns
echo "400000" > /proc/sys/kernel/sched_min_granularity_ns
# Miscellaneous tweaks
setprop dalvik.vm.startheapsize 8m
setprop wifi.supplicant_scan_interval 90
EDIT: Explanations:
# Remount all partitions with noatime
atime is a setting where the filesystem updates the access time of a file. This creates a write-after-every-read which slows things down. By default all partitions are mounted with relatime, which is an optimized version of atime. noatime is the fastest, and afaik we don't need atime.
# Tweak cfq io scheduler
Tweaked settings of the disk io scheduler more for flash memory. Defaults are optimized for spinning harddisks. Lowered the idle wait, re-enable the low latency mode of cfq, removed the penalty for back-seeks and explicitly tell the kernel the storage is not a spinning disk.
# Tweak kernel VM management
Set tendency of kernel to swap to minimum, since we don't use swap anyway.
Lower the amount of unwritten write cache to reduce lags when a huge write is required.
Increase tendency of kernel to keep block-cache to help with slower RFS filesystem.
Increase minimum free memory, in theory this should make the kernel less likely to suddenly run out of memory.
# Tweak kernel scheduler
Make the task scheduler more 'fair' when multiple tasks are running. This has a huge effect on UI and App responsiveness. These values are 10% of the Linux defaults, and about half of the Android defaults.
# Miscellaneous tweaks
Manually set the starting dalvik heap size.
Increase wifi scanning gap to reduce battery usage.
Click to expand...
Click to collapse
I'm interested in doing this but I'm not sure where should I put the file. I checked playlogos1 from /system/bin but it's a binary file.. Tried to find playlogos hack on the forum but can't really find anything...
i have a jpm with voodoo, and i have copy this code into /voodoo/scripts/init.sh
just simplely add to the end of it, of course, before the last line.
the system reboot is ok, but i havent see the effects yet.
btw, "ls -1 /sys/block/mmc*" in adb give us:
Code:
ls -1 /sys/block/mmc*
-1: No such file or directory
/sys/block/mmcblk0
/sys/block/mmcblk1
so, "-1" key is useless
[kab] said:
btw, "ls -1 /sys/block/mmc*" in adb give us:
Code:
ls -1 /sys/block/mmc*
-1: No such file or directory
/sys/block/mmcblk0
/sys/block/mmcblk1
so, "-1" key is useless
Click to expand...
Click to collapse
it should be -l, not one

[MOD] SHW-M110S Development (with lagfix/root/voodoo sound kernel)

For SHW-M110s development/discussion. (Korean Anycall SGS ONLY yes for any who don't know, we are officially part of the I9000 forum.
Koe1974 suggested this thread and will I think act as a co-OP on this discussion. Look for front page updates, links, whatever from him 3 posts down, (below the lost guy from China) in the future too.
Version 4 released
Version 4.0r1 released to fix Odin flashing problem
link to kernel
with tegrak_voodoo sound (v2) module, tegrak ext4 module, root (superuser.apk) and busybox 1.17.1 optional, safe mount option overides by default, auto detect lag fixed partitions (improves upgradeability and interchageability) [/B][/size] Compatible with previously z4modded ext2 setups. All ROM versions, SK05 through TA13 tested and released (link is below).
안녕하세요 to any of the Korean developers who find this. Please update us in English about what you are doing. Your English is probably MUCH better than my korean, and I live in Korea.. There are some people in China, Iran, Philippines, etc using this device who might be helped.
-------------------------------------------------------------------------------------------------------------------------
Ext4 (tegrak modules) z4build rooted voodoo sounds kernel link
A stock z4moded kernel with added ext4 support ( presently by "stealing" tegrak kernel modules.) and many tweaks to make it actually work.
This is now working with z4control to get an easy to apply ext4 lag fix!
------------------------------------------------------------------------------------------------------------------------------------
Bug discussion here please, usage discussion (how do get the file into odin?) .. maybe the general thread is better.
For now, our rooting guide is linked from my sig also, although the above linked kernel can also be made to provide root with no effort.
This type of initramfs modification can be done by unpacking a stock kernel making customizations and then applying z4build to it. But I used a z4modded kernel and then applied customizations and repacked. I did this because I set up to repack by hand anyway before knowing I wanted to use z4mod and even then, when I thought I needed to pack into a tegrak kernel (which z4build can't do). It turned out to cause complications, but also taught me a good bit about the process and about z4mod, and probably helped me find bugs.
Some other related useful links for Reference:
kernel extraction (commented by me specifically for tegrak lzma compressed initramfs and z4build split initramfs)
http://forum.xda-developers.com/wiki/index.php?title=Extract_initramfs_from_zImage
kernel repacking
http://forum.xda-developers.com/showthread.php?t=789712
It needs the initramfs to be cpio'd already something like this:
Code:
cd $initram
find ./ | cpio -H newc -o > $repackdir/newramfs.cpio
It also needs the editor.sh script modified to point to the cross-compiler.
By default it can only pack you initramfs into an image which previously had an uncompressed initramfs. This can be modified though easily.
kernel compiling
This old thread probably isn't too useful now..
http://forum.xda-developers.com/showthread.php?t=740740&page=2
We have much better info 3 posts down by koe1974.
Kernel sources here:
http://opensource.samsung.com/
search SHW-M110S.
The first froyo update has a nice readme with a link to the compiler (I don't have the link right this moment)
Not sure if we need to figure/find .configs, or if the ones included are ok to start. Just need to compile one once and see.
I got my compiler toolchain here:
http://www.codesourcery.com/sgpp/li...1-188-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
I thought it's the one recommended is the original froyo source from samsung, but Koe says they point to 2009 version, so I don't know now.
............
I flashed the korean voodoo sk22 kernel just to boot it into recovery. It has CW mod recovery. Might be useful. (BTW I don't recommend flashing unfamiliar kernels haphazardly, ex: this one injected a file into my ROM that interefered with z4mod until I realized it ) Mine BTW injects only one empty directory (/etc/init.d) and nothing else. Remove the kernel and all other changes dissappear. (z4control adds a tad more, but very little, most of its additions self destruct after use.)
Post reserved.
Post Removed, as requested.
Sent from my GT-I9000 using XDA App
Links:
Korea's equivalent to XDA
Lilinser's GitHub - kernel repack, deodexer, etc.
Project-Voodoo - initramfs (SK05)
Just for hobbies - Voodoo for SL28
Tegrak Kernel
SHW-M110S intramfs Requires further research.
Older M110S from someone at MIT working on the M110S potential resource
bml7 & initramfs possible resource
more initramfs
initramfs SK05 Tested .. OK
How-Tos:
Basic How-To Build Environment with built kernel test
First this diff is from a z4modded stock SL28 image to the custom kernel image. It's not against stock. So it includes tegrak files and scripts I changed. Also note the -N option. It pretends like files that don't exist do.. Any binary files that "differ" are actually added from tegrak.
Code:
diff -rbpN z4mod_sl28/initramfs/init.rc z4grak-construction-sl28/initramfs/init.rc
*** z4mod_sl28/initramfs/init.rc 2011-01-13 02:20:12.000000000 -0500
--- z4grak-construction-sl28/initramfs/init.rc 2011-01-11 07:43:34.000000000 -0500
*************** loglevel 3
*** 58,63 ****
--- 58,72 ----
mount j4fs /dev/block/stl6 /mnt/.lfs
insmod /lib/modules/param.ko
+ #ext4 modules by woo
+ insmod /tegrak/lib/modules/mbcache.ko
+ insmod /tegrak/lib/modules/jbd2.ko
+ insmod /tegrak/lib/modules/ext4.ko
+
+ # tegrak system lagfix by woo
+ #
+ insmod /tegrak/lib/modules/tegrak_module.ko
+
# Backwards Compat - XXX: Going away in G*
symlink /mnt/sdcard /sdcard
*************** service vt /system/bin/vtserver
*** 728,734 ****
#user system
#group system
-
service dumpstate /system/bin/dumpstate -s
socket dumpstate stream 0660 shell log
disabled
--- 737,742 ----
*************** service dumpstate /system/bin/dumpstate
*** 739,747 ****
# oneshot
-
# Added by z4mod
service z4postinit /init
oneshot
--- 747,761 ----
# oneshot
# Added by z4mod
service z4postinit /init
oneshot
+ #install root ingore the mount type, it doesn't matter
+ # syntax looks a little strange to me.. we'll see if it works
+ mount rfs /dev/block/stl9 /system rw remount
+ cat /sbin/su > /system/bin/su
+ chown root /system/bin/su
+ chmod 4755 /system/bin/su
+ mount rfs /dev/block/stl9 /system ro remount
\ No newline at end of file
diff -rbpN z4mod_sl28/initramfs/lpm.rc z4grak-construction-sl28/initramfs/lpm.rc
*** z4mod_sl28/initramfs/lpm.rc 2011-01-13 02:20:12.000000000 -0500
--- z4grak-construction-sl28/initramfs/lpm.rc 2011-01-11 06:37:28.000000000 -0500
*************** on init
*** 16,21 ****
--- 16,26 ----
insmod /lib/modules/param.ko
insmod /lib/modules/vibrator.ko
+ #ext4 modules by woo
+ insmod /tegrak/lib/modules/mbcache.ko
+ insmod /tegrak/lib/modules/jbd2.ko
+ insmod /tegrak/lib/modules/ext4.ko
+
mount rfs /dev/block/stl9 /system check=no
mount rfs /dev/block/mmcblk0p2 /data nosuid nodev check=no
Binary files z4mod_sl28/initramfs/sbin/sslvpn and z4grak-construction-sl28/initramfs/sbin/sslvpn differ
Binary files z4mod_sl28/initramfs/tegrak/bin/mkfs.ext4 and z4grak-construction-sl28/initramfs/tegrak/bin/mkfs.ext4 differ
Binary files z4mod_sl28/initramfs/tegrak/bin/tune2fs and z4grak-construction-sl28/initramfs/tegrak/bin/tune2fs differ
Binary files z4mod_sl28/initramfs/tegrak/lib/modules/ext4.ko and z4grak-construction-sl28/initramfs/tegrak/lib/modules/ext4.ko differ
Binary files z4mod_sl28/initramfs/tegrak/lib/modules/jbd2.ko and z4grak-construction-sl28/initramfs/tegrak/lib/modules/jbd2.ko differ
Binary files z4mod_sl28/initramfs/tegrak/lib/modules/mbcache.ko and z4grak-construction-sl28/initramfs/tegrak/lib/modules/mbcache.ko differ
Binary files z4mod_sl28/initramfs/tegrak/lib/modules/tegrak_module.ko and z4grak-construction-sl28/initramfs/tegrak/lib/modules/tegrak_module.ko differ
I'm a bit confused about sslvpn It's in my SL28 , it's not in my z4moded SL28. everything else diff as expected. Maybe I just lost it, maybe z4mod removed it. It's a small unimportant mystery.
BTW it looks like what I believe are the recovery keys have changed from SK22 to SL28, so maybe using the wrong kernel breaks something.
and my slightly modified version of the extraction script with commented lines to deal with lzma.
it's much faster (well.. why not), and it handles direcories a little better. It need a "/" somewhere in the file name though so use "./zImage".
Code:
#!/bin/bash
#MUCH faster than dd bs=1 skip=blah
#
# syntas is fastdd file skip <length_in_bytes_optional>
# skip is NOT optional and should be set to 0 read from begining.
#
fastdd () {
#dd with a skip is crazy slower cause it forces bs=1
#credit goes to somebody on the internet.
local bs=1024
local file=$1
local skip=$2
local count=$3
(
dd bs=1 skip=$skip count=0 2>/dev/null
if [[ "$count" != "" ]]; then
dd bs=$bs count=$(($count / $bs))
dd bs=$(($count % $bs)) count=1
else
dd bs=1024 2> /dev/null
fi
) < "$file"
}
zImage=$1
basedir=${1%/*}
echo working directory $basedir
mkdir $basedir/initramfs
outdir=$basedir/initramfs/
#========================================================
# find start of gziped kernel object in the zImage file:
#========================================================
pos=`grep -P -a -b -m 1 --only-matching $'\x1F\x8B\x08' $zImage | cut -f 1 -d :`
echo "-I- Extracting kernel image from $zImage (start = $pos)"
echo
echo "*** Start of compressed kernel image:" $pos
#========================================================================
# the cpio archive might be gzipped too, so two gunzips could be needed:
#========================================================================
fastdd $zImage $pos | gunzip > /tmp/kernel.img
pos=`grep -P -a -b -m 1 --only-matching $'\x1F\x8B\x08' /tmp/kernel.img | cut -f 1 -d :`
#
# Use next one for tegrak secuere 11 SL28
# It's an lzma header
# It's found by looking for 5D 00 in the exact same place as cpio (070701) is found in stock.
# The long string of FF's is the real give away since 5D 00 is too vague.
# pos=`grep -P -a -b -m 1 --only-matching '\x{5D}\x{00}\x..\x{FF}\x{FF}\x{FF}\x{FF}\x{FF}\x{FF}' /tmp/kernel.img| cut -f 1 -d :`
echo
echo "*** gzip position in kernel.img :" $pos "(start of gzipped cpio)"
#===========================================================================
# find start and end of the "cpio" initramfs image inside the kernel object:
# ASCII cpio header starts with '070701'
# The end of the cpio archive is marked with an empty file named TRAILER!!!
#===========================================================================
if [ ! $pos = "" ]; then
echo "-I- Extracting compressed cpio image from kernel image (start = $pos)"
# use either one of the next two lines for gzip
# dd if=/tmp/kernel.img bs=1 skip=$pos | gunzip > /tmp/cpio.img
fastdd /tmp/kernel.img $pos |gunzip > /tmp/cpio.img
# comment above and uncomment one of next two lines for lzma, if decompressing tegrak image.
# dd if=/tmp/kernel.img bs=1 skip=$pos | unlzma > /tmp/cpio.img
# fastdd /tmp/kernel.img $pos | unlzma > /tmp/cpio.img
start=`grep -a -b -m 1 --only-matching '070701' /tmp/cpio.img | head -1 | cut -f 1 -d :`
end=`grep -a -b -m 1 --only-matching 'TRAILER!!!' /tmp/cpio.img | head -1 | cut -f 1 -d :`
inputfile=/tmp/cpio.img
else
echo "-I- Already uncompressed cpio.img, not decompressing"
start=`grep -a -b -m 1 --only-matching '070701' /tmp/kernel.img | head -1 | cut -f 1 -d :`
echo start $start
end=`grep -a -b -m 1 --only-matching 'TRAILER!!!' /tmp/kernel.img | head -1 | cut -f 1 -d :`
echo end $end
inputfile=/tmp/kernel.img
fi
end=$((end + 10))
count=$((end - start))
if (($count < 0)); then
echo "-E- Couldn't match start/end of the initramfs image."
exit
fi
echo "-I- Extracting initramfs image from $inputfile (start = $start, end = $end)"
echo inputfile: $inputfile
echo start $start
echo count $count
echo outdir $outdir
# dd if=$inputfile bs=1 skip=$start count=$count > $outdir/initramfs.cpio
fastdd $inputfile $start $count > $basedir/initramfs.cpio
cd $basedir
basedir=`pwd`
cd $outdir; cpio -v -i --no-absolute-filenames < $basedir/initramfs.cpio
cp /tmp/kernel.img $basedir/
More to come.
I like the way this is going, appagom, please put [MOD] in the title.
GL on the new thread, if you hope to have Koreans stumbled upon the thread it might be good to add more phrases like:
루팅
갤럭시s
안드로이드
프로요
업그레이드
업데이트
I never really fully utilized it myself. I hope you get more done here or I'll just take the move personally. Actually, now that you guys were moving into compiling and building I thought this would come. Also, you should look to get some Soju out of this with some donate links or something, even if you aren't looking to take in any cash perhaps you could use it as a seed pot for bounties.
Most importantly, I need to know what "the lost guy from China" said...ㅋㅋㅋ
@Koe, don't waste your time on Gingerbread, get us Honeycomb
Compile a Kernel in 13 Lucky Steps
If you are not familiar with Linux, you might have a hard time following this. Just as I am writing how to do get setup to compile a kernel and compile Android apps, others have written how to setup VirtualBox, Ubuntu, AndroidSDK, etc. Please see documentation provided by Oracle, Google, Ubuntu, etc. before you ask for help about VirtualBox, Ubuntu and the SDK. Thanks.
This is written for people who have used Linux but have not compiled much. Or for the brave at heart who are looking for a nice weekend project. This will tell/guide you through getting a system setup that will not destroy your existing OS.
My host OS is Ubuntu 10.10 64-bit. I wanted had to make an Ubuntu 10.04 32-bit 64-bit system for development because I didn't want to deal with 64-bit vs. 32-bit issues but since Gingerbread requires a 64-bit compiler, I had to. Might as well just use my host system, but since we're here let's keep going!
So you're about to begin. Let's just get one thing straight. No! This will not result in a kernel you can flash. “Then why do this?, you ask. Ask yourself that!
1. Install VirtualBox and the Oracle VM VirtualBox Extension Pack (Currently 4.0.0 r69151)
http://www.virtualbox.org/wiki/Downloads
2. Download an Ubuntu ISO (I suggest Ubuntu Desktop 10.04 64-bit)
http://www.ubuntu.com/desktop/get-ubuntu/download
3. Create a new VM in VirtualBox (You may/have to modify the settings)
Operating System: Linux
Version: Ubuntu64
Extended Features: IO APIC
Processors: 2
RAM: 2048MB
Video Mem: 128MB
HDD: 32GB
Enable PAE/NX
Shared Drive: (I use a shared folder, more detail later)
Click to expand...
Click to collapse
4. Install VirtualBox Guest Additions
5. Install Ubuntu and Update Ubuntu
TIP: Mount your Shared Folder with fstab (Optional but helpful)
If you chose to use a shared folder you can auto-mount it via /etc/fstab.
NOTE: I use a shared folder named andDEV and I mount it on my desktop (~/Desktop). Below is what I add to my /etc/fstab (You may/have to change it)
Code:
andDev /home/koe/Desktop/andDev vboxsf uid=1000,gid=1000 0 0
Click to expand...
Click to collapse
6. Enable multiverse and partner "Software Sources"
7. Install additional software: NOTE: I would also recommend installing preload, but it is not required.
Code:
sudo apt-get install qt3-dev-tools texinfo git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk eclipse ia32-libs
8. Get and Setup the AndroidSDK (Everything you need to know is there or just Google for help)
http://developer.android.com/sdk/index.html
NOTE: Ubuntu 10.04 does not have Java 5 in it's repositories. Follow this link to setup to Java 5
9. Get and Setup ADT Plugin for Eclipse (Everything you need to know is there or just Google for help)
http://developer.android.com/sdk/eclipse-adt.html#installing
TIP: At this point you might want to try Google's “Hello, Android” tutorial.
Click to expand...
Click to collapse
10. Download and Install the Sourcery G++ Lite for ARM EABI Toolchain (Currently arm-2010.09)
http://www.codesourcery.com/sgpp/lite/arm/portal/subscription3053
Look for and click the link for Recommended Release
Look for and click the link for IA32 GNU/Linux TAR
Extract the archive. You will have a folder named arm-2010.09
Make a directory in your home directory named CodeSourcery
Ex. mkdir ~/CodeSourcery
copy the entire arm-2010.09 folder into CodeSourcery
Click to expand...
Click to collapse
11. Update your $PATH
You should be familiar with this because you had to do it to setup the AndroidSDK
Append the following to your PATH in .bashrc
Code:
~/CodeSourcery/arm-2010.09/bin
12 Download and Prepare the Samsung Source Code (Currently SHW-M110S_Opensource_Froyo_update2.zip)
http://opensource.samsung.com/
Click Mobile - Mobile Phones
Look for and download SHW-M110S_Opensource_Froyo_update2.zip
Extract the archive. Inside the new folder are two more archives.
Extract SHW-M110S_Kernel.tar.gz Inside there is a new folder Kernel
You can copy this to a more convenient location. I copy it to my desktop.
In the Kernel folder is a file named Makefile. Open it with your editor of choice.
Go to line 184. You will see ...
CROSS_COMPILE ?= /opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-
You have to change it to something like below, but see the koe? That is my username so you have to change it to your username.
CROSS_COMPILE ?= /home/koe/CodeSourcery/arm-2010.09/bin/arm-none-eabi-
Save Makefile.
Click to expand...
Click to collapse
13. Compile a Kernel
NOTES:
1. Do not try to compile the code in your Shared Folder. It will fail.
2. When issuing these commands you will see lots of output during this part, most of which is not useful to you at this point.
3. The amount of time it takes for the final make command to run will depend on your computer.
Click to expand...
Click to collapse
Open a terminal window and move into the Kernel directory. Issue the following commands.
Code:
$ make shw-m110s_defconfig
$ make menuconfig
When the config editor opens do the following:
DOWN ARROW to Userspace binary formats and press ENTER
DOWN ARROW to Kernel support for a.out and ECOFF binaries and press SPACE
RIGHT ARROW to Exit and press ENTER
RIGHT ARROW to Exit and press ENTER
Press ENTER again and it will exit back to the command line
NOTE: If you have a powerful computer and you want to speed up the build time, make can be run as, make -j# The # represents how much it will try to do at once. $ make does 1 operation, make -j3 tries to do 3. I have a 2.66 Ghz dual-core CPU and I allow the VirtualBox guest OS access to both cores, so I use make -j3 The compile finishes in about 12 minutes and allows me to still use my host OS. For now, you might just want to run make without the -j option to get a full understanding of how long it takes. Later you can test with values.
Click to expand...
Click to collapse
WARNING: Time is relative. This will take some time ... go make a sandwich or maybe even watch a movie.
Code:
$ make
When you see $ again check the last couple of lines of output. You want to see …
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
Click to expand...
Click to collapse
Congratulation! You just built a kernel for the m110s!
good write up.. Glad to see you hit the same a.out snag as me. Just makes me think it's not configured right and so I have low hopes. Will be fun to see what happens when you put an initramfs in it. I'd just unpack the stock one and try that first.
As for z4control.. I'm pretty interested in getting this working as something like this was the real reason I started messing with this. It seems there may be some issue with the z4mod's init wrapper not doing things it should but anyway.. just now seeing issues. flashed one kernel where I added some debug output added.. trying to understand it (not understanding it yet). I'm optimistic that I can track it down. edit:... definitely making progress, not quite there yet but getting closer.
appagom said:
good write up.. Glad to see you hit the same a.out snag as me. Just makes me think it's not configured right and so I have low hopes. Will be fun to see what happens when you put an initramfs in it. I'd just unpack the stock one and try that first.
Click to expand...
Click to collapse
Strictly to see if it would build completely and to get more info on how to do it, I did do an initramfs & kernel test build.
used the update2 kernel source
used the initramfs linked above (SHW-M110S intramfs Requires further research.)
ran find ./ | cpio -H newc -o > ~/Desktop/newramfs.cpio
added the cpio via menuconfig with no compression
It did build successfully and I ended up with a 7mb zImage vs. a 2.5mb.
There is no way in hell I am going to flash it because I do not know which initramfs (maybe from sk05) it is or what it contains but it did complete.
Now isn't this a kick in the nuts!
Since I got the toolchain all set I decided to focus on the Android source code. Following these directions .. http://source.android.com/source/download.html I got to "Building the code"
Code:
[email protected]:~/Desktop/myAnd$ source build/envsetup.sh
including device/htc/passion/vendorsetup.sh
including device/samsung/crespo/vendorsetup.sh
[email protected]:~/Desktop/myAnd$ lunch
You're building on Linux
Lunch menu... pick a combo:
1. full-eng
2. full_x86-eng
3. simulator
4. full_passion-userdebug
5. full_crespo-userdebug
Which would you like? [full-eng] 1
============================================
PLATFORM_VERSION_CODENAME=AOSP
PLATFORM_VERSION=AOSP
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv5te
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
============================================
[email protected]:~/Desktop/myAnd$ make
============================================
PLATFORM_VERSION_CODENAME=AOSP
PLATFORM_VERSION=AOSP
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv5te
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
============================================
Checking build tools versions...
build/core/main.mk:76: ************************************************************
build/core/main.mk:77: You are attempting to build on a 32-bit system.
build/core/main.mk:78: Only 64-bit build environments are supported beyond froyo/2.2.
build/core/main.mk:79: ************************************************************
build/core/main.mk:80: *** stop. Stop.
Well, 32-bit will do for now seeing how ::cough:: I'm not the one building gingerbread.
I guess my next how-to is going to be how to go out and buy a PC and setup a 64-bit development environment.
Well, 32-bit will do fro now see how ::cough:: I'm not the one building gingerbread.
I guess my next how-to is going to be how to go out and buy a PC and setup a 64-bit development environment.
Click to expand...
Click to collapse
Could try the gnu cross compiler I suppose maybe it's clever enough to work around it. Your computer really isn't 64 bit though? You could just install a 64 bit VM assuming it is.
koe1974 said:
added the cpio via menuconfig with no compression
Click to expand...
Click to collapse
Ok, that procedure is easier than it used to be, or than what I read it used to be. I'm not afraid to add one and flash it. Just busy with making one I like right now though.. then again.. sounds like a 10 minute interruption.. so.. we'll see... oh and I don't remember what was stopping xconfig from working, but something annoying.. it's quite a bit nicer than menuconfig. I need to learn how that works though.. cause really you should add modules from the compilation itself right.. so you cant have the initramfs already before you compile, unless make opens it and add the modules and re-cpio's it. Anyway.. I'll shoot first, ask later.
edit: just flashed.. it gave about 1 tenth of a blue bar and froze. Ok, that was fun, back to fixing and ext4 kernel up.
appagom said:
Could try the gnu cross compiler I suppose maybe it's clever enough to work around it. Your computer really isn't 64 bit though? You could just install a 64 bit VM assuming it is.
Click to expand...
Click to collapse
The VM I setup was 32bit, but it's 64bit now. I will just modify the How-To for a 64bit system.
4 bugs related z4control issues solved(ok 2 were probably the same as well as a fifth, so really 3)..
one, it's failing to create a directory it needs (/system/etc/init.d), reported, work around create by hand.
2) It's rfs formatting wrapper script which checked for voodoo, failed. Strange bug in sh actually.. workaround in script found and reported
bugs 3 and 4 details unimportant, were related to the mystery of where sslvpn went. z4build was splitting the initramfs by tacking it some of it brute force on to the end of the zImage. The init script found it again and unpacked the files before continuing. Oddly, it seems an uneeded because I fit the only big displaced file in just fine without splitting and I didn't even use heavy compression. Anyway, needed or not it caused two files to go missing, this one, and a small text file that reported the version of z4mod. this file prevented z4control from working.
I will not fix this tonight, but I mostly understand it (altough not in exact detail of precisely understanding some of the odd symptoms, but I think dealing with this will likely solve it all) My diffs could never find the version file, cuase I never unpacked it to know it even existed in the first place. Waaaah.. bug tracking is tiring. We should have this all running very shortly.
update: my first attempt at fixing the repacking bug.. resulted (I already feared this but hoped it would just go away) in a kernel that seems totaly complete, but where it seems something in the init wrapper isn't working... getting closer to finding it.
update: LAST BUG FIXED
The last bug(which I previously assumed was part of the repack bug) was actually aslo part of z4build, now documented here:
http://forum.xda-developers.com/showpost.php?p=10638535&postcount=1062
I'm pretty sure that one should really get it all going now. there are no lines of code left to break. I've tested almost every line now. I'll get a new kernel out, but will need to wait for an updated z4control. z4ziggy seems busy right now maybe (no complaint obviously).
I can fix this last bug in my roll out of the kernel. The other remaining ones can be worked around pretty easily, but not pretty for user instructions, better to wait probably.
SK05 Rebuild test (PASS)
We have doubts about if the shw-m110s_defconfig is what is used by samsung so I decided to try to make a working kernel from an initramfs and froyo_update source code.
General idea of what I did...
sk05 source code froyo_update (from samsung)
sk05 initramfs (link in post 4 "initramfs SK05 Tested .. OK")
cd initramfs_dir
find . -print0 | cpio -o0 -H newc | gzip -9 -f > some/path/initramfs.cpio.gz
cd kernel source code root directory
modify Makefile ln. 184
make aries_android_rfs_defconfig
make menuconfig
disable a.out
add path to initramfs archive
compression gzip
make
tar --format=ustar SK05rebuilt.tar zImage
Click to expand...
Click to collapse
Results in a zImage the same size (4.6mb) as samsung's, and it boots.
awesome..
I GOT IT
That was big fat B to solve. Debugging self destructing scripts that run in a startup environment with different mounts and different PATH variable is no fun and requires some imagination. I had to work around 2 more bugs in z4build but now I have user transparent workarounds to all of them.. plug and play. Unfortunately I have about 30 minutes more free time today so I probably wont post it today. I should clean up some comments and such in it first probably. We'll see.
appagom said:
awesome..
I GOT IT
Click to expand...
Click to collapse
Very nice!
Sent from my SHW-M110S using XDA App
the "awesome" comment was referring to you. Should be able to take the grak of z4grak with some compiling , but I'm happy with it in too.. doesn't matter.
Anyway.. I updated the kernel page (from the link on OP). The new kernel is there, but I pushed it out very fast. Didn't flash last repack myself yet after changing comments.. but I only changed comments. (I am running the posted copy now) It needs testing since my system has gotten a been used and non-pristine. Get z4control, you can use it to flash it if you want. the rest is all push button I hope.
Oh and default settings are less safe than Tegrak, not much if any better than ext2 actually. I think.. can't confirm right now. I recommend modifying etc/fstab to data=ordered,barrier=1 personally.. but that's what I like about z4.. you can decide for yourself.
Sent from my SHW-M110S using XDA App

init.d performance startup script

I've adapted the original performance tweaks by 'hardcore' @ XDA for my overclocked/undervolted Galaxy Tab. The tweaked values are pretty much the same as the ones recommended by the original poster, but my simple init.d/ script allows me to log default system values when pushing new values, which is useful for debugging. The script also contains comments to describe the role of each setting. Note that if you don't have init.d/ support in your kernel / initramfs, you can still run the script manually at each system start (use an app like GScript).
Code:
#!/system/bin/sh
#
# Original tweaks by 'hardcore' @ XDA
# http://forum.xda-developers.com/showthread.php?t=813309
# This is a startup script designed for /system/etc/init.d/.
# Note that "run-parts" support (for init.d/ scripts) is normally provided by custom a initramfs,
# which should bundle busybox in /sbin/. The /sbin/run-parts.sh script should take care of
# running init scripts (by calling /sbin/runparts), and it should subsequently trigger
# the device startup (using "setprop filesystem.ready 1", or similar).
# Note that the recovery mode typically doesn't run /system/etc/init.d/ startup scripts.
# Ensure /sbin/busybox takes precedence.
# Normally this is redundant, because the /init.rc startup script already sets the correct path.
export PATH=/sbin:$PATH
# Logging of old/new sysfs values, useful for double-checking.
logFile=/data/local/tmp/S_perf_tweaks.log
if [ -f $logFile ]
then
rm $logFile
fi
touch $logFile
# This function logs the old value and writes the new value.
echo_()
{
echo '' >> $logFile
echo -n "${2}${3} (${1}): " >> $logFile
#head -1 ${2}${3} >> $logFile
#read $firstLine < ${2}${3}
#echo -n $firstLine >> $logFile
contents=`echo -n $(cat ${2}${3})`
echo -n $contents >> $logFile
echo -n " ---> " >> $logFile
echo $1 > ${2}${3}
contents=`echo -n $(cat ${2}${3})`
echo -n $contents >> $logFile
}
# Note that the settings pushed by VoltageControl.apk
# could also be managed here (this only applies to kernels with clock/frequency tables and undervolt sysfs support):
#echo_ "50 50 50 25 25 25 25 " "/sys/devices/system/cpu/cpu0/cpufreq" "/UV_mV_table"
#echo_ 1400000 "/sys/devices/system/cpu/cpu0/cpufreq" "/scaling_max_freq"
echo "---------" >> $logFile
# Remount all partitions that use relatime with noatime and nodiratime instead.
# Note: atime generates a write-after-every-read, relatime is an optimized version of atime.
for k in $(mount | grep relatime | cut -d " " -f3)
do
echo "mount -o remount,noatime,nodiratime $k" >> $logFile
sync
mount -o remount,noatime $k
done
# Here is a sample test to measure read/write performance on rfs partitions:
### test for write: dd if=/dev/zero of=/data/test count=30000
### test for read: dd if=/data/test of=/dev/zero
echo "---------" >> $logFile
# Log the mount table
mount >> $logFile
echo "---------" >> $logFile
# Optimize the cfq/bfq I/O scheduler for flash memory (defaults are designed for spinning harddisks).
# Lower the idle wait, re-enable the low latency mode, remove the penalty for back-seeks,
# and explicitly tell the kernel that the storage is not a spinning disk.
for i in $(ls -1 /sys/block/stl*) $(ls -1 /sys/block/mmc*) $(ls -1 /sys/block/bml*) $(ls -1 -d /sys/block/tfsr*)
#for i in `ls /sys/block/stl* /sys/block/mmc* /sys/block/bml* /sys/block/tfsr*`;
do
# DEF noop anticipatory deadline cfq [bfq]
echo_ "bfq" $i "/queue/scheduler"
# DEF 1 ?
echo_ "0" $i "/queue/rotational"
# DEF 1 ?
echo_ "1" $i "/queue/iosched/low_latency"
# DEF 2 ?
echo_ "1" $i "/queue/iosched/back_seek_penalty"
# DEF 16384 ?
echo_ "1000000000" $i "/queue/iosched/back_seek_max"
# DEF 6 ?
echo_ "3" $i "/queue/iosched/slice_idle"
sync
done
# Set tendency of kernel to swap to minimum, since swap isn't used anyway.
# (swap = move portions of RAM data to disk partition or file, to free-up RAM)
# (a value of 0 means "do not swap unless out of free RAM", a value of 100 means "swap whenever possible")
# (the default is 60 which is okay for normal Linux installations)
# DEF 60
echo_ "0" "/proc/sys/vm" "/swappiness"
# Lower the amount of unwritten write cache to reduce lags when a huge write is required.
# DEF 20
echo_ "10" "/proc/sys/vm" "/dirty_ratio"
# Increase minimum free memory, in theory this should make the kernel less likely to suddenly run out of memory.
# DEF 3102
echo_ "4096" "/proc/sys/vm" "/min_free_kbytes"
# Increase tendency of kernel to keep block-cache to help with slower RFS filesystem.
# DEF 100
echo_ "1000" "/proc/sys/vm" "/vfs_cache_pressure"
# Increase the write flush timeouts to save some battery life.
# DEF 250
echo_ "2000" "/proc/sys/vm" "/dirty_writeback_centisecs"
# DEF 200
echo_ "1000" "/proc/sys/vm" "/dirty_expire_centisecs"
# Make the task scheduler more 'fair' when multiple tasks are running,
# which improves user-interface and application responsiveness.
# DEF 10000000
echo_ "20000000" "/proc/sys/kernel" "/sched_latency_ns"
# DEF 2000000
echo_ "2000000" "/proc/sys/kernel" "/sched_wakeup_granularity_ns"
# DEF 1000000
echo_ "1000000" "/proc/sys/kernel" "/sched_min_granularity_ns"
sync
# Miscellaneous tweaks
setprop dalvik.vm.startheapsize 8m
#setprop wifi.supplicant_scan_interval 90
echo '' >> $logFile
echo "---------" >> $logFile
#This apply a tweaked deadline scheduler to all RFS (and ext2/3/4, if existent) partitions.
#for i in /sys/block/*
#do
# DEF noop anticipatory deadline cfq [bfq]
#echo deadline > $i/queue/scheduler
#echo 4 > $i/queue/iosched/writes_starved
#echo 1 > $i/queue/iosched/fifo_batch
#echo 256 > $i/queue/nr_requests
#done
Thanks for this Daniel - since I know absolutely nothing about anything Android, all I can say is that I have 2 questions
1 - Would this script be any benefit to someone running a custom ROM (Overcome 1.1.3 in my case) and a custom kernel (Richard Trip's 1.4gHz EXT4)? I ask because I don't know if these guys have already including these tweaks or not... but maybe I should ask them instead...
2 - Is there any way you could put that script - in its most efficient, non-debugging form - in to a script file that us speed-freaks can just toss in to init.d and reboot?
Please do forgive me for any newbishness I have displayed here.
So should I put this script in /system/etc/init.d/ ?
UPDATE: Ok, I've done the script(without extension at the back of the file name) and put it in ~/init.d/, it runs well. I comment out the remount and logging function tho Tested it on some games that required load time like gangstar which lags alot previously, now just dnt have any lag time in it! Thanks!
Anyway, im running Overcome rom with richard's kernel, other than voltage script, i saw 2 more script that does the following:
10fixsh does:
"#!/system/bin/sh
busybox mount -o remount,rw /
find /sbin -maxdepth 1 -type l -exec rm {} \;
busybox mount -o remount,ro /
"
99done does:
"#!/system/bin/sh
sync;
setprop mcr.filesystem.ready 1;
"
So I just add your script as userinit since they do not have conflicting calls
Personally thinks that similar tweaks should be included in custom kernels so that those who wish to do more extreme settings can go with it while those who just wants increased performance as it is can still have the boost provided by such init script.
fastcx said:
Personally thinks that similar tweaks should be included in custom kernels so that those who wish to do more extreme settings can go with it while those who just wants increased performance as it is can still have the boost provided by such init script.
Click to expand...
Click to collapse
so basically just copy and paste the whole "code" in the first post, and create it as userinit.sh and put the userinit.sh file in /system/etc/init.d ?
am i right?
kay_kiat88 said:
so basically just copy and paste the whole "code" in the first post, and create it as userinit.sh and put the userinit.sh file in /system/etc/init.d ?
am i right?
Click to expand...
Click to collapse
still need more time to test, after some verification, none of the "/proc/sys/kernel" setting works with any of the kernel i'm using. thats y i need more time to rectify..
used richard's kernel and overcome kernel, both dont do anything now..perhaps wrong command in the script? Cause run-parts.sh does specify where to run script, and init.d does have 2 script in there that runs. So i'll need more time to make sure it works now..
Dont need to have .sh as extension, just a name for your script like the other 2 script that i posted in previous reply. And I did not copy the whole script to run, as the script seems questionable in some part..
fastcx said:
still need more time to test, after some verification, none of the "/proc/sys/kernel" setting works with any of the kernel i'm using. thats y i need more time to rectify..
used richard's kernel and overcome kernel, both dont do anything now..perhaps wrong command in the script? Cause run-parts.sh does specify where to run script, and init.d does have 2 script in there that runs. So i'll need more time to make sure it works now..
Dont need to have .sh as extension, just a name for your script like the other 2 script that i posted in previous reply. And I did not copy the whole script to run, as the script seems questionable in some part..
Click to expand...
Click to collapse
okay.. so basically just copy everything under the "code" and create it as userinit?
edit: hmmm okay thanks for you help. i don't think it's of any use for me now as my tab is quite fast and i don't do any intensive stuff on it. thanks anyway!
kay_kiat88 said:
okay.. so basically just copy everything under the "code" and create it as userinit?
edit: hmmm okay thanks for you help. i don't think it's of any use for me now as my tab is quite fast and i don't do any intensive stuff on it. thanks anyway!
Click to expand...
Click to collapse
Now i'm editing init.rc file instead, but it's not the safest thing to do
Wow all the best.. lol.
Sent from my GT-P1000 using Tapatalk
fastcx said:
Now i'm editing init.rc file instead, but it's not the safest thing to do
Click to expand...
Click to collapse
The init.rc file gets extracted from the initramfs ramdisc (packaged inside the zImage kernel) at each device startup. Changing this file's content is not a good idea. Regards, Dan
fastcx said:
So should I put this script in /system/etc/init.d/ ?
UPDATE: Ok, I've done the script(without extension at the back of the file name) and put it in ~/init.d/, it runs well.
Click to expand...
Click to collapse
Yes, the filename of the startup script must start with "S_" and must not end with ".sh". This is standard Linux stuff.
fastcx said:
find /sbin -maxdepth 1 -type l -exec rm {}
Click to expand...
Click to collapse
Removing the symlinks from "/sbin/" ... why ?
Normally Busybox should be installed properly in "/sbin/" by your kernel provider, you shouldn't have to touch this folder.
fastcx said:
99done does:
"#!/system/bin/sh
sync;
setprop mcr.filesystem.ready 1;
"
Click to expand...
Click to collapse
The "mcr.filesystem.ready" is only relevant if the "init.rc" file in the kernel zImage's initramfs ramdisc responds to a change to the "mcr.filesystem.ready" property (for example, when its value changes from 0 to 1). This is typically used to start the device normally, after *all* of the "/system/etc/init.d/" startup scripts have been executed.
The line of code "setprop mcr.filesystem.ready 1" is therefore typically included in "/sbin/runparts.sh", not in one of the "S_startup_scripts" (as this may trigger the device normal startup prematurely).
It really depends on your kernel, so it should be documented by your kernel provider.
daniel.weck said:
Yes, the filename of the startup script must start with "S_" and must not end with ".sh". This is standard Linux stuff.
It really depends on your kernel, so it should be documented by your kernel provider.
Click to expand...
Click to collapse
Great! thanks for clarifying! Sadly none of the kernel provider states any info on such matter. Will try your script again, as previously running thru gscript not all command works..
Copied your script 100%, put it in init.d with chmod 755, named it S_userinit, doesnt run..i double checked by cat value that I stated to change in the script.
Help? It obviously runs the UV script in init.d tho.
EDIT: Got it to work by editing the UV script, now settings are in! Great! Time to test anyway, nodiratime is not needed, noatime already has it
So how can I use this script - I want to
Hi, Just connected to my galaxy tab running froyo, and went looking in my filesystem for the init.d folder and yeah there isn't one
do i create one? where? and what permissions?
I try to keep this brief and not waste too much of your time.
many thanks for the script
Ttime & effort ++
andytof46 said:
Hi, Just connected to my galaxy tab running froyo, and went looking in my filesystem for the init.d folder and yeah there isn't one
do i create one? where? and what permissions?
I try to keep this brief and not waste too much of your time.
many thanks for the script
Ttime & effort ++
Click to expand...
Click to collapse
you will need a kernel that support init script, after that, /etc/init.d(or /system/etc/init.d) will be created
fastcx said:
Copied your script 100%, put it in init.d with chmod 755, named it S_userinit, doesnt run..i double checked by cat value that I stated to change in the script.
Help? It obviously runs the UV script in init.d tho.
EDIT: Got it to work by editing the UV script, now settings are in! Great! Time to test anyway, nodiratime is not needed, noatime already has it
Click to expand...
Click to collapse
Don't suppose you could post a copy of your trimmed & tweaked version of Daniel's script for us to use?
Cuz I, for example, have no idea what's useful in the original script, and what's not useful. But I at least know how to edit the UV script, heh.
jeebspawnshop said:
Don't suppose you could post a copy of your trimmed & tweaked version of Daniel's script for us to use?
Cuz I, for example, have no idea what's useful in the original script, and what's not useful. But I at least know how to edit the UV script, heh.
Click to expand...
Click to collapse
LOL here it goes
Code:
#!/system/bin/sh
#set UV
echo "0 0 0 0 0 0 0 0 " > /sys/devices/system/cpu/cpu0/cpufreq/UV_mV_table
echo 1000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
#select enabled states
echo "0 0 0 0 0 0 0 0 " > /sys/devices/system/cpu/cpu0/cpufreq/states_enabled_table
#set scheduler for stl, bml and mmc
for i in `ls /sys/block/stl*` /sys/block/bml* /sys/block/mmcblk*
do
echo "bfq" > $i/queue/scheduler
echo "0" > $i/queue/rotational
echo "1" > $i/queue/iosched/low_latency
echo "1" > $i/queue/iosched/back_seek_penalty
echo "1000000000" > $i/queue/iosched/back_seek_max
echo "3" > $i/queue/iosched/slice_idle
done
# Remount all partitions with noatime
for k in $(busybox mount | grep relatime | cut -d " " -f3)
do
sync
busybox mount -o remount,noatime $k
done
# Tweak kernel VM management
echo "0" > /proc/sys/vm/swappiness
echo "10" > /proc/sys/vm/dirty_ratio
echo "4096" > /proc/sys/vm/min_free_kbytes
# Tweak kernel scheduler, less aggressive settings
echo "18000000" > /proc/sys/kernel/sched_latency_ns
echo "3000000" > /proc/sys/kernel/sched_wakeup_granularity_ns
echo "1500000" > /proc/sys/kernel/sched_min_granularity_ns
# Misc tweaks for battery life
echo "2000" > /proc/sys/vm/dirty_writeback_centisecs
echo "1000" > /proc/sys/vm/dirty_expire_centisecs
# Miscellaneous tweaks
setprop dalvik.vm.startheapsize 8m
done
NOTE: If you change any settings in uv app, u'll revert S_volt_scheduler to ONLY UV settings, so It's recommended to edit your UV setting on this file instead of using uv app from now on if you wants to keep your other settings
Thanks dude!
I hit your Thanks Button too.
jeebspawnshop said:
Thanks dude!
I hit your Thanks Button too.
Click to expand...
Click to collapse
Thanks U should thanks the thread starter too U should just take it as reference, modify any that you feels ok, and perhaps post here as feedback on which makes things better, especially disc scheduler and task scheduler settings.
UPDATE: Made some changes to suggested value by daniel for "fairness", these setting really deals with multitasking better
echo "20000000" > /proc/sys/kernel/sched_latency_ns
echo "2000000" > /proc/sys/kernel/sched_wakeup_granularity_ns
echo "1000000" > /proc/sys/kernel/sched_min_granularity_ns
hey fastcx, i copied and pasted your script in the UV scheduler file in init.d but it seems that it's not working as the values don't apply. any ideas why?

[SHELL SCRIPT] Battery logging (discharge, capacity, etc)

After seeing apps like Android Battery Monitor, I wanted something I could run in a shell (adb) that would give me similar statistics, namely the battery discharge rate. I couldn't find any such tools or scripts, so I wrote one. Hopefully it will be useful to someone else, too.
The file paths are hard coded, and will likely only work on the Samsung Epic 4G Touch, however it could probably be easily adapted to other devices as well. It also probably requires busybox, since it uses some basic shell programs.
The script will output statistics every second, like this:
Code:
[DATE]|[TIME]|[DISCHARGE]|[CHARGE%]|[CHARGEMV]|[BATTTEMP]
2011/09/27|13:03:18|+0mA|92%|4101mV|31°C
2011/09/27|13:03:19|+0mA|92%|4101mV|31°C
2011/09/27|13:03:20|+0mA|92%|4101mV|31°C
2011/09/27|13:03:21|-83mA|92%|4018mV|32°C
2011/09/27|13:03:22|+0mA|92%|4018mV|32°C
2011/09/27|13:03:23|+0mA|92%|4018mV|32°C
2011/09/27|13:03:24|+0mA|92%|4018mV|32°C
2011/09/27|13:03:25|+0mA|92%|4018mV|32°C
2011/09/27|13:03:26|+0mA|92%|4018mV|32°C
2011/09/27|13:03:27|+0mA|92%|4018mV|32°C
2011/09/27|13:03:28|+0mA|92%|4018mV|32°C
2011/09/27|13:03:29|+0mA|92%|4018mV|32°C
2011/09/27|13:03:30|+45mA|92%|4063mV|32°C
Here's the script:
Code:
INTERVAL=1
CAPACITYVOLTAGE=0
while true; do
PREVVOLTAGE=$CAPACITYVOLTAGE
DATETIME=$(date +'%Y/%m/%d|%H:%M:%S')
CAPACITYVOLTAGE="$(( $(cat /sys/devices/platform/sec-battery/power_supply/battery/voltage_now) / 1000 ))"
CAPACITYPERCENT="$(cat /sys/devices/platform/sec-battery/power_supply/battery/capacity)"
DISCHARGE="+$(( $CAPACITYVOLTAGE - $PREVVOLTAGE ))"
TEMP="$(( $(cat /sys/devices/platform/sec-battery/power_supply/battery/batt_temp) / 10 ))"
echo "${DATETIME}|$(echo ${DISCHARGE}|sed -e 's/^+-/-/')mA|${CAPACITYPERCENT}%|${CAPACITYVOLTAGE}mV|${TEMP}°C"
sleep ${INTERVAL}
done
While a nice piece of work - this is not development. It is an App. Moving to the appropriate section.
jerdog said:
While a nice piece of work - this is not development. It is an App. Moving to the appropriate section.
Click to expand...
Click to collapse
Well, I was hoping to get some feedback and make some improvements before calling it an app, but that works.
xak944 said:
After seeing apps like Android Battery Monitor, I wanted something I could run in a shell (adb) that would give me similar statistics, namely the battery discharge rate. I couldn't find any such tools or scripts, so I wrote one. Hopefully it will be useful to someone else, too.
The file paths are hard coded, and will likely only work on the Samsung Epic 4G Touch, however it could probably be easily adapted to other devices as well. It also probably requires busybox, since it uses some basic shell programs.
The script will output statistics every second, like this:
Code:
[DATE]|[TIME]|[DISCHARGE]|[CHARGE%]|[CHARGEMV]|[BATTTEMP]
2011/09/27|13:03:18|+0mA|92%|4101mV|31°C
2011/09/27|13:03:19|+0mA|92%|4101mV|31°C
2011/09/27|13:03:20|+0mA|92%|4101mV|31°C
2011/09/27|13:03:21|-83mA|92%|4018mV|32°C
2011/09/27|13:03:22|+0mA|92%|4018mV|32°C
2011/09/27|13:03:23|+0mA|92%|4018mV|32°C
2011/09/27|13:03:24|+0mA|92%|4018mV|32°C
2011/09/27|13:03:25|+0mA|92%|4018mV|32°C
2011/09/27|13:03:26|+0mA|92%|4018mV|32°C
2011/09/27|13:03:27|+0mA|92%|4018mV|32°C
2011/09/27|13:03:28|+0mA|92%|4018mV|32°C
2011/09/27|13:03:29|+0mA|92%|4018mV|32°C
2011/09/27|13:03:30|+45mA|92%|4063mV|32°C
Here's the script:
Code:
INTERVAL=1
CAPACITYVOLTAGE=0
while true; do
PREVVOLTAGE=$CAPACITYVOLTAGE
DATETIME=$(date +'%Y/%m/%d|%H:%M:%S')
CAPACITYVOLTAGE="$(( $(cat /sys/devices/platform/sec-battery/power_supply/battery/voltage_now) / 1000 ))"
CAPACITYPERCENT="$(cat /sys/devices/platform/sec-battery/power_supply/battery/capacity)"
DISCHARGE="+$(( $CAPACITYVOLTAGE - $PREVVOLTAGE ))"
TEMP="$(( $(cat /sys/devices/platform/sec-battery/power_supply/battery/batt_temp) / 10 ))"
echo "${DATETIME}|$(echo ${DISCHARGE}|sed -e 's/^+-/-/')mA|${CAPACITYPERCENT}%|${CAPACITYVOLTAGE}mV|${TEMP}°C"
sleep ${INTERVAL}
done
Click to expand...
Click to collapse
1) How does one install the script?
2) How does one uninstall it?
3) How much does the script affect battery performance?
4) How stable is the script?
5) What makes this script better than other similar apps in the market?
>> 1) How does one install the script?
You don't. Just move it to an appropriate location on your phone via adb push command, change permissions to make executable & run it. It does not involve any formal installation/removal.
>> 3) How much does the script affect battery performance?
Neglible. even if you launched from a terminal emulator on-board your phone & not while it was connected via the USB to your computer
>> 4) How stable is the script?
Fairly since its quite simple. He is only reading those ascii files available on any typical linux based system & printing to console after some post-processing
Been interested in looking at what I can get my rooted device to do via Terminal/SSH, this is a great start Had to edit it a bit for my desire Z, however working a treat.. The script can lag a little if I use it via SSH with the screen off, however to be expected I suppose. A little Caffeine and it completely works as expected.
Code:
INTERVAL=1
CAPACITYVOLTAGE=0
while true; do
PREVVOLTAGE=$CAPACITYVOLTAGE
DATETIME=$(date +'%Y/%m/%d|%H:%M:%S')
CAPACITYVOLTAGE="$(cat /sys/devices/platform/rs30100001:00000000/power_supply/battery/batt_vol)"
CAPACITYPERCENT="$(cat /sys/devices/platform/rs30100001:00000000/power_supply/battery/capacity)"
DISCHARGE="+$(( $CAPACITYVOLTAGE - $PREVVOLTAGE ))"
TEMP="$(( $(cat /sys/devices/platform/rs30100001:00000000/power_supply/battery/batt_temp) / 10 ))"
echo "${DATETIME}|$(echo ${DISCHARGE}|sed -e 's/^+-/-/')mA|${CAPACITYPERCENT}%|${CAPACITYVOLTAGE}mV|${TEMP}°C"
sleep ${INTERVAL}
done
I'm off to try and create something similar for the GPS.. No idea how feasible as yet, but appreciate the inspiration.
Nice job on this script.
Very good work man keep it up
I had to edit it a bit for my Vibrant (Miui 9.23)
make file (I called mine "adb_batt.sh" placed it on my sdcard
I used Gscrip lite to run it (or terminal)
"sh ./mnt/sdcard/adb_batt.sh"
==================================
INTERVAL=1
CAPACITYVOLTAGE=0
while true; do
PREVVOLTAGE=$CAPACITYVOLTAGE
DATETIME=$(date +'%Y/%m/%d|%H:%M:%S')
CAPACITYVOLTAGE="$(( $(cat sys/devices/platform/i2c-gpio.6/i2c-6/6-0066/max8998-charger/power_supply/battery/voltage_now) / 1000 ))"
CAPACITYPERCENT="$(cat sys/devices/platform/i2c-gpio.6/i2c-6/6-0066/max8998-charger/power_supply/battery/capacity
)"
DISCHARGE="+$(( $CAPACITYVOLTAGE - $PREVVOLTAGE ))"
TEMP="$(( $(cat sys/devices/platform/i2c-gpio.6/i2c-6/6-0066/max8998-charger/power_supply/battery/batt_temp_check) / 10 ))"
echo "${DATETIME}|$(echo ${DISCHARGE}|sed -e 's/^+-/-/')mA|${CAPACITYPERCENT}%|${CAPACITYVOLTAGE}mV|${TEMP}°C"
sleep ${INTERVAL}
done
doesn't this do the same thing
https://market.android.com/details?id=ccc71.bmw&feature=search_result
BLOWNCO said:
doesn't this do the same thing
https://market.android.com/details?id=ccc71.bmw&feature=search_result
Click to expand...
Click to collapse
yes, but having a tweakable script version.
back on topic, trying to run the script but it complains
Code:
# sh logb
: not found
logb: 16: Syntax error: "done" unexpected (expecting "do")
frifox said:
yes, but having a tweakable script version.
back on topic, trying to run the script but it complains
Code:
# sh logb
: not found
logb: 16: Syntax error: "done" unexpected (expecting "do")
Click to expand...
Click to collapse
Sounds like you might've copied and pasted the script on a windows text editor, which uses DOS line endings. You need to convert them to unix line endings. If you use notepad++ to edit/save the file:
Edit > EOL Conversion > Unix Format
FBis251 said:
Sounds like you might've copied and pasted the script on a windows text editor, which uses DOS line endings. You need to convert them to unix line endings. If you use notepad++ to edit/save the file:
Edit > EOL Conversion > Unix Format
Click to expand...
Click to collapse
sh1t, i thought i made sure it pasted in unix format... oh well, redid it with notepad++ and that fixed it
I like the scripts and like to have a look into this on my xperia z1 compact. Has anybody has an idea, where I can find the batteryfolder on sony devices?

Metasploit console on ADB without chroot, working!

Well I've been working on getting the Kali Linux toolkit to run on Android without a chroot and I did it, just gotta mount all the subfiletree's or whatever to where they belong in Androids root dir ,"/" (NOT "/root") and set up the paths in the enviroment a it seems to be working.
I spent way more time researching and planning out exactly how I was going to exicute this, it still has some kinks as some of the filesystems clash or have files of the same name but with slightly moified content, I guess I gotta dig through all those and patch em up so it all flows together, I just ran on the presumtion that it was all compiled for arm and I think it all runs on the android kernel when you chroot into an img file. I basically just mounted the kali.img file and instead of chrooting into that I went backwords and moved everything into Androids root.
Im working on a script with sanity checks and error collection and all that, I am still learning bash, linux, kernel, android, all like a summer cram session so please forgive me if I dont know or it takes time to share something I think is even slightly worthy for ya'll.
Anyways for those interested here is a bit of the tail end of what all this research has become, I think metasploit uses ruby, so if msf is working I guess that is too... here it is
Code:
localhost etc # ls
CHANGELOG-CM.txt gps.conf ppp
CHANGES.txt hosts recovery-resource.dat
NOTICE.html.gz init.d security
apns-conf.xml init.goldfish.sh snd_soc_msm
audio_effects.conf init.qcom.efs.sync.sh ssh
audio_policy.conf init.qcom.mdm_links.sh system_fonts.xml
bash init.qcom.modem_links.sh terminfo
bluetooth init.qcom.post_boot.sh thermald-8064.conf
boot_fixup init.qcom.thermal_conf.sh thermald-8930.conf
build-manifest.xml media_codecs.xml thermald-8960.conf
dbus.conf media_profiles.xml thermald.conf
dhcpcd mkshrc vold.fstab
event-log-tags nano wifi
fallback_fonts.xml nfcee_access.xml
firmware permissions
localhost / # mount --rbind $subset/etc /etc
localhost / # which apt-get
/usr/bin/apt-get
localhost / # which mfsconsole
localhost / # which msfconsole
/usr/bin/msfconsole
localhost / # msfconsole
IIIIII dTb.dTb _.---._
II 4' v 'B .'"".'/|\`.""'.
II 6. .P : .' / | \ `. :
II 'T;. .;P' '.' / | \ `.'
II 'T; ;P' `. / | \ .'
IIIIII 'YvP' `-.__|__.-'
I love shells --egypt
Easy phishing: Set up email templates, landing pages and listeners
in Metasploit Pro's wizard -- type 'go_pro' to launch it now.
=[ metasploit v4.7.0-2013071701 [core:4.7 api:1.0]
+ -- --=[ 1131 exploits - 638 auxiliary - 180 post
+ -- --=[ 309 payloads - 30 encoders - 8 nops
stty: standard input: Bad file number
msf > exit
localhost / # ls
acct init.trace.rc
bin init.usb.rc
cache initlogo.rle
charger lib
config lpm.rc
d media
data mnt
default.prop opt
dev persist
efs proc
etc res
extSdCard root
firmware run
fstab.qcom sbin
init sdcard
init.cm.rc srv
init.goldfish.rc storage
init.qcom.class_core.sh sys
init.qcom.class_main.sh system
init.qcom.early_boot.sh tmp
init.qcom.lpm_boot.sh tombstones
init.qcom.rc ueventd.goldfish.rc
init.qcom.sh ueventd.qcom.rc
init.qcom.syspart_fixup.sh ueventd.rc
init.qcom.usb.rc usbdisk0
init.qcom.usb.sh usr
init.rc var
init.recovery.qcom.rc vendor
init.target.rc
localhost / # exit
exit
[email protected]:/ #
EDIT: Please note that to get this working I had to "su -c bash" so that some of the mount commands would work properly, this is why is says "localhost / #" and not "[email protected]:/ #", its bash and thats the same interpreter the normal chroot throws you into. This is bash from Androids / directory.
My kind of thinker. I'll have to look into this!
Sent from my SPH-L710 using xda app-developers app
Haven't gotten time to try out your mod yet but thought I'd let you know I did get Kali Linux installed on my GS3 and metasploit runs relatively well ssh'ing through terminal!
Sent from my SPH-L710 using xda app-developers app

Categories

Resources