Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[GUIDE] How to port a ROM[OUTDATED FOR MIUI]

OP Myrder

6th June 2013, 07:56 PM   |  #1  
Myrder's Avatar
OP Recognized Contributor
Flag Oklahoma City
Thanks Meter: 1,043
 
852 posts
Join Date:Joined: Oct 2012
Donate to Me
More
THIS ONLY WORKS FOR MIUIV4, I WILL GET A GUIDE TOGETHER ON HOW TO PORT MIUIV5 WHEN I HAVE TIME


Out of popular request, I have made this guide on how to port yourself.

Credit for this goes to @mirGantrophy and @AdhvanIt. If it wasn't for either of them, I wouldn't know as much as I do.

Code:
First off, this will be made as noob friendly as possible
but we all know that there will be things that just can't be made noob friendly.
Don't ask for a "one click" for this it will never happen because
It's a manual process you have to do yourself.
I am not in any way, responsible if you brick.
You should have some knowledge as to what you're doing.
If you're not confident/comfortable doing this...
DON'T EVEN THINK ABOUT IT!!!

Any and all questions, please post in the thread. You're also more than welcome to PM me and I'll help as much as possible.


Now, let's explain what porting is.
Quote:

In the easiest terms I can put it.. It's just taking a ROM from your device as your BASE ROM, then finding a ROM on a different device that's the same build number. As in, 4.1.X won't work with 4.2.X. You delete certain system files in you base, and copy those same files you deleted from your PORT ROM. Compile, test, decompile, fix: repeat.

What you'll need:

Code:
PATIENCE - this is most important because it won't always work the way you want it too.
a working computer
apktool
smali/baksmali
Android Kitchen - I use dsixda's kitchen in the dev/hacking forum
a diff tool - I use Meld as it's the easiest to use
Android SDK or just ADB/Fastboot
Before we start getting into the thick. Let me explain how this will be set up. Our BASE ROM will be from our device(Evita). Our PORT ROM will be from another device other than Evita. I personally like to use Crespo(Nexus S) but this can be done wil any other phone.

Also, let's make sure we aren't trying to port TouchWiz/Sense onto AOSP/AOKP that just won't work. As much as you try, it won't.. And I will probably laugh at you if I find out you tried doing that... Make sure your porting Sense/Sense, AOSP/AOSP, AOKP/AOKP.



STEP ONE
Code:
Download your BASE ROM of choice
STEP TWO
Code:
Download your PORT ROM of choice
STEP THREE
Code:
Use your android kitchen to set up a WORKING_Folder for your BASE ROM
STEP FOUR
Code:
Repeat step three for your PORT ROM, be careful here...
 It might explode into bright rainbow confetti. ;)
STEP FIVE
Code:
take your BASE ROM WORKING_folder, open it and navigate to /system

DELETE:
/app
/fonts
/framework
/media
STEP SIX
Code:
The files you just deleted from your BASE ROM, yeah. 
Let's take those from your PORT ROM and put them in your BASE ROM.
STEP SEVEN
Code:
Open build.prop from BASE ROM and PORT ROM
compare them side by side
STEP EIGHT
at the top, it will have something like

Code:
ro.build.id=
ro.build.display.id=
ro.build.version.incremental=
copy those lines from your PORT ROM to your BASE ROM

STEP NINE
Code:
Find your updater-scripts from both ROMS
/meta-inf/com/google/android
You know those fancy little titles and catch phrases you see in TWRP when flashing.. yeah, this is where you can do that. But I won't explain how to do that. You want to know, ask.

Code:
compare these files side by side and make any necessary changes.
DON'T TOUCH THE SYMLINKS, ACT LIKE THEY AREN'T THERE.
Last edited by Myrder; 12th May 2014 at 07:13 PM.
The Following 25 Users Say Thank You to Myrder For This Useful Post: [ View ]
6th June 2013, 07:57 PM   |  #2  
Myrder's Avatar
OP Recognized Contributor
Flag Oklahoma City
Thanks Meter: 1,043
 
852 posts
Join Date:Joined: Oct 2012
Donate to Me
More
================================================== ===============================

BREAK TIME!!!!!! (I literally took a break here... you should too.)

================================================== ===============================
Last edited by Myrder; 6th June 2013 at 08:00 PM.
The Following 6 Users Say Thank You to Myrder For This Useful Post: [ View ]
6th June 2013, 07:57 PM   |  #3  
Myrder's Avatar
OP Recognized Contributor
Flag Oklahoma City
Thanks Meter: 1,043
 
852 posts
Join Date:Joined: Oct 2012
Donate to Me
More
Now tha we have the BASIC port done... time to get into the nitty-gritty.

Here I won't be doing this in steps like I did the first part of this guide... Just because it's a little more "hands on" if you will.

Go ahead and open both WORKING_Folders
My set up, just as an example:


With this, you're moving files from left -> right


Navigate to /system/bin

Code:
compare both and see what's missing in BASE
move that over from your POR
Most of the time there isn't anything to move over,
but it doesn't hurt to check.
After that folder navigate to /system/etc/permissions
Code:
scroll through and compare file by file
move over the ones that are in your PORT to your BASE

After that, if your PORT and BASE both have init.d support it wouldn't hurt to move those files over as well. If there are any to move.


Now to move on to /system/lib

Code:
This one will be the most time consuming...
Your ROM won't boot if your missing some libs!!!!
So make sure your being as careful as possible to look at each file.
The ones that are in your PORT and aren't in your BASE
move those over.
I know that one was a little rough on the eyes but, we're almost done. Hang in there.

Last one, /system/xbin

Code:
delete the su binary from your BASE
move the one from your PORT over.
Now, ladies and gentlemen... This is your BASIC port. You still need to diff the framework.jar and services.jar. That's with the help of logcats. I'll walk you through those when you come around to it.
Last edited by Myrder; 12th June 2013 at 09:48 AM.
The Following 7 Users Say Thank You to Myrder For This Useful Post: [ View ]
6th June 2013, 07:57 PM   |  #4  
Myrder's Avatar
OP Recognized Contributor
Flag Oklahoma City
Thanks Meter: 1,043
 
852 posts
Join Date:Joined: Oct 2012
Donate to Me
More
How to diff

First, if you're using Ubuntu or any linux distro type:

Code:
sudo apt-get install meld
that will download and install meld for you. You'll be using this to make changes/fix bugs in your framework.jar/services.jar after looking at your logcat and figuring out what bug you have.



Once you have Meld, scroll down and download my smali/baksmali package.

Now that you have those, unzip and throw smali.jar into its own folder and baksmali.jar in its own folder.

How to use Smali/Baksmali

BAKSMALI

pull your classes.dex out from your BASE, rename it base

open terminal and cd to your baksmali directory
type:
Code:
java -jar baksmali.jar base.dex -o base
That will spawn a folder called base in your baksmali directory.

repeat above for your port, but name this one port.dex


SMALI
move your base folder over to this directory.

open terminal and cd to the smali directory
type:
Code:
java -jar smali.jar base -o classes.dex
put the generated file back into your framework.jar/services.jar where ever you took it from.
Last edited by Myrder; 6th June 2013 at 08:20 PM.
The Following 8 Users Say Thank You to Myrder For This Useful Post: [ View ]
6th June 2013, 07:58 PM   |  #5  
Myrder's Avatar
OP Recognized Contributor
Flag Oklahoma City
Thanks Meter: 1,043
 
852 posts
Join Date:Joined: Oct 2012
Donate to Me
More
MIUI SPECIFICS

This ROM, by far, is the hardest to port from any device. Mainly because it's unlike any other AOSP/AOKP ROM out there. There are certain binaries that you need and without them, your port WILL NOT boot, period.

Code:
First, pick what ROM yore porting. SENSE base MIUI or a NON-SENSE MIUI. 
If you decide to use a SENSE based MIUI, use a stock SENSE ROM. 
If you choose a NON-SENSE MIUI, use an AOSP/AOKP base.
It will work with either one.
If you're porting from another device to EVITA, 
use cm10 for AOSP or Rohans AOKP.


If you decide to port MIUI, work through the first part of my guide. Then follow what's below.

Navigate to /system/bin
Pull the installd binary from MIUI and put it in your base

Navigate to /system/xbin
pull the shelld binary from MIUI and put it in your base
same with the invoke-as binary

Navigate to /system/lib
There are 4 libs that are specific for MIUI, make sure you have them in your base.
Code:
-content-types.properties, needed for themes
-liblbesec.so, LBE Guard, MIUI su
-liblocSDK_2.2.so, prevents network location service FC
    JellyBean-only:
-libjni_resource_drm.so, needed for themes as well

Navigate to /system/etc

Code:
yellowpage.db, if you want to have phone calls... You'll need this
telocation.td, also could be named as telocation.db, location provider service
Navigate to /system/etc/permissions
Add to your base:
Code:
com.nxp.mifare.xml, nfc
MIUI-framework.xml, activates the framework.jar
com.google.android.media.effects.xml, needed for Gallery
com.google.widevine.software.drm.xml, could effect Playstore
com.google.android.maps.xml, Gmaps
BUILD.PROP EDITS
Along with what's needed in the first part, these are needed as well to have a true MIUI port.

Code:
ro.config.ringtone=
ro.config.notification_sound=
ro.config.alarm_alert=
ro.config.sms_received_sound=
ro.config.sms_delivered_sound=
UPDATER-SCRIPT
Any release/port of MIUI should have this line:
Code:
set_perm(0, 0, 06755, "/system/xbin/invoke-as");
Example so you know what I mean:
Code:
set_perm(0, 0, 06755, "/system/xbin/librank");
set_perm(0, 0, 06755, "/system/xbin/procmem");
set_perm(0, 0, 06755, "/system/xbin/procrank");
set_perm(0, 0, 06755, "/system/xbin/su");
set_perm(0, 0, 06755, "/system/xbin/invoke-as");
set_perm(0, 0, 06755, "/system/xbin/tcpdump");
Probelms with the SU binary?

Remember I told you not to mess with symlinks? Well.. You need to if you have SU problems...
put this line into your Updater-script
Code:
symlink("/system/xbin/su", "/system/bin/su");
paste it somewhere after
Code:
symlink("busybox"[big code bunch like "/system/xbin/etc]
but before
Code:
Unmount("/system")

Logcat showing something to the effect of "failed to initialize shell service?

That would be a shelld problem..
Use the Android kitchen to break down your boot.img in your base into the ramdisk and zImage(kernel)

In the ramdisk there is a file called init.rc
Open with a text editor
At the very bottom, paste these lines:
Code:
service shelld /system/xbin/shelld
      class main
Then...
/dance.
You now have a working MIUI port, bugs are your only issue now.


Last edited by Myrder; 12th June 2013 at 09:11 AM.
The Following 5 Users Say Thank You to Myrder For This Useful Post: [ View ]
6th June 2013, 07:58 PM   |  #6  
Myrder's Avatar
OP Recognized Contributor
Flag Oklahoma City
Thanks Meter: 1,043
 
852 posts
Join Date:Joined: Oct 2012
Donate to Me
More
Last edited by Myrder; 6th June 2013 at 08:27 PM.
The Following 4 Users Say Thank You to Myrder For This Useful Post: [ View ]
6th June 2013, 07:59 PM   |  #7  
Myrder's Avatar
OP Recognized Contributor
Flag Oklahoma City
Thanks Meter: 1,043
 
852 posts
Join Date:Joined: Oct 2012
Donate to Me
More
How to Obtain a Logcat


Download my adb/fastboot zip

Once downloaded, open cmd prompt in the adb dir. If using win7, hold shift+right click - If you're on Ubuntu CTRL + ALT + T

Type: adb devices - your serial number should show in cmd prompt.

Then type: adb logcat > logcat.txt - this will spawn a .txt file in your adb folder.

Recreate the error while you're running above cmd.

Press Ctrl+C to stop logcat.

Post logcat.txt contents into www.pastebin.com (make sure expire option is on the never option)
Last edited by Myrder; 6th June 2013 at 08:31 PM.
The Following 3 Users Say Thank You to Myrder For This Useful Post: [ View ]
6th June 2013, 08:21 PM   |  #8  
BreatheHT's Avatar
Senior Member
Flag Diamond Bar
Thanks Meter: 204
 
299 posts
Join Date:Joined: Mar 2012
Donate to Me
More
OMG... I love you man!!! Great stuff
6th June 2013, 08:28 PM   |  #9  
Myrder's Avatar
OP Recognized Contributor
Flag Oklahoma City
Thanks Meter: 1,043
 
852 posts
Join Date:Joined: Oct 2012
Donate to Me
More
Quote:
Originally Posted by BreatheHT

OMG... I love you man!!! Great stuff

I do believe I left a few things out but I can't remember what.. an hr and a half of straight typing has me a little confused... lol
The Following User Says Thank You to Myrder For This Useful Post: [ View ]
6th June 2013, 08:30 PM   |  #10  
nbunn's Avatar
Senior Member
Thanks Meter: 185
 
616 posts
Join Date:Joined: Oct 2009
More
Oh goodness I see a lot of bricks in the Evita's future. Haha. Good stuff though man!

Sent from my One X using xda app-developers app

The Following User Says Thank You to nbunn For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes