[GUIDE] How to Port

thaunknownartist

RAZR Developer
Aug 12, 2011
180
326
0
Logo-1.png

Introduction:
This guide will help you in porting ROM's to different devices. Although it my not work 100% of the time, it should you show the steps involved in porting a ROM but also which files are important to a device's functionality.


Things you will need:
  • The Android SDK, this contains ADB logcat which is a hugely important tool in ROM development. It lets us know what is perhaps causing an app to F/C or a ROM to bootloop.
  • Notepad++, very useful for altering scripts.
  • Patience, getting ports to boot can sometimes take a lot of effort and time but hopefully this guide will show you the quickest and easiest way to get your ported ROM booting.

Let's get started...
Okay first decide which ROM you would like to port, don't port HDPI ROM's to MDPI devices or vice versa it just won't work. And it's best to start with the easy and simple ports to get some experience behind you before you go off porting Sense 3.0 to your X10. Porting is fairly easy and requires only some folders, files and a boot.img to be replaced. Now because this is a universal guide I can only tell you how to get the basic hardware working on your port. AOSP ROMs are fairly easy to figure out so you won't have much trouble figuring out what needs replacing. Manufacturer specific ROMs such as Sense 3.0 ROMs are bit more difficult to figure out but the basic skills you will be taught here can be applied in principle to those ROMs.


Knowledge:
First off lets start with the biggie, the kernel. Those of you familiar with linux will know how important the kernel is a to system, I won't go into detail here but if your kernel isn't specific to your device then your ROM won't boot. The kernel is contained within the boot.img of your ROM's zip (or zImage if it's a Samsung). During flashing it is unpacked and wrote to the system. To replace the kernel we need to decompile it and no this isn't as easy as opening it winzip. The best way to do this is using Linux; we can use a combination of both perl scripts and terminal commands. In order for us too see the kernel files contained within the boot.img, we need to first unpack it and this will extract the kernel binary and the ramdisk. What you need at this point is the split_bootimg.zip. This contains a perl script which will extract both files and display the boot.img header, the kernel command line and the board name (if specified).
An example of the output would be: Page size: 2048 (0x00000800) Kernel size: 1388548 (0x00153004) Ramdisk size: 141518 (0x000228ce) Second size: 0 (0x00000000) Board name: Command line: no_console_suspend=1
So how to use this perl script you ask? Well... First open a terminal and cd to the directory which contains the perl scripts you just downloaded. Next, type this command: "perl split_bootimg.pl boot.img" and that will extract the kernel to your current directory. Now, we need to extract the ramdisk, the ramdisk has been unpacked from the boot.img and is sitting your current directory with the file name "boot.img-ramdisk.gz", at the moment this still isn't useful to us so we need to un-gzip and then un-cpio it. So for that we need the Linux terminal. So again from the terminal or using the same terminal enter these commands:
mkdir ramdisk < Creates a directory where we can store the ramdisk cd ramdisk < Changes our current directory to that of the ramdisk gzip -dc ../boot.img-ramdisk.gz | cpio -i < Will un-gzip and un-cpio ramdisk Okay so now we can see all the ramdisk files: ./init.devicename.rc ./default.prop ./proc ./dev ./init.rc ./init ./sys ./init.goldfish.rc ./sbin ./sbin/adbd ./system ./data
So what's important here is the "init.devicename.rc" and "unvented.device.rc". This is the target devices .rc files contained within the ramdisk, now all we have to do here is rename this .rc file to that of the device you are porting to, e.g: "init.trout.rc" > "init.hero.rc" Some devices ramdisk differ and may not contain "unvented.device.rc" so if this is case for you,then begin by renaming the init.device.rc to your model id and leave it at that. If you get problems well.. that's what the live support is for. The other file which may be of use to us here is "init.rc", this contains all the system wide kernel properties which we can change to our liking but we'll leave as it is for now. So now we've edited the ramdisk, we need to change the kernel so that the one the ROM uses is actually specific to our device, when we used the split_bootimg perl script it also unpacked the kernel and that is also in our current directory with the filename "boot.img-kernel". Easiest way to replace the kernel is to take a kernel update zip for your device, un-zip it and rename the zImage file to "boot.img-kernel" and copy and replace the file of the same name in your directory. Okay, now that's all done, we need to pack this back up into something that android can understand when it's being flashed. So we need to make a new boot.img from the files we have in our current directory. First, we need to pack the ramdisk back up into it's original state, so again we need to use the Linux terminal. The command that will do this is this:
find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
Remember the ../ is the path to the directory of your ramdisk, remember to remove anything that won't be used by the kernel as cpio will include EVERYTHING in the working directory. Okay now that the ramdisk is back in it's original format we need to repack the kernel and ramdisk into the boot.img. So back into the terminal we go and this time we're going to use the "repack-bootimg" perl script (as if that wasn't obvious enough). The command you will ise here is esentially the same to the one we used to split it, so:
"perl repack-bootimg.pl ../path to kernel ../path to ramdisk directory ../path to outfile"
And the boot.img is complete! So if we look back to the ROM we are porting we can see that we need to put the boot.img into the root of the zip, this will hold true for almost every Android ROM. Next we need to replace some of the files which allow the hardware and keys to work. This is the easy part. Go into the root of the zip and follow this path to the kernel modules;
"/system/lib/modules"
Delete all the files you find here. Now take the kernel modules which came along with the kernel you added to the boot.img and copy them there. Next follow this path to the propietary hardware files;
"/system/lib/hw"
Delete all the files you find here. Again this as simple as taking the files from a ROM meant for your device and copying them into this directory. So what we've done there is added the kernel modules that we can set symlinks to in the updater-script and contain the modules needed for things like WiFi, bluetooth etc. The "/hw" directory as you can see contains the files which control the sensors and lights such as GPS and the accelerometer. Next, we can look at making sure the hard and soft keys work, the files which contain the layout of your device keys can be found in;
"/system/usr/keylayout" and "/system/usr/keychars"
Touch only those 2 directories. Delete all the files in here and copy the ones from your device (following the same directory) here. Okay now to finish off we need to copy over the mount point information for your device and the WiFi drivers. Follow this path; "/system/etc" and delete only these files and directories.
- vold.fstab - /wifi - /ppp
Now follow the same path in a ROM for your device and copy over these files. Okay we're done! Before flashing take a look and some guides which show you how to write updater-scripts, incase you need to create important symbolic links.


Checklist:
/system/app: Bluetooth.apk → To fix the bluetooth problem Phone.apk → To fix the proximity sensor issue Added liquid settings & GApps
/system/bin: Since you probably use the old sensor, you need to add all the *_yamaha files. brcm_patchram_plus → To fix the bluetooth dhcpcd netd → To fix the wifi hotspot (you MUST change also /lib/libhardwarelegacy.so too, else you will get a bootloop) rild → To get the network working servicemanager → To get the sensors working vold → To get the vold working
/system/etc: the entire firmware folder to get wifi and sensors working the init.d folder to tweak the rom the permissions folder, added missing xmls the entire wifi folder to get the wifi working gps.conf → To improve the GPS hosts → To fix ads media_profiles.xml → To fix problems with camera and camcorder vold.conf and vold.fstab → To fix vold, if you don't change them the rom won't boot.
/system/framework: Added com.google.android.maps.jar to fix problems with the apps which uses GMaps. You can find there the files to tweak with smali to get some stuff working. For example, if you want to get the prox. sensor working well, you need to edit the PowerService class in services.jar.
/system/lib: the entire egl folder the entire hw folder the entire modules folder all the libOmx* .so files → To get the camcorder working all the libaudio* .so files → To get the audio working (if you don't change them, it won't boot) libandroid.so libauth.so libcamera.so and libcameraservice.so → These depends on the ROM. libcm, libcommondefs.so, libdiag.so, libdll.so, libdsm.so, libdss.so, libeffects.so, libg*.so libhardare_legacy.so libloc*.so liblog.so libmedia.so libmmgsdilib.so, libmmipl, libmmjpeg.so, libnfc_ndef.so, libnv.so libms3c_yamaha.so → To fix the sensors liboemcamera.so → To fix the camera & camcorder liboncrpc.so, libpbmlib.so, libqmi.so, libqueue.so libril*.so librtp_jni.so libsensor*.so libspeech.so libsqlite_jni.so libstagefright_*.so → These are usually not required libt99.so libvoicesearch.so libwebcore.so libwms.so libwmsts.so
/system/sd: The placeholder file. → To get sd working
/system/usr: the entire 'keychars' and 'keylayout' folders
/system/vendor: The entire folder.

Proof:
torch2424 said:
Hi, I first want to thank you for making this: http://forums.androidcentral.com/optimus-v-rooting-roms-hacks/168686-guide-how-port.html This may have been the greatest guide written by man :D Your awesome, I followed it exactly and I successfully ported(WITH ALOTTTT OF BUGS cause I havent done everything yet) JOYOS for p500 (http://forum.xda-developers.com/showthread.php?t=1616069), like and ios wanna be rom, using Harmonia 2.5 as a base, after 2 days of practice I got it to succesfullly got it to run on my phone :D Now, hoping that I can get 3g and wifi and things working, if I were to release this rom and become an android dev, how would I create the thread giving thanks and stuff to everything I used? :0 thank you for taking the time to read this message, Torch P.S your ICS rom is amazing and thank you for making it, Im SOOOOO hyped for v4 :D
 
Last edited:
Someone just asked about this too, very useful... I couldn't find it the other day when they needed it.

Sent from my LG-VM670 using Tapatalk 2

I added proof to the bottom of the post. If I get success stories I will update the main post as I go :cool:
 
Heyyy!!! :DD Im on the OP how cool :3 anyways, I totally took everything from the base on the checklist and put it on my Joy port, and nothing began working, no radio, no wifi, nothing :/ was I supposed to transfer the files over, or what am I supposed to do on the checklist? :0

EDIT: The camera works :) and camcorder works too, but its hard to tell when you stopped recording XD I think it might just be the app itself tho :0 but please someone help me, I'm quite eager to continue my project :D I was wondering, could it be the permissions or the updater scripts?
 
Last edited:
Heyyy!!! :DD Im on the OP how cool :3 anyways, I totally took everything from the base on the checklist and put it on my Joy port, and nothing began working, no radio, no wifi, nothing :/ was I supposed to transfer the files over, or what am I supposed to do on the checklist? :0

EDIT: The camera works :) and camcorder works too, but its hard to tell when you stopped recording XD I think it might just be the app itself tho :0 but please someone help me, I'm quite eager to continue my project :D I was wondering, could it be the permissions or the updater scripts?

I've been porting Joy too as a matter of fact, hmmmmmmm I might bring you onto the team. Don't be surprised if you get an invitation sometime.
 
Oh fashow :D but remember, I'm totally a noob, however, I have alottt of free time, and can learn FAST ^_^
 
I have deleted my vold.fstab. now my phone wont recognize my sd card and phone memory. only internak memory is running. could you hepl me restore it. Thanks.
 
I have deleted my vold.fstab. now my phone wont recognize my sd card and phone memory. only internak memory is running. could you hepl me restore it. Thanks.

What Rom are you on? You could always flash over it. You could also create a flashable zip for vold.fstab, or even ADB push it in recovery.

Sent from my HTC One V using Tapatalk 2
 

Members online

Forum statistics

Threads
954,053
Messages
6,960,415
Members
3,162,917
Latest member
ledgersupport2025