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

Search This thread

Myrder

Senior Member
Oct 30, 2012
855
1,025
Oklahoma City
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:
[COLOR="Red"]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...
[B][I][U]DON'T EVEN THINK ABOUT IT!!![/U][/I][/B][/COLOR]

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.
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:
[B][I][U]PATIENCE[/U][/I][/B] - 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.
[B][I][U][COLOR="Red"]DON'T TOUCH THE SYMLINKS, ACT LIKE THEY AREN'T THERE.[/COLOR][/U][/I][/B]

 
Last edited:

Myrder

Senior Member
Oct 30, 2012
855
1,025
Oklahoma City
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:

Screenshot_from_2013_06_12_02_42_42.png

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:
[B]This one will be the most time consuming...[/B]
[COLOR="Red"]Your ROM won't boot if your missing some libs!!!![/COLOR]
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:

Myrder

Senior Member
Oct 30, 2012
855
1,025
Oklahoma City
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:

Myrder

Senior Member
Oct 30, 2012
855
1,025
Oklahoma City
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
    [COLOR="Red"]JellyBean-only:[/COLOR]
-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");
[B]set_perm(0, 0, 06755, "/system/xbin/invoke-as");[/B]
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"[B][big code bunch like "/system/xbin/etc][/B]
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. :p


 
Last edited:

Myrder

Senior Member
Oct 30, 2012
855
1,025
Oklahoma City
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:

nbunn

Senior Member
Oct 1, 2009
625
183
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
 
  • Like
Reactions: saham424

InflatedTitan

Senior Member
Jul 7, 2012
2,966
1,169
OnePlus 9 Pro
Fail... Thanks for that. I knew I would probably mess something up.. lol

Lol sorry man. I gave it another shot last night and it acts like it flashes... Then says failed. But it'll let me reboot system. (It usually says no OS when something fails) when I reboot it'll go to the ROMs boot animation. But never gets past that. I'll grab a log cat this afternoon, it was late last night and I work extremely early. Your guide is the way I've been doing them and they always worked. Don't know what's up with this one.

Carbon, black bean, and deviantxone I was able to literally swap apps, framework, media, fonts... Then swap permissions.. Then set perm lines in updater script and those 3 worked perfectly. This one won't wtf lol

Sent from my One X using Tapatalk 2
 
Last edited:

Myrder

Senior Member
Oct 30, 2012
855
1,025
Oklahoma City
Lol sorry man. I gave it another shot last night and it acts like it flashes... Then says failed. But it'll let me reboot system. (It usually says no OS when something fails) when I reboot it'll go to the ROMs boot animation. But never gets past that. I'll grab a log cat this afternoon, it was late last night and I work extremely early. Your guide is the way I've been doing them and they always worked. Don't know what's up with this one.

Carbon, black bean, and deviantxone I was able to literally swap apps, framework, media, fonts... Then swap permissions.. Then set perm lines in updater script and those 3 worked perfectly. This one won't wtf lol

Sent from my One X using Tapatalk 2

Flash again but before you reboot after the fail,

Type adv pull /tmp/recovery.log

That will tell you why it failed in twrp

Sent from my HTC One XL using xda premium
 
  • Like
Reactions: InflatedTitan

Top Liked Posts

  • There are no posts matching your filters.
  • 24
    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:
    [COLOR="Red"]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...
    [B][I][U]DON'T EVEN THINK ABOUT IT!!![/U][/I][/B][/COLOR]

    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.
    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:
    [B][I][U]PATIENCE[/U][/I][/B] - 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.
    [B][I][U][COLOR="Red"]DON'T TOUCH THE SYMLINKS, ACT LIKE THEY AREN'T THERE.[/COLOR][/U][/I][/B]

    7
    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.​
    6
    =================================================================================

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

    =================================================================================
    6
    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:

    Screenshot_from_2013_06_12_02_42_42.png

    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:
    [B]This one will be the most time consuming...[/B]
    [COLOR="Red"]Your ROM won't boot if your missing some libs!!!![/COLOR]
    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.
    5
    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
        [COLOR="Red"]JellyBean-only:[/COLOR]
    -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");
    [B]set_perm(0, 0, 06755, "/system/xbin/invoke-as");[/B]
    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"[B][big code bunch like "/system/xbin/etc][/B]
    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. :p