[TOOL] CIVICX KERNEL PACKING TOOL-2.0 [TOOL-kernel] - Sony Xperia L

CIVICX KERNEL PACKING TOOL
Well i made this simple kernel packing tool for new users out there who want to enter into this kernel developement. I am using this tool of myself from many days and now i will like to share . Some names of bashcripts are **** given so dont look over those !
Code:
[COLOR="Red"]NOTE:THIS TOOL IS ADAPTED FOR XPERIA L ONLY , YOU WILL HAVE TO EDIT IT IN ORDER TO WORK WITH NEW DEVICE [/COLOR]
Ok so i consider all of you may be using Git and if you are not simply click on Download as zip
https://github.com/aniketroxx/Aniket_Packer
Click to expand...
Click to collapse
For Cloning Type this Command :
Code:
git clone https://github.com/aniketroxx/Aniket_Packer.git
Now in AOSP_RAMDISK
Insert the Ramdisk from Stock Kernel
Click to expand...
Click to collapse
Now in RECOVERY_RAMDISK
Insert or Create your own Recovery ramdisk folder Structure with ****ing init script and bootrec ,busybox and all
Click to expand...
Click to collapse
Go into cloned folder or downloaded folder and Simply type :
sh menu.sh
Click to expand...
Click to collapse
Rest of things are self explainatory !
Currently this is adopted for Packing of Kitkat Kernel which is having Page Size of 2048 ,
if you want to change it then simple open the pack.sh in any text editor [Provided that you are root directory of Packer]
Type command :
cd Z_PACKER
Click to expand...
Click to collapse
gedit pack.sh
Click to expand...
Click to collapse
At almost the end of line you will see page size , you can change it whatever you like
If you got any error then simple reply the thread
FAQ
AOSP_RAMDISK :
This will contain the ramdisk that you get from stock sony kernel , like as sony updated from 4.1 to 4.2 their ramdisk changed so here you can place that ramdisk in extracted form for further compression
Click to expand...
Click to collapse
RECOVERY:
Suppose you are implementing some cwm/twrp then then you can put it here for further xz compression
Click to expand...
Click to collapse
RECOVERY_RAMDISK:
This will contain the Recovery ramdisk structure with all of your bootrec and init.sh script and all
Click to expand...
Click to collapse
ZPACKER/OUT:
This will contain your output boot.img
You can flash the kernel directly through the option present in the menu
Click to expand...
Click to collapse
INPUT
Here you can put the boot.img of the kernel you want to extract
Click to expand...
Click to collapse
Z_IMAGE
Your extracted zImage will contain in this folder
Click to expand...
Click to collapse
EXTRACTED_RAMDISK
This will contain the ramdisk extracted from the boot.img , if you want to use it for packing then you will have to copy it to RECOVERY_RAMDISK
Click to expand...
Click to collapse

Changelog:
Version 1.0
Initial Release includes Packing Stock Ramdisk Packing Recovery Ramdisk Creating boot.img
Version 1.1
Added option for packing CWM/TWRP in XZ compression
Version 1.2
Added option for flashing kernel that you packed Fastboot must be installed
Version 1.3
Fix the normal bugs , syntax error in menu and remove device specific path
Version 1.4
Added the missing directory and changed SE-Linux to permissive
Version 1.5
Added automated fastboot and adb installer for linux thanks @HeadFox
Version 2.0
Added the ability to extract the kernel having ramdisk with xz compression​

Nice work! :highfive:

Nice work buddy

aniketroxx said:
Changelog:
Version 1.0
Initial Release includes Packing Stock Ramdisk Packing Recovery Ramdisk Creating boot.img
Version 1.1
Added option for packing CWM/TWRP in XZ compression
Version 1.2
Added option for flashing kernel that you packed Fastboot must be installed
Version 1.3
Fix the normal bugs , syntax error in menu and remove device specific path
Version 1.4
Added the missing directory and changed SE-Linux to permissive
Version 1.5
Added automated fastboot and adb installer for linux thanks @HeadFox​
Click to expand...
Click to collapse
Can you fix this? I am on Ubuntu 14.04 LTS
menu.sh: 38: menu.sh: Syntax error: ")" unexpected (expecting ";;")
Click to expand...
Click to collapse

FantasticalX said:
Can you fix this? I am on Ubuntu 14.04 LTS
Click to expand...
Click to collapse
Its fixed , sorry i forgot to push one commit ! Now just type in packer directory
Code:
git pull
or
Code:
git clone url
if you want to clone it somewhere else

aniketroxx said:
Its fixed , sorry i forgot to push one commit ! Now just type in packer directory
Code:
git pull
or
Code:
git clone url
if you want to clone it somewhere else
Click to expand...
Click to collapse
Thanks for fixed it! Btw can i unpack zImage with this tool?

FantasticalX said:
Thanks for fixed it! Btw can i unpack zImage with this tool?
Click to expand...
Click to collapse
no not yet , i will add it soon ! you can use kernel kitchen for unpacking

Ability to extract boot.img has been added to the tool @FantasticalX :fingers-crossed:

aniketroxx said:
Ability to extract boot.img has been added to the tool @FantasticalX :fingers-crossed:
Click to expand...
Click to collapse
Great! Glad to hear that! Thank you so much for your work :angel:

Related

[REF][DEV]How to unpack / repack normalboot.img

Hi all, like you know our phone is different from other cause - to flash the kernel - you need to pack it with the ramdisk files and flash it to the phone as normalboot.img.
Some people want try to build a custom kernel but after they obtain the zImage file they are not able to flash it to the phone.
So here is the "HOWTO" to explain what you have to do for unpack/repack normalboot.img.
You need Linux to do this (also a visrtualized distro).
1- download and unzip the attached file;
2- place the normalboot.img file into the tools folder;
3- go in the root folder and do:
Code:
./unpack-all.sh
4- now you have succesfull unpacked your file. You can find the zImage file in the "kernel" folder and the ramdisk files in the "ramdisk" folder.
Basically now you can do all that you want. If you have a custom kernel overwrite the zImage file with your. If you want edit the ramdisk go in the folder called "ramdisk" and mod what you want.
When you finished do:
Code:
./create_boot.img.sh
Now you will find the .tar file ready to be flashed on your phone with odin.
If you are asking yourself "where can i find normalboot.img file?" the answers are:
1- into the PDA.tar of your Firmware;
2- dump it from the phone with:
Code:
dd if=/dev/block/bml7 of=/sdcard/normalboot.img
Bye
Thanks Buddy..
BTW your posts are always very crisp and enlightening. I appreciate.
regards
I tried the script, and it seems to work. Seems, because it unpacked and repacked fine, and I replaced the kernel with a self compiled one. But, to make it short, the phone didn't boot. It was stuck on the "Galaxy S"-screen.
Any ideas, why a kernel which compiled without errors does not boot? Skin, did you change specific settings for compiling your OC-kernel, besides the overclocking adjustments?
XDA_Bam said:
I tried the script, and it seems to work. Seems, because it unpacked and repacked fine, and I replaced the kernel with a self compiled one. But, to make it short, the phone didn't boot. It was stuck on the "Galaxy S"-screen.
Any ideas, why a kernel which compiled without errors does not boot? Skin, did you change specific settings for compiling your OC-kernel, besides the overclocking adjustments?
Click to expand...
Click to collapse
I think that your kernel version doesn't match with the modules... so in your Makefile change the version name to match it with the stock.... so you have to change the version from 2.6.35.7 to 2.6.35.7-CL..... (don't remember if the number are correct)
Thanks, Skin! That did the trick. Now running self compiled vanilla kernel. Interestingly, it is about 200kb bigger than the stock kernel.
EDIT: Obviously, the repack-script is running fine.
other way to do dis is by using kitchen ..
js rename ur normalboot.img to boot.img den replace the boot.img in ur working directory ..
in the kitchen advanced options , unpack/repack boot.img ...
u ll get the same output
this one is easier as we dont need to remember the commands
XDA_Bam said:
Thanks, Skin! That did the trick. Now running self compiled vanilla kernel. Interestingly, it is about 200kb bigger than the stock kernel.
EDIT: Obviously, the repack-script is running fine.
Click to expand...
Click to collapse
To make it smaller you can use the Buildscript used in the froyo version of kernel source... Amit told me it this morning... and it worked greatly
bajju123 said:
other way to do dis is by using kitchen ..
js rename ur normalboot.img to boot.img den replace the boot.img in ur working directory ..
in the kitchen advanced options , unpack/repack boot.img ...
u ll get the same output
this one is easier as we dont need to remember the commands
Click to expand...
Click to collapse
Commands? You can do it with two mouse click!
Skin1980 said:
To make it smaller you can use the Buildscript used in the froyo version of kernel source... Amit told me it this morning... and it worked greatly
Click to expand...
Click to collapse
Yes, works. But my kernel stays at 3.3MB... still 0.2 larger than the stock one.
By the way: Had a SOD with the self-compiled kernel. Screen didn't wake up from standby, but soft buttons were lid. Guess the info from Samsung that closed source software is missing from the package is correct
i still have sod also with the new compilation mod.... by me sammy is missing something or simply the source are not updated like i supposed....
thanks....this rescued me
---------- Post added at 07:50 AM ---------- Previous post was at 07:20 AM ----------
i have a silly doubt
cud i download the linux kernel v3 from korg and compile it for i9003?or do i have to stick with 2.6.35?
Maybe it would be possible. The main problem are the drivers - they would most likely require major changes. But even CyanogenMod is running 2.6.37 and nothing more recent.
If you want to use a newer kernel, you could try that one, or - to minimize problems - use the 2.6.35.14 bugfix release. This seems most reasonable to me.
XDA_Bam said:
Maybe it would be possible. The main problem are the drivers - they would most likely require major changes. But even CyanogenMod is running 2.6.37 and nothing more recent.
If you want to use a newer kernel, you could try that one, or - to minimize problems - use the 2.6.35.14 bugfix release. This seems most reasonable to me.
Click to expand...
Click to collapse
shoot........404 not found
Those hackers...................
you are our phone's God!
Sent from my GT-I9003 using xda premium
i need help, i try to make stock normalboot.img tar with ur files.
but there is a big bug
phono booting but stay at "samsung" screen.
someone have this bug like me and u says that "chance ur kernel version in make boot file" but i cant find how chance kernel version in make boot file. how can i?
ROM: 2.3.6 JVKPB TUR ROM (galaxy sl i9003)
please help...
Skin1980 said:
Hi all, like you know our phone is different from other cause - to flash the kernel - you need to pack it with the ramdisk files and flash it to the phone as normalboot.img.
Some people want try to build a custom kernel but after they obtain the zImage file they are not able to flash it to the phone.
So here is the "HOWTO" to explain what you have to do for unpack/repack normalboot.img.
You need Linux to do this (also a visrtualized distro).
1- download and unzip the attached file;
2- place the normalboot.img file into the tools folder;
3- go in the root folder and do:
Code:
./unpack-all.sh
4- now you have succesfull unpacked your file. You can find the zImage file in the "kernel" folder and the ramdisk files in the "ramdisk" folder.
Basically now you can do all that you want. If you have a custom kernel overwrite the zImage file with your. If you want edit the ramdisk go in the folder called "ramdisk" and mod what you want.
When you finished do:
Code:
./create_boot.img.sh
Now you will find the .tar file ready to be flashed on your phone with odin.
If you are asking yourself "where can i find normalboot.img file?" the answers are:
1- into the PDA.tar of your Firmware;
2- dump it from the phone with:
Code:
dd if=/dev/block/bml7 of=/sdcard/normalboot.img
Bye
Click to expand...
Click to collapse
Wow you are great !!! Loved it .. so easy .... made my dead phone alive .. you are the best \m/

[Q] [GT-P3100][Kernel] Compiled kernel does not boot!

Hi,
I'm trying to boot my galaxy tab2 7 with compiled kernel.
First, I downloaded kernel source from http://opensource.samsung.com.
I download GT-P3100_JB_Opensource_Update2.zip file and extract it.
To compile, I followed ketut.kumajaya's thread (http://forum.xda-developers.com/show....php?t=2086996)
I build only kernel, not other modules. Compile was done without problem.
And I extract boot.img from Stock ROM file downloaded from samsung-updates.com (http://samsung-updates.com/device/?id=GT-P3100).
Stock ROM version is P3100XXCLJ3 (that's my device's baseband version).
I unpacked boot.img and I got boot.img-kernel.gz and boot.img-ramdisk.cpio.gz.
(To make sure unpack/repack tool is working properly, I simply unpack stock boot.img and repack it. And the new boot.img was working properly. So I assume my unpack/repack tool have no problem).
So, I replace boot.img-kernel.gz with zImage and repack it.
But this time new boot image does not working (Device stuck in boot logo)
What did I done wrong? Any body help! I've been stuck with this for a week now...
(When stock ROM is flashed, Kernel version in device info is "3.0.31-595683"
You must compile pvrsrvkm kernel module as I mentioned in http://forum.xda-developers.com/showthread.php?t=1859227 and then you can use KK-Boot 0.5.x core as your flashable zip template (have PowerVR 3D driver binary inside). If you decide to keep the stock PowerVR binary, change:
#define PVRVERSION_BUILD 2166536
Click to expand...
Click to collapse
to
#define PVRVERSION_BUILD 2120756
Click to expand...
Click to collapse
and
#define PVRVERSION_BUILD_HI 216
#define PVRVERSION_BUILD_LO 6536
Click to expand...
Click to collapse
to
#define PVRVERSION_BUILD_HI 212
#define PVRVERSION_BUILD_LO 0756
Click to expand...
Click to collapse
in pvrversion.h
Do not forget to copy pvrsrvkm_sgx540_120.ko to /system/lib/modules (backup the stock modules first!)
For trouble free development, I recommend you to use GT-P3110_JB_Opensource.zip, apply all my kernel patch and use my android_espresso_omap4430_r04_blackhawk_defconfig as your kernel config file. Good luck!
necesriverua
ketut.kumajaya said:
You must compile pvrsrvkm kernel module as I mentioned in http://forum.xda-developers.com/showthread.php?t=1859227 and then you can use KK-Boot 0.5.x core as your flashable zip template (have PowerVR 3D driver binary inside). If you decide to keep the stock PowerVR binary, change:
to
and
to
in pvrversion.h
Do not forget to copy pvrsrvkm_sgx540_120.ko to /system/lib/modules (backup the stock modules first!)
For trouble free development, I recommend you to use GT-P3110_JB_Opensource.zip, apply all my kernel patch and use my android_espresso_omap4430_r04_blackhawk_defconfig as your kernel config file. Good luck!
Click to expand...
Click to collapse
Many thanx.
I really appreiciate it.
I will try this right away.
ketut.kumajaya said:
You must compile pvrsrvkm kernel module as I mentioned in http://forum.xda-developers.com/showthread.php?t=1859227 and then you can use KK-Boot 0.5.x core as your flashable zip template (have PowerVR 3D driver binary inside). If you decide to keep the stock PowerVR binary, change:
to
and
to
in pvrversion.h
Do not forget to copy pvrsrvkm_sgx540_120.ko to /system/lib/modules (backup the stock modules first!)
For trouble free development, I recommend you to use GT-P3110_JB_Opensource.zip, apply all my kernel patch and use my android_espresso_omap4430_r04_blackhawk_defconfig as your kernel config file. Good luck!
Click to expand...
Click to collapse
Dear ketut,
Because I'm behind firewall, I cannot download pvrsrvkm kernel source.
Frankly, I have very little knowledge about android system. so I'm not sure I understand your guide correctly..
What I've done is as follows:
1. Download GT-P3110_JB_Opensource
2. Apply your patch from http://forum.xda-developers.com/showthread.php?t=1859227
3. Modify PVRVERSION_BUILD and PVRVERSION_BUILD_HI and PVRVERSION_BUILD_LOW in drivers/gpu/pvr/pvrversion.h (kernel source)
4. Apply android_espresso_omap4430_r04_blackhawk_defconfig and Build (using arm-2010q1-202..)
5. Repack zImage with ramdisk.cpio.gz (extracted from stock rom file)
6. Replace boot.img in your kkboot-0.5.2-core-p31xx.zip with repacked boot.img
7. Apply new kkboot.zip in CWM and installation failed and aborted.
Am I totally in wrong direction? What am I missing here?
I sincerely ask your help.
(I found that when build kernel after your patch, additional module files (.ko) are generated.
Should I do something with that?)
cks1119 said:
Dear ketut,
Because I'm behind firewall, I cannot download pvrsrvkm kernel source.
Frankly, I have very little knowledge about android system. so I'm not sure I understand your guide correctly..
What I've done is as follows:
1. Download GT-P3110_JB_Opensource
Click to expand...
Click to collapse
Correct.
2. Apply your patch from http://forum.xda-developers.com/showthread.php?t=1859227
Click to expand...
Click to collapse
Correct, all my patch from 01-07.
3. Modify PVRVERSION_BUILD and PVRVERSION_BUILD_HI and PVRVERSION_BUILD_LOW in drivers/gpu/pvr/pvrversion.h (kernel source)
Click to expand...
Click to collapse
Incorrect, nothing to do with pvr driver inside the kernel source, it's useless. You can download eurasia_km.tgz from http://www.mediafire.com/?m9te7t4rosp131d . Do not modify PVRVERSION if you plan to use my kkboot boot image.
4. Apply android_espresso_omap4430_r04_blackhawk_defconfig and Build (using arm-2010q1-202..)
Click to expand...
Click to collapse
Code:
export CROSS_COMPILE='/opt/toolchains/arm-2010q1/bin/arm-none-linux-gnueabi-'
export LDFLAGS=''
export CFLAGS=''
export SUBARCH=arm
export ARCH=arm
make mrproper
make android_espresso_omap4430_r04_blackhawk_defconfig
make -j4
5. Repack zImage with ramdisk.cpio.gz (extracted from stock rom file)
Click to expand...
Click to collapse
Incorrect, use kkboot ramdisk for now.
6. Replace boot.img in your kkboot-0.5.2-core-p31xx.zip with repacked boot.img
Click to expand...
Click to collapse
Correct.
7. Apply new kkboot.zip in CWM and installation failed and aborted.
Click to expand...
Click to collapse
Try to unpack and repack kkboot without modification, is it works?
Am I totally in wrong direction? What am I missing here?
I sincerely ask your help.
(I found that when build kernel after your patch, additional module files (.ko) are generated.
Should I do something with that?)
Click to expand...
Click to collapse
Unpack kkboot, you will see a lot of modules inside system/lib/modules
Try to unpack and repack kkboot without modification, is it works?
Click to expand...
Click to collapse
No, unpack tool that I have is not working.
I found the tool that you've uploaded, but the unzip password was not correct for some reason
I downloaded your tool in http://forum.xda-developers.com/showthread.php?t=1241005
But while unpacking, it says below:
Code:
BOARD_KERNEL_CMDLINE console=ttyO2,115200n8 mem=1024M androidboot.console=ttyO2 vram=20M omapfb.vram=0:16M
BOARD_KERNEL_BASE 80000000
BOARD_PAGE_SIZE 00000800
gzip: ../kkboot.img-ramdisk.gz: not in gzip format
cpio: premature end of archive
Is it require special tools to unpack kkboot image?
Forgot to mention, my ramdisk packed in lzo format You need lzop application to unpack it.
ketut.kumajaya said:
Forgot to mention, my ramdisk packed in lzo format You need lzop application to unpack it.
Click to expand...
Click to collapse
You mean only ramdisk?
If so, as my understanding, unpacking boot.img in kkboot-0.5.2 and repack without any change, should be working
whether your ramdisk is packed with lzo or not.
But when I did it, I still got installation fail.
(I used the unpackbootimg in blackhawk tool from http://forum.xda-developers.com/showthread.php?t=1241005)
By the way,
I've searching about lzop compressed ramdisk and found this: https://github.com/trevd/aos-tools/blob/master/scripts/unpack-ramdisk.sh
And with this method, I could unpack ramdisk file.
Code:
cat boot.img-ramdisk.gz | lzop -d | cpio -i
But, I think this is not the point.
ketut.kumajaya said:
Forgot to mention, my ramdisk packed in lzo format You need lzop application to unpack it.
Click to expand...
Click to collapse
I simply unpack and repack boot.img from kkboot-0.5.2-core-p31xx.zip
with boot.img-tools in http://forum.xda-developers.com/showthread.php?t=1241005
Then change original boot.img with repacked one and make new zip file in external SD card.
When I go to CWM recovery and try to install new zip file, then I got following message:
Code:
-Extracting files
set_perm : some changes failed
E:Error in /external_sd/newfile.zip
(Status 7)
Installation aborted
I've been trying other tools that I could find but still does not working :crying:
ketut.kumajaya said:
Forgot to mention, my ramdisk packed in lzo format You need lzop application to unpack it.
Click to expand...
Click to collapse
Finally done it!
I've got tab 2 running my own kernel!
Again, thank you for your help and all works you've done!:good:
cks1119 said:
Finally done it!
I've got tab 2 running my own kernel!
Again, thank you for your help and all works you've done!:good:
Click to expand...
Click to collapse
Congrat :good:

How To install a kernel you built yourself

How do you install a kernel that you built yourself?
---------------------------------
The answer, as I understand it:
Build a kernel, with some variation of "make zImage" as the last step
Make a gzipped ramdisk image by one of the two following methods:
Use cpio and gzip (like a standard linux initial-ramdisk)
Use mkbootfs (from Android Kitchen)
Create a boot image from the gzipped ramdisk and the kernel zImage by one of the two following methods:
Use abootimg
abootimg is available for ubuntu, and is included in the ubuntu images that rabits was distributing
Use mkbootimg (from Android Kitchen)
Convert the boot image to a blob with "blobpack" (part of blobtools)
More details as I experiment with this process.
bsammon said:
Is there a guide to how to install a kernel that you built yourself?
I've seen bits and pieces of this in various threads, but no complete (or semi-complete) document on how it's done.
Click to expand...
Click to collapse
I have been searching on this topic as well. You would have a better luck searching if you use a key word like "Unpack and Repack Kernel or Ramdisk".. Good luck..
You don't know my kernel repacking guide? -> http://forum.xda-developers.com/showpost.php?p=36925180&postcount=4
_that said:
You don't know my kernel repacking guide? -> http://forum.xda-developers.com/showpost.php?p=36925180&postcount=4
Click to expand...
Click to collapse
Thanks for the head up. I will look into it... :good:
Ahh... the development forum -- that's why I didn't see it. I'll take a look at that.
_that said:
You don't know my kernel repacking guide? -> http://forum.xda-developers.com/showpost.php?p=36925180&postcount=4
Click to expand...
Click to collapse
Where do I get the "mkbootfs" and "mkbootimg" tools mentioned in that guide?
bsammon said:
Where do I get the "mkbootfs" and "mkbootimg" tools mentioned in that guide?
Click to expand...
Click to collapse
I think they are part of the Android source. Standalone sources are available in dsixda's Android Kitchen, which is what I use.
_that said:
I think they are part of the Android source. Standalone sources are available in dsixda's Android Kitchen, which is what I use.
Click to expand...
Click to collapse
I think you mean this Android Kitchen. It appears that Asus devices aren't supported by Android Kitchen, but it's your experience that it works anyway?
bsammon said:
I think you mean this Android Kitchen. It appears that Asus devices aren't supported by Android Kitchen, but it's your experience that it works anyway?
Click to expand...
Click to collapse
Nah the tools mkbootfs and mkbootimg from dsixda's android kitchen work fine.
bsammon said:
I think you mean this Android Kitchen. It appears that Asus devices aren't supported by Android Kitchen, but it's your experience that it works anyway?
Click to expand...
Click to collapse
Yes, that one. I've never used the menu-driven stuff, but you can learn a lot from reading its scripts - and many of the tools included in the kitchen work fine for all Android devices.

[tool] ANDROID-ROM-REPACK-TOOLS

Note:I am sorry I can't post this in the Android development thread because my number of posts is low. Hopefully some mod can move it there.
Introduction
Since this project (Android_IMG_REPACK_TOOLS) is dead for 2 years now (last supported version is Marshmallow). I decided to do a new rom repacker that supports up to Android Oreo.
Supported OS
Linux
Supported Android Versions
android-5 (Lollipop)
android-wear-5
android-6 (Marshmallow)
android-7 (Nougat)
android-8 (Oreo)
android-9 (Pie) beta
Binaries included
append2simg
img2simg
simg2img
simg2simg
make_ext4fs (Google removed it for android 9. I will add a replacement in the future)
mkbootfs
mkbootimg
unpackbootimg (For android-wear-5, you can use the one in android-5)
sefcontext_compile
sefcontext_decompile
Usage
Check this post out for some use case. You'll need img2simg and make_ext4fs from my post.
sefcontext_compile and sefcontext_decompile:
ROMS since Android 7 (Nougat) come with a binary file_contexts but you need a text based file_contexts when you need to repackage the ROM. You'll need it for make_ext4fs. sefcontext_decompile converts the binary file_contexts into text version.
Code:
# file_contexts (human readable text file) -> file_contexts.bin (PCRE formatted binary file)
sefcontext_compile [-o <output_file>] <text_file>
# file_contexts.bin (PCRE formatted binary file) -> file_contexts (human readable text file)
sefcontext_decompile [-o <output_file>] <binary_file>
Source code
Repository
android-5
android-wear-5
android-6
android-7
android-8
android-9
Download links for Linux
Download page
android-5
android-wear-5
android-6
android-7
android-8
android-9
Change Log:
v3:
Added android-5 and android-wear-5 support
Added android-9 beta support
v2:
Added sefcontext_compile and sefcontext_decompile: converts between file_contexts.bin and file_contexts
Static linking to libc++: No need to install 3rd party libraries to use the binaries.
v1:
Added append2simg img2simg simg2img simg2simg make_ext4fs mkbootfs mkbootimg unpackbootimg
credits:
@A.S._id
android.googlesource
LineageOS
Created: 2018-03-16
Updated: 2018-08-18
[Placeholder]
[Placeholder2]
Can i extract a rom if i have only ssyetm. New. Dat??, i have file context. Bin in boot. Img can it be used?
I know usual extraction needs both these+system. Transfer. List but a rom which i m using have just this configuration.
what is simg2simg?
and how to make system.new.dat.br?
thanks for your work
zheshifandian said:
what is simg2simg?
and how to make system.new.dat.br?
thanks for your work
Click to expand...
Click to collapse
Use brtoli. Exe to make. Br from. Dat format
narshi shukla said:
Can i extract a rom if i have only ssyetm. New. Dat??, i have file context. Bin in boot. Img can it be used?
I know usual extraction needs both these+system. Transfer. List but a rom which i m using have just this configuration.
Click to expand...
Click to collapse
I believe this question is better suited in this thread. You'll need system.transfer.list in sdat2img.py which is provided over there. I haven't worked on a ROM that doesn't have system.transfer.list. Isn't system.transfer.list required for flashing the ROM?
Btw you need to convert file_context.bin to text format. There are a couple of closed source solutions here on xda. I am working on an open source version in my free time.
zheshifandian said:
what is simg2simg?
Click to expand...
Click to collapse
You can find answers to a lot of the questions you might have in the old project.
A.S._id said:
Yes, simg2simg can reduce file size by splitting into several parts, but it is usually not necessary, fastboot can flash and in this state
Click to expand...
Click to collapse
Awesomeness, easy and simple
hi bro i want extract oreo system.new.dat.br and also repack dat to .br in windows
please help me bro
and im unable to convert oreo file_context.bin to readable in windows
please help thanks in advance
New version available in Original Post.
Change log
v2:
Added sefcontext_compile and sefcontext_decompile: converts between file_contexts.bin and file_contexts
Static linking to libc++: No need to install 3rd party libraries to use the binaries.
marshharsha said:
hi bro i want extract oreo system.new.dat.br and also repack dat to .br in windows
please help me bro
and im unable to convert oreo file_context.bin to readable in windows
please help thanks in advance
Click to expand...
Click to collapse
Oreo ROMs come compressed by brotili. You can compile from source to get the executable or you can get the binaries directly from the release page (version 1.0). Use it to extract and repack .br.
I added a converter from file_context.bin to a readable format in the new version I just uploaded.
This project only supports Linux as of now. As for using it in Windows, you have 3 options,
Use a linux distro in VirtualBox (I currently use this option)
Install a linux bash shell in Windows 10
Build the project in Cygwin (hopefully someone can make a pull request and share it with the rest)
rkhat said:
Oreo ROMs come compressed by brotili. You can compile from source to get the executable or you can get the binaries directly from the release page (version 1.0). Use it to extract and repack .br.
I added a converter from file_context.bin to a readable format in the new version I just uploaded.
This project only supports Linux as of now. As for using it in Windows, you have 3 options,
Use a linux distro in VirtualBox (I currently use this option)
Install a linux bash shell in Windows 10
Build the project in Cygwin (hopefully someone can make a pull request and share it with the rest)
Click to expand...
Click to collapse
thanks brother for your kind reply can you give guide for make exe from brotli source? with java or c
thanks again
marshharsha said:
thanks brother for your kind reply can you give guide for make exe from brotli source? with java or c
thanks again
Click to expand...
Click to collapse
Just use a pre-built brotli from the release page (there is a window version). It doesn't matter that the executable is not the latest version as you only need to extract compress the .br file.
If you really need to build brotli for windows, just open scripts/appveyor.yml in the github repository. Decide which environment you want (I see they support 32-bit/64-bit versions for Visual Studio, Python, MinGW). Download the necessary software (python, mingw ...). Then run the commands in appveyor.yml using cmd in this order.
@rkhat
Hi and thanks for making the tools for us.
I am getting the below error when ./img2simg new-system.img news-system.img. I downloaded version for Nougat.
img2simg: /android-rom-repacker/external/platform/core/src/libsparse/sparse.c:153: int write_all_blocks(struct sparse_file *, struct output_file *): Assertion `pad >= 0' failed.
Aborted
I am running Ubuntu. Do you know what might be the problem ?
sdeft said:
@rkhat
Hi and thanks for making the tools for us.
I am getting the below error when ./img2simg new-system.img news-system.img. I downloaded version for Nougat.
img2simg: /android-rom-repacker/external/platform/core/src/libsparse/sparse.c:153: int write_all_blocks(struct sparse_file *, struct output_file *): Assertion `pad >= 0' failed.
Aborted
I am running Ubuntu. Do you know what might be the problem ?
Click to expand...
Click to collapse
Just tested a Nougat lineage ROM for Nexus 7 from here. No issues!
Are you sure you used this version for Nougat?
If you still have issues, can you link me the zipped ROM and more importantly the source you got it from so I can test it out? Thank you.
rkhat said:
Just tested a Nougat lineage ROM for Nexus 7 from here. No issues!
Are you sure you used this version for Nougat?
If you still have issues, can you link me the zipped ROM and more importantly the source you got it from so I can test it out? Thank you.
Click to expand...
Click to collapse
I think I found the issue. This is happening only when i perform it on the image created with
./make_ext4fs -s -l 3000M -a system new-system.img tmp/
If I just umount the image and then apply img2simg it works.
Is this strange or what ?
sdeft said:
I think I found the issue. This is happening only when i perform it on the image created with
./make_ext4fs -s -l 3000M -a system new-system.img tmp/
If I just umount the image and then apply img2simg it works.
Is this strange or what ?
Click to expand...
Click to collapse
Don't use "-s" (lowercase s) option. It only writes sparse headers in new-system.img. The file is only couple MBs instead of 3000MB you specified. I am curious how img2simg even worked.
Also, use "-S file_contexts" (uppercase S) option to apply the security contexts on files. The zipped ROM has file_contexts.bin (binary version) since Android Nougat. You'll need to convert it to text format. You can use the executable sefcontext_decompile included in my tools to convert file_contexts.bin to file_contexts.
rkhat said:
Don't use "-s" (lowercase s) option. It only writes sparse headers in new-system.img. The file is only couple MBs instead of 3000MB you specified. I am curious how img2simg even worked.
Also, use "-S file_contexts" (uppercase S) option to apply the security contexts on files. The zipped ROM has file_contexts.bin (binary version) since Android Nougat. You'll need to convert it to text format. You can use the executable sefcontext_decompile included in my tools to convert file_contexts.bin to file_contexts.
Click to expand...
Click to collapse
I am not using a zipped rom with file_contexts.bin, system.new.dat etc.
I am trying to mod a system.img from a fastboot rom for xiaomi. So far only managed to have the userdata.img working but system.img keeps giving me bootloops!. Will try your suggestion above...
build use cygwin window 7 x64
how build use cygwin on w7 x64? or can you make for windows too?
sorry for bad engglish
anggafzkdev99 said:
how build use cygwin on w7 x64? or can you make for windows too?
sorry for bad engglish
Click to expand...
Click to collapse
I don't use windows in this project. So you're on your own in building using cygwin
Alternatively, you can use Ubuntu on VirtualBox which is what I currently use.

[8/3/2019]Updated Android IMG Tools[Upto Android 9.0]

Since These tools are outdated there has been little movement with the tools since, @rkhat has made a source available to be built for linux, however im unable to get a compile.
So i decided to gather sources and make some modifications to get them compiling in cygwin and works upto android 8.1
Install cygwin in the default directory with the following packages.
libpcre1, zlib-devel, cmake, make, automake, gcc-core, gcc-g++, libgcc1, libstdc++6, cpio, flex, bison, cygwin32-gcc-core, patch, libintl
Source code
Prebuilt binaries
To build simply download and extract the source, open CMD and
Code:
path=%path%C:\cygwin64\bin;
cd to each directory and execture
Code:
make
To build e2fsprogs
Open cygwin
cd to the directory
Code:
mkdir build
cd build
../configure
make
Original Sources
Sparse utillities based on sources https://github.com/anestisb/android-simg2img
mkbootimg based on sources https://github.com/osm0sis/mkbootimg
mkbootfs based on sources https://github.com/osm0sis/mkbootfs
make_ext4fs based on sources https://github.com/jamflux/make_ext4fs
sefcontext_decompile based on sources https://github.com/wuxianlin/sefcontext_decompile
dtc based on sources https://github.com/dgibson/dtc
e2fsprogs based on sources https://github.com/tytso/e2fsprogs
Generates -
append2simg.exe
cpio.exe
dtc.exe
gzip.exe
img2simg.exe
make_ext4fs.exe
mkbootfs.exe
mkbootimg.exe
sefcontext_decompile.exe
simg2img.exe
simg2simg.exe
unpackbootimg.exe
mke2fs.exe
Contributors
SuperR, anestisb, rkhat2, osm0sis, jamflux, wuxianlin, Xannytech, CarmineRovito
Doing God's work I see.
Repo was on private, fixed it now
https://github.com/anpaza/make_ext4fs
I1V1A1N said:
https://github.com/anpaza/make_ext4fs
Click to expand...
Click to collapse
Thats a newer build, i may use it, thanks
Repository has been updated for partial 9.0 support
dose it support pie use make_ext4fs?
Nightmare_MYS said:
dose it support pie use make_ext4fs?
Click to expand...
Click to collapse
Unpacking yes but repacking not at the moment, i havent had time to look into mk2efs and the new e2fsdroid source code, the source for these are in the e2fsprogs repository, mk2efs already has a windows port in cygwin and the e2fsdroid sourcw code is in the contrib/android directory, i have built mk2efs correctly but i havent attempted e2fsdroid yet because i have been busy, maybe @osm0sis may be able to give it a shot
Ricky Divjakovski said:
Unpacking yes but repacking not at the moment, i havent had time to look into mk2efs and the new e2fsdroid source code, the source for these are in the e2fsprogs repository, mk2efs already has a windows port in cygwin and the e2fsdroid sourcw code is in the contrib/android directory, i have built mk2efs correctly but i havent attempted e2fsdroid yet because i have been busy, maybe @osm0sis may be able to give it a shot
Click to expand...
Click to collapse
i have no idea,i checked a lot of method,mke2fs just can creat a new null img,i still don't know e2fsdroid's effect,i had used ClassyKitchen to repack my pie,it working,but ClassyKitchen just a single exe file,
Nightmare_MYS said:
i have no idea,i checked a lot of method,mke2fs just can creat a new null img,i still don't know e2fsdroid's effect,i had used ClassyKitchen to repack my pie,it working,but ClassyKitchen just a single exe file,
Click to expand...
Click to collapse
thats quite odd, from looking into classy kitchen it seems that it does use make_ext4fs?
however i dont know how he has got it working, he tries hiding the functionallity of his tools quite abit, im guessing this is because of licensing issues preventing him to sell whats included in the tools and to stop other people from making a free version, the binaries are unpacked to %tmp%/BIN folder when processing a firmware, check it out
Ricky Divjakovski said:
thats quite odd, from looking into classy kitchen it seems that it does use make_ext4fs?
however i dont know how he has got it working, he tries hiding the functionallity of his tools quite abit, im guessing this is because of licensing issues preventing him to sell whats included in the tools and to stop other people from making a free version, the binaries are unpacked to %tmp%/BIN folder when processing a firmware, check it out
Click to expand...
Click to collapse
the free of classy kitchen just can build new img,if i know its working space,i maybe know it in Disk C,but i can't find it and dont't know the binaries unpacked where,i tryed to use make_ext4fs to build my pie img,it is not working,i sure Classy Kithen can,
Nightmare_MYS said:
the free of classy kitchen just can build new img,if i know its working space,i maybe know it in Disk C,but i can't find it and dont't know the binaries unpacked where,i tryed to use make_ext4fs to build my pie img,it is not working,i sure Classy Kithen can,
Click to expand...
Click to collapse
the binaries are in the %tmp%\BIN folder
Anyway this can be made to support Amazon boot images?
Sent from my MotoG3 using XDA Labs
DragonFire1024 said:
Anyway this can be made to support Amazon boot images?
Sent from my MotoG3 using XDA Labs
Click to expand...
Click to collapse
Please upload the boot image and ill see if i can do this, ill also update the sources soon because i made a utillity to split the MTK header from an MTK ramdisk
Ricky Divjakovski said:
Please upload the boot image and ill see if i can do this, ill also update the sources soon because i made a utillity to split the MTK header from an MTK ramdisk
Click to expand...
Click to collapse
Awesome. Thank you. I'll upload one as soon as I get home
Sent from my MotoG3 using XDA Labs
I'm trying to use img2sing.exe and getting "cygz.dll was not found" error. Is that file supposed to be in the zip?
zxcv888 said:
I'm trying to use img2sing.exe and getting "cygz.dll was not found" error. Is that file supposed to be in the zip?
Click to expand...
Click to collapse
that will be in your cygwin bin directory, either copy it from there to the same folder as the exe or or add the cygwin bin directory to your path environment variable
Ricky Divjakovski said:
the binaries are in the %tmp%\BIN folder
Click to expand...
Click to collapse
i didn't find that,
Nightmare_MYS said:
i didn't find that,
Click to expand...
Click to collapse
you have to run the progran and repack for it to appeart, as soon as its repacked the folder gets deleted
Ricky Divjakovski said:
Please upload the boot image and ill see if i can do this, ill also update the sources soon because i made a utillity to split the MTK header from an MTK ramdisk
Click to expand...
Click to collapse
here is the boot.img from the Amazon Fire HD 10, 2017, firmware version update-kindle-40.6.0.5_user_605485120.bin. Thank you so much. Let me know if you need anything else. Just extract the .img from the zip.

Categories

Resources