ALL IN ONE PORTING GUIDE
by @tushartomar
Code:
/* * Your warranty is now void. * * I am not responsible for bricked devices, dead SD cards, * thermonuclear war, or you getting fired because the alarm app failed. Please * do some research if you have any concerns about features included in this ROM * before flashing it! YOU are choosing to make these modifications, and if * you point the finger at me for messing up your device, I will laugh at you. */
INDEX:
GUIDE FOR MTK
MTK BUG FIXING
RECOVERY PORTING
QUALCOMM BUG FIXING
ABOUT ME :
My name is Tusharaka tomar AlphaGeek , mostly known for my work for Coolpad Note 3 , Note 3 Lite and Note 3 plus. A blogger and a YouTuber , ex member of A.M.T(anymous mediatek team)and a founding member of Team Zero
Update:-
Code:
*Updated Bug Fix Guide for MTK *Added SNAPDRAGON Bug fix guide. *Guide to port TWRP also updated. *Improved the thread. *Added more fixes. *Qualcomm porting guide added.
This is for all those users who want to port roms and use them in their devices.
But , before porting any rom,here are some of the main things you should keep in mind.
1)Base Rom :-
What is a Base Rom?
Code:
Base Rom is reffered to the Stock rom or the Default Rom of your device or sometimes the rom from which you will take base files(libs,apns,modem etc).
2)Port Rom
What is a Port Rom?
Code:
Port Rom is the rom which you will port for your device. like if you are working a rom of another device having similar specifications and porting it for your device then it is called PORT ROM.
3)Kernel
What is a Kernel?
Code:
The kernel is a computer program that is the core of a computer's operating system, with complete control over everything in the system. the central or most important part of something In easy words kernel acts as the middle man between the Software and the Hardware
When porting a rom , you should check the Kernel version of the Port Rom and the Base Rom
They both should be similar,
like you can port from :
3.18.xx to 3.18.xx only
3.10.xx to 3.10.xx only
BUGS IN THE BASE ROM OR IN THE PORTROM.
Yes , our Base Rom and the Port roms may contain bugs,
Those bugs will exist in our final Ported Rom also so , fixing those is not possible - Its always recommended to use a Stable or near to Stable Roms but hi, Custom Roms are made for pleasure only and these roms can't take place of stock roms.
Many users don't like Stock Rom (i.e Default Rom) so , they look for a Custom Rom.
Now let's talk about the main topic for which YOU ARE HERE!
PORTING A ROM!
In this Guide, i will tell one of the most easy way to BOOT UP THE ROM.
So, lets begin,
This guide will focus on MT6735/MT6753 porting.
Device i used is Coolpad Note 3 Lite
CPU:MT6735
But, it will work mostly on all MT675X SoCs , this can also be useful for MT67XX series but , My main focus is on MT675X
Without any delay let's talk about how you should porta ROM and what should be your focus at
YOU SHOULD FOCUS ON BOOTING THE ROM INSTEAD OF BUG FIXING AND DOING OTHER THINGS.
WHEN YOU PORT A ROM CHANGE FILES WISELY
DONT JUST COPY PASTE(always replace the files)
PORTING A ROM CAN GET TOUGH ACCORDING TO THE ROM, LIKE PORTING AN AOSP BUILD CAN BE EASY BUT PORTING A MIUI BUILD IS CONSIDERED ONE OF THE MOST TOUGHED AND IRRITATING THING.
RESPECT THE EFFORTS BY THE PREVIOUS DEV.
CREDITS, WHEN YOU PORT A ROM THAT ROM WAS MADE BY SOMEONE , PORTED BY SOMEONE or BUG FIXED BY SOMEONE - SO BY ANY MEANS IF YOU KNOW THE SOURCE AND THE DEV OR TEAM WHOSE BUILD YOU ARE PORTING PLEASE GIVE CREDIT.
THANKS.
NOW , FINALLY. LET'S TALK ABOUT THE PORTING GUIDE WHICH YOU ALL ARE WAITING FOR.
What you guys need:-
Code:
1)Base Rom 2)Port Rom 3)Any good Notepad 4)Any Boot.img repack or unpack tool 5)Brain
Now , if you have all the above mentioned things , Lets proceed.
BOOT.IMG :-
BOOT.IMG contains all the magic , it has the KERNEL inside which is one of the main thing.
Porting from Same CPU & GPU:-
NOTE:- When you are porting from a Similar devicehaving same chipset like porting from:-
MT6753 TO MT6753
MT6735 TO MT6735
Use this method (95% times working ):-
System/lib & lib64 :-
Code:
libaudiocomponentengine.so libaudiocustparam.so libnvram.so libnvramagentclient.so libnvram_platform.so libnvram_sec.so libcustom_nvram.so
System/etc :-
Code:
/Firmware folder /apnconfig /spnconfig /agps_profile_conf2 /media_codecs.xml
BLACK SCREEN AFTER LOGO???
REPLACE THIS LIB:- libcam.paramsmgr
To Fix Camera ( sometimes bootloop so try one by one ) :-
from System/lib & lib64 replace all libs starting like this:-
Code:
libcamera.mt6735 (mt6735 is according to my CPU ) libcameracustom.lib etc libcamalgo.lib
Unpack Boot.img of both Base & Port Rom
Code:
replace kernel and init.mt6735.rc ( not recommended always) and Fstab.mt6735
System/Lib(/64)/HW*
Done , Now zip em and flash.
90% Rom will boot with BUGS! ( NO ROM IS THERE WITHOUT BUGS, LOL 😂😜 )
==>READ BUG FIX METHOD ALSO{Later in this Guide}<==
For Cross Porting Like:-
MT6752 etc to MT6753/MT6735
DO REMEMBER TO CHANGE :-
Code:
System/xbin/mnld System/mddb System/etc/firmware System/etc/Apnconf System/etc/spnconf
In lib(/64)/HW :- add files accordingly to your CPU or rename them.
BLACK SCREEN AFTER LOGO :-
Code:
libcam.paramsmgr
BOOT.IMG PORTING:-
UNPACK both Base Rom and Port Rom Boot.img
In PORT ROM BOOT.IMG:-
Code:
replace the boot.img-kernel
and in ramdisk folder add these files from Base Boot.img to Port Boot.img
Code:
fstab.mt6735 init.mt6735.rc init.mt6735.usb.rc
Note:- Name may differ a little according to your CPU
REPACK THE BOOT IMAGE
NOTE:- If u get WIFI AND BLUETOOTH NOT SWITCHING ON OR BATTERY PERCENTAGE THEN REPLACE
Code:
init.project.rc
Done , You have succesfully ported Boot.img
Now , Lets focus on BUG FIXING
Bug Fixing isnt easy as it seems.
Replacing any wrong file or not supported file can easily give you bootloops.
It depends from ROM to ROM.
BUG FIXING[MTK]
Let's Begin.
If any lib missing in Base leave that - DONT WORRY
NOTE:- CHANGE LIB FILES FROM BOTH lib & lib64 folders
[I][SIZE="3"]
If you face "This rom is for Coolpad Note 3 Lite and your device is "K4Note"
To remove this delete the assertlines in Updater-script
ALWAYS CHANGE DPI IN BUILD.PROP ACCORDING TO YOUR STOCK ROM
Bootloop when porting
Code:
*libandroid_runtime.so *libandroid_servers.so *libmedia_jni.so *Repack boot.image (properly)
RadioFM
Code:
\system\bin\fmradio \system\etc\firmware\mt6620_patch_e3_hdr.bin \system\etc\firmware\mt6620_patch_e6_hdr.bin \system\etc\firmware\WMT.CFG \system\lib(/64)\libfmcust.so /system/lib(/64)/libfmjni.so
Sensors
Code:
/system/bin/akmd* /system/lib/libsensors.so /system/lib/libms3c_yamaha.so ( acc. To device) /system/etc/firmware (folder) /system/bin/servicemanager /system/bin/sensorservice System/bin/msensord system/etc/permissions/:- android.hardware.sensor.xxxxx.xml
FIX Offline charging:-
Code:
In Boot.img -> sbin/healthd System/Lib(/64):- Showlogo System/bin:- Kpoc_charger
Bluetooth\Wifi not turning On\Off(old)
Code:
\system\lib\module\mtk_stp_wmt
Wifi
Code:
/system/etc/wifi (folder) /system/bin/netcfg /system/bin/dhcpcd /system/bin/ifconfig /system/bin/hostap /system/bin/hostapd /system/bin/hostapd_bin /system/bin/pcscd /system/bin/wlan* /system/bin/wpa* /system/lib(/64)/libhardwarelegacy.so
Hotspot:-
Code:
/system/bin/netd
*follow Wifi fix also*
Camera
Code:
firstly try one by one: \system\lib(/64)\libcameracustom.so \system\lib(/64)\libcameraservice.so System/lib(/64)/camalgo /system/etc/media_profiles.xml /system/lib(/64)/libcamera.so /system/lib(/64)/liboemcamera.so \system\lib(/64)\hw\camera.default.so \system\lib(/64)\libcamera_client.so \system\lib(/64)\libcamer aprofile.so \system\lib(/64)\libmhal.so \system\lib(/64)\libmhalcontent.s o \system\lib(/64)\libmhaldrv.so \system\lib(/64)\libmhalmdp.so \system\lib(/64)\libmhalpipe.so \system\lib(/64)\libmhalscenario.so \system\lib(/64)\libmhalutility.so \system\etc\permission\android.hardware.camera.front.xml
Other cam files if any
*try one by one*
CamCoder/HwDecoder
Code:
\system\lib\libOmx*.so system/etc/media_codecs Green/pink Camera / video lagging system/lib(/64)/libdpframework.so
SD card/Memory
Code:
mt67**.fstab in boot.img /system/bin/vold /System/bin/pq System/bin/sdcard
WhatsApp Media Fix:-
Code:
from System/bin/ replace these files:- Media mediaserver netd service servicemanager surfaceflinger
GPS
Code:
\system\xbin\libmnlp /system/etc/gps.conf
Touch Screen(Haptic)
Code:
/system/usr /system/usr\keylayout\Generic.kl ->fix HomeKey
NFC ( experimental)
Code:
System/etc/: Nfc files System/etc/permissions/ nfc files System/lib/libnfc****** ( all starting from nfc )
Sim1/2 (RIL)
((Trustbin.bin flash it accordingly to LP or MM etc of stock rom))
Code:
\system\etc\firmware\modem.img \system\etc\permission (RIL) Try these aswell if ( you may suffer Bootloop ) /System/bin/mtkrild /System/bin/mtkrildm1 /system/bin/stmd
EXPERIMENTAL FIX for ril:-
Code:
System/ Lib(/64)/ :- Nvram Nvram_sec Nvram_platform Nvrammagentclient System/bin:- Gsm*** System/etc/trustzone Lib(/64):- Libril Libc2k*** Librilmtk
Audio/Sound:-
Code:
\system\lib\libaudio* .so system/lib(/64)/libaudiocustomparam system/lib(/64)/libaudiopolicymanager system/lib(/64)/libaudiopolicyservice system/etc/audio_effects system/etc/audio_policy System/lib(/64)/soundfx
Sometimes if Sound isn't working fully :::::
Code:
System/lib(/64)/hw/audioxxxxxxxxx (audio files)
Bluetooth:-
Code:
system/etc/bluetooth System/etc/permissions/android.hardware.bluetooth.xml /system/bin/uim* /system/bin/bluetooth* /system/lib(/64)/libbluetooth_mtk.so /system/lib(/64)/libbluetoothem_mtk.so
Ads
Code:
/system/etc/hosts ->replace with new files or use tweak.
=====>>ADVANCE BUG FIXING:-
Volte Fixing
( Will only work if your Base Rom , Port Rom and Kernel supports VOLTE )
Code:
Boot.img:- Zimage ( kernel - volte supported ) init.volte.rc
==THIS SHOULD NORMALLY FIX but if it doesn't try :- ==
Code:
System Folder:- bin/volte_stack bin/volte_imcb bin/volte_ua lib(/64)/volte_imsm build.prop(Not always required):- ro.mtk_volte_support=1 persist.mtk.volte.enable=1
FingerPrint:-
[Try one by one][If any file missing leave it]
Usual way to fix :-
Code:
System/etc/permissions/android.hardware.fingerprint.xml System/lib(/64)/libgatekeeper.so System/lib(/64)/hw/gatekeeper.mt6735.so System/(/64)/libmcgatekeeper.so System/lib(/64)/hw/fingerprint.default.so ( can break FP in some devices)
Advanced ( if usual doesn't work ):-
Code:
System/bin/:- fingerprintd Gx_fpd tee_deamon Lib64/lib:- ( if any missing leave that) Fpclient Fpalgorithm Fphal FPservice
IF ROM DOESNT BOOT TAKE LOG ( From ADB)
adb shell logcat > log.txt
and check what is causing issue
REFERENCE LINKS :-
Carliv Image Kitchen :-
https://forum.xda-developers.com/and...droid-t3013658
Cross Port and Porting Guides:-
https://forum.xda-developers.com/k3-...cross-t3310605
Unpack and Repack without PC guide:-
Meta-INF Info:-
http://www.mtkroms.com/2015/06/make-...-easy.html?m=1
Meta-Inf generator:- ( Not tested try but its worth a look)
https://forum.xda-developers.com/sho....php?t=1221003
Sample Recovery flashable zip:-
https://forum.xda-developers.com/and...y-zip-t3552916
Assert Failed ?check this:-
http://forums.androidcentral.com/opt...rt-failed.html
Need Some Rom Projects???:-
Go here:-
www.zerodevelopers.blogspot.com
GUIDE FOR SNAPDRAGON
Qualcomm Rom Porting
Porting from same chipset like SD410 to SD410
Use Android Image Kitchen to unpack the base and port boot.img in BOOT-BASE and BOOT-PORT folder.
2. Replace the files from the BASE TO PORT:
Code:
boot.img-zImage boot.img-dtb
Then in the BOOT-PORT/ramdisk/ folder compare the file fstab.qcom with that of the base i.e. BOOT-BASE/ramdisk/fstab.qcom.
REPACK BOOT.IMG
Replace this Boot.img in port.
*The Rom will boot with bugs .. ril , wifi etc
FOR MORE INFO
Do , have a look at these guides :
1 http://www.miuios.in/2014/12/how-to-...lcomm.html?m=1
2.http://en.miui.com/thread-70745-1-1.html
BUG FIXING FOR SNAPDRAGON
NOTE: THESE WORKED FOR FEW ROMS IN YU MSM DEVICES NOT SURE IF WILL WORK IN ALL.......
If you have properly edited the boot.img then only these fixes will help you
Compare the PORT FILES FROM BASE FILES:
Code:
uneventd.qcom.rc ( will fix sensor ) uneventd.rc
Copy and replace the following files from Base (ROM-PORTING/BASE) to Port (ROM-PORTING/PORT) to solve the given issues:
No sound bug:
Code:
system/lib/hw/ audio.primary.msm****.so audio.primary.default.so system/lib64/hw/ audio.primary.msm****.so audio.primary.default.so
Sound working in speaker but not working through headphones or vice-versa:
Code:
system/etc/ mixer_paths.xml (you can also try patching it with the base) Distorted Outgoing Sound during Phone call or Partial Sound: system/etc/acdbdata/MTP/ MTP_***.acdb (all files)
Home or any other button not working:
Code:
system/usr/keylayout/ goodix.kl gpio-keys.kl (important) Generik.kl
Video hw encoding/decoding not working:
Code:
system/etc/firmware/ venus.*** (all files starting with ‘venus’)
Sensors not working:
Code:
system/lib/hw/sensors.msm****.so (or sensors.lsm6db0.so) system/lib64/hw/sensors.msm****.so (or sensors.lsm6db0.so) system/lib/libsensorservice.so system/lib64/libsensorservice.so
Led notification not working:
Code:
system/lib/hw/lights.msm****.so system/lib64/hw/lights.msm****.so
Vibration not working:
Code:
system/lib/libhardware_legacy.so system/lib64/libhardware_legacy.so
FM not working:
Code:
system/lib/qcomfm_jni.so system/lib64/qcomfm_jni.so
Wifi not working:
Code:
system/lib/modules/wlan.ko
[Note: In MIUI, wlan.ko is renamed as pronto_wlan.ko and is also kept in system/lib/modules/pronto/ folder, so you have to replace in both the places.]
In some phones you may not find wlan.ko file. In that case you may try replacing these files
Code:
system/lib/libwcnss_qmi.so system/lib64/libwcnss_qmi.so
For slow WiFi network and other WiFi related issues replace these files:
Code:
system/etc/wifi/ -- all files system/etc/firmware/wlan/ -- all files
Camera and flash not working:
Code:
system/vendor/lib/ :- libactuator_***.so (all files starting with ‘libactuator’) libchromatix_***.so (all files starting with ‘libchromatix’) libmmcamera_***.so (all files starting with ‘libmmcamera’) system/lib/:- libmm-qcamera.so libmmcamera_interface.co system/lib/hw/ camera.msm****.so
[Note: If such files are also available in your BASE/system/vendor/lib64/ then you have to copy those files also to their respective place in PORT]
GUIDE TO PORTRECOVERY
PORT TWRP RECOVERY
Things You are Required ::-
Code:
1.Android Image Kitchen 2.Notepad++ 3.Base Recovery 4.TWRP to Port 5.Brain
First of All , You Guys need to unpack Recovery.img i.e both Stock Recovery or TWRP Recovery.
After this :-
You need to Copy these files from your Stock Recovery to the TWRP Recovery ( which you want to port ) :-
Lets Divide Step by Step ::--
*REPLACE FROM STOCK TO PORT*
STEP1:
Inside Ramdisk Folder ::::::
Code:
1.meta_init.modem.rc 2.meta_init.project.rc 3.meta_init.rc
STEP2:
Now replace your Kernel usually named as zimage-kernel
STEP3
Inside Ramdisk Folder(boot.img):::::::
Code:
1.fstab 2.ueventd.rc 3.ueventd.goldfish.rc.
STEP4
INSIDE RAMDISK/ETC
Code:
recovery.fstab
STEP5
Open Default.prop
and Compare it with stock Default.prop or your Build.prop ( add values from build.prop )
=============>>>>>>>
DONE!!!!! EVERYTHING IS IN PLACE
NOW REPACK IT AND FLASH.
YOU HAVE PORTED A RECOVERY....
WARNING: Do not replace any file unnecessarily, because it may give rise to new bugs in place of solving it. Always be specific!
Now Mostly its the end of the Guide / Tutorial / G.K on porting or whatever you call it.
Once again , i (Kuber Sharma) hope you guys succesfully learn porting and making roms soon.
You guys have my Best Wishes.
Thank You.
CREDITS:-
TUSHAR TOMAR FOR writing this.