[Samsung Galaxy W I8150] Christopher83:
Special features and sysfs settings (Part 1):

Here you can find some useful scripts that can be used with the following described features:

Scripts​

CPU voltage control VDD sys interface

This feature allows to customize the voltage assumed by each cpu scaling frequency.

It could be useful if you'd like to decrease one or more voltages for battery saving purposes (undervolting), or to increase/adjust them to prevent phone freezes (overvolting).

How to customize the voltages:

1) By downloading and using Trickster MOD or IncrediControl and changing the voltages table inside the SVS tab

2) By using customized init.d scripts (the custom values will be always restored after a reboot, if you don't format the system partition)

- Download one of the script named 01vdd_levels*

- If the file has been saved with .txt extension (stock browser), rename it by removing the .txt extension

- Edit the file by setting your customized voltages, where each line has this syntax

echo "[I][B][COLOR="Blue"]cpu_freq_HZ[/COLOR][/B][/I] [I][COLOR="SeaGreen"][B]mV[/B][/COLOR][/I]" > /sys/devices/system/cpu/cpu0/cpufreq/vdd_levels

cpu_freq_HZ is the cpu frequency in Hz you'd like to change

mV is the voltage you want to set

For example, the following line means that when the cpu frequency is 1516800 Hz = 1516 MHz, the voltage used will be 1175 mV

echo "1516800 1175" > /sys/devices/system/cpu/cpu0/cpufreq/vdd_levels

- Copy the new file inside /etc/init.d

- Give the rwxr-xr-x permissions to the file (read, write, execution for owner, read and execution for group users, read and execution for others)

- Reboot

3) By using Terminal Emulator (note that the values you set will be lost after a reboot/shutdown)

- Open Terminal Emulator

- Run these commands

su
# Run a command for each cpu frequency voltage you'd like to change
echo "[I][B][COLOR="Blue"]cpu_freq_HZ[/COLOR][/B][/I] [I][COLOR="SeaGreen"][B]mV[/B][/COLOR][/I]" > /sys/devices/system/cpu/cpu0/cpufreq/vdd_levels

cpu_freq_HZ is the cpu frequency in Hz you'd like to change

mV is the voltage you want to set

For example, the following line means that when the cpu frequency is 1516800 Hz = 1516 MHz, the voltage used will be 1175 mV

echo "1516800 1175" > /sys/devices/system/cpu/cpu0/cpufreq/vdd_levels

Alternative Extreme Undervolted (ExUV) settings

If after overclocking your I8150 you noticed some freezes when on ExUV kernel builds, you may use an alternative extremely undervolted setting with the init.d script you can find here: 01vdd_levels_alt_exuv

- Download the script

- If the file has been saved with .txt extension (stock browser), rename it by removing the .txt extension

- Copy the new file inside /etc/init.d

- Give the rwxr-xr-x permissions to the file (read, write, execution for owner, read and execution for group users, read and execution for others)

- Reboot

Force Fast Charge

This feature allows you to force AC charging for any charger that is detected as USB (eg. PC USB ports, USB Car Chargers) and pull the full current the charger can support, in such a way as to speed up the time required for a complete battery recharge.

By enabling this feature, the USB / ADB data transfers will be disabled (security limitation to protect your data).

How to enable/disable the Force Fast Charge:

1) By using the related setting inside System->Advanced->Force Fast Charge (only on CM 10 Beta 3 and next releases)

2) By downloading and using Trickster MOD or IncrediControl or NsTools

2) By directly editing the file /sys/kernel/fast_charge/force_fast_charge and setting 1 to enable the force charge, 0 to disable it (note that set value will be lost after a reboot/shutdown)

3) By using Terminal Emulator (note that set value will be lost after a reboot/shutdown)

- Open Terminal Emulator

- Run this command to enable the force fast charge feature

su
echo 1 > /sys/kernel/fast_charge/force_fast_charge

- Then, when you want to restore the normal status, run this command to disable the force fast charge feature

su
echo 0 > /sys/kernel/fast_charge/force_fast_charge

4) By using a customized init.d script, but I don't recommend it because you have to remember to disable the feature every time you want to connect your device to a pc for data transfering after every reboot

Battery life extender (BLX)

This feature has been developed by Ezekeel and allows to set a customized battery charging limit (100% is the default stock value, if you want, you can set a lower value).

As Ezekeel said, it is commonly accepted that both very low and very high charge states accelerate the degradation of the battery capacity (that is why you should store Li-Ion batteries at around 40% charge).

If you set a charging limit equal to 100, this feature will be disabled.

How to activate this feature and set a customized charging limit:

1) By downloading and using Trickster MOD or NsTools by setting the customized battery life extender charging limit

2) By using a customized init.d script (the custom value will be always restored after a reboot, if you don't format the system partition)

- Download the script named 15blx

- If the file has been saved with .txt extension (stock browser), rename it by removing the .txt extension

- Edit the file by setting your preferred charging limit (the downloaded script will set the charging limit to 95%)

- Copy the new file inside /etc/init.d

- Give the rwxr-xr-x permissions to the file (read, write, execution for owner, read and execution for group users, read and execution for others)

- Reboot

3) By directly editing the file /sys/class/misc/batterylifeextender/charging_limit (the value you set will be lost after a reboot/shutdown)

4) By using Terminal Emulator (note that set value will be lost after a reboot/shutdown)

- Open Terminal Emulator

- Run these commands (changing the charging limit = 95 with the preferred one)

su
echo 95 > /sys/class/misc/batterylifeextender/charging_limit

LowMemoryKiller

The LowMemoryKiller driver is used to kill a selected process and free the memory when it is under one of the defined thresholds.

The tuning of the driver could be achieved by means of two parameters exposed by the kernel module via sysfs interface:

- /sys/module/lowmemorykiller/parameters/minfree

This file includes a comma separated array of the threshold numbers for minfree memory size (in page units).

The parameter value set for K^Kernel is "2048,4096,6656,9216,14336,19456".

- /sys/module/lowmemorykiller/parameters/adj

This file includes the comma separated array of oomadj factors, if the corresponding minfree threshold has been reached, one of the process with an oomadj greater than this number will be killed.

The oomadj factor is a property associated to each process, its value is in a range from -17 to +15, the processes with a higher oomadj factor will be the first to be killed when a specific minfree threshold has been reached.

The parameter value set for K^Kernel is "0,20,50,100,250,500".

Frandom - Fast Random Generator

As Eli Billauer (the creator of this module) said, Frandom is a Linux kernel random number generator, which is 10-50 times faster than what you get from Linux built-in /dev/urandom. And it uses very little (/dev/frandom) or none (/dev/erandom) of the kernel's entropy pool, so it is very useful for applications that require a handy source for lots of random data.

How to test if frandom builtin module is correctly working:

- Download the script named frandom_test.sh

- Using your preferred file explorer, copy the file inside the folder /data/local of your device

- Give the rwxr-xr-x permissions to the file (read, write, execution for owner, read and execution for group users, read and execution for others)

- Open Terminal Emulator

- Run this command

/data/local/frandom_test.sh

You should see a result similar to this one:

​

If the urandom tests take more than 1 or 2 seconds and are more different than related frandom tests, then the random number generation is not fully optimized for your currently used kernel...

How to disable / re-enable the redirection to frandom module during boot process:

By using Terminal Emulator:

- Run these commands to create the flag file and disable Frandom redirection:

su
touch /data/frandom_disabled

- Or run these commands to delete the flag file and re-enable Frandom redirection:

su
rm /data/frandom_disabled

The change will take effect after a reboot.

RAM Console

This feature is useful expecially for development and debugging purposes, when occurs kernel panic / unexpected shutdowns or reboots. Pratically, the kernel messages are also stored inside a little RAM portion and restored during reboot after a kernel panic, inside the file /proc/last_kmsg.

Dynamic FSync

This feature has been developed by Faux123 and allows to dynamically manage the synchronous writes performed on file system (FSync).

It uses asynchronous writes when the screen is on, instead of synchronous writes, to have better performance and a slightly lower battery drain, while when the screen is off the synchronous writes are re-enabled to flush all the outstanding writes and prevent possible data loss.

How to enable/disable the Dynamic FSync (default enabled):

1) By downloading and using Trickster MOD

2) By directly editing the file /sys/kernel/dyn_fsync/Dyn_fsync_active and setting 1 to enable the dynamic fsync, 0 to disable it (note that set value will be lost after a reboot/shutdown)

3) By using Terminal Emulator (note that set value will be lost after a reboot/shutdown)

- Open Terminal Emulator

- Run this command to disable the dynamic fsync feature

su
echo 0 > /sys/kernel/dyn_fsync/Dyn_fsync_active

- Or run this command to re-enable the dynamic fsync feature

su
echo 1 > /sys/kernel/dyn_fsync/Dyn_fsync_active

Dynamic dirty page writebacks

This feature has been developed by me and allows to dynamically manage the dirty page writebacks with two different intervals, one when the screen is on and another when the screen is off.

It is based on a commit of Francisco Franco, but instead of using hard coded values and of disabling at all the dirty page writebacks while the screen is on (possibility of data loss), I preferred to use a customizable higher dirty page writebacks interval (15 seconds) than the default one (5 seconds) while the screen is on and a customizable default interval (5 seconds) when the screen is off.

By using a higher interval we have better performance and less battery consumption, with a very low risk of data loss.

How to customize the dynamic dirty page writebacks feature (default enabled):

Three new procfs parameters are exposed inside /proc/sys/vm path:

- dynamic_dirty_writeback is the activation status of this feature, set 1 to enable it, set 0 to disable it and use the standard behaviour

- dirty_writeback_active_centisecs is the interval for the dirty page writebacks when the system is active (screen on), the default value is 1500 centisecs (15 seconds)

- dirty_writeback_suspend_centisecs is the interval for the dirty page writebacks when the system is suspended (screen off), the default value is 500 centisecs (5 seconds)

In my kernel builds, during boot, I set other customized values:

- an interval of 30 seconds while the screen is on

- an interval of 10 seconds when the screen is off

1) By directly editing one of the file written above inside /proc/sys/vm and setting the preferred value (note that set value will be lost after a reboot/shutdown)

2) By using Terminal Emulator (note that set value will be lost after a reboot/shutdown)

- Open Terminal Emulator

- Run this command to disable the dynamic dirty page writebacks feature

su
echo 0 > /proc/sys/vm/dynamic_dirty_writeback

- Or run this command to re-enable the dynamic dirty page writebacks feature

su
echo 1 > /proc/sys/vm/dynamic_dirty_writeback

- Run this command to set customize the two intervals (30 seconds while the screen is on, 10 seconds when the screen is off)

su
echo "3000" > /proc/sys/vm/dirty_writeback_active_centisecs
echo "1000" > /proc/sys/vm/dirty_writeback_suspend_centisecs