Lanchon / REPIT

A Device-Only Data-Sparing Repartitioning Tool For Android
159 stars 25 forks source link

Galaxy Ace Plus GT-S7500 (trebon) (was: Unable to flash repit-dump.zip) #32

Closed gabriTB01 closed 8 years ago

gabriTB01 commented 8 years ago

Hi, I tried to flash repit-dump file in order to send you the log and support my galaxy ace plus (GT-S7500, trebon) but give me this error in the repit-dump.log:

flashize-ext: unable to extract package contents

[ERROR 1]

I use CM 11 by Liam D and the integrated kernel (http://forum.xda-developers.com/galaxy-ace-plus/development/wip-cyanogenmod-11-0-gt-s7500-t2957544) The TWRP version is 2.7.0.0 and it is unofficial (http://forum.xda-developers.com/galaxy-ace-plus/development/twrp-2-7-00-recommended-recovery-cm11-t3073271) I am using standard partition layout. I have the same error on my ace 2, maybe I am doing something wrong, i have also tried adb sideload in both devices with no success.Thanks.

Lanchon commented 8 years ago

hi,

REPIT uses flashize. flashize-ext is being unable to extract the contents of the zip using your recovery.

unfortunately toybox (used in CM13 recovery and AOSP recovery) has a very buggy unzip implementation, so i had to choose options carefully, use minimum options, AND silence the output of the unzip process.

the silencing is done here with the '>/dev/null': https://github.com/Lanchon/Flashize/blob/master/flashize-ext#L125

for this reason i can't know exactly why your recovery is not unzipping, but the exact same would happen to REPIT if i ported it to your device as it depends on the same flashize function.

if you want to help debug, please flash this modded dump that i made for you and post the log. it cranks up debugging output for the extraction process. (note: the zip is unsigned.) repit-dump-debug-ext.zip

thanks!

gabriTB01 commented 8 years ago

Hi, here is the log: repit-dump.txt Thanks.

Lanchon commented 8 years ago

your log contains:

+ export FLASHIZE_EXT_VERSION=2016-04-06
+ mkdir -p /tmp/flashize/
+ cd /tmp/flashize/
+ unzip -o /sdcard/repit-dump-debug-ext.zip -d /tmp/flashize/
Archive:  /sdcard/repit-dump-debug-ext.zip
  inflating: META-INF/com/google/android/update-binary
unzip: zip flags 1 and 8 are not supported
+ [ 1 -ne 0 ]
+ echo flashize-ext: unable to extract package contents
flashize-ext: unable to extract package contents
+ exit 1

[ERROR 1]

as you can see, unzip outputs unzip: zip flags 1 and 8 are not supported on a perfectly good zip and dies. your binary unzip in your twrp build is defective. you could upgrade twrp. i'll look more into this when i have time.

gabriTB01 commented 8 years ago

I never had problems in zip flashing. Your zip is the only that give me this problem. Unfortunately there aren't newer version of TWRP for my phones. Thanks a lot for your replies!

Lanchon commented 8 years ago

the busybox binary in your TWRP was compiled without the ENABLE_DESKTOP flag: https://git.busybox.net/busybox/tree/archival/unzip.c?h=1_24_stable#n554

this results in an unzip command that cannot understand 'streamed' zip files, which is a valid kind of zip file.

using zipdetails i can see that the files in the release zip are in fact 'streamed' (bit 3 of flags):

$ zipdetails repit-dump.zip

00000 LOCAL HEADER #1       04034B50
00004 Extract Zip Spec      14 '2.0'
00005 Extract OS            00 'MS-DOS'
00006 General Purpose Flag  0808
      [Bits 1-2]            0 'Normal Compression'
      [Bit  3]              1 'Streamed'
      [Bit 11]              1 'Language Encoding'
00008 Compression Method    0008 'Deflated'
0000A Last Mod Time         385D0437 'Fri Feb 29 00:33:46 2008'
0000E CRC                   00000000
00012 Compressed Length     00000000
00016 Uncompressed Length   00000000
0001A Filename Length       0029
0001C Extra Length          0004
0001E Filename              'META-INF/com/google/android/update-
                            binary'
00047 Extra ID #0001        CAFE 'Java Executable'
00049   Length              0000
0004B PAYLOAD

005BB STREAMING DATA HEADER 08074B50
005BF CRC                   98D6B44A
005C3 Compressed Length     00000570
005C7 Uncompressed Length   0000130C

...

during the make process of REPIT zips, they are whole-zip-signed at the final stage using Android's standard signapk tool. this tool is implemented in java, and for what i have read, any zip files produced using java's standard zip API are always 'streamed'.

i modified the make script to keep the unsigned version of zips. as expected, these files are not of the 'streamed' type:

$ zipdetails repit-dump-unsigned.zip | grep binary -C 14

BD0F6 LOCAL HEADER #9       04034B50
BD0FA Extract Zip Spec      14 '2.0'
BD0FB Extract OS            00 'MS-DOS'
BD0FC General Purpose Flag  0002
      [Bits 1-2]            2 'Fast Compression'
BD0FE Compression Method    0008 'Deflated'
BD100 Last Mod Time         489E550D 'Sat Apr 30 10:40:26 2016'
BD104 CRC                   98D6B44A
BD108 Compressed Length     0000056E
BD10C Uncompressed Length   0000130C
BD110 Filename Length       0029
BD112 Extra Length          001C
BD114 Filename              'META-INF/com/google/android/update-
                            binary'
BD13D Extra ID #0001        5455 'UT: Extended Timestamp'
BD13F   Length              0009
BD141   Flags               '03 mod access'
BD142   Mod Time            5724B5CA 'Sat Apr 30 10:40:26 2016'
BD146   Access Time         5724B5CA 'Sat Apr 30 10:40:26 2016'
BD14A Extra ID #0002        7875 'ux: Unix Extra Type 3'
BD14C   Length              000B
BD14E   Version             01
BD14F   UID Size            04
BD150   UID                 000003E8
BD154   GID Size            04
BD155   GID                 000003E8
BD159 PAYLOAD

...

i am attaching an unsigned version of dump for you to try: repit-dump-unsigned.zip

the problem is, not signing the zips is undesirable. recovery zips are supposed to be signed: unsigned zips will not work if the user chooses to check signatures, or if using a recovery that forces signature checking (such as CM12.1 and CM13 recoveries).

for now you can run dump unsigned on your current TWRP. as a full solution i would tell you that you need to find a TWRP build -older or newer- that has a working unzip implementation. for sure i do not like the idea of disabling zip signing on released REPIT files.

gabriTB01 commented 8 years ago

It is not a problem if the zip is unsigned. I have no possibility to update TWRP because there aren't newer version. I can try to use an older version but i think that the problem will remain. I attach the file. Thanks repit-dump.txt

Lanchon commented 8 years ago

hi, thanks

neither fdisk nor gdisk work on your eMMC!!!

==========================================================================================================
parted -s /dev/block/mmcblk0 unit MiB print free unit s print free
----------------------------------------------------------------------------------------------------------
Error: Unable to satisfy all constraints on the partition.

==========================================================================================================
sgdisk /dev/block/mmcblk0 --set-alignment 1 --print
----------------------------------------------------------------------------------------------------------

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format.
***************************************************************

Exact type match not found for type code 4D00; assigning type code for
'Linux filesystem'
Exact type match not found for type code 4500; assigning type code for
'Linux filesystem'
Exact type match not found for type code 4600; assigning type code for
'Linux filesystem'
Exact type match not found for type code 4700; assigning type code for
'Linux filesystem'
Exact type match not found for type code 5D00; assigning type code for
'Linux filesystem'
Exact type match not found for type code 4800; assigning type code for
'Linux filesystem'
Exact type match not found for type code 4A00; assigning type code for
'Linux filesystem'
Exact type match not found for type code 4B00; assigning type code for
'Linux filesystem'
Exact type match not found for type code 9000; assigning type code for
'Linux filesystem'
Exact type match not found for type code 9100; assigning type code for
'Linux filesystem'
Exact type match not found for type code 9200; assigning type code for
'Linux filesystem'
Exact type match not found for type code 9300; assigning type code for
'Linux filesystem'
Exact type match not found for type code 9500; assigning type code for
'Linux filesystem'
Exact type match not found for type code 9400; assigning type code for
'Linux filesystem'
Exact type match not found for type code 6500; assigning type code for
'Linux filesystem'
Exact type match not found for type code 9A00; assigning type code for
'Linux filesystem'
Exact type match not found for type code 6300; assigning type code for
'Linux filesystem'
Exact type match not found for type code 6700; assigning type code for
'Linux filesystem'
Exact type match not found for type code 6400; assigning type code for
'Linux filesystem'
Exact type match not found for type code 5800; assigning type code for
'Linux filesystem'
Exact type match not found for type code A000; assigning type code for
'Linux filesystem'
Warning! Main partition table overlaps the first partition by 33 blocks!
You will need to delete this partition or resize it in another utility.
Disk /dev/block/mmcblk0: 7634944 sectors, 3.6 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): C2E1D8BE-64E1-41C7-8503-32862F999811
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 7634910
Partitions will be aligned on 1-sector boundaries
Total free space is 204766 sectors (100.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1               1              40   20.0 KiB    8300  Linux filesystem
   2              41             340   150.0 KiB   8300  Linux filesystem
   3             341           41300   20.0 MiB    0700  Microsoft basic data
   5           49152           51151   1000.0 KiB  8300  Linux filesystem
   6           51152           53151   1000.0 KiB  8300  Linux filesystem
   7           53152           57151   2.0 MiB     8300  Linux filesystem
   8           57152           81727   12.0 MiB    8300  Linux filesystem
   9           81728           87871   3.0 MiB     8300  Linux filesystem
  10           87872           94015   3.0 MiB     8300  Linux filesystem
  11           94016          110399   8.0 MiB     8300  Linux filesystem
  12          110400          134975   12.0 MiB    8300  Linux filesystem
  13          134976          143167   4.0 MiB     8300  Linux filesystem
  14          143168          151359   4.0 MiB     8300  Linux filesystem
  15          151360          152383   512.0 KiB   8300  Linux filesystem
  16          152384         1176383   500.0 MiB   8200  Linux swap
  17         1176384         1483583   150.0 MiB   8300  Linux filesystem
  18         1483584         3396415   934.0 MiB   8300  Linux filesystem
  19         3396416         3420991   12.0 MiB    8300  Linux filesystem
  20         3420992         3470143   24.0 MiB    8300  Linux filesystem
  21         3470144         3478335   4.0 MiB     8300  Linux filesystem
  22         3478336         3580735   50.0 MiB    8300  Linux filesystem
  23         3580736         7429803   1.8 GiB     8300  Linux filesystem
  24         7429804         7437995   4.0 MiB     8300  Linux filesystem
  25         7437996               0   8.0 ZiB     8300  Linux filesystem

this is the first time ever i've seen such a thing on an android device.

i have no idea what could be wrong. maybe there's corruption in your device? have you tried repartitioning it by any other means?

in any case, fdisk doesn't run at all. if your device is "stock" (ie: not corrupted) it means that the partitioning scheme is non-standard and not supported by standard linux tools. as a consequence, REPIT will never support such a device.

if your device is corrupted, could you say what happened to it? would you consider reverting those changes?

thanks!

gabriTB01 commented 8 years ago

I tried to repartition modifing the pit file and then flash stock GB rom with ODIN with no success. I have only installed CM 11, my device shouldn't be corrupted. I removed a lot of apk to lighten the ROM because i want use my device only as a music player, nothing more. I can try to revert to stock, install TWRP and reflash the repit file to fix corruption.

Lanchon commented 8 years ago

well if it's working, then i wouldn't recommend you fix it. the partition table seems to be corrupted, but as long as android boots, it is not a real issue for you.

to fix you'd need to flash stock via odin using the right stock PIT file and with odin's repartition mode enabled. of course before doing that you have to take at least an EFS backup and keep it outside of the phone, just in case. this odin operation entails risks (wrong file(s), wrong options, wrong odin version, usb disconnect, or just random failues) and -again- i recommend against it if your phone is working.

finally, we have to consider the possibility that even with stock PIT there might be something strange going on with this phone model's partition table (but i think this is unlikely).

gabriTB01 commented 8 years ago

I tried to flash stock rom with the correct pit file but Odin gives me an error. I tried also to use Odin Multi Downloader to flash the ops file but the phone was not recognized by this tool. And so my partition table is still corrupted. Dont' worry if there aren't other solutions. Thanks.

Lanchon commented 8 years ago

well if you did odin right and it fails, it is definitely corrupted. i now think that this phone might have a corrupted msdos style partition table, rather than a GPT. if this is true, repit wouldnt run in that phone anyway.

yes, there are ways to fix it i am sure, but i can't help you without physically having the phone with me.

just let it be. :)

thanks for trying anyway!!