How to make a ROM - myTouch 3G, Magic Android Development

Hey XDA
This might be a dumb question, but i dont know where else to ask
I would like to try and make my own ROM for my magic, but i have no idea about where to start, so i was wondering if someone knew of a guide, or some other form of "getting startet" thingy?
And what about apps, how do you make them?
Does it require a Linux machine, or can it be done in windows?
Per

I'm interested in this as well , guys nobody wants to share with us your knowledge??

I too would like to know.

bump
I would like to know also. A quick guide or write-up would be supper nice.

Not to burst anyone's bubble but I seriously doubt a quick write-up would explain the steps on to creating your own ROM or how to write apps. If you really want to learn, I would suggest you take some programing classes at your local community college.

cptandroid said:
Not to burst anyone's bubble but I seriously doubt a quick write-up would explain the steps on to creating your own ROM or how to write apps. If you really want to learn, I would suggest you take some programing classes at your local community college.
Click to expand...
Click to collapse
A quick write up doesn't explain it, but equally going to college isn't applicable to rom cooking either.
All the information you need is on the Internet, have a look in this link where the basics are explained, and use google to fill in the blanks ...
http://www.johandekoning.nl/index.php/2009/06/07/building-android-15-build-environment/
The documentation in ASOP recommends Ubuntu for your dev machine (http://source.android.com/download) so familiarity with Linux is essential, also knowing how to use git will save you some time.
Also use the resources in the Dream section in this site. It's been around much longer than the Magic and most dev topics are already covered in a lot more detail than in Sapphire rom development. Above all I think you need a lot of time on your hands and understanding wifes/girlfriends etc as a lot of reading is necessary!

You basically need a Linux distro to be able to do the most modding. Here are the port tools:
http://www.4shared.com/file/122118622/fd190fe1/PortTools.html
Here's a nice quide that you can use as reference:
1. Download the original Nandroid backup of the Rogers-Wiped from Skittleguy (http://forum.xda-developers.com/showpost.php?p=4029461&postcount=4).
2. Unzip Rogers-Wiped.zip and move boot.img to a directory called "Org".
3. Download nk02ion_r4_LITE-signed.zip and upzip it to a directory called "nk02".
4. Move boot.img out of the nk02ion_r4_LITE-signed directory into a directory called "temp".
5. Open your Terminal window and navigate to your "temp" directory.
6. Unpack the boot image inside the "temp" directory :
Execute : $unpack-H.pl boot.img
This should give you 2 new files : boot.img-kernel and boot-img-ramdisk.gz
7. Remove boot.img and boot.img-kernel from the "temp" directory by doing :
Execute : $rm boot.img
Execute : $rm boot.img-kernel
You should now have only one file called boot.img-ramdisk.gz in your temp directory.
8. Navigate to the "org" directory.
9. Unpack the boot image inside the "org" folder :
Execute : $unpack-H.pl boot.img
This should give you 2 new files : boot.img-kernel and boot-img-ramdisk.gz
10. Move the boot.img-kernel file from the "org" directory to the "temp" directory.
Execute : $mv boot.img-kernel ../temp/
11. Remove the "org" directory
12. Navigate to the "temp" direcory
You should now have 2 files inside the "temp" directory, boot.img-kernel and boot.img-ramdisk.gz
13. Create a directory called boot.img-ramdisk inside the "temp" directory :
Execute : $mkdir boot.img-ramdisk
14. Move inside the newly created boot.img-ramdisk directory :
Execute : $cd boot.img-ramdisk
14. Unzip the boot.img-ramdisk.gz file :
Execute : $gunzip -c ../boot.img-ramdisk.gz | cpio -i
15. Check that the ramdisk is unpacked :
Execute : $ls -l
You should now see a bunch of files
16. Remove the boot.img-ramdisk.gz file inside the boot.img-ramdisk directory :
Execute : $rm boot.img-ramdisk.gz
17. Navigate to the temp folder and also delete the boot.img-ramdisk.gz file :
Execute : $rm boot.img-ramdisk.gz
You should now have 1 file called boot.img-kernel and 1 directory called boot.img-ramdisk inside the "temp" folder
18. Repack the kernel and ramdisk to a boot.img file :
Execute : $repack-H.pl boot.img-kernel boot.img-ramdisk boot.img
You should now have a new boot.img inside the "temp" directory.
19. Move the boot.img file to the nk02 directory :
Execute : $mv boot.img ../nk02/
20. Remove the "temp" folder.
21. Navigate to the nk02 folder and check that you have 1 boot.img file and 2 directories (META-INF and system)
22. Zip the boot.img and the 2 directories into an nk02.zip file
Execute : $zip -r nk02.zip *
23. Sign the nk02.zip file :
Execute : $java -jar signapk.jar testkey.x509.pem testkey.pk8 nk02.zip update.zip
24. Push update.zip to your SDcard :
Execute : adb push update.zip /sdcard/update.zip
25. Boot the device in fastboot mode.
27. $fastboot boot recovery-RAv1.0H.img
28. Select "Wipe data/factory reset"
29. Select "Apply sdcard:update.zip"
30. Select "Reboot system now"
31. Enjoy nk02ion_r4_LITE on your HTC branded Magic.
Click to expand...
Click to collapse
The above guide shows you how to modify the boot.img and how to sign the updates. That's a good start...

ok this is a dumb question i imagine but how to i sign a zip file? i have already made my rom but it wont work because it says its not signed

thejesster said:
ok this is a dumb question i imagine but how to i sign a zip file? i have already made my rom but it wont work because it says its not signed
Click to expand...
Click to collapse
Here is the thread where signing is explained.
I am no expert, but I managed to use this to modify other ROM's (Adding wallpaper, ringtones and removing apps etc.)
Signing made easy thread

Related

[HOWTO][TUT] Create a Custom ROM for Samsung Galaxy i9003

Hey there,
This is a guide on How to create a ROM
For boot sound, boot animation and themeing
Installing cygwin and Setting the kitchen up!
Finalizing , de-odexing, additional option and packing the ROM
Things you will need
-Cygwin
-Android Kitchen
-Patience
-Base ROM
--All files attached at the end--
-MagicISO
PS-> WIndows 7 users set the UAC level to minimum until you finish the whole thing. And also, make sure that nothing wxcept the META-INF folder in your ROM ins capital in letters! Just a small obseravtion in my third ROM! =P
First of all, let us extract the ROM files:
As you can see, In the folder of the XXKPH ROM, you have a system.rfs file. Copy that out to a seperate folder. In case, of any other base ROM, you can find it in the PDA file.
Now use MagicISO in order to extract the system.rfs into a seperate folder!
After that, you may find something with folders like, : app, vendor,etc,media and xbin.
Adding your apps!
Step 2
You are done with the first step!
Now, rename the folder where you have extracted system.rfs to “System” (without quotes) and move it to another folder. Call the new folder as “Custom FW”. Now create a folder called data, in which you create a sub-folder “app”. All the apps what you want to be pre-installed and can be deleted by the user go in here. (only .apk format). If you want apps which the user can not un-install, put the .apk in system/app.
Step 3
You may want to add custom boot sound and some themes,right? Okay! So here is the method.
Cutom Boot sound
First, navigate to /system/etc and find PowerOn.wav. This will enable you to change the boot sound. Replace it with a short tone of .wav format only. Now you,have changed the boot sound
To change the boot animation
1) Download the bootanimation and samsungani file attached below.
2) Put them in the /system/bin folder and replace the existing files there
3) Now download any boot animation, and rename the bootanimation to “sanim.zip”.
4) Now, navigate to /system/media and replace the “ODEanim” with “sanim.zip”
You are done with the bootanimation change
TO change the theme
Just replace the framework-res.apk and twframework-res.apk in the /system/framework folder
Installing Cygwin
Installing the Cygwin and Setting up the Kitchen
Download the Cygwin files attached below. Extract the zip to a folder. Now, you can see 3 icons, a read-me,a setup, and a folder. Choose the setup. Here You will choose install from local directory. Next, Navigate to the the folder of extraction of cygwin and choose the folder Cygwin_packages inside the cygwin extraction folder. Wait for some time. Then, You will come across a list of file. Click the 2-circle-arrows,untill, it displays “install”
After the procedure is complete, run the batch file. Now, minimise it and extract the android kitchen.
Keep it in some location like C:\Kitchen
Now, open the batch file window and type
cd C:\Kitchen
Wait for some time and then when the location the changed, type
./menu
As this is a HTC kitchen, you can't use all the features,
Now, go back to the folder “custom FW” and create a zip ( I repeat zip and NOT rar) of all the folder in the “Custom FW”. After that is done, navigate to the kitchen folder (C:\Ktichen) and palce the .zip in the “original_update” folder
Come back to the Cygwin Batch window. Now you select 1 (i.e. the first option and press enter.
Then, again press 1 twice!
Now after this is done, you can also use option 2 (rooting). You can change the ROM's name using option 8.
Step 5
De-odexing the FW.
In the batch window, choose option 0 and then choose 1.
Using this you can de-odex your FW.
Next, choose 99 to build and pack you ROM
And you are done with the custom ROM
---------------------------------------------------
Thanks to @sakindia123
Extracting and odin build
Code:
xvf ODIN_FILE.tar.md5
NOTE:.md5 is optional
Rebuilding
Code:
$ tar -H ustar -c amss boot.img csc.rfs recovery.img system.rfs >ODIN_FILE.tar
$ md5sum -t ODIN_FILE.tar >>ODIN_FILE.tar (signing the file)
$ mv ODIN_FILE.tar ODIN_FILE.tar.md5
Of course,u Have to put the name of ur file in place of ODIN_FILE
Mounting rfs(on linux)
Code:
mkdir system_mount
$ mount -o loop system.rfs system_mount
$ cp /folder/application.apk system_mount/app/ (adding aplications)
$ rm system_mount/app/application.apk (removing applications)
$ cp /folder/application.apk system_mount/app/application.apk (replacing aplications)
$ umount system_mount
Regards,
Rohan Mallya! =D
The essential files!
For the Kitchen ( thanks to dsixida)
For cygwin
Remeber to thank and vote in the POLL!!
Custom booting files ( one you have to replace for the bootanimation before you add sanim.zip!)(samsungani and bootanimation files)
MagicISO
Credits -.-
Misledz
Ganaboy
ronhoover88
Namaless
Vivek
Erahgon
Very informative posts. I hope this will lead to more ROM for our cellphone.
More things! ☻☻
You can zipalign and sign the ROM in HTC Android Kitchen itself! While COmpiling your ROM, Just select the interactive method! You can do it all there!
If you want to changes the build date and all, you can open the build.prop(present in /system folder) and change the values!
Reserved for future
If I may ask, do you have a source link for this or is it from you?
I typed it WHOLE? So..?? I did not get you well?
No worries, it's just I like to read the comments which are usually a good complement for every tut/info, so if it were from elsewhere I would have been happy to read them, that's all
can i use this port the miui rom?
r u sure u hav not copied this from elsewhere....bcoz the boot ani thing is wrong......i9003 has different format.....(i mayb wrong)
What boot ini,sak? Elaborate please??
You could also use the link below
http://forum.xda-developers.com/showthread.php?t=1168916
Sent from my GT-I9003 using XDA App
@ronhoover88 I went through it now. But, I think you cant use that meta-inf folder, the kernel adn the root script from that guide..If you feel this is thread is a WASTE OF TIME..Please tell me..I will make an attempt to delete it!
You dont have to delete...you have put a lot of effort...what i feel is, its better if you have created a rom using this guide and got it working...
Sent from my GT-I9003 using XDA App
Dude combined all this info in a single post
Sent from my GT-I9003 using XDA Premium App
The bootanimation thing is totally from vivek's thread..try it! It woooorks!

[Tutorial] How to port cf-root to other i9003 Firmwares [23/02/2012]

Tutorial for Porting Cf-root To Newer Firmware's
There were quite a few requests for a tutorial to create ginger bread cf-root. So here it is folks.
Big Thanks to skin1980 for helping me out.
Credits:
Chainfire for the cf-root.
Skin1980 for porting it to Samsung Galaxy SLCD.
Prerequisites:
Any Linux. Basic knowledge of linux is mandatory.
Tools for Unpacking and Packing images.
Base Samsung Galaxy SLCD Gingerbread Cf-root.
Samsung Galaxy SLCD Gingerbread Firmware ROM for cf-root creation.
Downloads & Setup
Any Linux: For this tutorial I am using Linux Mint KDE. You are free to use the Linux of your choice. Ideal starting point for downloading and installing Linux would be Distrowatch.com.
Tools for unpacking and packing images: These are sets of tools that allow you to unpack and pack boot images. Basically one requires just a few tools to achieve.
Link to Download: cfroot-tools.zip - 19 KB.
Download and exatract it into your home folder. It will create a cfroot-tools folder under home folder. Go to the folder and execute the following comand:
Code:
chmod +x *
Base Cf-root: Download any latest cf-root from this Link. Extract the normalboot.img from the cf-root tar file.
normalboot.img: Require normalboot.img extracted from downloaded Gb ROM.
Hex editor: You will require and Hex Editor. I am using bless hex editor. You can use any one which you are comfortable or the one available under your linux distribution.
Open terminal window and enter the following commands:
Code:
[FONT=Microsoft Sans Serif][SIZE=2]cd
[/SIZE][/FONT][FONT=Microsoft Sans Serif][SIZE=2]gedit ~/.bashrc[/SIZE][/FONT]
You can use any editor of your choice. The main purpose is to set the tools path. At the bottom of this file, add the following lines:
Code:
PATH=$HOME/cfroot-tools:$PATH
export PATH
Save and close the file.
Logoff from linux and login again for the new path to take effect.
The Actual Process
For the purpose of tutorial, I am going to use XXKPQ cf-root as the base and DDKP3 for creating new one.
Create a folder called “cfroot” with out the quotes under home.
Go to the created folder and create two more folders: DDKP3 and XXKPQ.
Now copy the normalboot.img extracted from XXKPQ cf-root and copy it into the XXKPQ folder. Next copy the normalboot.img fromDDKP3 firmware and copy it into DDKP3 folder.
Now go to the cfroot-tools folder under HOME and copy the decom.sh and recom.sh into XXKPQ and DDKP3 folders.
The above steps can be accomplished by the below code. Open command window and type the following:
Code:
cd
mkdir ~/cfroot
mkdir ~/cfroot/XXKPQ
mkdir ~/cfroot/DDKP3
cd ~/cfroot/XXKPQ
cp ~/cfroot-tools/*.sh .
chmod +x *.sh
cd ~/cfroot/DDKP3
cp ~/cfroot-tools/*.sh .
chmod +x *.sh
You need to press enter after each command.
From terminal window, first to change directory to XXKPQ, type the following commands:
Code:
cd ~/cfroot/XXKPQ
./decom.sh
After the execution of the above command, the following files and folders will be created:
normalboot.img-base
normalboot.img-cmdline
normalboot.img-pagesize
normalboot.img-ramdisk.gz => Ramdisk
normalboot.img-zImage => Kernel
Click to expand...
Click to collapse
Apart from these files, a folder called ramdisk will be created, into which the contents of normalboot.img-ramdisk.gz would have been extracted.
Now once more from the terminal window execute the following command:
Code:
cd ~/cfroot/DDKP3
./decom.sh
Also make note of the following values, which are shown, when the decom.sh script is executed.
Code:
BOARD_KERNEL_BASE 81800000
BOARD_PAGE_SIZE 00001000
Now under DDKP3 folder, edit the recom.sh file. Replace the value after --base with the value after BOARD_KERNEL_BASE. Replace the value after --pagesize with value after BOARD_PAGE_SIZE. Save the file.
Now we can switch to file manager. It will be easier to work using a file manager from here on. Open the XXKPQ/ramdisk and DDKP3/ramdisk folders separately in file manager.
Copy the folders res & sbin from base cf-root (XXKPQ in our case) and paste into DDKP3/ramdisk folder. Overwrite all when prompted.
Copy all the files under XXKPQ/ramdisk (in the root) to DDKP3/ramdisk.
From XXKPQ/ramdisk/lib/modules/2.6.35.7/kernel/ copy the fs folder into DDKP3/ramdisk/lib/modules/2.6.35.7/kernel/.
At this point of time, we no longer require the XXKPQ folder. So we can close the file manager window browsing XXKPQ folder.
Now comes the tricky and critical part. This must be done very carefully. We need to edit the .ko files using a hex editor.
Under the kernel/crypto/ folder, there is a pcbc.ko file, edit it using an hex editor. Search for 2.6.35.7 using find option in the editor. Now note down the six digit numbers starting immediately after 2.6.35.7-CL. In our case the magic number is 882023. Close the file and the editor.
Now we open the kernel/fs/ folder in the file manager.
Now open the mbcache.ko file in the hex editor. Search for 2.6.35.7 again. As we can see that the six digits after 2.6.35.7-CL is not 882023. In our case it is 709629. We need to change 709629 to 882023 and save the file. Different editors provide for different methods of editing. In my case I can just simply click on starting number that is 7 and start typing 882023 and save the file.
Now you need to do the same for two more files under kernel/fs/jbd2/ and kernel/fs/ext4/.
Now go back to ramdisk folder. Under ramdisk/sbin/boot/ there is a file called install.sh. We are now going to edit this file. This not important that you edit this file.
Edit the first line and replace XXKPQ with DDKP3.
Similarly under the “# Once be enough”, there is another XXKPQ which is to be replace with DDKP3.
Now save this file.
Now back to command prompt and execute the following commands:
Code:
cd ~/cfroot/DDKP3
./recom.sh
Executing the above script recreates the normalboot.img-ramdisk.gz, the normalboot.img and create DDKP3-CFROOT-16-02-2012.tar.
The DDKP3-CFROOT-16-02-2012.tar is the cf-root for DDKP3 and can be flashed using ODIN as Pda file.
*
Thats it folks. Hope my effort is worthwhile and benefits some of you.
*
Additional Links:
A text file Create Custom Rom (though not for our phone but is quite useful all the same) - Found it while searching google. Don't know who created it. But here is the link. Create_Custom_Rom.txt - 5 KB
The link to tools zip mentioned in the above text file. tools.tar.gz - 49 MB
Script to uncompress and compress UC Kernel
uc_decom.sh - 258 b
uc_recom.sh - 382 b
10 Chars ......
For Future Use
Whoa! This is huge! Awesomr work man! Thanks.
Edit - No offence meant, but it would be appropriate if the title is How to "port" or similar. Since it ws "created" by ChainFire and we just porting it.
ganeshbiyer is good, very patient, did not think that my trouble!
Has been helping me! Am very grateful!
great job! & i already translate it into chinese^^
and a problem:
after i run the script "decom.sh",it display following words:
[[email protected] xxkpq]# ./decom.sh
./decom.sh: line 5: unpackbootimg: command not found
gunzip: ../normalboot.img-ramdisk.gz: No such file or directory
cpio: premature end of archive
[[email protected] xxkpq]#
help me please~what's going on?
cRainin said:
great job! & i already translate it into chinese^^
and a problem:
after i run the script "decom.sh",it display following words:
[[email protected] xxkpq]# ./decom.sh
./decom.sh: line 5: unpackbootimg: command not found
gunzip: ../normalboot.img-ramdisk.gz: No such file or directory
cpio: premature end of archive
[[email protected] xxkpq]#
help me please~what's going on?
Click to expand...
Click to collapse
unpackbootimg must be in the path.
also it must be executable.
ganeshbiyer said:
unpackbootimg must be in the path.
also it must be executable.
Click to expand...
Click to collapse
sorry,i paste the wrong code. my problem is this:
[[email protected] XXKPQ]$ ./decom.sh./decom.sh: /home/chenyu/cfroot-tools/unpackbootimg: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
gzip: ../normalboot.img-ramdisk.gz: No such file or directory
cpio: premature end of archive
[[email protected] XXKPQ]$
cRainin said:
sorry,i paste the wrong code. my problem is this:
[[email protected] XXKPQ]$ ./decom.sh./decom.sh: /home/chenyu/cfroot-tools/unpackbootimg: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
gzip: ../normalboot.img-ramdisk.gz: No such file or directory
cpio: premature end of archive
[[email protected] XXKPQ]$
Click to expand...
Click to collapse
Need to install the missing file ld-linux.so.2
Sent from my GT-I9003 using xda premium
Thank you Ganeshbiyer! this is the tutorial for which send multiple private messages and never answered .. Thanks again, nowI can make a version for Gingerbread UBKPD.
goodbye
Yeah ganesh! A superb work..well done bro
thanks bhaiya....
Thanks for the tutorial buddy
Hope it has been useful.
_
Release all PERFECT! I had no problem in making the entire guide .. BUT ... when flashing in ODIN, and says that when it failed to finish.
I knew that I would be so easy, so I started to analyze both folders (my UBKPD and XXKPQ) and did not get that at the root of KPD I have 12 files and only 11 KPQ. The 12th file executable type KPD called RECOVERY. This file should remove it before using recom.sh?
Thanks again for the guide. goodbye
Edit2:
Well, my little patience led me to delete that file and then went back to RECOVERY recom.sh run and throw me error that could not erase normalboot.img and did not understand, but looking at the files in the root, not the size you normalboot.img was higher than the stock then replace the stock normalboot (+5 mb), run again and finally he created recom.sh cf.root, I flash with ODIN successfully without any problem in these +30 minutes.
Thanks (again).
Now I have as including UV & OC (freqmax 1100MHz is very good speed and would think you do not need more with this phone)
maybe a stupid question:
would it work with other phones as well? natually with the files of the other phone and not with the 9003 files
fabsau said:
maybe a stupid question:
would it work with other phones as well? natually with the files of the other phone and not with the 9003 files
Click to expand...
Click to collapse
Well you can always try
thanks for your reply
I will try it soon^^
wait for my next reply
greetings fabsau
i do it all at this tutorial and it create .tar fine without trouble.. i flash with odin also no problem happen.. but while device open.. at boot logo get stuck or freeze at long time.. why it happen???
i confuse with this line:-
-Copy the folders res & sbin from base cf-root (XXKPQ in our case) and paste into DDKP3/ramdisk folder. Overwrite all when prompted.
-Copy all the files under XXKPQ/ramdisk (in the root) to DDKP3/ramdisk.
-From XXKPQ/ramdisk/lib/modules/2.6.35.7/kernel/ copy the fs folder into DDKP3/ramdisk/lib/modules/2.6.35.7/kernel/
Click to expand...
Click to collapse
why do not copy all the file in ramdisk n skip copy file inside the ramdisk folder.. it is difference?? please tell me if i do a mistake.

[DEV-GUIDE] Flytouch 3 Superpad 2 - Custom ROM building tutorial

Dear All,
I have been building some custom Android ROMS for the past few years, and my latest toy is a Flytouch 3 I wanted to share some of my findings and methods here, perhaps other newbies like me will find it useful.
1. FT3 ROM contents:
FT3 ROMs will be in RAR or ZIP format and have 2 or 3 files in them as explained below. Just unzip or unrar the package to use them:
firmware2 - flash tool which burns the firmware ( I guess...lol)
bootloader-discovery - 7zip file which contains the bootloader
IMPORTANT! Do not flash a wrong bootloader to your device or it will be bricked! Actually this is the only way you can brick the thing, it's pretty sturdy in that sense. If you are not sure, do not copy bootloader-recovery to your sdcard when flashing, it will boot with your existing bootloader anyway.
firmware-discovery - 7zip file which contains the firmware and it's the main file you want to edit.
2. firmware-discovery contents:
This is the easy part! Modifying this file will let you modify system and data partitions. You can also use different ramdisks and kernels compatible with your device. It's a 7zip file and you can unpack and repack easily with the 7-zip file manager (http://www.7-zip.org/).
I use 7-zip on Windows although I use Ubuntu Linux as my main OS. There is something wrong with my 7-zip installation most probably, but I was too lazy to check it If you are on Windows anyway, you are good, just download and use 7-zip from the URL above. I advise that you do all your firmware-discovery editing within 7-zip file manager. That way, you won't have to worry about re-packing with the correct 7-zip settings. At least, that's how I do it and had no problems.
firmware-discovery will have these files in the 7zip package:
uImage - kernel
Very important Your kernel will make the difference between having and not having certain functionality, even if your hardware supports it.
uImage_recovery - recovery file - I beleive this is what runs when you push menu+power.
ramdisk.img - ramdisk
This is one of the interesting files you might want to play with. Ramdisk is a simple file system with some crucial files, mainly init.rc that lets you control the boot process. You can also stick a initlogo.rle image here to display a splash image in initial boot. More details below at title 4.
data.tar - /data partition - tar archive
All user data is stored here, including apps and user definable settings. This is what gets wiped when you do a recovery by pushing menu+power.
system.tar - /system partition - tar archive
System data, drivers and apps, including Android OS itself (except kernel). Certainly the most interesting part for the average modder
3. Editing system.tar and data.tar:
This might be the bulk of your modding, and most probably what will be most visible to the end user.
I very strongly suggest that you use a Linux system to edit these files. If you use Windows, file permissions will not be saved! If Windows is your main OS, simply install a VM host such as VirtualBox and install your fav Linux distro inside it. Most of them will have an Archive Manager with a GUI and will certainly support TAR. Even without a GUI, you can use "tar" and "untar" commands from a terminal to unpack and repack these files. When you are on Linux, TAR files will preserve file ownership and file permissions. This can be very crucial in your modding.
For modders who are new to Linux, I can recommend Ubuntu. It's very user friendly and easy to use in my opinion.
When you are done editing system.tar and data.tar copy them to your Windows box and drop and them to firmware-recovery file within 7-zip file manager.
4. Unpack, Edit and Repack ramdisk.img:
Now we are on to more serious stuff ramdisk.img consists of a 64 byte U-Boot header, followed by a gzip compressed ramdisk cpio image. So we need to strip the first 64 bytes, and use gunzip to extract it to a folder. After making the changes in the folder, we need apply cpio+gzip compression to the folder and add the 64 byte u-boot header again. You will need to use Linux and install the mkimage tool for these operations.
Here's the command to install mkimage tool in Ubuntu:
Code:
sudo apt-get install uboot-mkimage
It sounds complicated, but no worries, I have some shell scripts that can do all that for you! Thanks to leeh33 from Techknow for the scripts below:
unpack_ramdisk.sh
Code:
mkdir ramdisk
cd ramdisk
dd if=../ramdisk.img bs=64 skip=1 of=ramdisk.gz
gzip -dc ramdisk.gz | cpio -idmv
rm ramdisk.gz
repack_ramdisk.sh
Code:
cd ramdisk
find . | cpio -o -H newc -C 512 | gzip -n > ../ramdisk.cpio.gz
cd ..
mkimage -A ARM -O Linux -T ramdisk -C none -a 0x41000000 -e 0x41000000 -n hRamdisk -d ramdisk.cpio.gz ramdisk.img
rm ramdisk.cpio.gz
Create the scripts above using a text editor or download the attachment to this post and put the scripts together with your ramdisk.img file in a new folder. Executing unpack_ramdisk.sh will create a folder named ramdisk and extract the ramdisk contents here. You can edit e.g. init.rc in this folder, or add a static bootlogo. To add a custom bootlogo create a initlogo.rle image file by following this guide: http://www.androidtablets.net/forum/android-tablet-hacking/438-how-setup-static-bootlogo-before-animated-boot-animation.html Then place the resulting initlogo.rle file directly in the ramdisk directory.
After you are done editing the ramdisk folder, simply run repack_ramdisk.sh and your new ramdisk.img will be created, replacing the old one. Copy the ramdisk.img file to your Windows box again and drop it to firmware-recovery file within 7-zip file manager.
That's it, you have a custom ROM now! Please feel free to ask questions or correct me if you think I have any errors in the info above.
Happy Modding!!!
Tolga
Big problem about my device...
Thank you for this useful post!
I have seen a good knowledge about these devices(flytouch 3) and decided to post my question here:
I have a big problem! I used IUW Burning tool to flash my device. my device is:
SuperPad III (As box says)
Model: ANDR P1001
I decided to try tim's custom rom. It doesn't work. After restarting the device, screen become black (There was no connection
with screen, it was not turned on). The device had vibration when I pressed power button. It continued vibrating periodically(like it was restarting).
After that I flashed my device using IUW with most likely firmware, but during the process I FORGOT TO CHOOSE userdata.img FILE!
Now the device can't even communicate with pc.
OTG method is not working. The device no more vibrates at start up! At motherboard led is lighting when pressing power button.So IS MY DEVICE DEAD? Or is there any solution in this situation(Alternative communication, or whatever...)

(How to) unpack/repack boot.img using terminal apk

This is a tutorial I've decided to put together as I'm learning to compile kernels. It will cover unpacking and repacking a boot.img and/or recovery.img, and also touch on unpacking the ramdisk after we have unpacked the boot.img This tutorial will only focus on executing this on a android device using the terminal emulator app but of course you could use these tools on a PC in a adb shell.
This would not be possible without the hard work of xda member @Modding.MyMind. I am not responsible for anything you do to your device by using these tools.
What you will need
1. Android device
2. Have root
3. Have busybox installed (1.23.1 is recommended)
4. Terminal Emulator app
5. Root Explorer app
6. Your devices boot.img and/or recovery.img
7. mkbootimg_tools-master.zip (download below)
https://www.dropbox.com/s/fiat0zrf2f533uq/mkbootimg_tools-master.zip?dl=0
DIRECTIONS
1. Let's pull the boot.img we are going to work with using dd. Open your terminal and type su > press enter. Type dd if=/dev/block/platform/msm_sdcc.1/by-name/boot of=/sdcard/boot.img > press enter and now you should see a file on your sdcard called boot.img
2. Place the zip file on the root of your internal sdcard and extract it. You will see a folder called mkbootimg_tools-master and inside that folder you will see 2 folders. One called ARM and one called README.md Now we are going to copy the ARM folder to data/local/tmp and paste it inside of the tmp folder.
3. Now we need to go the ARM folder that you just copied inside tmp and set the permissions to 0777 (rwxrwxrwx) and also set the same permissions for each file inside the ARM folder.
4. Now go inside the ARM folder and copy the bash file to system/xbin and set the permission to chmod 0755 (rwxr-xr-x)
5. Ok now copy the boot.img file that we pulled onto your sdcard inside the ARM folder and leave the permissions for that file 0666 (rw-rw-rw-)
6. Open up your terminal emulator app and type su > press enter
7. Now we are going to change directories to the ARM folder which we want to be in by typing cd data/local/tmp/ARM > press enter
########################################
Now to unpack your boot.img
1. Type ./mkboot boot.img bootfolder > press enter and you will see the magic happen. It will automatically create a folder called bootfolder which is your project folder and you can name it whatever you like but I like to call it bootfolder and if I was unpacking a recovery.img I would call it recoveryfolder
2. So now you have your unpacked boot.img.
3. Now go to your terminal and type cd bootfolder > and press enter. We are going into your bootfolder now because that is where your ramdisk.gz is located and we are now going to decompress your ramdisk by typing gunzip -dc ramdisk.gz | cpio -i > and press enter and it will decompress your ramdisk for you.
4. So now you have unpacked a boot.img and also learned how to decompress your ramdisk.
########################################
How to decompress a ramdisk in lzma format
1. ./mkboot recovery.img workfolder
2. cd workfolder/ramdisk
3. Now type lzma -dc ../ramdisk.lzma | cpio -i; strings *.ko
4. Now you will have your lzma compressed ramdisk inside your workfolder
#######################################
Now we are going to repack your boot.img
1. In your terminal type cd .. > and press enter so you will move back 1 directory into your ARM folder.
2. Now to repack you are going to type ./mkboot bootfolder boot.img > and press enter and that will repack your boot.img for you
*wherever you saw me type a > don't ever type that as I was just showing that you are done the command or syntax and your are ready to press enter
Source code https://github.com/ModdingMyMind/mkbootimg_tools/commit/6c44267b4a8a43504c870678c68df6a31b8e2f18
Screenshot - https://www.dropbox.com/s/se171tzgnf6wp0q/Screenshot_2015-03-12-02-49-50.png?dl=0
Screenshot - https://www.dropbox.com/s/5bzt8p6l2ltosl6/Screenshot_2015-03-12-02-50-04.png?dl=0
Thanks to @leonardoafa for being a great help & friend
How different is it for a recovery image file please?
Is the same, just put your recovery.img in the ARM folder and you might want to call your project folder something different than bootfolder (ex; recoveryfolder) so you don't get confused or forget
Oh yes, however ramdisk folder is empty when you use only a recovery image. Less content of course.
image45 said:
Oh yes, however ramdisk folder is empty when you use only a recovery image. Less content of course.
Click to expand...
Click to collapse
When i use twrp everything is working perfect. Your ramdisk is probably in a lzma format I'm guessing
As you can see im inside of my ramdisk folder, which is inside my recoveryfolder
https://www.dropbox.com/sc/ffyy2ndrkl57hn4/AACV__FpJuScCvIvErx2WFffa
@image45 i added how to decompress a ramdisk in lzma format to the op
Nice guide :good:
Yes very detailed, thank you.
@skulldreamz
Hi my friend, do you still want to learn about scripts.
Please go to telegram app.
Thanks
@image45 can you sendme your image that uses a lzma compressed ramdisk. The project supports lzma so there should be no need to decompress it manually however, if the project is not doing what it should already be doing then I need to debug the script, find the culprit, make my fix, and push the changes to my github. Would be greatly appreciated. Thanks.
app
Hy,
I use this app for long time to open boot.img and extract ramdisk.
The app asked then if you want open the ramdisk also.
Only click on your boot.img and in 4 sec its open.
Second function is to pack a boot.img.
Very simple to use, also for beginners.
konsolen said:
Hy,
I use this app for long time to open boot.img and extract ramdisk.
The app asked then if you want open the ramdisk also.
Only click on your boot.img and in 4 sec its open.
Second function is to pack a boot.img.
Very simple to use, also for beginners.
Click to expand...
Click to collapse
It only decompresses gzip ramdisks. Doesn't support other types unless you modify the ramdisk.sh script used inside the apk. It also doesn't support images with dt binaries which is more common nowadays. I use to use this a long time ago but to say it simple, it is outdated and lacks support.
However, if it works then I say use it. Especially if the person isn't comfortable with command lines.
Very helpful thx
Thanks
Sent from my SAMSUNG-SGH-I747 using Tapatalk
I see this is an older thread but tried it on my Nexus 6p. When I repacked boot it was significantly smaller in size. It also has the warning of non standard address. Anything I should do or be aware of?
Fe Mike said:
I see this is an older thread but tried it on my Nexus 6p. When I repacked boot it was significantly smaller in size. It also has the warning of non standard address. Anything I should do or be aware of?
Click to expand...
Click to collapse
Try using mkboot....
https://github.com/xiaolu/mkbootimg_tools
The Sickness said:
Try using mkboot....
https://github.com/xiaolu/mkbootimg_tools
Click to expand...
Click to collapse
Thank you, bare with me as Im fairly new to this. Just to be clear, when i go to link there is the ARM folder that has all the same stuff in it or the single mkboot file thats 9.46mb in size? Not sure how to download just the mkboot file. When i click it, it just opens up the code. Do i copy and paste the code?
Fe Mike said:
Thank you, bare with me as Im fairly new to this. Just to be clear, when i go to link there is the ARM folder that has all the same stuff in it or the single mkboot file thats 9.46mb in size? Not sure how to download just the mkboot file. When i click it, it just opens up the code. Do i copy and paste the code?
Click to expand...
Click to collapse
You have to clone the source using "git clone" in your terminal. Which means you need to be on Linux
The Sickness said:
You have to clone the source using "git clone" in your terminal. Which means you need to be on Linux
Click to expand...
Click to collapse
Ok, I was able to clone using cygwin. But i was reading in the forums that the size of extracted boot from phone will not be the same as it being repacked. So I used original files from this post and and just extracted, unpacked, and repacked. Then just flashed img thru twrp and everthing went well. Thank you for your response.
SHM said:
It only decompresses gzip ramdisks. Doesn't support other types unless you modify the ramdisk.sh script used inside the apk. It also doesn't support images with dt binaries which is more common nowadays. I use to use this a long time ago but to say it simple, it is outdated and lacks support.
However, if it works then I say use it. Especially if the person isn't comfortable with command lines.
Click to expand...
Click to collapse
Why haven't you made something like this, he's just using someone else's tools, please MMM, you're the man

[Tutorial] NOOB-Friendly Instructions on Packing and Repacking system.new.dat file

I am a Windows user, and I was having quite the trouble unpacking and repacking system.new.dat files. I tried all sorts of Windows Chinese tools for the job, but no matter what I did, when I put the system.new.dat file and system.transfer.list file back into the flashable zip (even if I made no changes to the system.new.dat file... just unpacked and repacked), I would get an error flashing the file.
I finally got around this by installing Ubuntu 16.04 Xenial Xerus on VirtualBox. You can find a lot of tutorials online about how to do that. I am basing my instructions off of xpirt's tutorial on unpacking and repacking with the tools he provides. But it took me about 2 days to figure it out because I kept running into problems since some of the instructions made assumptions that the user knows how to use Linux. I am very new to Linux. I am not completely sure how to do *everything* from the command line, so if someone wants to add to my instructions to make it easier, please do so. But these are the things I did to figure it out.
So here are the noob-friendly Linux Ubuntu instructions on how to unpack and repack:
Section 1: Getting everything Ready
1. Download your flashable .zip rom. In my case, I downloaded cm-12.1-20150619-UNOFFICIAL-afyonltetmo.zip to my Ubuntu Desktop. You can download it to your Home Directory as well. Doesn't matter.
2. Download sdat2img. I downloaded mine to my Home Directory.
3. Download img2sdat. I also downloaded this to my Home Directory.
4. Extract all 3 zips, by right clicking on them and choosing 'Extract Here.' It will extract them into their own directories. The main directories that you need to pay attention to are /sdat2img-master/ and /img2sdat-master/
5. Download ext4fs either right into the sdat2img-master folder, or anywhere you want and then drag and drop it into the sdat2img-master folder.
6. Open Terminal, and install Python 2.7, if it's not already installed. Put
Code:
sudo apt-get install python-2.7 python-pip
Section 2: Beginning the Unpacking Process
*Note, you can copy and paste the codes; however, you can't use keyboard shortcuts in terminal. You have to right click and choose your option.
*Another note: Where you see "user" in the terminal commands, substitute it with your Linux username.
1. In your extracted folder from your flashable zip, right click on system.new.dat and system.transfer.list and choose 'cut.' Then paste them in the sdat2img-master folder.
2. Back in Terminal put
Code:
cd sdat2img-master
. That will get you into the right directory.
3. Now put
Code:
./sdat2img.py system.transfer.list system.new.dat system.img
. That will create your raw ext4 .img file.
4. You want to create an output directory for all the files that are in system.img. Put
Code:
mkdir output
5. Now you can mount system.img, and it will mount it into that output folder. Put
Code:
sudo mount -t ext4 -o loop system.img output/
6. You might have the problem that you don't have ownership of all the files (they have little "locks" on them). To gain ownership, put
Code:
sudo chown -R user:user /home/user/sdat2img-master/output
. If you still can't get read and write access, just try rebooting your Ubuntu virtual computer. That was the only thing that finally worked for me. You can start modifying stuff as you wish.
Section 3: Compress files back to a raw ext4 image
1. You are now going to need your file_contexts file from your original extract rom zip. COPY (not cut) and paste it into the sdat2img-master folder.
2. You are also going to need your 'make_ext4fs' file. Make sure it is in the sdat2img-master folder. You might have trouble with permissions, so just in case, put
Code:
chmod 777 /home/user/sdat2img-master/make_ext4fs
into terminal.
3. In Files (Ubuntu's "File Manager"), in the sdat2img-master folder, right click on your system.img file and go to 'Properties'. Notice the information in "Size." Ignore the GB, but look at the bytes. Mine is 2,411,724,800. Copy that number, but remove the commas. So mine is 2411724800.
4. Next is the actual compressing part. Put
Code:
./make_ext4fs -T 0 -S file_contexts -l 2411724800 -a system system_new.img output/
into terminal, but substitute '2411724800' with whatever size you got from the Properties in system.img. You will now how a new file called system_new.img.
Section 4: Converting ext4 (raw image) to img (sparse image)
1. Now you will need to install img2simg. In Terminal, put
Code:
sudo apt-get install android-tools-fsutils
2. Now you can put
Code:
img2simg system_new.img system_new_sparse.img
You will now have a file called system_new_sparse.img that is ready to be packed in a new dat file.
Section 5: Converting img (sparse image) to dat (sparse data)
1. Cut and paste your system_new_sparse.img into img2sdat-master folder that you made earlier.
2. Now you need to navigate to that folder in terminal. Put
Code:
cd /home/user/img2sdat-master
3. Now you can put
Code:
./img2sdat.py system_new_sparse.img
to create your new dat file. It will first ask you which Android version it's for. Enter the number corresponding and hit enter.
4. You're now pretty much done. As you'll see, it created 3 files: system.new.dat, system.patch.dat, and system.transfer.list. Just paste these files into your folder where your flashable zip files are, replacing any original ones in there. Make sure you also have your file_contexts file in there as well. Highlight all the files in there, right click, and zip them up. Then name your flashable zip whatever you want and try flashing!

Categories

Resources