[Android Software Development] digyvijaykumar123:
PORTING

PORTING​

>>>>Follow STEP I if you have port rom flashable via cwm.To check that your rom is flashable vai cwm see above post for structure.Those who having SP Tools flashable port rom follow StepII directly.<<<<

First we will port and check that rom boots or not by simple way,then if it boots then we will modify it and tweak it by using kithcen.Or you can skip this step I and directly follow step II but you have to do almost all things from step I in Step II except modifying updater script.If you do these things in step I then no need to do in Step II.

STEP I​

[*]Make a folder and name it as you want and copy and paste your port rom zip in it,means make a clone file of it and we will be working with clone zip,always keep in mind.I said to copy paste as if your rom did not boot up then you have a backup of clean port rom.

[*]Now create a folder under original update of kitchen- " WORKING_XXXX "

[*]Then open zip using 7zip(make 7zip is as default app) and drag drop boot.img to " WORKING_XXXX " folder.Now Open kitchen and Press 1 to setup working Folder.And go with default in all steps forward.(keep 7zip opened,you will need to drag back boot.img in it)

[*]After working folder setuped.Now press 0 for advance option and hit enter.Now press 12 and hit enter.Now you press "w" to extract boot.img from working folder.

[*]After sucessful extraction you will find a folder under kitchen named BOOT EXTRACTED.

[*]Now you have to copy zImage from stock boot extracted folder(which was created by you in second post last step) to this BOOT EXTRACTED folder and replace it.

[*]Then switch to kitchen and press "b" to build boot.img from BOOT EXTRACTED folder then after repacking boot.img finish,you have to drag and drop only boot.img(kitchen/working folder)(not meta-inf) to port rom zip.

[*]Now Open System Folder In port Zip and drag drop build.prop file out of it to anywhere you wish.

[*]Now edit it with Notepad++.

[*]Add this line if you are porting from a higher resolution device- ro.sf.lcd.density=220 .Change its value after rom boots as to your display resolution.If after rom boots up and everything looking large then reduce the value and if looking small then increase it.

[*]You can Edit These Values as desired:-

ro.build.id=
ro.build.display.id=
ro.custom.build.version=
ro.build.version.release=This is Andriod version That Displays in Settings
ro.product.model=
ro.product.brand=
ro.product.name=
ro.product.device=
ro.product.manufacturer=
ro.build.bluetooth.name=

[*]EDIT BELOW LINES TO SET YOUR TIMEZONE AND AREA REGION.You can find your default details in your stock rom's build.prop which you extracted earlier.

ro.product.locale.language=(en for English,ru for Russian and other similar codes for other language)
ro.product.locale.region=(us for usa, IN for india etc.)
persist.sys.timezone=( Asia/kolkata for india,Asia/... different for different regions)

[*]Now after editing done drag build.prop to port zip.

[*]Now keep opened port zip one side and open stock rom system folder which we extracted in post 2.

[*]Open System/etc/firmware in both zip and stock folder.Now drag modem.img from stock folder to zip and drop it.

[*]Now head to lib folder in both.Here you have to drag and drop libcamercustom.so file to port zip.

[*]Go to system/lib/modules now,here drag and drop mtk_stp_wmt.ko file to port zip.If rom did not boots forward then you should drag and drop whole modules folder under system/lib of port zip.

[*]Go to usr/keylayout in both and drag drop Generic.kl file from stock to port zip.

[*]Lastly drag and drop a launcher like nova,apex or any to system/app/ of port zip in case port launcher did not worked.

[*]IF you rom did not booted by applying all above steps then replace these folder/files from stock to port:-

1)system/etc/firmware

2)system/lib/hw

3)system/lib/modules

4)system/vendor

[*]If your cwm port rom zip have these files then delete those.

---uboot.bin

---preloader

---logo.bin(you can keep it but you need your stock logo.bin which is available in sptool flahable roms.I will also tell you how to create own logo.bin and bootanimation in below post.)

[*]Your zip should look like this-

--Meta-inf

--system

--boot.img

--data (in some roms)

[*]After deleting the extra files you need to modify the updater script which can be found under,Meta-inf/com/google/android/updater-script...we are modifying by own only this time as we have to check only.During building rom from kitchen,it will be automatically created

as we registered our device.If we do not register our device in kitchen then during making roms from kithcen our current updater script will converted to update script which will be again converted to updater script and that will cause installation aborted error.

[*]Now drag and drop updater script from zip to anywhere and open it with notepad++,now find lines below-

format("ext4", "EMMC", "/dev/block/[COLOR="DarkOrange"]mmcblk0p7[/COLOR]", "0");
format("ext4", "EMMC", "/dev/block/[COLOR="DarkOrange"]mmcblk0p5[/COLOR]", "0");
mount("ext4", "EMMC", "/dev/block/[COLOR="Red"]mmcblk0p7[/COLOR]", "/data");
mount("ext4", "EMMC", "/dev/block/[COLOR="Red"]mmcblk0p5[/COLOR]", "/system");

[*]Here you have to deal with text in red.Your updater script may be different so use your brain and understand what i am saying forward.Text in red is mount point.In above mmcblk0p7 is mount point of data folder and mmcblk0p5 is mount point of system folder.So you need to replace mount points of updater script with your device mount points.You must found mount points of your device during registering device to kitchen.So open recovery.fstab or that kitchen/tool/edify_defs/your file with notepad++ and copy replace mount points from your device file to updater-script of port zip.If you find those lines any more places in updater script then also replace there.Here you only need some mind to use.For example if you edited and replaced red text then you must also replace orange text as they are also same.

[*]Remove the lines of the files which you removed in zip if there,like uboot.bin,logo.bin,preloader etc...they will look like below codes,you only need to find the line matching to the file you removed and deleat that.

package_extract_file("uboot.bin", "/dev/uboot");
or
assert(package_extract_file("uboot.img", "/tmp/uboot.img"),
write_raw_image("/tmp/uboot.img", "uboot"),
delete("/tmp/uboot.img"));
or
assert(package_extract_file("preloader.img", "/tmp/preloader.img"),
write_raw_image("/tmp/preloader.img", "preloader"),
delete("/tmp/preloader.img"));

[*]And replace this line

assert(package_extract_file("boot.img", "/tmp/boot.img"),
write_raw_image("/tmp/boot.img", "bootimg"),
delete("/tmp/boot.img"));

From this if any error occurs during installtion like boot.img assert failed.

package_extract_file("boot.img", "/dev/boot");

[*]Drag back the updater-script to zip from where it was taken from.

What we have done above is that we drag and drop some stock files from stock rom to port zip without extrating it.

​

Now you are good to flash your ported rom.Make CWM backup if you want to go back to previous rom or rom did not booted.After that wipe data factory reset,wipe cache partition,wipe dalvic cahce under advance option and then format system under mount and storage OF CWM RECOVEY then install zip from sd card and install your zip.I said SD card in first post if your rom did not booted and you understood your mistake and modified your port rom zip then you can do that directly by transferring zip to sd and flash instead of installing or restoring another rom.But for the users with not sd card must save their CWM backup or a working cwm flahable Rom zip otherwise they will have to reflash the rom by SP tools if rom didnot booted.

STEP II​

NOTES BEFORE BEGINNING STEP II :-

If you ported your ROM using STEP I and booted then for modifying use this STEP II.

If you tried porting rom using STEP I but it is showing installation aboted then follow this STEP II directly.

IF you have SP Flash tools format port rom and you extracted system folder and boot.img from your stock rom using my method then Follow STEP II directly.

STEP II contains some steps from STEP I,so if you already did those steps in STEP I and using same zip here then you can skip steps here.If you get confused then again do all steps.

STEP(A)- ADDING A WORKING FOLDER IN KITCHEN

FOR CWM ROM:-

Create a folder " WORKING_XXXX " under kitchen/original _update if you haven't.If you having it then check that it is empty.

Now open your port zip (or zip you ported through STEP I and was booted) and extract its System and boot.img to "WORKING_XXXX " folder.

Open kitchen and press "1" to setup a working folder.

Press Enter and select "WORKING_XXXX " folder by it assigned digit and hitting Enter

Now it will ask for name,you may change it or leave it,it does not matter.Skip it by pressing Enter.

It will start copying files to a working folder,wait sometime.

After it will ask to view Rom info,then press Y and see its info as your wish.

Now you have a working folder setup-ed.

FOR SP TOOLS ROM:-

Extract system.img & boot.img from port rom zip to C;\cygwin\home\username\kitchen\original_update

Run Kitchen and press "1" to setup working folder and hit enter.

Now again hit Enter,this time it will ask you to choose an option to select working folder,Select system.img&boot.img one folder by pressing its value and hitting enter.

Now it will ask about changing working folder name,leave it as default and hit enter.So kitchen will now start copying rom to working folder.

After Copying files it will auto prompt and open Ext2Explore application.In some cases it will show that error message that "unable to read disk,please make sure you are running appliacation with administrative rights."But don't worry,click ok.

Now after Ext2Explore opened,click on "FILE" on upper left corner and click on "OPEN IMAGE".Now browse to kitchen directory and go through newly created working folder and you will find "ext4_system.img" under system folder.Select it.

Right click on file selected in Ext2Explore and Click on SAVE,now browse to same folder where "ext4_system.img" was.Means newly created working folder/system under kitchen directory.

Then it will extract "ext4_system.img" to same folder.After finishing extraction close the Ext2Explore application.Now hit Enter in kitchen and go with default then Press y to view ROM info as per your wish.

Now you have a working folder setup-ed.

STEP(B)-Porting Rom

PATCHING BOOT.IMG:-

After successful creation of working folder you will find a new folder created named like-"WORKING_041214_135729".

Open kitchen then Press 0 for advance option and hit enter.Now press 12 and hit enter.Now you press "w" to extract boot.img from working folder.

After sucessful extraction you will find a folder under kitchen named BOOT EXTRACTED.

Now you have to copy zImage from stock boot extracted folder(which was created by you in second post last step) to this BOOT EXTRACTED folder and replace it.

Now switch to kitchen and press "b" to build boot.img from BOOT EXTRACTED folder then after repacking boot.img finish press x to exit and back to main menu.

Editing Build Prop:-

you will find build.prop under kitchen/your_working_folder/system/

Edit build.prop with notepad++

You can Edit These Values as desired:-

ro.build.id=
ro.build.display.id=
ro.custom.build.version=
ro.build.version.release=This is Andriod version That Displays in Settings
ro.product.model=
ro.product.brand=
ro.product.name=
ro.product.device=[B][U][COLOR="Red"]NAME OF FILE WHICH YOU USED TO REGISTER YOUR DEVICE TO KITCHEN[/COLOR][/U][/B]
ro.product.manufacturer=
ro.build.bluetooth.name=

EDIT BELOW LINES TO SET YOUR TIMEZONE AND AREA REGION.You can find your default details in your stock rom's build.prop which you extracted earlier.

ro.product.locale.language=(en for English,ru for Russian and other similar codes for other language)
ro.product.locale.region=(us for usa, IN for india etc.)
persist.sys.timezone=( Asia/kolkata for india,Asia/... different for different regions)

Add this line if you are porting from higher resolution deice or lower resolution device.If from higher to lower then put lower values and if lower to higher then put higher values.

ro.sf.lcd_density=xxx

Now after editing done save it and exit.

Patching Rom With Some STOCK Rom Files:-

Copy modem.img from stock Rom- System/etc/firmware to kitchen/working_folder/system/etc/firmware and replace it.

Copy libcamercustom.so file from stock Rom- System/lib to kitchen/working_folder/system/lib and replace it.

Copy mtk_stp_wmt.ko file from stock Rom- System/lib/modules to kitchen/working_folder/system/lib/modules and replace it.If ROM not booted then replace whole modules.

Copy Generic.kl file from stock Rom- System/usr/keylayout to kitchen/working_folder/system/usr/keylayout and replace it.

Download any launcher apk from net link nova,apex etc and paste into kitchen/working_folder/system/app/

If after Building rom from next step,your rom did not booted then replace these files from stock to port then build rom.

1)system/etc/firmware

2)system/lib/hw

3)system/lib/modules

4)system/vendor

Building Rom

After all above steps done,now switch to kitchen and press 99 to build ROM.

But before pressing 99 check that you put name of file by which you registered your device to kitchen in build.prop/ro.product.device="".If you registered with name x then put like this-ro.product.device="x"

If you have not done above step then you will get installation aborted error during installation.If you are confused to register device send me required fies as asked by me in above post.

After all checked now press 99

Select Build Option 1 then hit Enter

Now it will ask to zip-lang the apk,do as your wish.

After that step it will convert Updater Script and ask two option,Proceed or cancel,then Proceed by pressing "y".

It will then start making update.zip.Wait some time.

Next it will ask to sign the zip or not?You should go with default by signing update zip by hitting Enter or Pressing "y" then pressing enter.It will take some time.

After that if you want to change your ROM name then put desired name by pressing y or leave as it is by hitting Enter or 'N' then enter.

Collect you rom.zip from Output_zip folder created under kitchen directory.

Flash it and check it.

If you find some bugs then see post below to solve bugs or if you are not able to find bug solution below then post it.I will tell you how to solve it if i know.

I have ported 10+ Roms using this method,this should work for you too.Hopes that your ROM will boot.Good Luck.​