[DEV][TOOL] kernel.sin unpacker {UPDATED for Z1 and above!}

Search This thread

weaponXandroid

Senior Member
Jan 10, 2011
162
74
Mumbai
OK so figured out how to use perl, but getting an error, in cmd which is:-

removed old directory kernel.sin-ramdisk
Can't spawn "cmd.exe": No such file or directory at unpack-kernelsin.pl line 84.

extracted ramdisk contents to directory kernel.sin-ramdisk/



But there is nothing in kernel.sin-ramdisk folder, "empty"
And I got two files, kernel.sin-header, kernel.sin-kernel.

Is this the out put expected?

Sorry if i m irritating u
 

DooMLoRD

Inactive Recognized Developer
Jul 27, 2010
13,187
39,710
Pune
OK so figured out how to use perl, but getting an error, in cmd which is:-

removed old directory kernel.sin-ramdisk
Can't spawn "cmd.exe": No such file or directory at unpack-kernelsin.pl line 84.

extracted ramdisk contents to directory kernel.sin-ramdisk/



But there is nothing in kernel.sin-ramdisk folder, "empty"
And I got two files, kernel.sin-header, kernel.sin-kernel.

Is this the out put expected?

Sorry if i m irritating u

there are many dependencies for unpacking the ramdisk (gunzip, cpio binary)... thats why i told u to use linux... i am sure if u search u can find windows versions of those files... but symlinks are NOT preserved by windows thats why use linux...
 
  • Like
Reactions: weaponXandroid

CosmicDan

Senior Member
Jun 19, 2009
5,906
7,746
37
Sydney
Xiaomi Poco X3 Pro
there are many dependencies for unpacking the ramdisk (gunzip, cpio binary)... thats why i told u to use linux... i am sure if u search u can find windows versions of those files... but symlinks are NOT preserved by windows thats why use linux...

Well Cygwin knows how to use NTFS symlinks and junctions and does it well, just that the pure-win32 ports of the GNU toolchains don't have that capability. Those of us who can't/won't install Linux are best off trying Cygwin.

Thanks a lot for this, much appreciated. Now I can get to work on testing out custom MTD layouts for FXP.

EDIT: About repacking.... I assume we have to join kernel.sin-header to the beginning of kernel.sin-kernel in order to get the raw zImage right...? Then we convert that with bin2elf and etc. Will try it and test a flash and confirm that a repacked RAMDisk works under Cygwin, otherwise I'll start downloading Ubuntu.

EDIT2: Nope, no need to append the loader. Anyway, those of us on Windows who want to repack it, use this batch file:

Code:
:: the_laser's sinTools example with updates/comments
:: updates and comments by jonusc
@echo off
:BEGIN
:: Repack the kernal image
bin2Elf.exe 2 0x20008000 kernel.sin-kernel 0x20008000 0x0 kernel.sin-ramdisk.cpio.gz 0x24000000 0x80000000
:: Convert to SIN and define linux partition map
bin2sin.exe result.elf 03000000220000007502000062000000
:: Cleanup
del result.elf
ren result.elf.sin kernel.sin
:: Move repacked kernel to template folder overwriting the old kernel
::   (i) Optional. Repack yourself if missing, choose kernel the repack is based on
move /Y kernel.sin .\template-fxp047
cd template-fxp047
:: Pack it to an FTF (zip) with 7-Zip commandline version.
::   (i) Optional. Repack yourself using whatever ZIP program and rename to FTF.
..\7z a -tzip -r ..\X10_CUSTOM_REPACK.FTF *
cd..

:END
...you cannot edit the ramdisk cpio in Windows however. Apparently the Cpio port for Win32 supports cross-platform symbolic link handling but I am yet to investigate and test it. Cygwin's "port" doesn't appear to support it either.
 
Last edited:

DooMLoRD

Inactive Recognized Developer
Jul 27, 2010
13,187
39,710
Pune
Well Cygwin knows how to use NTFS symlinks and junctions and does it well, just that the pure-win32 ports of the GNU toolchains don't have that capability. Those of us who can't/won't install Linux are best off trying Cygwin.

Thanks a lot for this, much appreciated. Now I can get to work on testing out custom MTD layouts for FXP.

EDIT: About repacking.... I assume we have to join kernel.sin-header to the beginning of kernel.sin-kernel in order to get the raw zImage right...? Then we convert that with bin2elf and etc. Will try it and test a flash and confirm that a repacked RAMDisk works under Cygwin, otherwise I'll start downloading Ubuntu.

EDIT2: Nope, no need to append the loader. Anyway, those of us on Windows who want to repack it, use this batch file:

Code:
:: the_laser's sinTools example with updates/comments
:: updates and comments by jonusc
@echo off
:BEGIN
:: Repack the kernal image
bin2Elf.exe 2 0x20008000 kernel.sin-kernel 0x20008000 0x0 kernel.sin-ramdisk.cpio.gz 0x24000000 0x80000000
:: Convert to SIN and define linux partition map
bin2sin.exe result.elf 03000000220000007502000062000000
:: Cleanup
del result.elf
ren result.elf.sin kernel.sin
:: Move repacked kernel to template folder overwriting the old kernel
::   (i) Optional. Repack yourself if missing, choose kernel the repack is based on
move /Y kernel.sin .\template-fxp047
cd template-fxp047
:: Pack it to an FTF (zip) with 7-Zip commandline version.
::   (i) Optional. Repack yourself using whatever ZIP program and rename to FTF.
..\7z a -tzip -r ..\X10_CUSTOM_REPACK.FTF *
cd..

:END
...you cannot edit the ramdisk cpio in Windows however. Apparently the Cpio port for Win32 supports cross-platform symbolic link handling but I am yet to investigate and test it. Cygwin's "port" doesn't appear to support it either.

as i said before windows doesnt correctly handle the symlinks and the symlinks in the ramdisk get broken causing the device to not boot... this is because the /sbin/ueventd is symlinked to /init and if u have ramdisk with integrated recovery then ALL busybox (recovery) applets are symlinks to /sbin/recovery...


no u dont need to join kernel.sin-header

kernel.sin-kernel is the actual zImage


also u need the modified loader.sin to be packed with FTF... i am not sure if FlashTool will accept that kind of FTF (7zip packed)
 

CosmicDan

Senior Member
Jun 19, 2009
5,906
7,746
37
Sydney
Xiaomi Poco X3 Pro
as i said before windows doesnt correctly handle the symlinks and the symlinks in the ramdisk get broken causing the device to not boot... this is because the /sbin/ueventd is symlinked to /init and if u have ramdisk with integrated recovery then ALL busybox (recovery) applets are symlinks to /sbin/recovery...


no u dont need to join kernel.sin-header

kernel.sin-kernel is the actual zImage


also u need the modified loader.sin to be packed with FTF... i am not sure if FlashTool will accept that kind of FTF (7zip packed)

Yeah all the busybox commands are symlinked and it seems cygwin's cpio doesn't handle them at all whereas apparently the native win32 port of cpio can, but I will try "porting" your pearl script to win32 another time if I feel the need.

With the -tzip parameter it's just packing to a ZIP file, the loader.sin is included in the template folder - that's the original FTF file extracted ready for replacing+repacking. I've tested rebuilding DoomKernel and FXP kernel with this batch file and they flash fine, though of course I couldn't repack the RAMDisk to a gzipped cpio under Windows so it's nothing special yet.
 

Idea Generator

Senior Member
Nov 6, 2011
68
4
Tuticorin
THIS IS FOR ADVANCED/EXPERIENCED USERS ONLY


[ info ]

hello devs/users this should be a useful tool (its just a small perl script) for u guys... i have modified the popular unpack-bootimg.pl script to support the (new) kernel.sin files... so it will basically unpack kernel.sin to zImage and ramdisk, ramdisk will also be extracted...


[ requirements ]

  1. linux machine
  2. perl


[ supported devices ]

  • Xperia X10 (GB update, custom kernels for unlocked bootloaders)
  • Xperia 2011 devices (Arc, Arc S, Neo, Play, Mini, Mini Pro, Ray, Pro, Active, Live Walkman)


[ download link ]

unpack-kernelsin


[ usage ]

Code:
./unpack-kernelsin.pl kernel.sin


icon8.gif


Enjoy!

I'm getting permission denied error. Can some one help me ?
 

championswimmer

Inactive Recognized Developer
Oct 22, 2011
5,018
8,446
New Delhi
android.championswimmer.tk
it works perfectly fine with me for cygwin

you need to set up cygwin the way it has been suggested for setting up cyanogenmod build enviromment (that way, all dependent packages automatically get installed)

and cygwin should be installed after java is installed on a compter installing java after cygwin causes unknown bad problems :p
 
  • Like
Reactions: Toledo_JAB

CosmicDan

Senior Member
Jun 19, 2009
5,906
7,746
37
Sydney
Xiaomi Poco X3 Pro
Maybe off topic I don't know, but I wonder if any of the top X10 devs are any closer to creating custom partition layouts? Particularly taking some of that massive wasted space from /system and giving it to /data. I tried doing it but was too scared to brick my X10 :)
 

championswimmer

Inactive Recognized Developer
Oct 22, 2011
5,018
8,446
New Delhi
android.championswimmer.tk
Maybe off topic I don't know, but I wonder if any of the top X10 devs are any closer to creating custom partition layouts? Particularly taking some of that massive wasted space from /system and giving it to /data. I tried doing it but was too scared to brick my X10 :)

we do not really have an official unlocked bootloader....what we really have is bypass which neglects checking the kernel headers(yes the-laser's method is also essentially a bypass ... only the OEM can actually unlock bootloader and Sony has NOT done so for x10)... thus accessing partitions is still not possible.



Sent from my X10S using xda premium
 

DooMLoRD

Inactive Recognized Developer
Jul 27, 2010
13,187
39,710
Pune
we do not really have an official unlocked bootloader....what we really have is bypass which neglects checking the kernel headers(yes the-laser's method is also essentially a bypass ... only the OEM can actually unlock bootloader and Sony has NOT done so for x10)... thus accessing partitions is still not possible.



Sent from my X10S using xda premium

That's wrong... The signature is still checked by the hacked loader of the_laser...

Sent from my HTC One X using XDA
 

championswimmer

Inactive Recognized Developer
Oct 22, 2011
5,018
8,446
New Delhi
android.championswimmer.tk
That's wrong... The signature is still checked by the hacked loader of the_laser...

Sent from my HTC One X using XDA

oh... ok...sorry... my ignorance :p

OFFTOPIC
what are these mtd4 and userdate partitions for.. seem like hidden partitions.... or for baseband usage?

___continuing here and not spamming the thread more ____

yes i was talking of the fourth one :p
apps log? hmm i didnt know that...other three i knew :)
thanks


Sent from my X10S using xda premium
 
Last edited:

DooMLoRD

Inactive Recognized Developer
Jul 27, 2010
13,187
39,710
Pune
oh... ok...sorry... my ignorance :p

OFFTOPIC
what are these mtd4 and userdate partitions for.. seem like hidden partitions.... or for baseband usage?

Sent from my X10S using xda premium

the mtds are for:
/system
/data
/cache

and i think there is one for apps log...

MTD format is usually used for NAND based device..
 

CosmicDan

Senior Member
Jun 19, 2009
5,906
7,746
37
Sydney
Xiaomi Poco X3 Pro
....so I guess that means no :) I could have sworn it was possible while building the kernel (in cygwin or preferably linux of course) when I looked at the code a while back, but I gave up because it'd require a custom recovery image. Oh well, I've gotten used to TB-Pro "Integrate System App" filters I use to save space on /data.
 

brenty108

Senior Member
Jan 12, 2011
914
242
santa flora
Medium user

I um...I'm lost I download pearl and the file from this trend but what next? I wanna extra the system.sin from my x10 2.3.3. someone please reply. I'm using Windows Xp.
 

CosmicDan

Senior Member
Jun 19, 2009
5,906
7,746
37
Sydney
Xiaomi Poco X3 Pro
I um...I'm lost I download pearl and the file from this trend but what next? I wanna extra the system.sin from my x10 2.3.3. someone please reply. I'm using Windows Xp.

Completely different. You need to use SIN2BIN tool then extract (or mount) the img with some .img tool that can read yaffs2 filesystems. On Windows it's complicated, you are better off just flashing the stock FTF ROM then doing adb pull /system with USB Debugging.

If you don't know how to do that, you probably shouldn't be doing whatever it is you're trying to do :cool:
 

rocketero

Senior Member
Jan 1, 2012
355
71
I have maybe a stupid question, but bear with me..

I have a boot.img is around 10MB in size.

When I use unpack_kernelsin or the method explained by iridaki and after repacking the new-boot.img the total size is only around 5.2MB .. why is that?

also that new-boot.img is not working on my tablet. the --cmdline (in ./repack_bootimg.pl) says it is: ''androidboot.hardware=qcom", that's the only parameter I inpup in --cmdline,

anyways some light on this issue is appreciated.
 

iridaki

Retired Forum Moderator
Feb 21, 2007
4,532
5,190
37
Edinburgh, Scotland
I have maybe a stupid question, but bear with me..

I have a boot.img is around 10MB in size.

When I use unpack_kernelsin or the method explained by iridaki and after repacking the new-boot.img the total size is only around 5.2MB .. why is that?

also that new-boot.img is not working on my tablet. the --cmdline (in ./repack_bootimg.pl) says it is: ''androidboot.hardware=qcom", that's the only parameter I inpup in --cmdline,

anyways some light on this issue is appreciated.

This tool you are referring tool is only to be used with Xperia 2011 devices.
It will not work on any other tablet/smartphone model.
 

rocketero

Senior Member
Jan 1, 2012
355
71
This tool you are referring tool is only to be used with Xperia 2011 devices.
It will not work on any other tablet/smartphone model.

who know, I found this tool: the DsiXDA's Kitchen tool and made a successful newboot.img that I could flash. but still not full support for scripts running at /system/etc/init.d at boot time.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 41
    THIS IS FOR ADVANCED/EXPERIENCED USERS ONLY


    [ info ]

    hello devs/users this should be a useful tool (its just a small perl script) for u guys... i have modified the popular unpack-bootimg.pl script to support the (new) kernel.sin files... so it will basically unpack kernel.sin to zImage and ramdisk, ramdisk will also be extracted...


    [ requirements ]

    1. linux machine
    2. perl


    [ supported devices ]

    • Xperia X10 (GB update, custom kernels for unlocked bootloaders)
    • Xperia 2011, 2012, 2013 H1 devices
    • Xperia 2013 H2 devices onwards with dt.img extraction support


    [ download link ]

    unpack-kernelsin.pl


    [ usage ]

    Code:
    ./unpack-kernelsin.pl kernel.sin


    icon8.gif


    Enjoy!
    7
    D
    Deleted member 3665957
    safer and proper way - parse SIN header, extract payload, parse ELF header in payload, extract program tables.

    everything other, like signature search and heuristic analyze, can work, but can fail ;)
    4
    Little correction here ;-)
    1F8B08 is the tar.gz magic number and has nothing to do with SE :p

    But you are right its safer to search for the whole magic.

    Regards

    Also, are you sure 1F 8B is enough? Because I see a lot of 1F 8B in kernel.sin, while 1F 8B 08 is the kernel magic for SE devices.



    Sent from my LT15i using Tapatalk
    2
    you are right i try it today and it worked perfectly! but how can i build boot.img from this files?:confused:

    https://github.com/freexperia/boot_tools/blob/master/build-bootimg-mogami/makeit.sh
    1
    nice work! can you make one in ms-dos batch version? :D

    aZuZu u are the expert at porting linux stuff to windows ;)