Sunday, November 16, 2014

How to Port Rom | Mediatek Devices | Easy Method | With Pictures


NOTE: Ak-Tricks is not responsible if you brick your phone. This tutorial has been tested on many devices. Make a nandroid backup before flashing the new ported ROM


This is a full detailed guide with screenshots of 'How to port Rom' of Mediatek SoCs. I reapeat this only for devices that have mediatek chipsets. Moving to our guide, here I'll show how you can port Rom of similar chipset and Rom of different chipsets. So yeah!

Just to let you know, followings are the chipsets that work while porting from chipset other than your phone's chipset
  • MT6589 to MT6577
  • MT6582 to MT6572
  • MT6577 to MT6572
 Only ICS to ICS version, and Jellybean to Jellybean version
Note: May work from 4.1 to 4.2 (Not sure but you can give it a try)

 Requirments:

  1. WinRar or 7-zip (or any other tool similar to them)
  2. Notepad++
  3. Stock Rom of your phone. (that comes with your phone)
  4. Port Rom (that is the rom you want to run in your phone)
  5. Last but not the least, a brain and little patience. :D
First of all, Make 2 folders for your ease, name one folder 'Base ROM' and the other 'Port ROM'.
Here the Base ROM is your phone's orignal ROM and Port ROM is the one you want to run in your phone.


These are the ROMs i've. Stock Rom is the orignal, and the other port rom.



Now we need to extract the above downloaded roms in their respective folders (folders shown above). Open both the folders like shown below.



Moving to our guide now. :)


How to Port ROM from similar chipset






  •  1. Go to system in both folders and copy Vendor and Usr folder from Base Rom to Port Rom.


     



  • 2. Go to system/lib in both folders and copy modules and hw folder and libncurses.so file and paste it into Port Rom folder.



    Note: If you're porting LeWa OS or MIUI Rom, no need to to copy libncurses.so file. Since i'm porting LeWa From LeWa so there is no Libncurses.so file. I'll show later what to do more while porting LeWa OS.
  • 3. Go to /system/etc and copy Bluetooth and Firmware folder and Vold.fstab and vold.fsta.nand file from Base Rom and paste it into Port ROM.


  • 4. Now to final part, go back to the main folder and copy boot.img from Base ROM and paste it into Port Rom folder.
  • 5. Now Go to META-INF\com\google\android in both base rom and port rom folder and open Updater-script using Notepad++

    • Look for below lines
      format("ext4", "EMMC", "/dev/block/mmcblk0p3", "0", "/system");
      mount("ext4", "EMMC", "/dev/block/mmcblk0p3", "/system");
    • Change 'mmcblk0p3' with your Base Rom. For example if your base rom has 'mmcblk0p5' and Port rom has 'mmcblk0p3' then change it into 'mmcblk0p5' as your base rom.


  •  6. Now finally archiving it into zip file. Make sure you select zip not rar.




    Note: The above guide was for the ROMs other than LeWa OS and MIUI Roms. You just have to make little changes in the boot.img file. For that you must have (Unpack/pack .img tool or Android Kitchen). I've android kitchen i'll use that. You can download tool from here

    • Now flash it via CWM or TWRP.

    For LeWa/MiUi OS:

    • Open init.rc file with notepad++ after unpacking the boot.img
    • Find for these lines

       on early_property:ro.build.type=user
        write /proc/bootprof "INIT: user build setting"
        export BOOTCLASSPATH /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/mediatek-common.jar:/system/framework/mediatek-framework.jar:/system/framework/secondary-framework.jar:/system/framework/CustomProperties.jar:/system/framework/mediatek-telephony-common.jar:/system/framework/mediatek-op.jar
      
       on early_property:ro.build.type=userdebug
        write /proc/bootprof "INIT: userdebug build setting"
        export BOOTCLASSPATH /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/mediatek-common.jar:/system/framework/mediatek-framework.jar:/system/framework/secondary-framework.jar:/system/framework/CustomProperties.jar:/system/framework/mediatek-telephony-common.jar:/system/framework/mediatek-op.jar
      
      
       on early_property:ro.build.type=eng
        write /proc/bootprof "INIT: eng build setting"
        export BOOTCLASSPATH /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/mediatek-common.jar:/system/framework/mediatek-framework.jar:/system/framework/secondary-framework.jar:/system/framework/CustomProperties.jar:/system/framework/mediatek-telephony-common.jar:/system/framework/mediatek-op.jar:/system/framework/emma.jar
    • Add this line if system port Rom is LeWa :/system/framework/lewa-framework.jar at the end of first paragraph and 3rd paragraph. If it is MUII ROM then add this line :/system/framework/miui-framework.jar at the end of first and 3rd paragraph.
    • Finally Compile the boot.img and you're done.

    For Porting Fix:

    • Change respective files shown if facing that specific problem below from Port Rom and copy Base Rom files and paste to Port.

    Code:
     *system/etc/permissions
     *system/etc/security
     *system/etc/audio
     *system/etc/wifi
     *system/lib/drm
     *system/lisystem/lib/soundfx

    Porting Fix For Advance Users:

    Framework Fix:

    • Decompile framework.jar.
    • Goto \smali\com\mediatek
    • Replace all files from Base to Ported rom's image
    • Now goto \smali\com\android\server and similarly replace all files from Base Rom to Port Rom.
      This would fix bootloop, mms.apk, phone,apk and setting.apk force closes.

    Camera Fix:

    •  Replace Files all the below files from Port Rom with Base Rom

      \system\lib\libcamalgo.so
      \system\lib\libmhaldrv.so
      \system\lib\libcamera_client.so
      \system\lib\libcameracustom.so
      \system\lib\libcameraprofile.so
      \system\lib\libcameraservice.so

    GPS Fix:

    •  Replace

      /system/xbin/libmnlp

    For Bluetooth and WiFi Fix:

    • Replace

      /system/lib/libbluetooth_mtk.so
      /system/lib/libbluetoothem_mtk.so

    For Radio Fix:

    • Replace
      \system\lib\libaudio.a2dp.default.so
      \system\lib\libaudio.primary.default.so
      \system\lib\libaudiocompensationfilter.so
      \system\lib\libaudiocustparam.so
      \system\lib\libaudioeffect_jni.so
      \system\lib\libaudioflinger.so
      \system\lib\libaudiosetting.so
      \system\lib\libfmar1000.so
      \system\lib\libfmcust.so
      \system\lib\libfmjni.so
      \system\lib\libfmmt6616.so
      \system\lib\libfmmt6620.so
      \system\lib\libfmmt6626.so
      \system\lib\libfmmt6628.so

    For Fixing WiFi and FM-Radio do this

      • Open build.prop in system folder. Open with Notepad++
      • And find for this line
        fmradio.driver.chip=1
      • Change it to 3 if your device is MT6628

        fmradio.driver.chip=3

        Not needed in MT6672

      • Find these lines
        mediatek.wlan.chip=MT6620
        mediatek.wlan.module.postfix=_mt6620
      • Replace by your Base Rom e.g. if your rom has MT6628 then change MT6620 to MT6628

        mediatek.wlan.chip=MT6628
        mediatek.wlan.module.postfix=_mt6628


      Now open updater script and Find this line symlink("wlan_mt6620.ko", "/system/lib/modules/wlan.ko") if not found then add and change MT6620 to your respective number which is MT6628


    How to Port ROM from different chipset



    1. Download Stock ROM of your phone and the ROM which you want to PORT.

    2. Repeat Step 1, 2 & 3 from the upper part i.e (PORT FROM SIMILAR CHIPSET).

    3. Go to system in both Base and Port ROM's folders. And Open build.prop using Notepad++. 

    4. Search for this line ro.mediatek.platform. And replace the chipset with your ROM's chipset.

    Before


    After



    You can see the two highlighted lines. The above one is of PORT ROM and the below one is of BASE ROM.

    5. Now Go to META-INF/com/google/android in both the folders and open Updater-script with Notepad++.

    6. Search for this line set_perm(0, 0, 0644, "/system/vendor/lib/hw/gralloc.mt65xx.so"); if found then change the red highlighted with your CPU. And if not found then add it with set_perm lines.

    Before




    After



    You can see the highlighted lines.

    7. Now decompile both rom boot.img with any tool or with Android Kitchen and do the following steps.





    8. The above two extracted images are shown. Now delete both the zImage file from both the folders and rename PORT rom's boot.img-ramdisk folder to PORT-ramdisk.


    9. Now copy all files of Port-ramdisk folder to your Stock rom's image boot.img-ramdisk folder






    10. Now goto boot.img-ramdisk i.e. of yours stock rom and Open init.rc using Notepad++.


    11. Search for the lines shown below.


     on early_property:ro.hardware=mt6582
      setprop ro.mtk.hardware mt6572
      
     on early_property:ro.hardware=mt6589
      setprop ro.mtk.hardware mt6572

    12. Keep the upper line unchanged i.e early_property.

    BEFORE


    AFTER




    13. Now decompile the boot.img and copy it to your Port Rom folder.

    14
    . Repeat 4th and 6th step of the 1st section i.e (porting from similar chipset) and you're done.




    IF YOU FACE ANY PROBLEM REGARDING THIS TUTORIAL, SHARE IN THE COMMENTS AREA.



  • 1 comment: