[HTC Sensation] TheWall-[ITA]:
init.d scripts

Hi guys! I hope you'll find this thread useful.

Sorry for crossposting, but I wanted to keep first post as clean as possible.

I'm trying to understand why scripts in init.d folder does not work. Searching around the web I found out that the android system can be set to run them or not by configuring something in the file init.rc. But I really don't know how to modify it and I read that this file shouldn't be modified by hand because it is re-created at every boot. I'm not a real expert. Can someone confirm this? :confused:

By the way I found a simple workaround to run the 99kernel script at boot.

I installed Script manager and I runned the 99kernel script. The script runs, but it gives "file not found" errors when trying to set CPU settings. I think this is beacuse the ROM handles this settings in a different way.

The other configurations in the script (like sweep2wake) are working properly. So I copied the script and I commented out the section related to CPU and I/O scheduler. Here's the code.

#!/system/bin/sh
#Script originally made by Axetilen. Modified by Sultan (android1234567)
#Updated for albinoman887's ChronicKernel (98% of the credit goes to android1234567. Thanks so much man :)
#Updated for ChronicKernel-linaro

# Configure your options here #

# Config default CPU Gonvernor (Disabled by default: When disabled uses internal Kernel setting)
# For better battery life switch to badass
# Kernel Default: ondemand
# Possible values
# badass
# ondemand
# interactive
#= lagfee
# performance
#GOV=badass

# Config I/O scheduler
# deadline
# cfq
# noop
# vr
# sio (default)
#IO=sio

# Config CPU max frequency
# Default: 1566000 (1566Mhtz)
# Overclockable to - 1836000 (1836Mhtz)
# for badass set to 1566mhtz (best performance/battery life)
#MAXFREQ=1566000

# Config CPU min frequency
# Default: 384000 (384Mhtz)
# Range 384000 - 1944000 (384Mhtz - 1944Mhtz)
#MINFREQ=384000

# Config 3D GPU clock
# 228571000 = 228mhz
# 266667000 = 267mhz (default)
# 300000000 = 300mhz (Recomended For balance of Performance and Battery life)
# 320000000 = 320mhz
GPU=266667000

# Config 2D GPU clock
# 145455000 = 145mhz
# 160000000 = 160mhz
# 200000000 = 200mhz (default)
# 228571000 = 228mhz (Recomended For balance of Performance and Battery life)
# 266667000 = 267mhz
DD=200000000

# Badass
# possible values
# 1 = performance
# 2 = balanced
# 3 = battery saving
#BADASS=2

# Enable Sweep2Wake
# 0 = disabled (default)
# 1 = enabled
# 2 = enabled (with no button backlight during sweep)
SWEEP=2

# Enable Fastcharge
# 0 = disabled
# 1 = substitute AC to USB charging always
# 2 = substitute AC to USB charging only if there is no USB peripheral detected
FASTCHARGE=0

# Fsync Control
# Disabled by default (recomended)
# 2 = Fsync disabled
# 1 = Fsync enabled
FSYNC=2

# TUN
# Disabled by default
# 0 = Disabled
# 1 = Enabled
TUN=0

# End of configurable options #

################# DON'T CHANGE ANYTHING BELOW THIS LINE #################

## Config CPU governor
# echo "$GOV" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# echo "$GOV" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

# Config 3D GPU setting
chmod 644 /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/max_gpuclk
chmod 644 /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/gpuclk
echo $GPU > /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/max_gpuclk
echo $GPU > /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/gpuclk

# Config 2D GPU setting
chmod 644 /sys/devices/platform/kgsl-2d0.0/kgsl/kgsl-2d0/max_gpuclk
chmod 644 /sys/devices/platform/kgsl-2d0.0/kgsl/kgsl-2d0/gpuclk
chmod 644 /sys/devices/platform/kgsl-2d1.1/kgsl/kgsl-2d1/max_gpuclk
chmod 644 /sys/devices/platform/kgsl-2d1.1/kgsl/kgsl-2d1/gpuclk
echo $DD > /sys/devices/platform/kgsl-2d0.0/kgsl/kgsl-2d0/max_gpuclk
echo $DD > /sys/devices/platform/kgsl-2d0.0/kgsl/kgsl-2d0/gpuclk
echo $DD > /sys/devices/platform/kgsl-2d1.1/kgsl/kgsl-2d1/max_gpuclk
echo $DD > /sys/devices/platform/kgsl-2d1.1/kgsl/kgsl-2d1/gpuclk

# Config USB forced fastcharge
chmod 644 /sys/kernel/fast_charge/force_fast_charge
echo "$FASTCHARGE" > /sys/kernel/fast_charge/force_fast_charge

# Config Sweep2Wake (with compatibility with NLJ's fix)
if [ "$SWEEP" = "0" ]
then
chown radio.system /sys/android_touch/sweep2wake
chmod 664 /sys/android_touch/sweep2wake
echo 0 > /sys/android_touch/sweep2wake
fi

if [ "$SWEEP" = "1" ]
then
chown radio.system /sys/android_touch/sweep2wake
chmod 664 /sys/android_touch/sweep2wake
echo 1 > /sys/android_touch/sweep2wake
fi

if [ "$SWEEP" = "2" ]
then
chown radio.system /sys/android_touch/sweep2wake
chmod 664 /sys/android_touch/sweep2wake
echo 2 > /sys/android_touch/sweep2wake
fi

# Config badass CPU Gonvernor
#CUR_GOV="`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`"
#echo badass > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
#sleep 3
#case ${BADASS} in
#	1)
#	$L "badass: setting performance oriented configuration"
#	echo 1188000 > /sys/devices/system/cpu/cpufreq/badass/two_phase_freq;
#	echo 1512000 > /sys/devices/system/cpu/cpufreq/badass/three_phase_freq;
#	echo 120 > /sys/devices/system/cpu/cpufreq/badass/busy_threshold;
#	echo 80 > /sys/devices/system/cpu/cpufreq/badass/busy_clr_threshold;
#	echo 8 > /sys/devices/system/cpu/cpufreq/badass/semi_busy_threshold;
#	echo 4 > /sys/devices/system/cpu/cpufreq/badass/semi_busy_clr_threshold;
#	;;
#	2)
#	$L "badass: setting balanced configuration"
#	echo 918000 > /sys/devices/system/cpu/cpufreq/badass/two_phase_freq;
#	echo 1188000 > /sys/devices/system/cpu/cpufreq/badass/three_phase_freq;
# echo 50000 > /sys/devices/system/cpu/cpufreq/badass/sampling_rate
#	echo 130 > /sys/devices/system/cpu/cpufreq/badass/busy_threshold;
#	echo 100 > /sys/devices/system/cpu/cpufreq/badass/busy_clr_threshold;
#	echo 14 > /sys/devices/system/cpu/cpufreq/badass/semi_busy_threshold;
#	echo 6 > /sys/devices/system/cpu/cpufreq/badass/semi_busy_clr_threshold;
#	;;
#	3)
#	$L "badass: setting battery saving configuration"
#	echo 918000 > /sys/devices/system/cpu/cpufreq/badass/two_phase_freq;
#	echo 1188000 > /sys/devices/system/cpu/cpufreq/badass/three_phase_freq;
#	echo 140 > /sys/devices/system/cpu/cpufreq/badass/busy_threshold;
#	echo 110 > /sys/devices/system/cpu/cpufreq/badass/busy_clr_threshold;
#	echo 80 > /sys/devices/system/cpu/cpufreq/badass/semi_busy_threshold;
#	echo 20 > /sys/devices/system/cpu/cpufreq/badass/semi_busy_clr_threshold;
#	;;
#esac
#echo ${CUR_GOV} > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# Config CPU Frequency
# chmod 644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
# echo $MAXFREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
# chmod 644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
# echo $MINFREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
#
# chmod 644 /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
# echo $MAXFREQ > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
# chmod 644 /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
# echo $MINFREQ > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq

# Config i/o scheduler
# chmod 644 /sys/block/mmcblk0/queue/scheduler
# echo "$IO" > /sys/block/mmcblk0/queue/scheduler
# chmod 644 /sys/block/mmcblk1/queue/scheduler
# echo "$IO" > /sys/block/mmcblk1/queue/scheduler

# Config Fsync
if [ "$FSYNC" = "2" ]
then
echo "0" > sys/class/misc/fsynccontrol/fsync_enabled
fi

# Config TUN
if [ "${TUN}" = "1" ]; then
if [ -e /system/lib/modules/tun.ko ] ; then
insmod /system/lib/modules/tun.ko
$L "Inserted tun kernel module."
fi
fi

This is the script with my setup. Modify it with your preferred settings.

With Script Manager you can run this script from every directory (I'm keeping it on my SD card) and you can run it at boot.

Open the script from Script Manager and select "Root" option and "Boot" option.

I also wrote a script to check if the settings are all ok. You can run it WITHOUT root privileges with Script Manager. Here's the code.

#!/system/bin/sh
# Simple script to check GPU frequencies and other kernel features status
# Created by TheWall

echo -n "3DGPU max: "
cat /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/max_gpuclk

echo -n "3DGPU curr: "
cat /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/gpuclk

echo -n "2DGPU max: "
cat /sys/devices/platform/kgsl-2d1.1/kgsl/kgsl-2d1/max_gpuclk

echo -n "2DGPU curr: "
cat /sys/devices/platform/kgsl-2d1.1/kgsl/kgsl-2d1/gpuclk

echo -n "Fast Charge: "
FC=$(cat /sys/kernel/fast_charge/force_fast_charge)
if [ "$FC" = "0" ]
then
echo "disabled"
fi
if [ "$FC" = "1" ]
then
echo "substitute AC to USB charging always"
fi
if [ "$FC" = "2" ]
then
echo "substitute AC to USB charging only if there is no USB peripheral detected"
fi

echo -n "Sweep2Wake: "
S2W=$(cat /sys/android_touch/sweep2wake)
if [ "$S2W" = "0" ]
then
echo "disabled"
fi
if [ "$S2W" = "1" ]
then
echo "enabled"
fi
if [ "$S2W" = "2" ]
then
echo "enabled (no button backlight)"
fi

echo -n "Fsync: "
FS=$(cat sys/class/misc/fsynccontrol/fsync_enabled)
if [ "$FS" = "0" ]
then
echo "disabled"
else
echo "enabled"
fi

This is just a workaround, not a real fix. I'd like to know something more about this by ROM's dev. :)

Ps: as usual on xda, I'm not responsible for how you use the scripts in this post. ;) If you don't know what you're doing don't mess with it!