new to init.d - guide? - Galaxy S III Q&A, Help & Troubleshooting

Just starting to look into writing my own init.d (for use with perseus kernel for example.)
can any one point me in the right direction for a beginners guide to init.d?
I have searched but it is mainly linux in general that comes up - nothing specific to Android or the GSIII.
thanks

found this, which seems a very good start.
Beginner's Guide to init.d Scripts
init.d scripts has to be copied to /system/etc/init.d. All scripts in init.d are automatically executed after booting. (in Siyah, 30 seconds after booting)
I) How To:
1) In an editor such as notepad++, type #!/system/bin/sh
This should be the first line of all shell scripts. This invokes the compatible shell to execute our scripts.
2) From next line, type in your scripts line by line. After saving, push it to /system/etc/init.d using root explorer.
3) Use Script Manager from market to run the script as root to make sure there are no errors. (if you're confident of your script, then no need of script manager)
note: if you use editors such as wordpad to create a script, the carriage return leaves some 'invisible' illegal characters in the script and hence the script will fail to execute. So use editors such as notepad++, or use script manager itself to make the script.
4) If there are no errors when you run using script manager, then navigate to the script and set the following permissions:
owner: read,write
group: read
others: read
Also check 'set UID' and 'set GID'.
Now you're all good to go. Your script will be executed each time you reboot.
II) References:
We can use init.d scripts to perform a lot of things.
Refer post 2 from Q&A (courtesy kwerdenker)
http://forum.xda-developers.com/show....php?t=1325831
Use this post as a reference on how to tweak or change Cpu Frequencies/Voltages, Gpu Frequencies/Voltages, Bus Speed, I/O Scheduler, Charge Current, etc.
Apart from these, you can also tweak sched_mc values, change backlight response curve, change upper and lower thresholds for second-core-active (for screen-on and screen-off), etc.
III) Examples:
1) sched_mc
Ex:
echo "1" > /sys/devices/system/cpu/sched_mc_power_savings
This cause filling cpu0 (1st core) first for long running threads and processes.
Valid values are 0, 1 and 2
2) Second Core Active Threshold
Ex 1:
echo "70" > /sys/module/pm_hotplug/parameters/loadh
echo "25" > /sys/module/pm_hotplug/parameters/loadl
During screen on, This causes cpu1 to kick-in only after the load on cpu0 reaches 70% and cpu1 to turn off when load is less than or equal to 25%
Ex 2:
echo "90" > /sys/module/pm_hotplug/parameters/loadh_scroff
echo "35" > /sys/module/pm_hotplug/parameters/loadl_scroff
During screen off, This causes cpu1 to kick-in only after the load on cpu0 reaches 90% and cpu1 to turn off when load is less than or equal to 35 %. Useful to control power drain when you're listening to music when screen off, etc.
3) Tweak brightness Response Curve
Ex:
echo "30" > /sys/class/misc/brightness_curve/min_bl
echo "24" > /sys/class/misc/brightness_curve/max_gamma
This means any brightness value below 30 will have 0 gamma and brightness level above 30 will be linearly mapped to [0:24] gamma levels.
30 & 24 are stock values. Beta 16 will have voodoo color support as well. Use Voodo Screen Tuning R&D app from market to experiment and play around with yur SAMOLED screen.
4) Tweak Governors
Ex:
echo "85" > sys/devices/system/cpu/cpufreq/ondemandx/up_threshold
This means when ondemandx is used, the polling function scales cpu up to next frequency when cpu is 85% loaded w.r.t current frequency.
Many thanks to droidphile

Related

[Q] init.d script of sampling rate ---- need little help

I'm having problems with following init.d script, all other scripts get executed but this one does not get executed
#!/system/xbin/busybox sh
echo "45000" > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
There are no syntax errors, blank spaces etc
Am I using correct code to change sampling rate ?
Nobody ?
Kernel supports 45000 sampling rate. So nothing wrong with it either.

[Q] How to set-up and troubleshoot init.d scripts?

I have a Nexus 4, running CM10.1 and Faux123's latest kernel. I want to use an init.d script to set the governor, tuneables, and other things instead of an app (all of the apps I've tried have an issue with permissions/settings not sticking, plus I take any opportunity to eliminate 3d party apps when possible).
Running into some issues getting this to work right, hoping someone can help --
My init.d script successfully applies the following on boot: stop mpdecision, choose FIOPS as the I/O scheduler, put the GPU clock max at 400 mHz. However, any commands I have in the script that are related to the CPU governor, parameters, and eco mode/snake charmer do not work.
I thought I had put my script (named "userinit.sh", placed in /data/local) in the wrong place or something, but like I said it successfully stops mpdecision on boot, sets the i/o to FIOPS and makes the read-ahead 2048kb, and sets the GPU max to 400 mHz -- none of the other commands work though. Any ideas?
Running Cyanogenmod 10.1 nightlies with 002b6 faux kernel. I've also set the permissions of the file to 755 (rwxr-xr-x), is that right?
My script looks like this (the ones in green work fine, the rest in red don't work):
#!/system/bin/sh
su
stop mpdecision
echo "intellidemand" > /sys/devices/system/cpu/cpu0/scaling_governor
echo 594000 > /sys/devices/system/cpu/cpu0/scaling_min_freq
echo 1350000 > /sys/devices/system/cpu/cpu0/scaling_max_freq
echo 1 > /sys/devices/system/cpu/cpufreq/intellidemand/eco_mode
echo 1350000 > /sys/devices/system/cpu/cpufreq/intellidemand/lmf_active_max_freq
echo 1026000 > /sys/devices/system/cpu/cpufreq/intellidemand/lmf_inactive_max_freq
echo 1350000 > /sys/kernel/msm_cpufreq_limit/cpufreq_limit
echo "fiops" > /sys/block/mmcblk0/queue/scheduler
echo 2048 > /sys/block/mmcblk0/queue/read_ahead_kb
echo 400000000 > /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/max_gpuclk
I would love any advice on what steps I need to take to get this working correctly, as well as any info about init.d scripts generally, I threw this one together after some Googling but who knows if its even in the right format. Thanks!

[Q&A] [ROM] Gohma 2.0 - 12/15/2014 [Android Wear]

Q&A for [ROM] Gohma 2.0 - 12/15/2014 [Android Wear]
Some developers prefer that questions remain separate from their main development thread to help keep things organized. Placing your question within this thread will increase its chances of being answered by a member of the community or by the developer.
Before posting, please use the forum search and read through the discussion thread for [ROM] Gohma 2.0 - 12/15/2014 [Android Wear]. If you can't find an answer, post it here, being sure to give as much information as possible (firmware version, steps to reproduce, logcat if available) so that you can get help.
Thanks for understanding and for helping to keep XDA neat and tidy!
It appears that the vibration and other settings are not active in Gohma 2.0
From my research it seems that the /system/etc/rc.d/01tweaks file never gets to run.
I have been messing around with my watch to find a place to trigger execution of that directory but haven't found one yet.
Where did you put an initialization for it last time?
Alynna said:
It appears that the vibration and other settings are not active in Gohma 2.0
From my research it seems that the /system/etc/rc.d/01tweaks file never gets to run.
I have been messing around with my watch to find a place to trigger execution of that directory but haven't found one yet.
Where did you put an initialization for it last time?
Click to expand...
Click to collapse
I'll have a fix shortly, sorry!
Alynna said:
It appears that the vibration and other settings are not active in Gohma 2.0
From my research it seems that the /system/etc/rc.d/01tweaks file never gets to run.
I have been messing around with my watch to find a place to trigger execution of that directory but haven't found one yet.
Where did you put an initialization for it last time?
Click to expand...
Click to collapse
The init.d/rc.d directories seem to be run from the /system/etc/install-recovery.sh file. Look there and you should see the run-parts command. Which btw okibi, is ingenious, using the stock recovery script to provide init.d support in the face of a kernel that doesn't support it natively.
What software compilation are using Gohma 2.0? I´ve been testing and I have the corrosion problem with a Lg G watch (1,4 volts between pins while being out of the charger), perhaps the base isn´t a "finished-on-Y" compilation?
Nice work, 0 lag everywhere!
Bootloop
While I was running the windows installation to upgrade to 2.0, the program crashed, and the rom is stuck in a bootloop. I can boot into fastboot, and the recovery, but nothing. Any help?
tharrllz said:
While I was running the windows installation to upgrade to 2.0, the program crashed, and the rom is stuck in a bootloop. I can boot into fastboot, and the recovery, but nothing. Any help?
Click to expand...
Click to collapse
http://forum.xda-developers.com/showthread.php?p=54250887
Toolkit should work to get back to stock lollipop.
Still a bug
There is still a little bug in gohma 2.1, but I fixed it in the script.
SOMETHING sets the governor back to userspace/787200 about a minute into the watches' boot.
I logged in and watched it occur.
However the other parameters now stick.
I fixed it with the following:
#!/system/bin/sh
/system/xbin/sysrw
##############################
# BEGIN CUSTOM USER SETTINGS #
##############################
# increase vibration intensity
# default is 80
echo 85 > /sys/class/timed_output/vibrator/amp
# default is 20
echo 175 > /sys/class/timed_output/vibrator/driving_ms
# switch from userspace to ondemand governor
# echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# echo 787200 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
# Defer change until later, see enforcer below.
GOV=ondemand
FREQ=1094400
# set dpi (default is 240, smaller number means smaller text)
setprop ro.sf.lcd_density 200
##############################
# END CUSTOM USER SETTINGS #
##############################
# improve sd cache
if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]; then
echo 2048 > /sys/devices/virtual/bdi/179:0/read_ahead_kb
fi
# improve block speed
for node in `busybox find /sys -name nr_requests | grep mmcblk`; do echo 1024 > $node; done
# gpu rendering
busybox mv /system/lib/egl/libGLES_android.so /system/lib/egl/libGLES_android.bak
busybox sed -i '/0 0 android/d' /system/lib/egl/egl.cfg
# adjust minfree
echo "0" > /sys/module/lowmemorykiller/parameters/debug_level
echo "2560,4096,6144,12288,14336,18432" > /sys/module/lowmemorykiller/parameters/minfree
# improve file system mounts
busybox mount -o remount,noatime,nodiratime,noauto_da_alloc,data=ordered,nobh,barrier=0 -t auto /
busybox mount -o remount,noatime,nodiratime,noauto_da_alloc,data=ordered,nobh,barrier=0 -t auto /sys
busybox mount -o remount,noatime,nodiratime,nodelalloc,noauto_da_alloc,data=ordered,nobh,barrier=0 -t auto /system
busybox mount -o remount,noatime,nodiratime,nodelalloc,noauto_da_alloc,data=ordered,nobh,barrier=0 -t auto /data
busybox mount -o remount,noatime,nodiratime,nodelalloc,noauto_da_alloc,data=ordered,nobh,barrier=0 -t auto /cache
# improve transitions
if [ -e /data/data/com.android.providers.settings/databases/settings.db ]; then
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update system set value = 0.5 where name = 'transition_animation_scale'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update system set value = 0.5 where name = 'animator_duration_scale'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update system set value = 1 where name = 'window_animation_scale'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update global set value = 0.5 where name = 'transition_animation_scale'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update global set value = 0.5 where name = 'animator_duration_scale'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update global set value = 1 where name = 'window_animation_scale'"
fi
# enable sysctl tweaks
busybox sysctl -p /system/etc/sysctl.conf
/system/xbin/sysro
# Wait around for the system to change the governor and change it back, then exit when we're sure its set.
# This function will remain running for a minute to enforce the change, until it's sure the system won't change it back.
enforcer () {
X=0
while [ $X -lt 12 ]; do
if [ ! `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` = $GOV ]; then
echo $GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo $FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
X=0
else
X=$(($X+1))
fi
sleep 5
done
unset X
}
enforcer &
Alynna said:
There is still a little bug in gohma 2.1, but I fixed it in the script.
SOMETHING sets the governor back to userspace/787200 about a minute into the watches' boot.
I logged in and watched it occur.
However the other parameters now stick.
I fixed it with the following:
Click to expand...
Click to collapse
I reinstalled using your additional governer tweak, is there any way to check and make sure its working? Seems to have made a noticeable improvement, it reduces some random lag i was getting with Wear Mini Launcher
myke66 said:
I reinstalled using your additional governer tweak, is there any way to check and make sure its working? Seems to have made a noticeable improvement, it reduces some random lag i was getting with Wear Mini Launcher
Click to expand...
Click to collapse
I log into the phone using:
adb shell
and check that the /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor remains 'ondemand'.
I noticed when I logged in with gohma 2.0 and 2.1, that this would get switched back to 'userspace' after a little less than a minute.
I'm not sure the 01tweaks file was even executed in 2.0. Definitely is executed in 2.1, but, something else in the system was changing the scaling settings back to defaults.
if its not working, the file above will be 'userspace', if it does, it is 'ondemand'.
Also, I have set my default top speed to 1.0ghz which is why wear launcher is probably snappier. This MAY have an impact on battery life, but probably not too much because the watch remains at about 300mhz whenever idle.
You can check /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies for valid values for the FREQ variable. Lower numbers probably mean marginally better battery life.
myke66 said:
I reinstalled using your additional governer tweak, is there any way to check and make sure its working? Seems to have made a noticeable improvement, it reduces some random lag i was getting with Wear Mini Launcher
Click to expand...
Click to collapse
A handy utility that you can sideload on our watch is PerfMon by Chainfire:
http://forum.xda-developers.com/showthread.php?t=1933284
If your frequency fluctuates from 300 to 1190, then you are on ondemand governor.
---------- Post added at 12:19 PM ---------- Previous post was at 11:50 AM ----------
Alynna,
Thanks for the enforcer mod. For some reason after installing your mod, the governor was still on userspace/787200. After playing around I changed sleep from 5 to 10 and now it works great.
:good:
The standard 5.0 ROM version has a new sleep function that turns off the watch display if it hasn't moved for 30 minutes. This is driving me nuts as I always put my watch next to my monitor while I'm working so I have to keep waking it up or I miss notifications.
Is this "feature" in this ROM and if so, is there any way to turn it off or extend the timeout ?
Thanks
i'm looking at the rom and kernel.
the kernel looks like it has more option/tweaks.
i know both dont work together a bit normal cause the rom is a bit the same it are tweaks and no visual changes
i think kernel looks better. in way of functions.
just this rom has also more cpu steps? 300-1.1ghz?
cause if im right stock just is locked on 778mhz? and even with wear control app seems like i can't change it (i mean i don't realy know cant see if power save or balanced governers do any thing). need to check with a app how fast my cpu is running.
This ROM had been great! One question: Does the reset option in the watch settings properly reset and keep gohma tweaks? I tend to flash allot of ROMs on my phone and have been flashing my watch back to stock then each time as well as reflashing gohma. Stock recovery here. See no real reason for custom when everything is done using adb and computer.
Nandrew said:
This ROM had been great! One question: Does the reset option in the watch settings properly reset and keep gohma tweaks? I tend to flash allot of ROMs on my phone and have been flashing my watch back to stock then each time as well as reflashing gohma. Stock recovery here. See no real reason for custom when everything is done using adb and computer.
Click to expand...
Click to collapse
Yup. Just reset between phone ROM flashes.
Any update or thoughts on if we can find a way to make this ROM stop pumping out the 1.74 volts to our wrists via the metal contacts? Just discovered the whole issue of corrosion via the voltage emitted from the watch while being worn. I checked mine, running this ROM, and sure enough: it's live. 1.74 volts of electricity going into your wrist while you wear this thing. LG claims to have sent out a software fix a while back.
Thanks for the development & work on this ROM! Hopefully an "ah-ha" moment can be had and get this issue solved!
To think some people actually pay to have electricity run thru their body.. LG didn't consider it a feature? Lol
No corrosion here.
Gohma 2.2 - NEED DOWNLOAD
Jake's site to download the rom seems to be acting up. The download is extremely slow and keeps failing. I am in desperate need of this excellent ROM!! Does anybody have an alternate download link for Gohma 2.2? Any help is greatly appreciated.
Quick question? Installed 2.2 and everything runs fine except Perfmon only shows one core active. If I run the adb script I can turn the others on but for some reason by default one one core is up after a reboot. Any help.
kwd114kwd114 said:
Quick question? Installed 2.2 and everything runs fine except Perfmon only shows one core active. If I run the adb script I can turn the others on but for some reason by default one one core is up after a reboot. Any help.
Click to expand...
Click to collapse
The 01tweaks script on 2.3 didn't work for me either. Ondemand and frequency are correctly set, but only one core. Couple of workarounds:
1. Set the cores directly using adb commands from your PC.
2. Sideload kernel adiutor from the play store (nice kernel tuner app that works on our watch, dev is active on XDA)
3. Or modify the 01tweaks script to set the cores within the enforcer part of the script (right after $GOV and $FREQ are set)
Code:
# Wait around for the system to change the governor and change it back, then exit when we're sure its set.
# This function will remain running for a minute to enforce the change, until it's sure the system won't change it back.
enforcer () {
X=0
while [ $X -lt 12 ]; do
if [ ! `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` = $GOV ]; then
echo $GOV > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo $FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo "1" > /sys/devices/system/cpu/cpu1/online
X=0
else
X=$(($X+1))
fi
sleep 5
done
unset X
}
enforcer &

[Ramdisk Kernel Mod] LateAutumn zImage + Zetsubou init tweak for Lineage OS 14.1

This is just a proof of concept for "if we like a Kernel but don't like the default setting and too lazy to use kernel adiutor to apply the desirable setting" ​
Basically I just changed the Late Autumn installer zip using the goodies from Zetsubou. So this is a Late Autumn kernel with my modifications to ramdisk.
Here's the difference:
1. Enable doubletap2wake by default
2. Set CPU maximum frequency to 1401600
3. Set CPU minimum frequency to 200000
4. Set GPU maximum frequency to 550000
5. Set GPU minimum frequency to 100000
6. Enable MSM CPU hotplug by default
7. Disable GPU Adreno idle by default
Warning:
Only tested on lineage-14.1-20170126-nightly-wt88047 !!
Make sure to install this kernel on top of that rom stock kernel...
And make sure to clear the kernel adiutor setting too... You can set the others later, I did a dirty trick to let the CPU minimum frequency goes to 200 with interactive governor. I don't know if others got this weird problem, in my device set min freq to 200 didn't work with interactive governor.
How to install:
- Make sure you have lineage-14.1-20170126-nightly-wt88047 rom with the stock kernel
- Flash from TWRP like usual
Download:
https://drive.google.com/file/d/0B3ue12JCB2NgbVo3ODkxeVN1Ylk/view?usp=drivesdk
Credits:
@nicknitewolf for the awesome lineage official build
@iamsubhranil for the amazing stable kernel
@Ashish94 for the various genius tweaks
My modifications details:
1. In anykernel.sh file
Code:
# begin ramdisk changes
# add zetsubou initialization script
insert_line init.rc "import /init.zetsubou.rc" after "import /init.environ.rc" "import /init.zetsubou.rc";
# adb secure
backup_file default.prop;
replace_string default.prop "ro.adb.secure=0" "ro.adb.secure=1" "ro.adb.secure=0";
replace_string default.prop "ro.secure=0" "ro.secure=1" "ro.secure=0";
# change CPU
backup_file init.qcom.power.rc;
replace_string init.qcom.power.rc "scaling_min_freq 200000" "scaling_min_freq 800000" "scaling_min_freq 200000";
replace_string init.qcom.power.rc "1 200000:85" "1 800000:85" "1 200000:85";
# end ramdisk changes
2. Add file init.zetsubou.rc :
Code:
on boot
#S2W
write /sys/android_touch/sweep2wake 0
#DT2W
write /sys/android_touch/doubletap2wake 1
#S2S
write /sys/android_touch/sweep2sleep 0
on property:sys.boot_completed=1
#a53 max
chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 1401600
#GPU
write /sys/class/kgsl/kgsl-3d0/devfreq/min_freq 100000000
write /sys/class/kgsl/kgsl-3d0/max_gpuclk 550000000
write /sys/module/adreno_idler/parameters/adreno_idler_active N
# Enable MSM Hotplug
write /sys/module/msm_hotplug/msm_enabled 1
Will try it over RR and let u know if it is working or not.
Thanx
Wow, another indonesian devs. try it asap :highfive:

problem with manually hotplugging cpuX in rooted android device

Hi every one
I have a Lenovo vibe p1a42 which is rooted properly along with the SuperSU.
I'm going to write a custom userspace governor, using cpufreq and hotplug facility but I have some problem with online and some other entries in sysfs.
I have 8 cores and it is possible to change the corresponding entries in sysfs. I can successfully selecting the userspace governor by:
Code:
adb shell
su
echo userspace > /sys/devices/system/cpu/cpuX/cpufreq/scaling_governor
I do the last line for each core and then I set the valid frequency by writing to corresponding scaling_setspeed files.
I know it is possible to dynamically on/off each core by writing 1/0 to the corresponding /sys/devices/system/cpu/cpuX/online entry.
However, I cannot change the status of some processor to online by:
Code:
echo "1" > /sys/devices/system/cpu/cpuX/online
two cores of eight are always off and it seems that it cann't be controlled, manually, in this manner.
I know there is some kind of hotplug manager in android devices which activate appropriate core numbers according to the load.
How can I get ride of such hotplug manager and get full access to all cores due to the maximum performance?

Categories

Resources