Not everyone owns a pc but most android user wishes to build or port roms, those who have pc they can build or port roms very easy but what about them who don’t have pc? Now it is possible our hardworking devlopers in XDA have released some tools that can do the same as the pc one. This article covers all the essential steps required to port roms. Please note that this article only cover porting roms not building roms from source and building roms without pc is currently impossible and steps listed below only explains system and kernel extracting, repacking procedure not full guide to port roms because some files vary in different devices. Let’s start with identifying the terms!
What is porting roms?
Porting roms means the process of taking another rom from another device with similar hardware and modifying it by replacing files from your device to work on your device is called porting roms. In other words modifying another device rom and running it in your device is called porting.
What is kernel?
Kernel is a bridge between hardware and software. It also controls the voltage means it supply only required voltage to the hardware so it is responsible for your device battery life. If you do something wrong in porting kernel then your device will not turn on.
What is mkbootimg tool?
Mkbootimg tools are the tools which are used to extract boot.img(kernel).
Let’s start porting
1. Make two folder base and port. The base one is from your device rom and port one is for the rom you want to port.
2. Download both the port and base rom of same android version and extract them to their corresponding folders.
3. Download sdat2img and mkbootimg tool (links are given below)
4. Install busybox and terminal emulator from play store
5. Install the sdat2img.zip through TWRP recovery and make sure that your system has 70mb of free space
6. convert the both system_new.dat one by one to system.img by running this command through terminal emulator:-
Cd system.img location sdat2img <system_transfer_list> <system_new_file> <system_img>
In system_new.dat location type where you stored your base and port rom system_new.dat
7. Now both system_new.dat has been converted to system.img
8. Extract the system.img by this command:-
mount -t ext4 -o loop system.img system
cp -rf system system2
9. Both the system.img has been extacted now replace the files as needed
1. Flash the mkbootimg_tools.zip through twrp
2. Install hex editor from play store
3. Open the hex editor then open boot.img and delete every thing before android!. Do the same for the another one also. After removing it should look like this
4. Place both the boot.img to data/local/tmp
5. Open terminal emulator and run this command:-
6. For base boot.img:-
unmkbootimg -i boot.img
7. For port:-
unmkbootimg -i boot.img
Extracting the ramdisk
8. Create a folder for ramdisk by running:-
9. Run this to extract ramdisk:-
gunzip -c ../ramdisk.cpio.gz | cpio -i
10. Now let’s repack the ramdisk by running:-
mkbootfs ./ramdisk | gzip > myramdisk.gz
Rename the myramdisk.gz to ramdisk.gz
Then copy and replace it with the one on your base kernel folder
Repacking the kernel
1. To repack first run cd command and go to data/local/tmp/base then run this command in terminal emulator:-
mkbootimg –base 0 –pagesize 2048 –kernel_offset 0x80408000 –ramdisk_offset 0x81808000 –second_offset 0x81300000 –tags_offset 0x80400100 –cmdline ‘console=ttyHSL0,115200,n8 user_debug=31’ –kernel kernel –ramdisk ramdisk.cpio.gz -o boot.img
The boot.img has been repacked now copy the boot.img to the ported rom folder and paste it and repack the rom.
Congrats you have ported your own rom without pc!
Mkbootimg tool- https://drive.google.com/file/d/0Bzt8mctLFz_6Y0ozUGx4aDBTSVk/view?usp=drivesdk
Modding.mymind(XDA) for mkbootimg tools.
RendyAK(XDA) for sdat2img.