FORUMS
Remove All Ads from XDA

How to Port Samsung Rom to other Samsung devices (Updated as of 4/19/2017)

4,059 posts
Thanks Meter: 7,543
 
By malbert16442, Senior Member on 15th October 2016, 07:15 PM
Post Reply Email Thread

(Success Stories)

Quote:
Originally Posted by jonathanmohamed

I have successfully ported s7 and n7 firmware using this guide.
Awesome guide!. 9/10

Quote:
Originally Posted by corsicanu

@malbert16442 this is pure GOLD. Gave you all my thanks for today. I'll try it myself today. Also waiting patiently for updates . Cheers!

Quote:
Originally Posted by armaowl

is the reason i was allowed me to port my own Rom!






1. Kernel is second most important because it determines if rom boots or whether
we could access a log.

2. Since we are trying to boot a rom not meant to be on our device, it could be alittle hard getting this thing to run.

3 Contact a kernel dev and ask them for adb insecure kernel or a kernel with usb debugging enabled at boot. This will help us obtain those logs at boot.

4. In some rare cases Logs might show that specific kernel services are not accessible.
In this case we only change the init.environ.rc. Which has the frameworks needed to boot.

5. If you can't get kernel logging at boot use this in recovery after 2 mins of booting.
Code:
adb pull /data/tombstones


Part 2


Adb is key in any port. Adb is the secret. It gives us the ability to access logs be able to debug issues in our ROM.

1. Download adb drivers

http://forum.xda-developers.com/show...8#post48915118
Thanks Member @Snoop05

2. Test adb by using 'adb devices" in cmd

You should see online

3. If offline try using adb kill-server and repeat step 2.

4. When making a loging for these ports we use the phrase adb logcat *:E > filename

this ensures that we filter the logs by errors and remove the long set of lines like thermal updates ...etc




Part 3


In order to port firmware

1. Download Stock firmware extract it with tool
Websites to get stock firmware are
http://updato.com/firmware-archive-select-model
or https://forum.xda-developers.com/gal...mware-t2988647

2.We will deodex our rom using Fulmics or similar deodexer
Either a kitchen like "http://forum.xda-developers.com/chef-central/android/kitchen-superrs-kitchen-t3202296/page26" or similar.
Thanks @SuperR
https://forum.xda-developers.com/and...r-1-0-t3512081
Thanks @xpirt

3. Learn how to use APK DECOMPILE TOOLS SUCH AS TICKLEMEANDRIOD
http://forum.xda-developers.com/show....php?t=1633333
Thanks @Ticklefish

4. Remove Apps Priv-app and Framework of base. In a new folder use Fulmics to deodex this. Store somewhere safe.

5. Deodex Port and copy the Apps, Framework and Priv-app into the Base of stock rom.

6. In Ticklemeandriod you notice we have 6 work Areas. For our Roms we will only need two. The most common files we will use are services.jar, and framework.jar.

7. Take the services and framework our our Port and decompile in work area 1.

8. Take the services and framework of our Base and decompile in work area 2.

9. We will Perform a quick Step to help if App signatures become corrupt or cannot be read.

Follow this guide by @ikrom

http://forum.xda-developers.com/show...postcount=2957

10. After this lets move to debugging our apps and frameworks.





Part 4 (Tools and debugging)

My favorite tools to use include WinMerge and FileSeek

1. Winmerge enables us to compare two files. For example a stock jar and one of our port.

2. File seek allows us to search for a specific references.

I use file seek to search for weird terminology I see on my log.

3. Terminology




Part 5 ( Terminology)


1. In a logcat we are looking for three things when debugging. "E JavaBinder:", "E art", "E AndroidRuntime: FATAL EXCEPTION:"

2. The order to debug we search in logcat. When beginning it is not specific but, I usually search for Art errors first.

3. So for example if I get in my logcat
Code:
"01-01 01:26:25.169  5599  7183 E JavaBinder: java.lang.NoSuchMethodError: No virtual method activityPauseTrigger(Landroid/content/Intent;Landroid/content/pm/ActivityInfo;Landroid/content/pm/ApplicationInfo;)V in class Lcom/android/internal/app/ActivityTrigger; or its super classes (declaration of 'com.android.internal.app.ActivityTrigger' appears in /system/framework/framework.jar:classes2.dex)"
I got the location which is framework jar Class2

Code:
activityPauseTrigger(Landroid/content/Intent;Landroid/content/pm/ActivityInfo;Landroid/content/pm/ApplicationInfo;)V is the missing info in the port smalis and
log says it is somewhere in
Code:
Lcom/android/internal/app/ActivityTrigger; or the files with idential names to Activity trigger
4. In this case missing method could be found in stock smali. This is where we use win merge to cleanly copy new method from stock to port.

5. But Mike what if The logcat doesnt tell me location. We will then use fileseek in this instance.

Example: Log tells me
Code:
 "01-01 00:24:17.509  7524  7539 E JavaBinder: java.lang.UnsatisfiedLinkError: No implementation found for void com.android.internal.app.ActivityTrigger.native_at_pauseActivity(java.lang.String) (tried Java_com_android_internal_app_ActivityTrigger_native_1at_1pauseActivity and Java_com_android_internal_app_ActivityTrigger_native_1at_1pauseActivity__Ljava_lang_String_2)
"
No implementation means that we must remove this file as it is not found in the libs. What location? We dont know yet ?

Code:
com.android.internal.app.ActivityTrigger.native_at_pauseActivity(java.lang.String
is what we are looking for

According to fileseek I would look for pauseActivity because it is a keyword

According to file seek I may get 100 references but I see one that says
Code:
.method ActivityTrigger.native_at_pauseActivity
I would then use winmerge to cleanly delete/copy the file from my stock smali to the new one. From the location I found in Fileseek.

6. Let me give a example of a Runtime error.

Code:
"07-25 09:17:08.975 16379 16379 E AndroidRuntime: java.lang.NoSuchMethodError: No interface method setDataFromNSFLP(ILandroid/os/Bundle;)V in class Landroid/location/ILocationManager; or its super classes (declaration of 'android.location.ILocationManager' appears in /system/framework/framework.jar)
So log told us to look in framework for a file with
Code:
setDataFromNSFLP(ILandroid/os/Bundle;)V
Boot up file seek and repeat steps above.




Part 6

So we booted now what.

Lets now work on fixing local errors.

Use logcat to possible fcs and reboots.

All firmware edits are different so this guide will help if you are learning the way android works.

What to look out for

Remember the Base folder we deodexed. We will use this to help fix issues in our rom.

1. Take the McRegistry Folder and ffffffff0000000 File move this to our booted rom.

2. Now in the Ported firmware copy the Fonts folder and the files named font in /etc to our booted rom.

3. Delete these folders - " preloadedmdm ", " sipdb " and " tts from booted rom and replace with that from ported firmware.

4. Open " Media " folder in booted rom

Delete Audio folder
Replace with Ported firmware audio folder.

5. In /etc/permission add the missing software permissions not hardware like slocation or camera-flash.

6. In build-prop
Replace these values with that of port.

Code:
ro.build.scafe.size=
ro.build.scafe.shot=
ro.build.scafe.cream=
ro.build.scafe.version=
ro.com.google.gmsversion=
ro.build.version.sdl=
ro.config.ringtone=
ro.config.notification_sound=
ro.config.alarm_alert=
ro.config.media_sound=
ro.config.ringtone_2=
ro.config.notification_sound_2=
7. Add this code to build-prop

Code:
wlan.wfd.hdcp=disable


Let's Fix Messages and Phone FCS on first boot

1. From ported from take the libselinux.so to fix message fcs

2. To fix Phone fcs take the mapconprovider.xml from port



64 bit firmware to 32bit

1. Replace 64 bit libs with 32 bit alternatives.

2. You could find 32 bit libs in 32 bit firmware.

32bit all that could be found will be attached here for all users



Fix location problems in Rom

With our services.jar decompiled take these smalis from base and use Winmerge to copy to Port jar.
Code:
services.jar\smali\com\android\server\location folder to that of port
also take the
Code:
services.jar\smali\com\android\server\LocationManagerService$xxx
Smalis and move from base to port location.





1. Take NFC.apk and Bluetooth.apk from base and move to new Rom folder.

OR A more complex NFC fix would be to look in PackageManagerService.smali
of services.jar

look for the NFC model of the device you are porting from

1. So use FileSeeker
to search for method with "supportNfc"

2. Replace it with your model number.

Example the NFC number of Note 7 is S3FWRN5
I would replace it with the NFC number of S5 which is NXP_PN547C2


Blur


https://forum.xda-developers.com/sho...ostcount=10031



AOD FRAMEWORK FIX


Credits :
@Patrick.H (NX Team)
@karkasss (NX Team)
@Develoid ALT and F4 (AOD touch / Bluelight filter fix)
@asc1977, @DaOldMan (AOD brightness control)
(Please copy & paste when you add our credits)

Download this file extract to services.jar

https://mega.nz/#!KgMxwQDR!g0yy7a6Iz...SMYAc8p6kOjIs4

Compare the PowerManagerService Smails.

then recompile


OR
thanks @oluwaponmile
follow this guide

https://forum.xda-developers.com/sho...postcount=8139





Lets fix ported Cameras

Code:
GUIDE IS IN PROGRESS WORKING ON VIDEOThis will be a hard thing to accomplish. Also make sure that Camera is recompiled using New signatures.

First lets find the native resolutions of your camera for this we look in native camera.

Keep this open in one window.

Now open up camera and take log.

Most likely you would get a error saying missing resolution


KNOX STATUS REVERT (Kernel)

@topjohnwu for reset prop

The reset prop source was removed from topjohnwu thread however you could use the prebuilt binary in his magisk release zips.

1. Pick your device arch and remove binary from zip

2. Now download a tool to extract boot images.

3. Navigate to sbin and drop your resetprop binary.

4. Get back to root directory and add this file http://www106.zippyshare.com/v/AzldZO7A/file.html

5. Now in init.rc add this code

Code:
# Call Knox Reset
service knox-daemon /system/bin/sh /init.knox.sh
    class main
    user root
    oneshot
Device Specific Section
(Section will detail device specific edits for particular devices once users post.)

Quote:
Originally Posted by mitko7411

So I haven't really made a new list of smalis for porting roms, but here's the ones just to boot ANY 6.0.1 firmware on J5 2015.
Debug
GpsLocationProvider
KnoxVpnPacProcessor
TADriver
SchedPolicyManager




No Pm type message below.
Also I will post below all the logs I used to boot Note 7 firmware on my s5
The Following 71 Users Say Thank You to malbert16442 For This Useful Post: [ View ] Gift malbert16442 Ad-Free
 
 
15th October 2016, 07:19 PM |#2  
malbert16442's Avatar
OP Senior Member
Flag Area 51(◕_◕)
Thanks Meter: 7,543
 
Donate to Me
More
All the edits used to boot Note 7 firmware on S5 it is different for every device.

https://mega.nz/#!8ZtzWCJR!rqTrvD5K3...FZawSzpobFDF98
The Following 21 Users Say Thank You to malbert16442 For This Useful Post: [ View ] Gift malbert16442 Ad-Free
15th October 2016, 07:31 PM |#3  
ROBERT CM's Avatar
Senior Member
Flag Lima
Thanks Meter: 882
 
Donate to Me
More
Thanks for this guide..
The Following User Says Thank You to ROBERT CM For This Useful Post: [ View ] Gift ROBERT CM Ad-Free
15th October 2016, 09:22 PM |#5  
malbert16442's Avatar
OP Senior Member
Flag Area 51(◕_◕)
Thanks Meter: 7,543
 
Donate to Me
More
Quote:
Originally Posted by Ticklefish

A nice guide. Thanks!

Thanks

Sent from my SM-A810S using Tapatalk
The Following 6 Users Say Thank You to malbert16442 For This Useful Post: [ View ] Gift malbert16442 Ad-Free
16th October 2016, 05:50 AM |#6  
talayy's Avatar
Senior Member
Flag Kuala Lumpur
Thanks Meter: 1,022
 
Donate to Me
More
Great (y) Extremely helpful, time for noobs to port now
16th October 2016, 01:03 PM |#8  
SnoopyOne's Avatar
Member
Flag Kaohsiung City
Thanks Meter: 41
 
More
Thanks manYou helped me.
16th October 2016, 09:41 PM |#9  
thereassaad's Avatar
Recognized Contributor
Flag Bierut
Thanks Meter: 9,594
 
More
Well ,,


Malbert , im sure 100% , too much things missed in ur guide mate , this way how u do it isn't an how to ported rom from different devices , or high end to previous years device's , sorry to say this but this isn't a full guide & its just a point for drop app/prev/fram to ur stock base then try to booted then with bootloop logcat u will got what's the missing things well ,




Sorry to say it but this isn't a Full guide for HOW TO PORT Roms , ....



Edit ::


Next time try to be more specific & gives more details & which files / jars / smali / apks / libs / xml / config & which we can use & got from ported base to stock base ,
The Following 6 Users Say Thank You to thereassaad For This Useful Post: [ View ] Gift thereassaad Ad-Free
16th October 2016, 10:02 PM |#10  
malbert16442's Avatar
OP Senior Member
Flag Area 51(◕_◕)
Thanks Meter: 7,543
 
Donate to Me
More
Quote:
Originally Posted by thereassaad

Well ,,


Malbert , im sure 100% , too much things missed in ur guide mate , this way how u do it isn't an how to ported rom from different devices , or high end to previous years device's , sorry to say this but this isn't a full guide & its just a point for drop app/prev/fram to ur stock base then try to booted then with bootloop logcat u will got what's the missing things well ,




Sorry to say it but this isn't a Full guide for HOW TO PORT Roms , ....



Edit ::


Next time try to be more specific & gives more details & which files / jars / smali / apks / libs / xml / config & which we can use & got from ported base to stock base ,

Thanks assaad will fix when I get time I get what you are saying but this is a intro. I can't explicitly state which jars apks or libs are needed because they are all different for different devices. XML and permissions I could elaborate on but you can't expect me to possibly give a overview of everything right. Hope you understand thanks. I never explicitly stated this was a full guide and you shouldn't treat it as such.

Sent from my SM-A810S using Tapatalk
The Following 4 Users Say Thank You to malbert16442 For This Useful Post: [ View ] Gift malbert16442 Ad-Free
16th October 2016, 10:08 PM |#11  
thereassaad's Avatar
Recognized Contributor
Flag Bierut
Thanks Meter: 9,594
 
More
Well my friend , i never do ,,

For example without editing systemserver.smali the rom will never booted & u know this very well , i just means to be very static for some useful tips for such framework / & well known smali that need to be our eyes on them .. that's all my point means ..

Good luck my friend
The Following 3 Users Say Thank You to thereassaad For This Useful Post: [ View ] Gift thereassaad Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes