HOW TO PORT ANY ROMS FOR QUALCOMM DEVICES. - THIS GUIDE IS FOR PORTING ROMS OF QUALCOMM SNAPDRAGON DEVICES SHARING SAME CHIPSET. AND BY THIS METHOD YOU CAN PORT ANY ROM LIKE, MIUI,CYANOGEN MODE ROMS AND ANY ONE OF YOUR CHOICE.
DISCLAIMER: This guide is written to help the emerging devs. Soft bricking is common in porting ROMs. But, I am not responsible if you somehow hard-brick your device. Do it at your own risk.but I will take all the credit you can give me if it works for you.
PREREQUISITES
Things required for porting:
➤ Device for which the ROM you want to port.
➤ Port ROM i.e. the ROM of other devices sharing same chipsets which you want to port(here we have MIUI7)
➤ Base ROM i.e. the ROM which is exclusively made for your device.
➤ PC with windows or any linux OS.
➤ Android Image Kitchen to modify boot.img - CLICK HERE
➤ Notepad++ to edit scripts. - CLICK HERE
➤ Meld to compare files and folders - CLICK HERE
➤ Winrar or 7zip for dealing zips - CLICK HERE
➤ Apktool (for advance tasks only) - CLICK HERE
➤ And a normal working mind and some common sense
IMPORTANT NOTES
➤ This guide will teach you to port ROMs from devices with similar hardware specs and same Qualcomm Snapdragon chipset.
➤ The Port ROM and the Base ROM should have the same android version.
➤ ROMs containing DAT(system.new.dat) files should be properly unpacked.
➤ this guide is based on this configuration:
⏩ BASE ROM: Micromax Knight (ARM64)(MSM8939)
⏩ BASE ROM: Stock system( system.img from firmware)
⏩ ANDROID VERSION: 5.0.2 Lollipop
⏩ PORT DEVICE: YU Yureka (ARM64)(MSM8939)
⏩ PORT ROM: MIUI7 Lollipop
PREPARING PORTING ENVIRONMENT
1 Make sure you have plenty of storage in your PC.
2 Make a folder named EXP MIUI (you can take whatever name you want)
3 Inside that folder create two folders: (i) BOOT-EDITING (ii) ROM-PORTING
4 In ROM-PORTING folder create two folder named as BASE and PORT and Create same folder as BASE and PORT in BOOT-EDITING folder too.
5 Now place the extracted Port ROM(i.e. MUI7) in PORT folder and Base ROM(i.e. STOCK) in BASE follder.
6 Similarly place the MIUI7 boot.img in BOOT-PORT folder and STOCK boot.img in BOOT-BASE folder.
These steps are required to properly organize the project and will be helpful in our later discussions.
CLEANING UP:
Just delete some unwanted files and keep only 'META-INF' folder, 'data' folder(if available), 'system' folder, 'boot.img' and 'file_contexts' file(if available) in PORT Folder.
Now let's do some work to make the Port ROM boot first.
1 Open the updater-script file in PORT/META-INF/com/google/android/ with Notepad++.
2 Delete the first line containing "get_device_compatible(...."or"assert(getprop..." which restricts the flashing process to other devices,
3 Then delete the lines containing scripts for flashing radio,modem image etc. which are not required for our base device.
boot.img editing -
1. Use Android Image Kitchen to unpack the base and port boot.img in BOOT-BASE and BOOT-PORT folder.2. Replace the files boot.img-zImage, boot.img-dtb, boot.img-ramdisk.cpio.gz (not so important) in BOOT-PORT/split_img/ with that of BOOT-BASE/split_img.
3. Then in the BOOT-PORT/ramdisk/ folder compare the file fstab.qcom with that of the base i.e. BOOT-BASE/ramdisk/fstab.qcom. (You can use Meld for it.)
EDITING fstab.qcom USING MELD: STEP 1 |
EDITING fstab.qcom USING MELD: STEP 2 |
After this repack your boot.img and place it in your port ROM folder (i.e. PORT) and create a flashable zip. You will be able to boot this time. But, you may face sensors, sound, camera, ext sd-card etc. issues. So let us move on to fix those issues through boot.img first.
4. If the port device doesn’t support external sd-card but your base device does then you make the following changes to your BOOT-PORT/ramdisk/init.qcom.rc file:
Remove ‘#’ from the lines containing scripts for mounting or fusing ‘sdcard1’. You can do this simply by comparing the port init.qcom.rc with that of base through Meld application. (Note: You may also need to add some lines if missing in the port init.qcom.rc)
5. After sd-card, let’s move towards fixing camera, led, sensors etc. issues. For that we need to edit the init.rc and init.target.rc files.
6. Even after doing the above steps you may find that sensors are not working. So for that you have to do the following step –
Compare the port uneventd.qcom.rc in BOOT-PORT/ramdisk folder with that of base and add the missing lines to the port. This will fix your sensors issue.
7. Similarly compare other BOOT-PORT files like uneventd.rc, file_contexts etc. with that of BOOT-BASE and use your brain to replace required lines.
8. To fix other issues use your common sense.
9. If you are doing boot.img editing at the beginning of your project, then some of you may find that even after doing all these steps, sensors, led, camera etc. are not working. But don’t lose heart, for that you have to start your ROM Porting.
ROM Porting -
Before starting ROM porting, your base and port ROM should be properly deodexed as I discussed before. If you have correctly edited the boot.img then the following steps will help you to solve your bugs.
1. Debloating Port ROM: Just delete unwanted apps or bloatwares from your port ROM. You will find them in /data/, /system/app/ and /system/priv-app/ folders.
2. According to my previous instructions you should have placed your port ROM to PORT folder and base ROM to BASE folder.
3. Adding missing files and folders: You may add missing files from BASE/system/bin/ to PORT/system/bin/. For this you can just copy all the files from BASE/system/bin/to your PORT/system/bin/ without replacing any file.
Similarly you can do the same process in system/xbin/, system/fonts/, system/etc/, system/usr/ etc. and their sub-folders.
But always use your brain to decide which files you should add and which you should not.
You may also add some missing folders from your base ROM to your port ROM, e.g. system/tts folder, system/etc/init.d and other important folders.
4. Fixing permission related issues: Now you have to work on system/etc/permissions folder. Just compare handheld_core_hardware.xml and platform.xml of port ROM with that of base and add or replace some lines if required.
You can do the same for some other permission files if required, but as I am always saying use your common sense.
5. Replacing files: Copy and replace files in system/etc/firmware and in system/etc/wifi from base to port.
Copy and replace the files goodix.kl, gpio-keys.kl, Generic.kl in system/usr/keylayout/ from base to port.
We will discuss more about replacing files in bug-fixing section.
6. Open system/framework/framework-res.apk of both base and port with 7zip in two different windows but don’t extract. Then navigate to framework-res.apk/res/xml/ of base and copy storage_list.xml and power_profile (optional) and paste to the Winrar window of port framework-res.apk/res/xml/ and replace the existing files. Then close the Winrar window.
Build.Prop Editing
You can edit required parts of build.prop to reflect the brand, model no. etc. according to your preference. You may also add some tweaks and other things to save battery and to add features.
(But in MIUI 7 according to my experience changing the ro.product.manufacturer gives rise to issue in video recording through third-party apps and changing the ro.product.device trims some features from the ROM.)
Now your Porting Project is ready to be flashed and to be reviewed. Congrats!
And thats it now you can zip all files and flash your ported rom. If you still face any bugs after porting your rom you can read the below guide.
No comments
Post a Comment