Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,737,406 Members 42,316 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE] How To Add Init.d Support to Your Kernel & Rom

Tip us?
 
alireza7991
Old
#1  
alireza7991's Avatar
Senior Member - OP
Thanks Meter 2213
Posts: 752
Join Date: Sep 2012
Location: Shahrekord

 
DONATE TO ME
Default [GUIDE] How To Add Init.d Support to Your Kernel & Rom

What is init.d ?

Init.d is a feature which allows you to run brunch of scripts at boot . Thats really useful while you want to set values which reset at boot or run/do any thing at every boot or install tweaks , engines and....

There are some ways to add this feature to you rom but always best way is to add init.d support directly by your kernel . I want to help you to do this

Requirements

1- Ability to unpack boot.img & ramdisk
2- Some basic linux shell knowloedge
3- Having Busybox located in /system/bin/busybox at your rom

Step 1: Making kernel ready

1- Unpack kernel then ramdisk
2- Open Init.rc with a text editor
3- Add this codes at the end , before the paragraph which there is "stop bootanim" command in it :

Code:
Select Code
service sysinit /system/bin/sysinit
oneshot
4- Save , Exit and repack ramdisk and boot.img

Step 2 : Making Rom Ready !

1- Open /system/bin/sysinit
2- Add this codes :

Code:
Select Code
#!/system/bin/sh
export PATH=${PATH}:/system/bin:/system/xbin
chmod 777 /system/etc/init.d/*
logwrapper busybox run-parts /system/etc/init.d/
3- Set permissions of sysinit to 777 or 755 ( rwxrwxr-x | rwxrwxrwx )
4- Make a directory at system/etc and name it init.d

Now you have init.d support !
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.

Brian Kernighan
The Following 34 Users Say Thank You to alireza7991 For This Useful Post: [ Click to Expand ]
 
RobyRc
Old
#2  
Senior Member
Thanks Meter 77
Posts: 337
Join Date: Feb 2012
Location: Nashville
Bull*hit. JUST INSTALL pimpmyrom and finish ..Easy.
My Toys: Samsung Galaxy S+ 8gb,iPhone 5 White 64gb,Nexus 10 32gb.

Samsung Galaxy S+
ROM: AOSP 4.3.1
Kernel: Custom 3.4
Special thanks: Arco68,FreeXperia,Alex(LGDev).


Nexus 5
ROM: Soooon.
 
broodplank1337
Old
#3  
broodplank1337's Avatar
Recognized Contributor / Recognized Developer
Thanks Meter 9902
Posts: 4,922
Join Date: Nov 2011
Location: Nijmegen

 
DONATE TO ME
Someone had to document this ^^, good job
Device: Samsung Galaxy S4 (i9505)

Latest Development:
 

Roms:
AOSP v4.4.4 (KTU84P) from source for I9505 (Github)
- Cleanest ROM available for i9505. along with up-to-date stock kernel, also forms a perfect base for ROM developers.

Apps:
Galaxy S4 Glove Mode App (Playstore link)
- Do you want the Glove Mode of the S4 but your ROM doesn't support it? Use this app to enable/disable it easily.

Latest Scraps:
Proprietary Lib Cleaner / Silent proprietary libs / Live Thermal Monitor / GIT Conflict Fixer

Projects in development:
 

broodROM KitKat "Aiming for perfection"
- Custom ROM with really high standards, more info soon

For sources you can visit my Github. Or take a look at all my projects

The Following User Says Thank You to broodplank1337 For This Useful Post: [ Click to Expand ]
 
alireza7991
Old
#4  
alireza7991's Avatar
Senior Member - OP
Thanks Meter 2213
Posts: 752
Join Date: Sep 2012
Location: Shahrekord

 
DONATE TO ME
Quote:
Originally Posted by RobyRc View Post
Bull*hit. JUST INSTALL pimpmyrom and finish ..Easy.
Pimp uses one of the worst method to add this feature to your ROM ! it doesn't effect on kernel so : 1- running init.d is slower 2- init.d is not stable at all 3- not usable for ones want to add this feature to his/her kernel 4- not run init.d at end of boot so some script which needs some binaries that are not loaded yet doesn't work 5- Can not be used for room devs

This method is the official method which is used on most famous kernels such as brood kernel . and best for devs and users

any way that depends on users idea that this is good or not
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.

Brian Kernighan
The Following 7 Users Say Thank You to alireza7991 For This Useful Post: [ Click to Expand ]
 
Stefano187
Old
#5  
Stefano187's Avatar
Senior Member
Thanks Meter 187
Posts: 327
Join Date: May 2012
Location: Frosinone

 
DONATE TO ME
Quote:
Originally Posted by RobyRc View Post
Bull*hit. JUST INSTALL pimpmyrom and finish ..Easy.
Why are you so rude?
There are ways and ways to express own opinions... And alireza has just explained you why this method is better then PIMPMYROM.

Sent from my AriesVe using xda premium

Motorola Moto G (xt1032)
Rom: Stock 4.4.2
Kernel: Faux Kernel
Recovery: Team Win Recovery Project
Bootloader: Unlocked
Root: SuperSU
Samsung Galaxy S Plus (GT-I9001)
Rom: AriesVE DevConnection Team CM 11.0
Kernel: K^Kernel 3.4.x OC/EXUV 370MB
Recovery: Team Win Recovery Project by ADC Team
Baseband: XXKPO
Governor: SmartAss V2
I/O Scheduler: SIO
CPU Frequencies: 245-1824 MHz
"Logic will get you from A to B. Imagination will take you everywhere." [Albert Einstein]
The Following 4 Users Say Thank You to Stefano187 For This Useful Post: [ Click to Expand ]
 
RobyRc
Old
#6  
Senior Member
Thanks Meter 77
Posts: 337
Join Date: Feb 2012
Location: Nashville
Quote:
Originally Posted by alireza7991 View Post
Pimp uses one of the worst method to add this feature to your ROM ! it doesn't effect on kernel so : 1- running init.d is slower 2- init.d is not stable at all 3- not usable for ones want to add this feature to his/her kernel 4- not run init.d at end of boot so some script which needs some binaries that are not loaded yet doesn't work 5- Can not be used for room devs

This method is the official method which is used on most famous kernels such as brood kernel . and best for devs and users

any way that depends on users idea that this is good or not
You are wrong.
My Toys: Samsung Galaxy S+ 8gb,iPhone 5 White 64gb,Nexus 10 32gb.

Samsung Galaxy S+
ROM: AOSP 4.3.1
Kernel: Custom 3.4
Special thanks: Arco68,FreeXperia,Alex(LGDev).


Nexus 5
ROM: Soooon.
 
ktulu84
Old
#7  
Senior Member
Thanks Meter 1117
Posts: 1,148
Join Date: Jan 2013
Location: Pescara
Quote:
Originally Posted by RobyRc View Post
You are wrong.
well, if he is wrong you can explain why, he explained why according to him is better this way, you could explain why not

SAMSUNG GALAXY S PLUS (GT-i9001)
ROM: CM11 by AriesVE DevConnection Team (ION+PMEM ADSP)
KERNEL: K^Kernel 3.4.x ION+PMEM ADSP with phantom key presses filter
  • home_allowed_irqs = 1
  • home_report_wait = 11
GOVERNOR CPU: SmartassV2
FREQs: 245 MHz - 1401 MHz
SCHEDULER I/O: noop
BASEBAND: I9001XXKPO
RECOVERY:TWRP 2.7.1.0 fully fixed by ADC Team (Full SElinux support)
The Following User Says Thank You to ktulu84 For This Useful Post: [ Click to Expand ]
 
vMAC
Old
#8  
Senior Member
Thanks Meter 11
Posts: 157
Join Date: Oct 2007
What happens if your ROM doesn't have /system/bin/sysinit?
 
alireza7991
Old
#9  
alireza7991's Avatar
Senior Member - OP
Thanks Meter 2213
Posts: 752
Join Date: Sep 2012
Location: Shahrekord

 
DONATE TO ME
Quote:
Originally Posted by vMAC View Post
What happens if your ROM doesn't have /system/bin/sysinit?
* Your rom has sysinit -> You have already init.d support and no need to this guide

* Your rom has'nt it -> You need to do my guide to get init.d support
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.

Brian Kernighan
The Following 3 Users Say Thank You to alireza7991 For This Useful Post: [ Click to Expand ]
 
GT-af
Old
#10  
GT-af's Avatar
Senior Member
Thanks Meter 68
Posts: 129
Join Date: Oct 2012
Location: Paris
Quote:
Originally Posted by alireza7991 View Post
* Your rom has sysinit -> You have already init.d support and no need to this guide

* Your rom has'nt it -> You need to do my guide to get init.d support
And is it possible to create sysinit and init.d folder with an updater script?
Think to the button if a message helped you.

Devices:

-Samsung Galaxy Ace GT-S5830i (closed sources device)

-LG Nexus 5

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes