*** I TAKE NO CREDIT. I JUST MADE A GUIDE TO HELP YOU***
A STEP BY STEP TUTORIAL :
I find many people struggling with unpacking a boot image and expecially repacking it. So here is a simple guide to unpack and repack the boot image.
>You need some tools so make sure you download all these.
List : (links available at bottom of page
split_bootimg.pl
repack_bootimg.pl
dsixda kitchen (you need some files from here)
Not to mention, a linux based system
> First you need to make some correction to repack_bootimg file(if downloaded from other source) . open it using gedit or some editor.
> check third line from bottom which is starting with system...If it is ending with $ARGV[2] then make this change
Add --base 0x19200000 and then close with " .
This now should look like
$ARGV[2] --base 0x19200000");
> Save it and exit. Now place boot.img and the two files in a folder(create new one. Don't mess it up)
> Now go to dsixda kitchen folder >tools >mkboot and copy all the files to your working directory
> Now you have mkbootfs.c and mkbootimg.c files along with needed header files. You have to make them executable. For that, run this command
gcc -o mkbootfs mkbootfs.c
change the permissions
chmod a+x ....(path)/mkbootfs
Now do the same for mkbootimg.c
gcc -o mkbootimg mkbootimg.c
change the permissions
chmod a+x ....(path)/mkbootimg
Now you are ready to go. Just navigate to directory in command prompt and type
./split_bootimg.pl boot.img
(or)
perl split_bootimg.pl boot.img
you will get some files. one is kernel and other is ramdisk. extract ramdisk.gz. Now again extract ramdisk(cpio file) . Make necessary changes.
To repack, use this command
perl repack-bootimg.pl <kernel_name> ramdisk_directory_name boot.img
( you need mkbootimg for this to work)
Bingo you have a boot.img which is ready to test.
LINKS :
Split_bootimg.pl : http://www.mediafire.com/?i4omee9loaxawtk
Repack_bootimg.pl : http://www.mediafire.com/?sthhkkkkctdvb3d
dsixda kitchen : http://forum.xda-developers.com/showthread.php?t=633246
IS YOUR dsixda kitchen FIX FOR MOTO ?
duansindo said:
IS YOUR dsixda kitchen FIX FOR MOTO ?
Click to expand...
Click to collapse
If you are talking about using the kitchen for motorola, it supports only few devices.
Motorola Atrix (unconfirmed)
Motorola CLIQ / CLIQ XT
Motorola Droid (unconfirmed)
Motorola Milestone (unconfirmed) - you may need to remove the boot.img before building
here is moto list...If you are talking about repacking n stuff, it supports any vendor.
godson32
can sum1 plz help me.... i have evo root 2.2 i was trying to nandriod backup in restore . once i got done doing both i rebooted sys. all i get is the while htc evo screen oh ima noob, plz sum one help, oh im running clockworkmod recovery v2.6.0.1
godson32 said:
godson32
can sum1 plz help me.... i have evo root 2.2 i was trying to nandriod backup in restore . once i got done doing both i rebooted sys. all i get is the while htc evo screen oh ima noob, plz sum one help, oh im running clockworkmod recovery v2.6.0.1
Click to expand...
Click to collapse
Try the evo forum.
ok im trying to repack a kernel and i get mkbootimg not found i already downloaded a mkbootimg zipbut dont know what to do with it can someone guide me on what to do with mkbooting thanks in advance
Check out the Kitchen
http://forum.xda-developers.com/showthread.php?t=633246
In that zip, i use scripts/boot_img_tools to unpack. Then I looked through build_boot_img to get the command syntax for mkbootfs and mkbootimg. It also shows the commands for compiling those tools. They are in the tools folder. The mkbootfs will create the ramdisk image. Then mkbootimg will combine it and the zImage into a boot.img (or recovery.img).
I can't remember the parameters off hand, but that script (build_boot_img) will tell you everything you need to know.
Thanks ill check it out
Sent from my SCH-R720 using xda premium
Good morning family!
It's my very first time posting in this subforum, but I think this tutorial was actually something needed, since all threads everyone can found while Googling are quite old (like, from the Xperia S times ), and also I'm quite tired of infinite threads like this and this, so...
Today I bring you an extensive and unified guide on how to extract ANY SYSTEM FILE from a FlashTool's Firmware (FTF), whether it's from the userdata.sin or from the system.sin.
Since this is going to be a guide for all OSes, there are some programs you'll need in general,
Latest version available of FlashTools (for SIN dumping purposes).
A reader tool for the extracted image, which can be:
An EXT4 reader / mounter.
An Unyaffs2, if you're using this guide for an old device (like the already mentioned Xperia S, and older).
Some cups of coffee, and lots of patience [IMPORTANT].
But, some of them will be platform specific, so the thread will split in:
2nd post: WINDOWS
3rd post: LINUX
4th post: OSX
Here you've a video tutorial showing the whole process for the 3 OSes:
If you're enjoying it, don't forget to press Thanks button and rate this thread!
WINDOWS GUIDE
Step 1 - Extract the SIN we need
Using your favourite archive manager (WinRAR, 7-Zip, etc), open the FTF you want to extract the files from. (FYI: an FTF is just a Zip file with renamed extension)
Now copy/extract the SIN you want to unpack to a folder of your preference.
Step 2 - Dump the SIN
I'll take into account you already had installed Flashtools and Java JRE, in which case I highly encourage you to update both to the latest version available.
Now, open Flashtools. Click on Tools, Sin Editor. Hit the [...] and locate the SIN you previously extracted. Now, hit the [Extract Data] button. After a couple of minutes the bar should start running.
Once finished, you can have 2 kind of files: a .yaffs2 or a .ext4/.ext3/.ext2 file, which require different procedures on how to see it's contents.
Step 3.a - Convert the file to a readable format - UnYaffs2
If the file you get is a .yaffs2 format file, you're going to need to extract it. For doing so, you need this tool, which contains a executable and a cygwin dll.
Extract this .rar contents to the very same folder where you placed the SIN, and thus, where the .yaffs2 is located.
Now, while you're in that folder press the shift key in your keyboard, and while you keep pressing it, right click on a blank space in that folder. In the menu choose Open a Command Prompt here.
To end the proccess, type
Code:
unyaffs2.exe [COLOR="DarkOrchid"]<the-name-of-the-yaffs2>[/COLOR]
Where <the-name-of-the-yaffs2> you must type the file name of the yaffs2 (e.g. system.yaffs2)
The files will get extracted and you'll be able to pick the ones you need.
Step 3.b - Mount the image - Linux Reader
There're many many tools to mount a EXT format image in Windows, but in this case, I'll use the Diskinternals Linux Reader, since it's free and it's compatible with all 3 possible formats you can encounter: .ext4/.ext3/.ext2.
Download it from here and install it. (It must be this version, since newer ones are broken.)
Once done, you should be perfectly able to double-click-to-mount the EXT file Flashtools generated without any trouble.
LINUX GUIDE
Step 1 - Extract the SIN we need
Using your favourite archive manager (Ark, Peazip, etc), open the FTF you want to extract the files from. (FYI: an FTF is just a Zip file with renamed extension)
Now copy/extract the SIN you want to unpack to a folder of your preference.
Step 2 - Dump the SIN
I'll take into account you already had installed Flashtools and Java JRE, in which case I highly encourage you to update both to the latest version available.
Now, open Flashtools. Click on Tools, Sin Editor. Hit the [...] and locate the SIN you previously extracted. Now, hit the [Extract Data] button. After a couple of minutes the bar should start running.
Once finished, you can have 2 kind of files: a .yaffs2 or a .ext4/.ext3/.ext2 file, which require different procedures on how to see it's contents.
Step 3.a - Convert the file to a readable format - UnYaffs2
If the file you get is a .yaffs2 format file, you're going to need an extra tool to extract it. For doing so, you are going to need the unyaffs2 tool.
You can download a pre-compiled binary from here, or you can compile your own using GCC with the source code, the header and the code below inside a Terminal (Ctrl+Alt+T to open it).
Code:
gcc -o unyaffs unyaffs.c
Once you've a working UnYaffs2 binary, just copy it to the very same folder where you placed the SIN, and thus, where the .yaffs2 is located, and type in a Terminal (Ctrl+Alt+T to open it).
Code:
cd [COLOR="DarkOrchid"]<file-route-of-the-sin>[/COLOR]
./unyaffs2 [COLOR="Blue"]<the-name-of-the-yaffs2>[/COLOR]
Where <file-route-of-the-sin> is where the SIN was located, and where <the-name-of-the-yaffs2> you must type the file name of the yaffs2 (e.g. system.yaffs2)
The files will get extracted and you'll be able to pick the ones you need.
Step 3.b - Mount the image
Since we're already in Linux, mounting a EXT image is not that hard. Just mount it using this commands in a Terminal (Ctrl+Alt+T to open it).
Code:
cd [COLOR="DarkOrchid"]<file-route-of-the-sin>[/COLOR]
mkdir android
sudo mount -t ext[color="RED"]*[/color] -o loop <name-of-the-image> android/
Where <file-route-of-the-sin> is where the SIN was located, where <the-name-of-the-image> you must type the file name of the ext image (e.g. system.ext4), and finally, where ext*, replace * with the version number of the EXT image you're mounting, usually, ext4
Now, once finished, to unmount it, type in a Terminal.
Code:
sudo umount android
rm -fr android
OSX GUIDE
Step 1 - Extract the SIN we need
Using your favourite archive manager (UnRarX, ZipEg, etc), open the FTF you want to extract the files from. (FYI: an FTF is just a Zip file with renamed extension)
Now copy/extract the SIN you want to unpack to a folder of your preference.
Step 2 - Dump the SIN
I'll take into account you already had installed Flashtools and Java JRE, in which case I highly encourage you to update both to the latest version available.
Now, open Flashtools. Click on Tools, Sin Editor. Hit the [...] and locate the SIN you previously extracted. Now, hit the [Extract Data] button. After a couple of minutes the bar should start running.
Once finished, you can have 2 kind of files: a .yaffs2 or a .ext4/.ext3/.ext2 file, which require different procedures on how to see it's contents.
Step 3.a - Convert the file to a readable format - UnYaffs2
If the file you get is a .yaffs2 format file, you're going to need an extra tool to extract it. For doing so, you are going to need the unyaffs2 tool.
You can download a pre-compiled binary from here, or you can install your own using Brew. From a Terminal (Command+Space, then type in Terminal) type the following commands.
Code:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null #This is just to Install Brew for the first time. If you already have it, it's not needed.
brew install unyaffs
If you chose using the UnYaffs2 binary, copy it to the very same folder where you placed the SIN, and thus, where the .yaffs2 is located.
If you chose the Brew installation, just continue.
Now, type in a Terminal (Command+Space, then type in Terminal).
Code:
cd [COLOR="DarkOrchid"]<file-route-of-the-sin>[/COLOR]
unyaffs2 [COLOR="Blue"]<the-name-of-the-yaffs2>[/COLOR]
Where <file-route-of-the-sin> is where the SIN was located, and thus, where the yaffs2 file is located; and where <the-name-of-the-yaffs2> you must type the file name of the yaffs2 (e.g. system.yaffs2)
The files will get extracted and you'll be able to pick the ones you need.
Step 3.b - Mount the image - Ext4FUSE
There're many many tools to mount a EXT format image in OSX, but in this case, since we don't need RW access, but just RO, I'll use ext4fuse, since it's free and it's more than compatible with our needs.
To install it you'll need Brew. To get things ready, type the following commands in a Terminal (Command+Space, then type in Terminal).
Code:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null #This is just to Install Brew for the first time. If you already have it, it's not needed.
brew tap homebrew/fuse
brew install Caskroom/cask/osxfuse
brew install ext4fuse
If you're on OSX Yosemite, El Capitan, or Leopard, you may need an extra command to add yourself to the Operator group, so that you can have readonly permissions to the disks.
Use it only if you get an error while trying to access the mounted EXT image later.
Code:
sudo dscl . append /Groups/operator GroupMembership [COLOR="red"]<your-user>[/COLOR]
Where your user <your-user> is your username.
Now, to mount the ext4 image, type in a Terminal (Command+Space, then type in Terminal).
Code:
mkdir android
ext4fuse [COLOR="DarkOrchid"]<path-to-the-ext4-image>[/COLOR] android
Where <path-to-the-ext4-image> you must type in the full path where the SIN was located, and thus, where the EXT4 image is located.
Use this as reference.
Reserved
In case I need it
Great job! Keep up the good work!!
Well. great guide.
Just a note, Microsoft officially released Bash on Ubuntu on Windows yesterday. Try it. It's a full fledged Linux subsystem but unfortunately only available to Windows Insiders. It would be the best alternate to cygwin.
Boot.img
How can i extract the boot.img
or is this applicable to every single .sin file present in the .ftf file
serajr said:
Great job! Keep up the good work!!
Click to expand...
Click to collapse
Thank you, I appreciate your words
mfbcool said:
Well. great guide.
Just a note, Microsoft officially released Bash on Ubuntu on Windows yesterday. Try it. It's a full fledged Linux subsystem but unfortunately only available to Windows Insiders. It would be the best alternate to cygwin.
Click to expand...
Click to collapse
I know, I saw the demonstration in the //build/, but since it hasn't been released for all yet (I guess it'll be for Redstone 2?), I didn't saw it necessary to be included.
sandeep.sethi said:
How can i extract the boot.img
or is this applicable to every single .sin file present in the .ftf file
Click to expand...
Click to collapse
No, this is only applicable for system.sin, userdata.sin, cache.sin and probably modem.sin.
However, if many of you request it, I could try making another for the kernel (boot.img)... But remember, every device doesn't have the same way/method to unpack the kernel, so making a generic tutorial for all wouldn't be possible
No, this is only applicable for system.sin, userdata.sin, cache.sin and probably modem.sin.
However, if many of you request it, I could try making another for the kernel (boot.img)... But remember, every device doesn't have the same way/method to unpack the kernel, so making a generic tutorial for all wouldn't be possible
Click to expand...
Click to collapse
if u can provide the guide it would be very helpful :fingers-crossed: :fingers-crossed:
This thread got featured in XDA Portal, thank you guys!
I tried extracting Xperia Pro's system SIN (can't remember the exact name but the one with the largest file size) using the latest version of Flashtool but wasn't successful. Like it's not supported yet.
Might be quite helpful for many I think as myself was looking for this.
What worked for me on Win 10 Pro x64 using CYGWIN:
1)First unpack the TWRP backup archive.
2)Then grab the two files named:
system.ext4.win000
system.ext4.win001
3)Next rename these files to:
system.ext4.win000.tar
system.ext4.win001.tar
4)Download and Install CYGWIN
5)Go to:
C:\cygwin64\home\YOURUSERNAMEHERE
6)Create a folder named "untar"
7)Now type these command in CYGWIN Terminal
Code:
[COLOR="Red"]cd c:/[/COLOR]
Code:
[COLOR="Red"]cd C:/cygwin64/home/YOURUSERNAMEHERE/untar[/COLOR]
Code:
[COLOR="Red"]tar -xvf system.ext4.win000.tar
tar -xvf system.ext4.win001.tar[/COLOR]
8)That's it! The /system folder was just unpacked to the /untar dir we just created before. Now you can
We need a couple of more things yet:
9)Collect the 'boot.emmc.win' file from the unpacked TWRP archive and rename it to boot.img.
9.1)Optional. Collect the 'logo.emmc.win' file from the unpacked TWRP archive and rename it to logo.img.
10)Now collect a META-INF folder from any custom rom which is made for K3 Note (yes there are many! :laugh: )
We have all the files! Now we need just to create a zip file!
11)Select the META-INF,system and boot.img and create an archive using WinRAR, 7zip or similar.
Optional: Add also the logo.img in the zip if it's present in the TWRP backup.
12)Done.
Credits: @carl1961
911-Future_Maker said:
Might be quite helpful for many I think as myself was looking for this.
What worked for me on Win 10 Pro x64 using CYGWIN:
1)First unpack the TWRP backup archive.
2)Then grab the two files named:
system.ext4.win000
system.ext4.win001
3)Next rename these files to:
system.ext4.win000.tar
system.ext4.win001.tar
4)Download and Install CYGWIN
5)Go to:
C:\cygwin64\home\YOURUSERNAMEHERE
6)Create a folder named "untar"
7)Now type these command in CYGWIN Terminal
Code:
[COLOR="Red"]cd c:/[/COLOR]
Code:
[COLOR="Red"]cd C:/cygwin64/home/YOURUSERNAMEHERE/untar[/COLOR]
Code:
[COLOR="Red"]tar -xvf system.ext4.win000.tar
tar -xvf system.ext4.win001.tar[/COLOR]
8)That's it! The /system folder was just unpacked to the /untar dir we just created before. Now you can
We need a couple of more things yet:
9)Collect the 'boot.emmc.win' file from the unpacked TWRP archive and rename it to boot.img.
9.1)Optional. Collect the 'logo.emmc.win' file from the unpacked TWRP archive and rename it to logo.img.
10)Now collect a META-INF folder from any custom rom which is made for K3 Note (yes there are many! :laugh: )
We have all the files! Now we need just to create a zip file!
11)Select the META-INF,system and boot.img and create an archive using WinRAR, 7zip or similar.
Optional: Add also the logo.img in the zip if it's present in the TWRP backup.
12)Done.
Credits: @carl1961
Click to expand...
Click to collapse
How would I go about making a flashable Odin file from my TWRP backup? I want to flash it with Odin.
You are the best
Thanx Very Much
can we unpack backups taken from twrp-3.0.2 ?? I can't unpack them
It would be interesting to do the opposite. Owning boot.img, recovery.img, system.img and create a TWRP flashable backup.
When I unpack my backup created with TWRP, there is no "boot.emmc.win". I have data.ext4.win000, data.ext4.win001, and system.ext4.000 and the md5 hashes. That's it. Where do I find these? thanks
pwntrik said:
When I unpack my backup created with TWRP, there is no "boot.emmc.win". I have data.ext4.win000, data.ext4.win001, and system.ext4.000 and the md5 hashes. That's it. Where do I find these? thanks
Click to expand...
Click to collapse
I believe this would happen if you did not check the box for the Boot partition when you created the backup. If you make another backup with that box checked, you should see this file in the result.
is this possible to make it as a bat file to automate the process?
superbeef150 said:
I believe this would happen if you did not check the box for the Boot partition when you created the backup. If you make another backup with that box checked, you should see this file in the result.
Click to expand...
Click to collapse
Since I posted that, I figured out why there's no boot or recovery: TWRP doesn't give you the option in rbox's latest build (Not sure why?) You could easily use dd to make a backup of the boot and recovery sectors if you run Advanced>Terminal in TWRP.
hi..
I did all the steps but unfortunately it didn't work
---------------------------------------------------------------
Dr [email protected] ~
$ cd c:/
bash: cd: command not found
Some OEMs violating GPL licenses and won't publish linux kernel sources for their Android devices.
On this post I’ll explain how to port kernel source to any android device.
Maybe you can port kernel sources to other SoCs with similiar ways but I've explained qcom way.
What do we need ?
A Computer which has Linux or Mac installation.
Device to test.
Let’s Start, Shall we ?
First of all we need to take dmesg of stock kernel using adb shell dmesg > dmesg.txt command. (I recommend you to take it while device is booting)
You got dmesg ? Nice. Open it with any text editor and search for “hardware” or “machine” and note the result to somewhere. By doing this we’ll get the name of device-tree-blobs.
Download android image kitchen and extract it to somewhere.
Now hold and move your device’s stock boot.img to unpackimg.(bat/sh)
Now your stock kernel got extracted to split_img/boot.img-zImage. After this line I will referance this file as “stock kernel”
Fetch split-appended-dtb using git clone https://github.com/MacTavishAO/split-appended-dtb-mac command. We’ll use this tool to extract dtb from stock kernel.
Copy stock kernel to split-appended-dtb-mac folder.
Now we will extract dtb(device-tree-blobs) from stock kernel. If you are on Linux use ./split-appended-dtb boot.img-zImage command for Mac use ./split-appended-dtb-mac boot.img-zImage command.
Now we have bunch of files named dtbdump_xx.dtb. We have to find out which one our device uses. Use grep -r <machine name that we found at step 2> . to find out which dtb our device using. (Write different parts of machine name to find out)
Install dtc using apt install device-tree-compiler command.
Let’s say it turns out dtbdump_21.dtb is the right one. We have to decompile dtb file to dts using dtc -I dtb -O dts -o extracted.dts dtbdump_21.dtb command.
Now we have to extract defconfig from stock kernel.
Use wget https://github.com/torvalds/linux/raw/master/scripts/extract-ikconfig && chmod a+x extract-ikconfig command to download necessary tool.
Use ./extract-ikconfig boot.img-zImage > extracted_defconfig to get defconfig from stock kernel.
Now we got what we need, we need to download kernel source to start porting to our device.
After this point I’ll start to explain as porting to Qualcomm device but almost same on other system-on-chips.
Go to Settings -> About Phone -> and note “Kernel version”
We need to download soc manufacturer’s sources. From here find msm-X.X that matching with your phone and copy link of it.
And from here find tag matching your chipset and write it down somewhere.
Use git clone <sources from 2 steps up> -b <tag>
Now enter to msm-X.X folder.
Copy extracted_defconfig to arch/<your device's architecture>/configs/ folder.
If your device is arm64 copy extracted.dts to arch/arm64/boot/dts/qcom/ if this directory doesn’t exist copy to arch/arm/boot/dts/qcom/ folder. (If you have 3.x qcom device skip the arm64 part and copy it directly into arm)
Open “Makefile” file in arch/arm(64)/boot/dts/qcom/ and add extracted.dts to the line matching with your chipset.
It’s time to import drivers. After this step I cannot help you because every devices’ hardware isn’t same but I can give some tactics.
To get driver names you can read dts file or install any device info app from Google Play Store etc.
Search these names and GitHub you can find files and commits which will help you to add drivers.
You did all of these without my help ? Excellent! Now it’s time to build kernel. I suggest you to use @natchanchance 's kernel compilation guide.
After compiling kernel. Copy compiled kernel to split_img folder which mentioned at early of this tutorial. rename it to boot.img-zImage and double click repackimg.(bat.sh) and you have new file named image-new.img.
Boot it using fastboot boot image-new.img command and if everything is working you can use fastboot flash boot image-new.img to use it permanently.
Leave a comment here about your questions. I'll try to reply all of them.
Planned to make a guide video about it but I don't have much time. Keep checking this thread may I post soon.
Reserved
Reserved.
Reserved
Thanks Dude!
This is very useful guide especially fir those who want to port the kernel source.
Thanks man. I am following your guide.
Thanks ?
While looking for matching dtbdump file I got a match in all four files for PMI8996, which file should I use?
"We have to decompile dtb file to dts using dtc" stuck at this step.
Any help on which "App" to use to find driver names..
Thanks
CPUZ / AIDA64
ataberkozen said:
It’s time to import drivers. After this step I cannot help you because every devices’ hardware isn’t same but I can give some tactics.
To get driver names you can read dts file or install any device info app from Google Play Store etc.
Search these names and GitHub you can find files and commits which will help you to add drivers.
Click to expand...
Click to collapse
I've found another way to find hardware info using hwinfo tool inside termux. The trick is to use it with root permissions.
Install hwinfo in termux:
Code:
apt-get install hwinfo
Run it with root permission tee into a text file:
Code:
su -c $(which hwinfo) | tee hwinfo.txt