Skip to content

not able to flash Galaxy s3 userdata partition #55

Closed
nka11 opened this Issue Oct 5, 2012 · 14 comments

5 participants

@nka11
nka11 commented Oct 5, 2012

OS : linux ubuntu 12.04

Here is the pit :

 heimdall print-pit --verbose --no-reboot
Heimdall v1.4 RC1

Copyright (c) 2010-2012, Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Detecting device...
      Manufacturer: "SAMSUNG"
           Product: "Gadget Serial"

            length: 18
      device class: 2
               S/N: 0
           VID:PID: 04E8:685D
         bcdDevice: 021B
   iMan:iProd:iSer: 1:2:0
          nb confs: 1

interface[0].altsetting[0]: num endpoints = 1
   Class.SubClass.Protocol: 02.02.01
       endpoint[0].address: 83
           max packet size: 0010
          polling interval: 09

interface[1].altsetting[0]: num endpoints = 2
   Class.SubClass.Protocol: 0A.00.00
       endpoint[0].address: 81
           max packet size: 0200
          polling interval: 00
       endpoint[1].address: 02
           max packet size: 0200
          polling interval: 00
Claiming interface...
Attempt failed. Detaching driver...
Claiming interface again...
Setting up interface...

Checking if protocol is initialised...
ERROR: libusb error -7 whilst receiving packet.
Protocol is not initialised.

Initialising protocol...
Protocol initialisation successful.

Beginning session...
Session begun with device of type: 0.

Downloading device's PIT file...
PIT file download successful.

Entry Count: 16
Unknown 1: 1598902083
Unknown 2: 844251476
Unknown 3: 30797
Unknown 4: 0
Unknown 5: 0
Unknown 6: 0
Unknown 7: 0
Unknown 8: 0


--- Entry #0 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 80
Attributes: 2 (STL Read-Only)
Update Attributes: 1 (FOTA)
Partition Block Size: 0
Partition Block Count: 1734
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: BOOTLOADER
Flash Filename: sboot.bin
FOTA Filename: 


--- Entry #1 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 81
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size: 1734
Partition Block Count: 312
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: TZSW
Flash Filename: tz.img
FOTA Filename: 


--- Entry #2 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 70
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size: 34
Partition Block Count: 16
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: PIT
Flash Filename: mx.pit
FOTA Filename: 


--- Entry #3 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 71
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size: 50
Partition Block Count: 2048
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: MD5HDR
Flash Filename: md5.img
FOTA Filename: 


--- Entry #4 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 1
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size: 8192
Partition Block Count: 8192
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: BOTA0
Flash Filename: -
FOTA Filename: 


--- Entry #5 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 2
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size: 16384
Partition Block Count: 8192
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: BOTA1
Flash Filename: -
FOTA Filename: 


--- Entry #6 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 3
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size: 24576
Partition Block Count: 40960
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: EFS
Flash Filename: efs.img
FOTA Filename: 


--- Entry #7 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 4
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size: 65536
Partition Block Count: 16384
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: PARAM
Flash Filename: param.bin
FOTA Filename: 


--- Entry #8 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 5
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size: 81920
Partition Block Count: 16384
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: BOOT
Flash Filename: boot.img
FOTA Filename: 


--- Entry #9 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 6
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size: 98304
Partition Block Count: 16384
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: RECOVERY
Flash Filename: recovery.img
FOTA Filename: 


--- Entry #10 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 7
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size: 114688
Partition Block Count: 65536
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: RADIO
Flash Filename: modem.bin
FOTA Filename: 


--- Entry #11 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 8
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size: 180224
Partition Block Count: 2097152
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: CACHE
Flash Filename: cache.img
FOTA Filename: 


--- Entry #12 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 9
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size: 2277376
Partition Block Count: 3145728
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: SYSTEM
Flash Filename: system.img
FOTA Filename: 


--- Entry #13 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 10
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size: 5423104
Partition Block Count: 1146880
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: HIDDEN
Flash Filename: hidden.img
FOTA Filename: 


--- Entry #14 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 11
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size: 6569984
Partition Block Count: 16384
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: OTA
Flash Filename: -
FOTA Filename: 


--- Entry #15 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 12
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size: 6586368
Partition Block Count: 0
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: USERDATA
Flash Filename: userdata.img
FOTA Filename: remained

Ending session...

First I tried with the true partition name :

heimdall flash --USERDATA userdata.img --verbose 
Heimdall v1.4 RC1

Copyright (c) 2010-2012, Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
      Manufacturer: "SAMSUNG"
           Product: "Gadget Serial"

            length: 18
      device class: 2
               S/N: 0
           VID:PID: 04E8:685D
         bcdDevice: 021B
   iMan:iProd:iSer: 1:2:0
          nb confs: 1

interface[0].altsetting[0]: num endpoints = 1
   Class.SubClass.Protocol: 02.02.01
       endpoint[0].address: 83
           max packet size: 0010
          polling interval: 09

interface[1].altsetting[0]: num endpoints = 2
   Class.SubClass.Protocol: 0A.00.00
       endpoint[0].address: 81
           max packet size: 0200
          polling interval: 00
       endpoint[1].address: 02
           max packet size: 0200
          polling interval: 00
Claiming interface...
Attempt failed. Detaching driver...
Claiming interface again...
Setting up interface...

Checking if protocol is initialised...
ERROR: libusb error -7 whilst receiving packet.
Protocol is not initialised.

Initialising protocol...
Protocol initialisation successful.

Beginning session...
Session begun with device of type: 0.

Downloading device's PIT file...
PIT file download successful.

ERROR: Partition "USERDATA" does not exist in the specified PIT.
Ending session...
Rebooting device...
Releasing device interface...
Re-attaching kernel driver...

So, a new try with partition id gives :

heimdall flash --12 userdata.img --verbose 
Heimdall v1.4 RC1

Copyright (c) 2010-2012, Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
      Manufacturer: "SAMSUNG"
           Product: "Gadget Serial"

            length: 18
      device class: 2
               S/N: 0
           VID:PID: 04E8:685D
         bcdDevice: 021B
   iMan:iProd:iSer: 1:2:0
          nb confs: 1

interface[0].altsetting[0]: num endpoints = 1
   Class.SubClass.Protocol: 02.02.01
       endpoint[0].address: 83
           max packet size: 0010
          polling interval: 09

interface[1].altsetting[0]: num endpoints = 2
   Class.SubClass.Protocol: 0A.00.00
       endpoint[0].address: 81
           max packet size: 0200
          polling interval: 00
       endpoint[1].address: 02
           max packet size: 0200
          polling interval: 00
Claiming interface...
Attempt failed. Detaching driver...
Claiming interface again...
Setting up interface...

Checking if protocol is initialised...
ERROR: libusb error -7 whilst receiving packet.
Protocol is not initialised.

Initialising protocol...
Protocol initialisation successful.

Beginning session...
Session begun with device of type: 0.

Downloading device's PIT file...
PIT file download successful.

ERROR: No partition with identifier "12" exists in the specified PIT.
Ending session...
Rebooting device...
Releasing device interface...
Re-attaching kernel driver...

and i have same result with --userdata option.
I think it's an issue, i hope i gave enough information to debug.

@Benjamin-Dobell
Owner

Certainly looks like a bug. I'll get on it!

Thanks for the detailed report :)

@Benjamin-Dobell
Owner

Well that was quick ;)

Heimdall doesn't recognise the partition because it has a block count of zero. Heimdall doesn't try to flash partitions with a size of zero (usually it means it's a junk entry in the PIT file). It's possible that your phone doesn't actually have any room allocated for USERDATA at the moment.

Alternately, maybe the PIT file block counts aren't reliable and Heimdall should just flash them regardless. Whilst that's slightly concerning, it may well be the case.

If you want to give it a try then remove:

entries[i]->GetBlockCount() > 0 && 

from lines 258, 269, 280 and 291 of libpit/Source/libpit.cpp, then recompile both libpit and Heimdall and try flash the USERDATA partition.

@nka11
nka11 commented Oct 5, 2012

Done, looks good.

Thanks for a so quick resolution. Best regards

@nka11 nka11 closed this Oct 5, 2012
@rjmcguire
@nka11
nka11 commented Oct 5, 2012

There is no reason for this patch to not work (in fact it works). The possible repercussions may enforce flashing a partition which really has a block count of 0 (And i'm still looking for a user case where it happens and may cause damage).

My stupid question is :

  • Why the samsung pit has such an "error" or did i break that pit with a previous Odin usage....

This phone exisits with 2 internal memory size. Maybe it's a choice the rom designer of vendor to set this value to 0 in order to have the same PIT usable on 16 or 32G version of the device...

just wondering, will make some investigations around..

@rjmcguire
@Benjamin-Dobell
Owner

Well I would have expected one of two things to happen:

  1. The flash failed, probably with a failed to confirm end of file transfer sequence error. This basically means the bootloader on the phone refused to flash the partition. I would expect no device damage.

  2. The flash failed silently and the data in the file you tried to flash didn't actually make it on your phone.

Basically if it worked I'll be very surprised ;-)

@nka11
nka11 commented Oct 5, 2012

In fact i'm not sure it completely works, as i can't verify for now the content of the part on the phone.
I need to flash userData for Firefox OS, but it still not boot : http://forum.xda-developers.com/showthread.php?p=32395373#post32395373

I'm sure about that : the process doesn't fail, the verbose mode shows me output about writing files and any existing data on the partition is wiped.

@rjmcguire
@Benjamin-Dobell
Owner

Well the FOTA filename for the partition is 'remained'. Perhaps the bootloader interprets 0 to mean whatever space is left over.

For now I'm going to reopen this issue. I don't really want to apply the patch officially until I can confirm that it actually works. I'll do some more investigation with my GT-I9300 when I get home.

@nka11
nka11 commented Oct 5, 2012

Here is my proposal (tested and working) :
in libpit.cpp, replace
entries[i]->GetBlockCount() > 0 &&
by
(entries[i]->GetBlockCount() > 0 || strcmp(entries[i]->GetFotaFilename(), "remaining")) &&

@michield

Had the same problem on Galaxy S2, with boot partition not flashing. Can confirm that the change from nka11 (change && to || on 4 lines in libpit.cpp) works. Used Heimdall v1.4 RC1

@vanviegen

I used to get 'ERROR: Partition name for "primary-boot" could not be located' when attempting to update the boot loader on my i9100. nka11's patch fixes that.

CAUTION: do not just replace && by || as phpartisan suggested, as that is incorrect and dangerous. Refer to nka11's comment instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.