[TOOL][Windows,Linux,Android,Apple] Unpack any Sony firmware file

Search This thread

munjeni

Senior Member
Jun 2, 2011
9,720
22,376
I did it on Cygwin but it is written for Linux primarily and should work for you.

Code:
cd ~;
git clone https://github.com/tpoechtrager/osxcross;
git clone https://github.com/AaronWallace/MacOSX_SDKs;
cd MacOSX_SDKs;
tar -cJf ../osxcross/tarballs/MacOSX10.7.sdk.tar.xz MacOSX10.7.sdk;
cd ../osxcross;
sudo tools/get_dependencies.sh;

This should make sure you've got the needed Linux packages. Note that I had to downgrade to LLVM 3.9.1 for it to work on Cygwin, but that might not be necessary on Linux.

Then just build it.

Code:
./build.sh;
#if this gets some LTO issues at link-time you can try with `DISABLE_LTO_SUPPORT=1 ./build.sh;`

./build_gcc.sh;
#this is optional since you'll already have clang

Full documentation on the osxcross repo here:
https://github.com/tpoechtrager/osxcross/blob/master/README.md

If you're able to get that working in the next couple of days I'll release AIK v3.1 rapid fire with it included before I leave on holiday. :) :highfive:

Well done, toolchain created, but some errors in my kernel dump source code:

Code:
kernel_dump.c:167:13: warning: implicit declaration of function 'fopen64' is invalid in C99 [-Wimplicit-function-declaration]
        FILE *fp = fopen64(filename, "rb");
                   ^
kernel_dump.c:167:8: warning: incompatible integer to pointer conversion initializing 'FILE *' (aka 'struct __sFILE *') with an
      expression of type 'int' [-Wint-conversion]
        FILE *fp = fopen64(filename, "rb");
              ^    ~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:173:2: warning: implicit declaration of function 'fseeko64' is invalid in C99 [-Wimplicit-function-declaration]
        fseeko64(fp, 0, SEEK_END);
        ^
kernel_dump.c:174:9: warning: implicit declaration of function 'ftello64' is invalid in C99 [-Wimplicit-function-declaration]
        size = ftello64(fp);
               ^
kernel_dump.c:256:11: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        if ((sin = fopen64(filein, "rb")) == 0) {
                 ^ ~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:349:13: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                        if ((elf = fopen64(fileout, "wb")) == NULL) {
                                 ^ ~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:677:12: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                if ((elf = fopen64(fileout, "wb")) == NULL) {
                         ^ ~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:720:14: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        if ((source = fopen64(source_file, "rb")) == NULL) {
                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:725:14: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        if ((target = fopen64(target_file, "wb")) == NULL) {
                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:770:5: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        fi = fopen64(in, "rb");
           ^ ~~~~~~~~~~~~~~~~~
kernel_dump.c:818:15: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                        if ((fooff = fopen64(fnameoff, "wb")) != NULL) {
                                   ^ ~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:860:15: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                        if ((fooff = fopen64(fnameoff, "wb")) != NULL) {
                                   ^ ~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:898:6: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                fo = fopen64(fname, "wb");
                   ^ ~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:899:9: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                fooff = fopen64(fnameoff, "wb");
                      ^ ~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:938:5: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        fo = fopen64(fname, "wb");
           ^ ~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:1032:5: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        fi = fopen64(fld, "rb");
           ^ ~~~~~~~~~~~~~~~~~~
kernel_dump.c:1121:7: warning: implicit declaration of function 'gunziper' is invalid in C99 [-Wimplicit-function-declaration]
                if (gunziper(argv[2], fld))
                    ^
kernel_dump.c:1124:5: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                a = fopen64(fld, "rb");
                  ^ ~~~~~~~~~~~~~~~~~~
kernel_dump.c:1128:4: warning: implicit declaration of function 'untar' is invalid in C99 [-Wimplicit-function-declaration]
                        untar(a, argv[2], argv[1]);
                        ^
19 warnings generated.
 "/home/Desktop/osxtoolchain/osxcross/target/bin/i386-apple-darwin11-ld" -demangle -dynamic -arch i386 -macosx_version_min 10.5.0 -syslibroot /home/Desktop/osxtoolchain/osxcross/target/bin/../SDK/MacOSX10.7.sdk -o kernel_dump.i386-apple-darwin11 -lcrt1.10.5.o /tmp/lz4-16d666.o /tmp/unpackbootimg-3a4efe.o /tmp/kernel_dump-383f4f.o -lSystem -lgcc_s.10.5
Undefined symbols for architecture i386:
  "_fopen64", referenced from:
      _file_size in kernel_dump-383f4f.o
      _convert_sin_to_elf in kernel_dump-383f4f.o
      _copyf in kernel_dump-383f4f.o
      _extract_elf in kernel_dump-383f4f.o
      _kernel_dump_main in kernel_dump-383f4f.o
  "_fseeko64", referenced from:
      _file_size in kernel_dump-383f4f.o
      _convert_sin_to_elf in kernel_dump-383f4f.o
      _extract_elf in kernel_dump-383f4f.o
      _kernel_dump_main in kernel_dump-383f4f.o
  "_ftello64", referenced from:
      _file_size in kernel_dump-383f4f.o
      _convert_sin_to_elf in kernel_dump-383f4f.o
  "_gunziper", referenced from:
      _kernel_dump_main in kernel_dump-383f4f.o
  "_main", referenced from:
      start in crt1.10.5.o
     (maybe you meant: _kernel_dump_main)
  "_untar", referenced from:
      _kernel_dump_main in kernel_dump-383f4f.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Seems LFS is not supported?
 
Last edited:
  • Like
Reactions: osm0sis

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,773
40,456
Halifax
GT-i9250
Google Nexus 4
Well done, toolchain created, but some errors in my kernel dump source code:

Code:
kernel_dump.c:167:13: warning: implicit declaration of function 'fopen64' is invalid in C99 [-Wimplicit-function-declaration]
        FILE *fp = fopen64(filename, "rb");
                   ^
kernel_dump.c:167:8: warning: incompatible integer to pointer conversion initializing 'FILE *' (aka 'struct __sFILE *') with an
      expression of type 'int' [-Wint-conversion]
        FILE *fp = fopen64(filename, "rb");
              ^    ~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:173:2: warning: implicit declaration of function 'fseeko64' is invalid in C99 [-Wimplicit-function-declaration]
        fseeko64(fp, 0, SEEK_END);
        ^
kernel_dump.c:174:9: warning: implicit declaration of function 'ftello64' is invalid in C99 [-Wimplicit-function-declaration]
        size = ftello64(fp);
               ^
kernel_dump.c:256:11: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        if ((sin = fopen64(filein, "rb")) == 0) {
                 ^ ~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:349:13: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                        if ((elf = fopen64(fileout, "wb")) == NULL) {
                                 ^ ~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:677:12: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                if ((elf = fopen64(fileout, "wb")) == NULL) {
                         ^ ~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:720:14: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        if ((source = fopen64(source_file, "rb")) == NULL) {
                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:725:14: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        if ((target = fopen64(target_file, "wb")) == NULL) {
                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:770:5: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        fi = fopen64(in, "rb");
           ^ ~~~~~~~~~~~~~~~~~
kernel_dump.c:818:15: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                        if ((fooff = fopen64(fnameoff, "wb")) != NULL) {
                                   ^ ~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:860:15: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                        if ((fooff = fopen64(fnameoff, "wb")) != NULL) {
                                   ^ ~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:898:6: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                fo = fopen64(fname, "wb");
                   ^ ~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:899:9: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                fooff = fopen64(fnameoff, "wb");
                      ^ ~~~~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:938:5: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        fo = fopen64(fname, "wb");
           ^ ~~~~~~~~~~~~~~~~~~~~
kernel_dump.c:1032:5: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
        fi = fopen64(fld, "rb");
           ^ ~~~~~~~~~~~~~~~~~~
kernel_dump.c:1121:7: warning: implicit declaration of function 'gunziper' is invalid in C99 [-Wimplicit-function-declaration]
                if (gunziper(argv[2], fld))
                    ^
kernel_dump.c:1124:5: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int'
      [-Wint-conversion]
                a = fopen64(fld, "rb");
                  ^ ~~~~~~~~~~~~~~~~~~
kernel_dump.c:1128:4: warning: implicit declaration of function 'untar' is invalid in C99 [-Wimplicit-function-declaration]
                        untar(a, argv[2], argv[1]);
                        ^
19 warnings generated.
 "/home/Desktop/osxtoolchain/osxcross/target/bin/i386-apple-darwin11-ld" -demangle -dynamic -arch i386 -macosx_version_min 10.5.0 -syslibroot /home/Desktop/osxtoolchain/osxcross/target/bin/../SDK/MacOSX10.7.sdk -o kernel_dump.i386-apple-darwin11 -lcrt1.10.5.o /tmp/lz4-16d666.o /tmp/unpackbootimg-3a4efe.o /tmp/kernel_dump-383f4f.o -lSystem -lgcc_s.10.5
Undefined symbols for architecture i386:
  "_fopen64", referenced from:
      _file_size in kernel_dump-383f4f.o
      _convert_sin_to_elf in kernel_dump-383f4f.o
      _copyf in kernel_dump-383f4f.o
      _extract_elf in kernel_dump-383f4f.o
      _kernel_dump_main in kernel_dump-383f4f.o
  "_fseeko64", referenced from:
      _file_size in kernel_dump-383f4f.o
      _convert_sin_to_elf in kernel_dump-383f4f.o
      _extract_elf in kernel_dump-383f4f.o
      _kernel_dump_main in kernel_dump-383f4f.o
  "_ftello64", referenced from:
      _file_size in kernel_dump-383f4f.o
      _convert_sin_to_elf in kernel_dump-383f4f.o
  "_gunziper", referenced from:
      _kernel_dump_main in kernel_dump-383f4f.o
  "_main", referenced from:
      start in crt1.10.5.o
     (maybe you meant: _kernel_dump_main)
  "_untar", referenced from:
      _kernel_dump_main in kernel_dump-383f4f.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Seems LFS is not supported?

Surprising that macOS as a desktop OS wouldn't have that.. I asked for you in case there's an easy fix: https://github.com/tpoechtrager/osxcross/issues/146
 
  • Like
Reactions: munjeni

munjeni

Senior Member
Jun 2, 2011
9,720
22,376

Ok, so no need fopen64 and fseeeko64 its by default configured for LFS, right? Just need to add flags D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE , right?

But what about FILE *blabla? Seems osx don't have FILE type! This is warning I'm getting:

Code:
warning: incompatible integer to pointer conversion initializing 'FILE *' (aka 'struct __sFILE *') with an
      expression of type 'int' [-Wint-conversion]
        FILE *fp = fopen64(filename, "rb");

Edit:
Ok, probably because fopen64 is used... will try now!
 
Last edited:
  • Like
Reactions: osm0sis

munjeni

Senior Member
Jun 2, 2011
9,720
22,376
Had hard time building for apple since can't make any static lib with its crosstool, so missed libz and libsparse, but good thing done it this way:

Code:
o64-clang -D_FILE_OFFSET_BITS=64 -Wall -O3 -I./include -Iandroid-simg2img-master/include lz4.c unpackbootimg.c zlib-1.2.9/adler32.c zlib-1.2.9/crc32.c zlib-1.2.9/deflate.c zlib-1.2.9/infback.c zlib-1.2.9/inffast.c zlib-1.2.9/inflate.c zlib-1.2.9/inftrees.c zlib-1.2.9/trees.c zlib-1.2.9/zutil.c zlib-1.2.9/compress.c zlib-1.2.9/uncompr.c zlib-1.2.9/gzclose.c zlib-1.2.9/gzlib.c zlib-1.2.9/gzread.c zlib-1.2.9/gzwrite.c untar.c android-simg2img-master/backed_block.c android-simg2img-master/output_file.c android-simg2img-master/sparse.c android-simg2img-master/sparse_crc32.c android-simg2img-master/sparse_err.c android-simg2img-master/sparse_read.c kernel_dump.c -o kernel_dump.x86-apple-darwin11

Done! Hope its ok and working. Attachment on first post! :)
 
  • Like
Reactions: osm0sis and shoey63

shoey63

Recognized Contributor
Had hard time building for apple since can't make any static lib with its crosstool, so missed libz and libsparse, but good thing done it this way:

Code:
o64-clang -D_FILE_OFFSET_BITS=64 -Wall -O3 -I./include -Iandroid-simg2img-master/include lz4.c unpackbootimg.c zlib-1.2.9/adler32.c zlib-1.2.9/crc32.c zlib-1.2.9/deflate.c zlib-1.2.9/infback.c zlib-1.2.9/inffast.c zlib-1.2.9/inflate.c zlib-1.2.9/inftrees.c zlib-1.2.9/trees.c zlib-1.2.9/zutil.c zlib-1.2.9/compress.c zlib-1.2.9/uncompr.c zlib-1.2.9/gzclose.c zlib-1.2.9/gzlib.c zlib-1.2.9/gzread.c zlib-1.2.9/gzwrite.c untar.c android-simg2img-master/backed_block.c android-simg2img-master/output_file.c android-simg2img-master/sparse.c android-simg2img-master/sparse_crc32.c android-simg2img-master/sparse_err.c android-simg2img-master/sparse_read.c kernel_dump.c -o kernel_dump.x86-apple-darwin11

Done! Hope its ok and working. Attachment on first post! :)
Well I'm sure @osm0sis will love it. Just want to give a big thanks to you bro. I no longer use flashtool at all because of your tools. That includes my new Xperia X premium.
Pure genius [emoji4]
 
  • Like
Reactions: munjeni and osm0sis

deboopi2

Senior Member
Nov 12, 2011
587
50
MECHELEN
extracting kernel.elf

Hi I need kernel.elf.
Do I use your tool to extract it from my cell phone
or
I have the rom in a FTF file, when opening with zip I can see the kernel.sin file, is thee a better way to extract kernel.elf from kernel.sin.
or
can I use it to extract kernel.elf from ftf file.

How doI use it, I cannot see where the source is given, is this because you always need to run it from a command bix on the phone, or how should I use ir?

regards
 

shoey63

Recognized Contributor
Hi I need kernel.elf.
Do I use your tool to extract it from my cell phone
or
I have the rom in a FTF file, when opening with zip I can see the kernel.sin file, is thee a better way to extract kernel.elf from kernel.sin.
or
can I use it to extract kernel.elf from ftf file.

How doI use it, I cannot see where the source is given, is this because you always need to run it from a command bix on the phone, or how should I use ir?

regards
Windows user? Just drag and drop kernel.sin onto unpackimg and let the kitchen do its work. Then double click repackimg you will get an image-new.img which you can use rootkernel tool on.
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,773
40,456
Halifax
GT-i9250
Google Nexus 4
Last edited:

deboopi2

Senior Member
Nov 12, 2011
587
50
MECHELEN
Ok but the OP gives the commands like this
  • kernel_dump DESTINATIONFOLDER PATHTOTHEFILE
  • kernel_dump out kernel.elf
  • kernel_dump out boot.img
I donn't know where the source is, only the destinationfolder and the pathtofile.
Do I run it against the ftf file or what ?
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,773
40,456
Halifax
GT-i9250
Google Nexus 4
Yeah, wrong thread if you want kernel.sin to kernel.elf, but RIGHT thread if you want kernel.sin to AOSP boot image. And tobias's rootkernel tool can handle either;)

This is the kernel_dump thread though, not AIK or rootkernel, so this IS the right thread if you want only .sin to .elf. ;)

Had hard time building for apple since can't make any static lib with its crosstool, so missed libz and libsparse, but good thing done it this way:

Code:
o64-clang -D_FILE_OFFSET_BITS=64 -Wall -O3 -I./include -Iandroid-simg2img-master/include lz4.c unpackbootimg.c zlib-1.2.9/adler32.c zlib-1.2.9/crc32.c zlib-1.2.9/deflate.c zlib-1.2.9/infback.c zlib-1.2.9/inffast.c zlib-1.2.9/inflate.c zlib-1.2.9/inftrees.c zlib-1.2.9/trees.c zlib-1.2.9/zutil.c zlib-1.2.9/compress.c zlib-1.2.9/uncompr.c zlib-1.2.9/gzclose.c zlib-1.2.9/gzlib.c zlib-1.2.9/gzread.c zlib-1.2.9/gzwrite.c untar.c android-simg2img-master/backed_block.c android-simg2img-master/output_file.c android-simg2img-master/sparse.c android-simg2img-master/sparse_crc32.c android-simg2img-master/sparse_err.c android-simg2img-master/sparse_read.c kernel_dump.c -o kernel_dump.x86-apple-darwin11

Done! Hope its ok and working. Attachment on first post! :)
@munjeni, the i386 binary from your attachment worked on my girlfriend's MacBook Pro (x86_64) on which I've been testing, but the "x86" o64-clang binary you include only gives "Killed: 9" when run. Any ideas?

Edit: Nevermind.. downloaded and unzipped again directly on the MacBook and it worked. Must have gotten corrupted in a network copy at some point! Thanks for your work! I'll have it in AIK-Linux v3.1 soon. :):highfive:
 
Last edited:
  • Like
Reactions: munjeni and shoey63

soulless_div

Member
Jul 5, 2017
15
1
question(maybe wrong thread but anyways) - how to make boot img from kernel elf or sin file? and will it be possible to flash it using fastboot? i mean something like fastboot flash boot boot.img. thanks in advance
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,773
40,456
Halifax
GT-i9250
Google Nexus 4
question(maybe wrong thread but anyways) - how to make boot img from kernel elf or sin file? and will it be possible to flash it using fastboot? i mean something like fastboot flash boot boot.img. thanks in advance

If you have a newer Sony device that allows AOSP boot.img files to be flashed to it with an unlocked bootloader, then my Android Image Kitchen (which includes @munjeni's excellent kernel_dump for the SIN processing,) can do this for you. You can find the link in my signature or search XDA/Google. :good:
 
  • Like
Reactions: bigrammy and oF2pks

Top Liked Posts

  • There are no posts matching your filters.
  • 75
    Disclaimer:

    Our tool was made for testing and educational purposes, ME is not responsible for what you have doing using our tool, you must agree that you using our tool on your own risk, I am not responsible for anything or anything else you doing/do with using our tool!

    Hello! I have made universal tool which is able to extract any format of the Sony image. Also tool is able to dump and extract directly from block device. After 20.Jan.2017 we are able now to convert sin file on the fly and flash it directly to block device. Supported formats which tool is able to deal with:

    1. sin v1
    2. sin v2
    3. sin v3
    4. sin v4
    5. sin v5
    6. img
    7. elf

    How to use:
    since this is a command line tool, you must run it trought an batch file or trought your command line, e.g:
    sony_dump DESTINATIONFOLDER PATHTOTHEFILE
    sony_dump out kernel.elf
    sony_dump out boot.img
    sony_dump out kernel.sin
    sony_dump out /dev/block/platform/msm_sdcc.1/by-name/boot (android version only)
    sony_dump out /dev/block/platform/msm_sdcc.1/by-name/FOTAKernel (android version only)
    sony_dump out anysinfile.sin
    for flashing sin file to block device e.g: sony_dump /dev/block/platform/msm_sdcc.1/by-name/system system.sin

    Enjoy!

    Changelog:
    - 01.Jan.2017 -> implemented sin to elf converter, now kernel.sin can be extracted
    - 01.Jan.2017 -> now any sin file can be converted to converted.file
    - 02.Jan.2017 -> now sin version 3 with lz4 compressed data is supported
    - 02.Jan.2017 -> improved non compresed sin files extraction
    - 02.Jan.2017 -> some cleanups ; now arm version, arm version with pie and linux version
    - 04.Jan.2017 -> fix large sin files extraction, curently I have removed arm and windows version of the program since I have no idea how to get LFS working on non 64bit platform, so last one is for Linux 64-bit platform only until I find a way to write files bigger than 2gb :( If you have working example tell me please!
    - 05.Jan.2017 -> LFS fixed, now tool generates valid system.ext4 from uncompressed sin, suuport again for linux, for arm, for windows, tested only on linux and windows by now, tool support by now large files (LFS) and propertly generates output. If you find bugs please report. Tommorow hope fix for compressed big sin files
    - 07.Jan.2017 -> finished. Now all types of the sin files can be extracted. Sin files decompression fail on 32 bit machines/devices if output file reach 0xffffffff bytes so everything after output of the 0xffffffff bytes is not a valid, I have no idea which toolchain have full 64 bit support on 32 bit platform so I am unable to make LFS (large files support) on 32 bit platfom. File output which is smaller than 0xffffffff bytes is valid on 32 bit platform. But on any 64 bit platform tool working flawless and you can extract any sin file so no problem with LFS and etc! I have tested on win10 64 bit and ubuntu 64 bit and can confirm that any sin files is extracted correctly. Tried on android 32 bit but file output which is smaller than 0xffffffff bytes is a valid but till after file reach size of the 0xffffffff bytes is no more valid! Have no idea why. Not tried on 64 bit android but I am pretty sure it will work the same like on 64 bit windows and 64 bit linux.
    - 07.Jan.2017 -> while compared extracted sin with one of the flashtool I have noticed one or two blocks missing in my output file :(, it was since whileloop was wrong in one case, done some right small changes and now all case is ok, file is identic to one from flashtool
    - 08.Jan.2017 -> Finally tool is abble to work on booth 32 bit and 64 bit linux, android and windows machine by fully supporting LFS
    - 12.Jan.2017 -> sony_dump, detect file extensions in sin
    - 12.Jan.2017 -> small tool for convert file_contexts.bin (binary) to file_contexts (textual)
    - 15.Jan.2017 -> removed part of the old mechanism related to sin version and file size detection, in some case cache.sin was failed to extract since file size calculation was wrong, now definitelly any sin file can be extracted
    - 20.Jan.2017 -> redesigned a way for extracting boot.sin files, now it extract elf instead of unpacking it fully, so if you need to unpack fully just rerun tool with elf file. Also now we can convert on the fly and flash any sin file directly to block device
    - 01.May.2017 -> support for sin version 1 & 2, some improvements for ver 3
    - 18.May.2017 -> compiled for mipsel 32bit & 64bit (litle endian), mips 32bit and mips 64bit (big endian), linux 32bit & 64bit, arm 32bit and arm 64bit, windows, all is static without dependencies
    - 07.Jun.2017 -> support for sin version 4
    - 24.12.2017 -> apple x86 and apple i386 support
    - 12.06.2018 -> sin version 5 support
    - 13.06.2018 -> self implemented custom sparse format (no more need libsparse) because had problem with out of memory extracting large sin files
    - 17.06.2018 -> fully implemented sin v5, removed mips and mips64 big endian builds (because my tool not support that)
    - 17.10.2019 -> some sin files produce wrong ext4 file, fixed now. Removed osx support right now, if you need it download source code from git and compile by self, I have no free time to mess with it
    - 18.10.2019 -> another bug discovered, ext4 padding on some sin files was missing, fixed now
    - 20.10.2019 -> some updates, osx binaries now included
    - 03.11.2019 -> propertly unpack ext4 images, this include extra bytes at the end of ext4, it is realy need if you going to fully emulate sony gpt disk inside virtual machine ; inflate progress bar

    Small tool for converting binary->plaintext plaintext->binary file_contexts:
    - https://xdaforums.com/showpost.php?p=70881172&postcount=1985

    Credits:
    - I must give credit to @Androxyde since I have looked into his java source code for understanding lz4a commpresed sin's, thanks for open source, I realy appreciate your hard work on flashtool!

    Source code:
    - https://github.com/munjeni/anyxperia_dumper
    8
    finished. Now all types of the sin files can be extracted. Sin files decompression fail on 32 bit machines/devices if output file reach 0xffffffff bytes (4 gb) so everything after output of the 0xffffffff bytes (4 gb) is not a valid, I have no idea which toolchain have full 64 bit support on 32 bit platform so I am unable to make LFS (large files support) on 32 bit platfom. File output which is smaller than 0xffffffff bytes (4 gb) is valid on 32 bit platform. But on any 64 bit platform tool working flawless and you can extract any sin file so no problem with LFS and etc! I have tested on win10 64 bit and ubuntu 64 bit and can confirm that any sin files is extracted correctly. Tried on android 32 bit but file output which is smaller than 0xffffffff bytes (4gb) is a valid but till after file reach size of the 0xffffffff bytes (4gb) is no more valid. 32 bit platform is limited and we can do nothing on that. Not tried on 64 bit android but I am pretty sure it will work ok the same like on 64 bit windows and 64 bit linux.

    This tool is primary designed for extracting any sony boot image format from, you can extract any boot image using this tool on 32 bit platform or on 64 bit platform without any problem, without cares to LFS! But for seccondary thing you can use to extract any sin file, on 64 bit platform it will success for sure but on 32 bit platform it is limited because LFS in my case is not working corectly on 32 bit platform if output of the file is bigger than 4 GB :)
    8
    New version is out!

    - 12.06.2018 -> sin version 5 support
    8
    New version of the filecont tool now in windows, linux and arm, and also new version of the kernel_dump tool, enjoy!

    How to convert file_contexts.bin binary to plaintext file_contexts:
    filecont file_contexts.bin file_contexts

    You can use/modify these files and/or include them in your work as long as proper credits and a link to this thread are given.
    6
    Update:
    now tool is able to extract any sin file and output it to converted.file