[Android General] Jitheshwar:
Thread will be best viewed in website

[CENTER][COLOR="red"]Your warranty is now void.[/COLOR]
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 before asking help and reporting bugs.
Please read the entire OP instructions and FAQ,if any.
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.
A lot.[/CENTER]

This thread is for spreadtrum Marshmallow, lollipop and KitKat phones. I made this guide for porting especially CM/CM based ROMs. This thread is in under progress, I'll be keep adding and changing things. These lines will be removed when I think I'm done.

Requirements

A PC /Laptop /Even your android phone is enough for porting, since your not building ROM, provided that you know how to get things done

Android Image Kitchen

A ZIP archiver(winzip,7z,etc)

Notepad++/your favorite one

HEX Editor (for Android available on play store)

A working brain with basic understanding skills properly installed

An Android device with the chipset as per the title (of cource this will work on iPhone and Windows phones but sadly my

kitten eaten

flashing instructions , so blame my kitty:silly:)

A working custom recovery (if you don't have one, this thread might help you)

Aroma File Manager (this is used to skip the process of extracting system files from system.ext.win and system.new.dat and compressing it back)

Stock ROM (extracted to easily accessable folder, since we are going to port the ROM not using normal File Manager but a recovery based file manager

Custom ROM(S) (download links are in the 2nd post)

I'll suggest you to concentrate on booting the ROM rather fixing bugs at first shot, because if we are sure that the ROM boots we can go further, otherwise it's waste of time.

Marshmallow ROM porting guide

=> Download and Extract the ROM. Since ROM(S) is zipped out of custom recovery backup you'll see system.ext4.win (which is a compressed system folder) boot.emmc.win (boot.img) and some, maybe, compressed using system.new.dat.

Porting boot.img

=> Copy stock boot.img to working directory of AIK

=> Unpack boot.img and rename ramdisk to ramdisk.s and split_img to spli_img.s

=> Copy boot.emmc.win to working directory of AIK and rename it to boot.img

=> Unpack boot.img

=> Replace the following

/ramdisk/lib/modules with /ramdisk.s/lib/modules

/ramdisk/lib/modules/mali.ko with /system/lib/modules/mali.ko from stockrom

=> delete split_img and rename split_img.s to split_img

repack it and rename image-new.img to boot.emmc.win and replace Custom ROM boot.emmc.win with ported boot.emmc.win.

Porting System

=> Boot to recovery and wipe system, data, cache and dalvik-cache and flash the CM13/Marshmallow ROM

=> Go back to tab menu of TWRP tap on 'Mount tab' Mount system and go back to flash tab and flash aroma file manager zip

=> Now you are on Aroma FM. Copy and replace the following files with stock ROM files:

/system/lib/hw/<all files> except files audio.primary.sc8830.so & bluetooth.default.so

/system/etc/ all audio related files except audio_effect.conf

/system/etc/codec_pga.xml

/system/etc/ media related files

/system/etc/tiny_hw.xml

/system/lib/egl/libGLES_mali.so

/system/lib/libEGL.so

/system/lib/libGLES_trace.so

/system/lib/libGLESv1_CM.so

/system/lib/libGLESv2.so

/system/lib/libMali.ko,if any

=> After replacing files exit Aroma FM and reboot the system. Booting will take a while (~10m) so please be patient.

Bug Fixing Guide

Camera Fix

Open lib files one by one on stock rom lollipop & search for "_ZN7android5Fence4waitEj"(without quotes) with notepad++ (mainly look into the files related to camera.sc8830.so, to know open it with HeX editor and see what are the necessary lib***.so files)

In my case "_ZN7android5Fence4waitEj" are available on stock libui.so where that file needed by camera.sc8830.so

SO open camera.sc8830.so with HexEditor and search for libui.so

Then rename libui.so of stock rom file to libcm.so and save it

Copy and paste modified file to the exact directory and wipe data, cache, dalvik-cache (data is nedded because if the camera HAL fails to load at first time CM ROMs won't show camera app in that case it is must to wipe data)

Then reboot & make sure camera.sc8830.so loaded correctly with logcat

Fix for possible bootloops when porting Marshmallow ROM using lollipop kernel

Soon.....

Note:-I'm sure the marshmallow ROM(s) will boot on lollipop device also (because I personally tested with my phone but I need confirmation that this works on marshmallow devices also.

Lollipop ROM porting guide

Porting boot.img

=> Copy stock boot.img to working directory of AIK

=> Unpack boot.img and rename ramdisk to ramdisk.s and split_img to spli_img.s

=> Copy custom ROM boot.img to working directory of AIK

=> Unpack boot.img

=> Replace the following:

/ramdisk/lib/modules with /ramdisk.s/lib/modules

/ramdisk/lib/modules/mali.ko with /system/lib/modules/mali.ko from stockrom

delete split_img and rename split_img.s to split_img

repack it and rename image-new.img to boot.img and replace Custom ROM boot.img with ported boot.img.

Porting system

=> Boot to recovery and wipe system, data, cache and dalvik-cache and flash the CM12/lollipop ROM

=> Go back to tab menu of TWRP tap on 'Mount tab' Mount system and go back to flash tab and flash aroma file manager zip

=> Now you are on AromaFM. Copy and replace the following files with stock ROM files:

/system/lib/egl/libGLES_mali.so

/system/lib/hw/<all files> except files audio.primary.sc8830.so & bluetooth.default.so

/system/lib/modules<all files>

/system/vendor/lib/libbt-vendor.so with stockrom /system/lib/libbt-vendor.so.

=> After replacing files exit Aroma FM and reboot the system. Booting will take a while (~10m) so please be patient.

Typing Bug Fixing Guide

KitKat ROM porting guide

Porting boot.img

=> Copy stock boot.img to working directory of AIK

=> Unpack boot.img and rename ramdisk to ramdisk.s and split_img to spli_img.s

=> Copy custom ROM boot.img to working directory of AIK

=> Unpack boot.img

=> Replace the following

/ramdisk/sbin files with /ramdisk.s/sbin files

/ramdisk/init.sc8830.usb.rc with /ramdisk.s/init.sc8830.usb.rc

/ramdisk/init.usb.rc with /ramdisk.s/init.usb.rc

=> Delete split_img and rename split_img.s to split_img

repack it and rename image-new.img to boot.img and replace Custom ROM boot.img with ported boot.img.

Porting system

=>Replace the following:

/system/lib/egl/<all files>

/system/lib/hw (following files) :

camera.sc8830.so

camera2.sc8830.so

gralloc.default.so

gralloc.sc8830.so

hwcomposer.sc8830.so

keystore.default.so

lights.sc8830.so

local_time.default.so

power.default.so

sensors.sc8830.so

sprd_gsp.sc8830.so

/system/lib/modules<all files>

/system/vendor/lib/libbt-vendor.so with stock ROM /system/lib/libbt-vendor.so

Booting will take a while (~10m) so please be patient)

NOTE: If you stuck at Splash Logo (Manufacturer's logo) then delete CM11/system/lib/egl/libGLES_mali.so from recovery and then wipe data, cache, dalvik-cache and reboot.

Bug Fixing Guide

Camera Fix

Copy files camera.sc8830.so, camera2.sc8830.so & libandroidfw.so from stock ROM

Rename libandroidfw.so to libandroidcm.so

=> Download and install Hex Editor (Users who are using Android for porting can use Hex editor from playstore)

Open camera.sc8830.so with Hex Editor and search for libandroidfw.so & rename it to libandroidcm.so

Save camera.sc8830.so file, copy and paste it to CM/CM based ROM

Do the same for camera2.sc8830.so

This will fix the error "Cannot load Camera HAL" which is caused by camera.sc8830.so mising start_SprdPrefTracking & stop_SprdPrefTracking argument which is available only on original libandroidfw.so on your stockrom.

Reboot your device

If you haven't seen camera app then you may need to wipe the data and dalvik-cache but there is an alternative for this. The alternative is using third party camera app from play store if the camera works then you are good to go

but to have CM stock camera you must need to wipe data

WiFi/Hotspot fix

Part - I

Make sure your stock ROM WiFi (WLAN) driver name is sprdwl.ko on /system/lib/modules

Copy the following folder(s) from stok rom & paste to cm-11.0 rom

--/system/etc/wifi/<all files>

/system/etc/dhcpcd/<all files>

--/system/etc/connectivity_calibration.ini (related to WiFi connectivity)

--/system/etc/connectivity_configure.ini (related to Bluetooth connectivity)

I suggest you to replace files from Aroma FM (since we don't need to set permissions, etc which will automatically done by Aroma FM)

If you are replacing files from root explorer you need to properly set the permissions and Ownership/Group of particular for otherwise there will be no point in replacing the files and this will result in either unfixed bug or bootloop for this properly note down the permissions and Ownership/Group of individual files

for ex: /system/etc/dhcpcd/dhcpcd-run-hooks has permissions "-r-xr-x--- or 0550" and Owner is "dhcp" and Group is "shell"

Part - II

Unpack cm-11.0/based ported boot.img and replace "init.wifi.rc" file with this init.wifi.rc

Flash the modified boot.img using Flashify/ from recovery using flash image option (recommended)

To test whether the WiFi driver properly loaded or not

use terminal emulator type

su
<enter>
cat /proc/modules
<enter>

see whether the sprdwl.ko present on loaded modules list.

Try to use WiFi and immediately see the logs (use logcat Extreme app from play store) set if there are any errors

Do the same with Hotspot

as a result you may need to replace some files under --/system/bin/

ex:

--/system/bin/dhcpcd

--/system/bin/hostopad

--/system/bin/wcnd

--/system/bin/wpa_cli

--/system/bin/wpa_supplicant

etc

To root flash Magisk (systemless-root only for lollipop and above) or SuperSU

Credits: Hadi Khoirudin, Advan S4p [Official] fb group, [MENTION=7598239]@ki[/MENTION],

[MENTION=7606820]Jitheshwar[/MENTION] (it's me :silly: )​

Created 2/10/2017

Last Updated 3/10/2017