[KERNEL] 1497MHz Permanent overclock kernel with intermediate speeds! - G2 and Desire Z Android Development

Now that we have permanent root, we can have even more fun with overclocking. This is an actual kernel, not a module, meaning that there are no scripts to run every time you restart the device, and there are a lot more speeds to choose from, from 806MHz all the way up to 1497MHz.
Just run SetCPU (set on boot will work if you have permanent root!) and set the speed to whatever you want. This is purely an overclocking kernel and is not undervolted, but undervolting is easy for other devs. Just tweak the frequency tables and recompile.
We can now properly changes voltages! With voltage increases, it is possible to push the G2 to absolutely ludicrous speeds. I've limited this kernel to 1497MHz, but I've seen speeds as high as 1.7GHz (!!!) at 1400mV. It scales remarkably in most benchmarks, too. The MSM7x30 chipset is a true overclocking champion.
For safety, this kernel defaults to 806MHz at boot (like overclocking kernels on most other devices). Use SetCPU (in my sig or on the Market) to tweak speeds precisely. (Devs: the max frequency on boot can also be adjusted in the modified cpufreq.c file).
I am not responsible for any damage these instructions or this software may cause!
Installation
I recommend flashing Cyanogen's BaconBits which contains this, more CPU governors, a newer kernel, no wifi bug, and other goodies: http://forum.xda-developers.com/showthread.php?t=834565. The binaries below are not necessary if you flash BaconBits. You'll get the overclock anyway!
Github: https://github.com/coolbho3k/vision_oc_kernel
Binaries: http://pokedev.com/setcpu/vision_oc_kernel_2.zip
Mirror: http://dl.dropbox.com/u/36553/vision_oc_kernel_2.zip
If you want to install using the old method and the binaries I posted above:
Boot into fastboot. Using the fastboot utility, run:
fastboot flash zimage zImage
Where "zImage" is the path to the zImage posted in the zip above.
You'll notice at first that your wifi doesn't work. Don't worry! In Android:
adb push bcm4329.ko /sdcard/bcm4329.ko
adb shell
su
mount -o remount,rw /dev/block/mmcblk0p25 /system
cat /sdcard/bcm4329.ko > /system/lib/modules/bcm4329.ko
EDIT: argh, I keep forgetting our ro.secure is still 1. Fixed the instructions.
Where "bcm4329.ko" is the path to the wifi module posted in the zip above. Then reboot and enjoy.
Have fun guys. This was a lot less of a pain to make than the module and I only had to actually write like three lines of code.
Developers: customizing the overclocked speeds and voltages
Just add lines to the struct acpu_freq_tbl. There are no L values to worry about unlike the 8x50 platform (this time, we automatically detect the required L value), but remember that each speed must be a multiple of 19200. The only thing you need to worry about is the voltage and the VDD_RAW:
Code:
...
{ 1017600, PLL_2, 3, 0, 192000, 1200, VDD_RAW(1200) },
{ 1113600, PLL_2, 3, 0, 192000, 1200, VDD_RAW(1200) },
{ 1209600, PLL_2, 3, 0, 192000, 1200, VDD_RAW(1200) },
{ 1305600, PLL_2, 3, 0, 192000, 1200, VDD_RAW(1200) },
{ 1401600, PLL_2, 3, 0, 192000, 1300, VDD_RAW(1300) },
{ 1497600, PLL_2, 3, 0, 192000, 1300, VDD_RAW(1300) },
...
For a lower voltage, in this case 1100mV, at 1017.6MHz:
Code:
{ 1017600, PLL_2, 3, 0, 192000, 1100, VDD_RAW(1100) },
For 1.7GHz @1400mV (warning: only tested once, and the phone got very hot. I would not recommend this ) edit: actually, 1350mV is the max you can go, I don't know what I was thinking, but this works anyway:
Code:
{ 1708800, PLL_2, 3, 0, 192000, 1400, VDD_RAW(1400) },
Then add the speeds you actually want to use to the freq_table struct, remembering to keep incrementing the first column as you go down.
Code:
...
{ 4, 1017600 },
{ 5, 1113600 },
{ 6, 1209600 },
{ 7, 1305600 },
{ 8, 1401600 },
{ 9, 1497600 },
...
How it works
The G2's CPU speeds are based on the clock output of one of several PLLs. In the default MSM7x30 configuration, the 806.4MHz speed is based on PLL2, which also runs at 806.4MHz by default. (the MSM8x55 is an identical SoC, but runs PLL2 at 1017.6MHz. There is also a 1.2GHz version of the 8x55 floating around somewhere! The stock kernel for the 8x55 reports 1024MHz as the speed, but I think this is off by a few MHz).
So to overclock, we have to change the output of PLL2. The output of PLL2 is based on the speed of TCXO, which runs at 19.2MHz. The output of PLL2 is defined as 19.2 multiplied by an integer at the address MSM_CLK_CTL_BASE + 0x33c, called the L value. By manipulating this multiplier, we can also safely manipulate the output of PLL2, and as a result, safely manipulate the CPU speed when cpufreq switches us to a speed that uses PLL2. I was able to figure out the location of the PLL2 L value using this commit on Code Aurora. Turns out the address is the same as it is on the MSM7200 platform!
My previous kernel module hack that we used did this kind of inelegantly. It wrote a new multiplier to PLL2 and basically corrected cpufreq so that it (correctly) thought that this speed was no longer 806.4MHz. It required the addresses of several data structures in the kernel because it needed to know where to manipulate cpufreq. However, since our module could only change PLL2 once and not every time there is a frequency switch, we could only have one overclocked speed. If we overclocked to 1.42GHz, we lost 806.4MHz and everything in between.
The ability to flash kernels, however, makes our lives a lot easier. Without the need to hack kernel memory to get it to do what we want, overclocking practically requires only four lines of code:
From there, changes to the frequency table to define speeds/voltages is rather trivial.
Code:
#define PLL2_L_VAL_ADDR (MSM_CLK_CTL_BASE + 0x33)
...
/* Program PLL2 L val for overclocked speeds. */
if(s->src == PLL_2) {
writel(s->acpu_clk_khz/19200, PLL2_L_VAL_ADDR);
}
The above runs during frequency switching. It basically checks if the speed we're switching to runs on PLL2, and if it does, we write the value equal to (clock speed we want)/19200 to the L value address. A much simpler solution, and much more flexible, than the kernel module method. Thank god for permaroot (or just scotty and #g2root)

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

Excuse a NOOB - but how do you boot into fastboot? Is that Volume Down + Power Button?
EDIT:
Nevermind I got it, but when I do "adb push bcm4329.ko /system/lib/modules/bcm4329.ko" I get the following:
failed to copy 'bcm4329.ko' to '/system/lib/modules/bcm4329.ko': Permission denied
However I am fully rooted, any ideas?

thanks for the post.

TL24 said:
Nevermind I got it, but when I do "adb push bcm4329.ko /system/lib/modules/bcm4329.ko" I get the following:
failed to copy 'bcm4329.ko' to '/system/lib/modules/bcm4329.ko': Permission denied
However I am fully rooted, any ideas?
Click to expand...
Click to collapse
i get read-only file system. i tried to chmod the modules folder but i get the same error.

Ah oops, you'll have to remount system as rw first. Adding to topic.

coolbho3000 said:
Ah oops, you'll have to remount system as rw first. Adding to topic.
Click to expand...
Click to collapse
Is that while we're still in fastboot?

Works great, thanks!
fastboot just for the zImage
adb push or Root Explorer or Terminal Emulator to cp the wifi file.
I used terminal emulator...
Code:
su
mount -o remount,rw /dev/block/mmcblk0p25 /system
cp /sdcard/bcm4329.ko /system/lib/modules/bcm4329.ko
mount -o remount,ro /dev/block/mmcblk0p25 /system
WiFi is working fine now...

TL24 said:
Is that while we're stillin fastboot?
Click to expand...
Click to collapse
I can't get mount to work in adb

Heh, whoops, did I get the system mount command wrong? Fixed it.

Thanks for the work. Worked for me hear.

Works great. Thanks a lot. My G2 just increased in resale value lol.

how does the OC affect battery life?

score. i got it. thanks. i did the mount command via adb shell, copied the module to the sdcard and did cp /sdcard/bcm4329.k0 /system/lib/modules in terminal on the phone. all is well now.

How do you get into fast boot?

Fixed the instructions for pushing the wifi module, hopefully...

k0mpresd said:
score. i got it. thanks. i did the mount command via adb shell, copied the module to the sdcard and did cp /sdcard/bcm4329.k0 /system/lib/modules in terminal on the phone. all is well now.
Click to expand...
Click to collapse
That still doesn't work for me wtf!?
If I do:
adb push bcm4329.ko /sdcard/bcm4329.ko
adb shell
su
mount -o remount,rw /dev/block/mmcblk0p25 /system
cp /sdcard/bcm4329.ko /system/lib/modules
I get:
cp: not found
So to get around this, I adb pushed the bcm4329.ko into the sdcard and from there - moved it into the system/lib/modules using Root Explorer.
Will that work?

We don't have the 'cp' command by default.
I used 'cat /sdcard/bcm4329.ko > /system/lib/modules/bcm4329.ko' instead.
Worked for me...

Posted a version 2 with fixes for mistakes I made in the frequency table. This one should work well. You don't have to reflash the wifi module.
seancneal said:
We don't have the 'cp' command by default.
I used 'cat /sdcard/bcm4329.ko > /system/lib/modules' instead.
Worked for me...
Click to expand...
Click to collapse
Right, depending if you used visionary or not you might not have busybox. Going to update the instructions, thanks.

When I try:
cat /sdcard/bcm4329.ko > /system/lib/modules
I get:
cannot create /system/lib/modules: is a directory

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

[Tweak] Boost RAM Management - get more free RAM! // [23.03.2011] Fixed Permissions.

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

[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?

Can I calibrate the accelerometer? Camera horizon level is not indicated correctly.

Hello,
I tried some camera apps (Cameringo+, aillis, and ProShot) which had a horizontal level indicator, but all the indicators did not indicate the true horizontal level. It seems that the built-in accelerometer is wrong. Is there any method to calibrate the wrong sensor?
Thanks,
*push*
I have the same problem. I can't play racing games or use cardboard apps. Can anyone help?
best regards
I have the same problem.
More precisely, when I run the "GPS Status & Toolbox" app and the device is stationery, I get a non-zero rotation vector.
GPS Status shows a 3 degrees/second rotation, even when the device is still.
Since it's a brand new unit, I'm likely to return it to Goog.
I have the same problem, but don't know any solution. Seems it's a common problem.
After further investigations, it seems like there is some calibration data that's not being read when the device boots.
If anyone has the same problem and has root, can you:
Post the contents of:
Code:
/persist/sensorcal.json
Code:
/data/misc/sensorcal_saved.json
Then turn off SELinux or patch the SELinux policy (SuperSU required) by either running:
Code:
setenforce 0
OR
Code:
supolicy --live 'allow sensortool devpts chr_file { read write getattr }' 'allow sensortool persist_sensortool_file file { write }'
Then run:
Code:
/vendor/bin/sensortool.bullhead -c gyro
while the phone is still. This will overwrite
Code:
/persist/sensorcal.json
.
And finally post the contents of
Code:
/persist/sensorcal.json
after this modification.
Your gyro should now be functioning correctly until the next reboot.
It looks like Nexus 5X "forgets" to read the calibration data upon boot.
The above procedure will force a recalibration and forces the sensor hub to use the new calibration data.
I'm looking at a way to load the calibration data into the sensor hub without having to recalibrate, but this may need some serious hacking.
Fif_ said:
After further investigations, it seems like there is some calibration data that's not being read when the device boots.
If anyone has the same problem and has root, can you:
Post the contents of:
Code:
/persist/sensorcal.json
Code:
/data/misc/sensorcal_saved.json
Then turn off SELinux or patch the SELinux policy (SuperSU required) by either running:
Code:
setenforce 0
OR
Code:
supolicy --live 'allow sensortool devpts chr_file { read write getattr }' 'allow sensortool persist_sensortool_file file { write }'
Then run:
Code:
/vendor/bin/sensortool.bullhead -c gyro
while the phone is still. This will overwrite
Code:
/persist/sensorcal.json
.
And finally post the contents of
Code:
/persist/sensorcal.json
after this modification.
Your gyro should now be functioning correctly until the next reboot.
It looks like Nexus 5X "forgets" to read the calibration data upon boot.
The above procedure will force a recalibration and forces the sensor hub to use the new calibration data.
I'm looking at a way to load the calibration data into the sensor hub without having to recalibrate, but this may need some serious hacking.
Click to expand...
Click to collapse
Thanks for your post. Inspired by what you said, I found the other guys and myself are having an miscalibrated accelerate sensor. And it's a little bit difficult to calibrate this sensor than the gyro, since a flat table is needed and the back of 5x is not flat (due to the camera).
P.S. can you post the undo command of this?
Code:
supolicy --live 'allow sensortool devpts chr_file { read write getattr }' 'allow sensortool persist_sensortool_file file { write }'
yaoppp said:
Thanks for your post. Inspired by what you said, I found the other guys and myself are having an miscalibrated accelerate sensor. And it's a little bit difficult to calibrate this sensor than the gyro, since a flat table is needed and the back of 5x is not flat (due to the camera).
Click to expand...
Click to collapse
Great to be able to help.
I found it easy to calibrate the accelerometer: just raise the middle and bottom section of the phone over a book. The camera parts can be dangling.
I have since made more discoveries and was able to calibrate the device correctly and have the calibration persist on reboot.
My sensors problems are now gone!
Instructions follow below.
yaoppp said:
P.S. can you post the undo command of this?
Code:
supolicy --live 'allow sensortool devpts chr_file { read write getattr }' 'allow sensortool persist_sensortool_file file { write }'
Click to expand...
Click to collapse
Just reboot. These changes are in memory only.
If you actually want to undo the policy changes without rebooting, run as root:
Code:
supolicy --live 'deny sensortool devpts chr_file { read write getattr }' 'deny sensortool persist_sensortool_file file { write }'
---------- Post added at 04:30 PM ---------- Previous post was at 03:47 PM ----------
After struggling with this for a while, here's the latest update about what I found.
Contrarily about what I wrote earlier on, the Nexus 5X does read the calibration data in /persist/sensorcal.json at boot.
What happens is the calibration procedure (as initiated by /vendor/bin/sensortool.bullhead -c <sensor>) correctly calibrates the sensor, updates the sensor with the new calibration data, then writes the calibration file /persist/sensorcal.json wrong.
That's why running /vendor/bin/sensortool.bullhead -c <sensor> fixes the problem until the next reboot.
So the fix is to edit by hand the /persist/sensorcal.json file, trying to tweak the calibration values, reboot, check the sensor and do that a few times until you have no sensor bias.
Well, you can do it this way (rebooting between every change to /persist/sensorcal.json), or you can look at the next post for an alternate method that does not involve rebooting twenty times.
WARNING: If you make a typo editing /persist/sensorcal.json, like adding a comma where it's not needed or removing one where it's needed, your device will not boot. You will have to get into recovery and fix the file there. What's even worse, a factory reset will not fix a busted /persist/sensorcal.json as /persist is not wiped during factory reset.
DO THIS AT YOUR OWN RISK
Before you make any change to /persist/sensorcal.json:
Make a backup of the file
Make sure you know how to restore that backup from recovery, without Android booting.
Again: a mess up will softbrick your phone.
My particular case:
My gyrometer readings were off. When the device was still, a simple app to report the gyro reading was returning a non-zero value. The device was thinking it was rotating around only one axis.
Needless to say all apps that used the gyro (eg. driving games) were not happy about this.
My original /persist/sensorcal.json file looked like this:
Code:
{
"accel": [
22,
-2,
-8
],
"gyro": [
22,
-9,
-9
],
"proximity": 1
}
}
I started changing the numbers in the gyro section. After changing the "22" to "100" and rebooting, I saw that my original faulty axis was still wrong, but also another axis was now busted.
So I reverted that change, moved on the next number.
Finally I found that the third figure was the one that was corresponding to my busted axis.
I managed to tweak that number until my gyro was reporting no motion at rest.
And now my Nexus 5X's sensors are just fine, and I can play driving games
My final /persist/sensorcal.json looks like this:
Code:
{
"accel": [
22,
-2,
-8
],
"gyro": [
22,
-9,
-73
],
"proximity": 1
}
}
Since the problem is likely to be memory corruption in /vendor/bin/sensortool.bullhead, on your device, a different calibration value may be affected.
If you want to "factory recalibrate the device" (and re-break your sensors), just follow the instructions in post #5.
Rereading /persist/sensorcal.json without rebooting
The method therein allows you to edit /persist/sensorcal.json then have the on-board sensor re-read that file without having to reboot.
Requirements:
A Nexus 5X device (duh)
Busybox installed
Supersu installed
The attached bullhead-reread-sensor-calibration.zip file.
A root shell (either via ADB or with a Terminal app + su)
Instructions:
Unzip bullhead-reread-sensor-calibration.zip under /sdcard. This will create two new files:
bullhead-reread-sensor-calibration
sensortool-writewrap.so
After every change to /persist/sensorcal.json, run in your root shell:
Code:
sh /sdcard/bullhead-reread-sensor-calibration
. You should see:
Code:
supolicy v2.74 (ndk:arm64-v8a) - Copyright (C) 2014-2016 - Chainfire
Patching policy ...
(Android M policy compatibility mode)
-allow:sensortool:devpts:chr_file:read=ok
-allow:sensortool:devpts:chr_file:write=ok
-allow:sensortool:devpts:chr_file:getattr=ok
- Success
resetting target.
sensorhub said: 'Hello, world!'
sensorhub said: 'Found Bosch BMP280 Pressure/Temperature Sensor'
sensorhub said: 'Found Rohm RPR-0521 Proximity/ALS Sensor'
sensorhub said: 'Found Bosch BMI160 Accel/Gyro Sensor'
sensorhub said: 'init: 22 -2 -8, 22 -9 -73, 0.00, 1'
The numbers on the last line will be different for your device.
Your sensor hub's calibration data has been updated. Note that if you had an app actively reading from the sensors, since they were reset, you will need to quit the app and restart it.
Further notes:
The above script makes no permanent changes to your system (but temporarily alters your SELinux policy, a reboot will reset the policy to its secure default).
The script uses an interposition shared library (sensortool-writewrap.so) that was compiled with the Android NDK from the C file source attached. If you're just using this tool, there is no need to download the C file.
Good guide on how to calibrate your sensors manually.
This should help calibrating your sensor manually if you use the method above:
https://docs.google.com/document/d/14uwBu0R7Yv6bwl5Y7CE1vpFWetnSzgs-zt0GwOaDwIg/edit?pref=2&pli=1
If you don't want to go through the Excel route and exporting the data from the phone, the app "Sensor Kinetics Pro" has a low-pass filter option for all sensors.
You can check that your sensor readouts are as close as possible to zero after tweaking /persist/sensorcal.json as explained in the previous posts.
Fif_ said:
The method therein allows you to edit /persist/sensorcal.json then have the on-board sensor re-read that file without having to reboot.
Click to expand...
Click to collapse
Just wanted to thank you for all these instructions. My accelerometer was 5 degrees off in landscape and while the calibration tool did manage to calibrate it correctly (these settings also stuck for me after reboot), it also calibrated the upright position off by 2 degrees. Some quick manual editing thanks to your method and I now have everything calibrated correctly. It was impossible to take a panorama in landscape before this, so I owe you a really big thank you!
CazeW said:
Just wanted to thank you for all these instructions. My accelerometer was 5 degrees off in landscape and while the calibration tool did manage to calibrate it correctly (these settings also stuck for me after reboot), it also calibrated the upright position off by 2 degrees. Some quick manual editing thanks to your method and I now have everything calibrated correctly. It was impossible to take a panorama in landscape before this, so I owe you a really big thank you!
Click to expand...
Click to collapse
Happy it was useful to someone.
I would have thought the problem was more widespread.
Ok, I probably know the answer, but is there any chance to calibrate it without root permissions? Even if it resets after reboot. I have brand new phone without any scratches, I don't want to loose warranty and change it to a perfect shiny brick (at least not yet). I know my luck, it's gonna be just like that.
I've tried to force Google to admit, that this problem affects every (or almost every) single one Nexus 5X and they should at least add calibration option, because sending phone to the service takes time and isn't the best option. They gave me a standard answer to contact the service :good:
productforums.google.com/forum/?utm_medium=email&utm_source=footer#!topic/nexus/2Xkk3X4KvYQ;context-place=forum/nexus (I can't add link as link, I'm not a trusted user )
Yes, root is required.
However, you can unlock the bootloader, root, follow the instructions and calibrate, and then reimage the device and relock the bootloader.
You'll then have a calibrated stock device, which should be covered by the warranty.
Can You tell me which values did You edited? I have 5 degrees off in landscape too and just can't get right value. I think I actually has problem with accel sensor, not with gyroscope.
P.S. Seems like in Android 7.0 there is no /vendor/bin/sensortool.bullhead .
Instead in init.bullhead.sensorhub.rc I found it uses /system/bin/nanoapp_cmd which have little different format like
/system/bin/nanoapp_cmd calibrate gyro
Click to expand...
Click to collapse
But it actually throws me an "Failed to open /dev/nanohub: err=13 [Permission denied]" error, even after I called both
supolicy --live 'allow sensortool devpts chr_file { read write getattr }' 'allow sensortool persist_sensortool_file file { write }
supolicy --live 'allow nanoapp_cmd devpts chr_file { read write getattr }' 'allow nanoapp_cmd persist_sensortool_file file { write }
Click to expand...
Click to collapse
Any ideas? Anyone tried that hack on Android 7.0 stock?
I've just changed values in /persist/sensorcal.json. My tilt was almost 6 degrees and I knew that the y-axis is bad.
My origin values:
Code:
{
"accel": [
21,
-21,
-8
],
"gyro": [
-1,
-9,
-10
],
"proximity": 9
}
I've changed -21 to -31, then reboot and then i had almost 8 degrees error so it was a bad direction. I've changed it to 0 and now it is perfect.
Now my sensorcal.json loks like this:
Code:
{
"accel": [
21,
0,
-8
],
"gyro": [
-1,
-9,
-10
],
"proximity": 9
}
I'm on the stock rom again and it still works.
@Fif_ I have no words to tell you how awesome you are. THANKS!
Denfox said:
Can You tell me which values did You edited? I have 5 degrees off in landscape too and just can't get right value. I think I actually has problem with accel sensor, not with gyroscope.
P.S. Seems like in Android 7.0 there is no /vendor/bin/sensortool.bullhead .
Instead in init.bullhead.sensorhub.rc I found it uses /system/bin/nanoapp_cmd which have little different format like
But it actually throws me an "Failed to open /dev/nanohub: err=13 [Permission denied]" error, even after I called both
Any ideas? Anyone tried that hack on Android 7.0 stock?
Click to expand...
Click to collapse
Just try to disable SELinux entirely with:
Code:
setenforce 0
and then run nanoapp_cmd.
Fif_ said:
Just try to disable SELinux entirely with:
Code:
setenforce 0
and then run nanoapp_cmd.
Click to expand...
Click to collapse
This not works for me unfortunately.
But actually I did calibration by doing values bust.
As a result to compensate 5 degrees at the Y axis I've changed the value in the calibration json on 25 units.
Thanks for a solution! :good:
Hi, thanks, this worked great.
It was tilted almost 7°
As a note I have to modify "accel" section, not "gyro".
Code:
{
"accel": [
27,
-8,
-4
],
"gyro": [
5,
7,
-10
],
"proximity": 8
}
Main post should be as permanent is 5x section
JP
Hi guys, I have the same problem but only in landscape mode. For example if i take a pano in portrait the image is aligned well, while if i try to do it on landscape it's inclined on the right. Which value i have to change in that file?
giorgis91 said:
Hi guys, I have the same problem but only in landscape mode. For example if i take a pano in portrait the image is aligned well, while if i try to do it on landscape it's inclined on the right. Which value i have to change in that file?
Click to expand...
Click to collapse
Some people had to change the gyro section, others the accel section.
Please read the entire thread, make a backup of sensorcal.json, then try to run sensortool/nanoapp_cmd, see if that helps.

Question [How-to] Enable Call Recording on Pixel 6 Pro [Root needed]

Install: https://play.google.com/store/apps/details?id=com.termux
Then open Termux
Type:
apt update; apt install sqlite
SU
Then type:
/data/data/com.termux/files/usr/bin/sqlite3 /data/user/0/com.google.android.gms/databases/phenotype.db
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__enable_call_recording", 0, 1, 0)
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__force_within_call_recording_geofence_value", 0, 1, 0)
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__use_call_recording_geofence_overrides", 0, 1, 0)
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__force_within_crosby_geofence_value", 0, 1, 0)
Next:
Clear dialer data
Open dialer and force close (clear from recent apps)
Open the dialer once again and in settings screen, you should see: "call recording"
Optional:
Depending on your location, you might get a pre-recording prompt notifying you (and the other party on the line) that the call may be recorded. This can be disabled by unzipping the attached file and copying the files to: /data/data/com.google.android.dialer/files/callrecordingprompt
Then in termux, run the following command
SU (unless your initial Termux session is still running)
chmod -R 777 /data/data/com.google.android.dialer/files/callrecordingprompt
Please note that disabling this prompt may be illegal depending on your jurisdiction. Some places however only require single party consent. Hence, why I posted this. You are responsible to know the laws of your jurisdiction. I will not be held liable for you breaking the law.
Major props to this thread: https://forum.xda-developers.com/t/...ding-in-stock-dialer-app-root-needed.4321719/
And @gisthere and @Liranazuz5
The above is a modification from their work on that thread. Most notability the removal of some ";" in the code that caused database errors and the combination of 2 different posts (flag implementation + app w/ database flags sync).
Intention of this thread: bring this information to Pixel 6 Pro owners. Please go and like the original thread/user posts (instead of this thread).
mkhcb said:
Install: https://play.google.com/store/apps/details?id=com.termux
Then open Termux
Type:
apt update; apt install sqlite
SU
Then type:
/data/data/com.termux/files/usr/bin/sqlite3 /data/user/0/com.google.android.gms/databases/phenotype.db
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__enable_call_recording", 0, 1, 0)
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__force_within_call_recording_geofence_value", 0, 1, 0)
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__use_call_recording_geofence_overrides", 0, 1, 0)
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__force_within_crosby_geofence_value", 0, 1, 0)
Next:
Clear dialer data
Open dialer and force close (clear from recent apps)
Open the dialer once again and in settings screen, you should see: "call recording"
Major props to this thread: https://forum.xda-developers.com/t/...ding-in-stock-dialer-app-root-needed.4321719/
And @gisthere and @Liranazuz5
The above is a modification from their work on that thread. Most notability the removal of some ";" in the code that caused database errors and the combination of 2 different posts (flag implementation + app w/ database flags sync).
Intention of this thread: bring this information to Pixel 6 Pro owners. Please go and like the original thread/user posts (instead of this thread).
Click to expand...
Click to collapse
Good info. For those of us that are too lazy to go through those steps, there is also a tiny app available to enable call recording as well (rooted devices only). Just install, enable from the app, and after 15 minutes or so you should see the call recording button/option. Been using on my device for a bit now and no issues. There are also a ton of flags available you can experiment with, just use caution in doing so. I am not the dev and no credit goes to me. Just sharing the devs (jacopotediosi) work:
Releases · jacopotediosi/GAppsMod
Tweak Google apps (e.g., Phone and Messages) to unlock hidden features (e.g., available only in some countries or on certain devices). Root is required. - jacopotediosi/GAppsMod
github.com
scott.hart.bti said:
Good info. For those of us that are too lazy to go through those steps, there is also a tiny app available to enable call recording as well (rooted devices only). Just install, enable from the app, and after 15 minutes or so you should see the call recording button/option. Been using on my device for a bit now and no issues. There are also a ton of flags available you can experiment with, just use caution in doing so. I am not the dev and no credit goes to me. Just sharing the devs (jacopotediosi) work:
Releases · jacopotediosi/GAppsMod
Tweak Google apps (e.g., Phone and Messages) to unlock hidden features (e.g., available only in some countries or on certain devices). Root is required. - jacopotediosi/GAppsMod
github.com
Click to expand...
Click to collapse
Nice find!
mkhcb said:
Install: https://play.google.com/store/apps/details?id=com.termux
Then open Termux
Type:
apt update; apt install sqlite
SU
Then type:
/data/data/com.termux/files/usr/bin/sqlite3 /data/user/0/com.google.android.gms/databases/phenotype.db
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__enable_call_recording", 0, 1, 0)
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__force_within_call_recording_geofence_value", 0, 1, 0)
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__use_call_recording_geofence_overrides", 0, 1, 0)
INSERT INTO FlagOverrides(packageName, user, name, flagType, boolVal, committed) VALUES("com.google.android.dialer", "", "G__force_within_crosby_geofence_value", 0, 1, 0)
Next:
Clear dialer data
Open dialer and force close (clear from recent apps)
Open the dialer once again and in settings screen, you should see: "call recording"
Major props to this thread: https://forum.xda-developers.com/t/...ding-in-stock-dialer-app-root-needed.4321719/
And @gisthere and @Liranazuz5
The above is a modification from their work on that thread. Most notability the removal of some ";" in the code that caused database errors and the combination of 2 different posts (flag implementation + app w/ database flags sync).
Intention of this thread: bring this information to Pixel 6 Pro owners. Please go and like the original thread/user posts (instead of this thread).
Click to expand...
Click to collapse
Hi buddy,
All credit for these call recording values goes to @gisthere !
But yeah, i'm still using that method on the P6Pro.
Just a note, in some regions there is a stupid voice message whenever you start recording. So, in order to eliminate that just replace these two files in /data/data/com.google.android.dialer/files/callrecordingprompt with the files inside that that zip file attached. Rename the unzipped files accordingly .
Liranazuz5 said:
Hi buddy,
All credit for these call recording values goes to @gisthere !
But yeah, i'm still using that method on the P6Pro.
Just a note, in some regions there is a stupid voice message whenever you start recording. So, in order to eliminate that just replace these two files in /data/data/com.google.android.dialer/files/callrecordingprompt with the files inside that that zip file attached. Rename the unzipped files accordingly .
Click to expand...
Click to collapse
So I replaced the files and now it says "Recording Failed" when I replaced the files. What permissions are your files? Any tips?
Edit: seems like the files above are corrupt and hence why I can't get it to work.
Edit 2: It appears that the file owner, which I can't seem to reproduce, has to be exactly the same as the original file.
Edit 3: chmod -R 777 /data/data/com.google.android.dialer/files/callrecordingprompt seems to have fixed the issue.
Can we uninstall sqlite after the changes are done?
@mkhcb "Edit 3: chmod -R 777 /data/data/com.google.android.dialer/files/callrecordingprompt seems to have fixed the issue." -> This with the corrupt files or the original files?
mkhcb said:
So I replaced the files and now it says "Recording Failed" when I replaced the files. What permissions are your files? Any tips?
Edit: seems like the files above are corrupt and hence why I can't get it to work.
Edit 2: It appears that the file owner, which I can't seem to reproduce, has to be exactly the same as the original file.
Edit 3: chmod -R 777 /data/data/com.google.android.dialer/files/callrecordingprompt seems to have fixed the issue.
Click to expand...
Click to collapse
I should've mentioned that smh, sorry buddy, it was late..
WhoIsJohnGalt1979 said:
@mkhcb "Edit 3: chmod -R 777 /data/data/com.google.android.dialer/files/callrecordingprompt seems to have fixed the issue." -> This with the corrupt files or the original files?
Click to expand...
Click to collapse
The files are not corrupt, I thought they were since I couldn't open it with VLC. Even if it is corrupt, it works with the right permission .
These are just an "empty" wav files, that's all .
Liranazuz5 said:
These are just an "empty" wav files, that's all .
Click to expand...
Click to collapse
I figured based on the size. I thought it would at least be 1 second of nothing sounds, but nope.
mkhcb said:
I figured based on the size. I thought it would at least be 1 second of nothing sounds, but nope.
Click to expand...
Click to collapse
Yeah lol, 00:00 seconds recording.
Great job on that guide, nicely done Sir!
scott.hart.bti said:
Good info. For those of us that are too lazy to go through those steps, there is also a tiny app available to enable call recording as well (rooted devices only). Just install, enable from the app, and after 15 minutes or so you should see the call recording button/option. Been using on my device for a bit now and no issues. There are also a ton of flags available you can experiment with, just use caution in doing so. I am not the dev and no credit goes to me. Just sharing the devs (jacopotediosi) work:
Releases · jacopotediosi/GAppsMod
Tweak Google apps (e.g., Phone and Messages) to unlock hidden features (e.g., available only in some countries or on certain devices). Root is required. - jacopotediosi/GAppsMod
github.com
Click to expand...
Click to collapse
This module worked very well on my pixel 6 for almost 7 months. now, suddenly the phone starts to prmopt"not support in your region"
How it woks for you now?
Chmod is a linux or terminal command. Will it work if we just change the permissions in a root explorer on the phone?
Spookymyo said:
Chmod is a linux or terminal command. Will it work if we just change the permissions in a root explorer on the phone?
Click to expand...
Click to collapse
Yes
Edit: Darn sorry for the bump. I got a notification and thought this was a new question. Then I realized the notification was a like, not a reply to my thread.
I purchased the full version of 'call recorder' by skvalex. Pricy, but just works.
fil3s said:
I purchased the full version of 'call recorder' by skvalex. Pricy, but just works.
Click to expand...
Click to collapse
I can confirm it is working without any problems. Thanks for the heads up!

Categories

Resources