Heimdall icon indicating copy to clipboard operation
Heimdall copied to clipboard

Gs5 fixes for Pit + flash

Open sshimko opened this issue 10 years ago • 55 comments

There are problems on the GS5 when sending empty bulk transfers during Pit file packet requests.This put the entire session into a wonky state. Request none be sent for these packets.

sshimko avatar Sep 03 '14 20:09 sshimko

BTW a quick look at the Issues list and this might fix #203 #209 etc.

sshimko avatar Sep 03 '14 20:09 sshimko

Quick tested on the SM-G900F (S5 klte) the print-pit and flash commands. Both are working now using your patchset.

jehoffmann avatar Sep 05 '14 07:09 jehoffmann

@sshimko Thanks for the patch! I've been meaning to look into this and was hoping to do so this week-end. So it looks like you've saved me some of the work.

However, I can't go ahead and merge this patch in its current state as you've commented out some code and also made some superfluous (and slightly incorrect) changes to the error messages. The patch is still very helpful though.

Which of the following would you prefer:

  1. After I've performed the necessary testing, me let you know what changes are necessary so you can modify your patch and then I'll merge it.
  2. Me simply do whatever needs to be done myself.

No. 2 is more straight-forward for me, but it means you wouldn't get your name in the commit history - your call.

Benjamin-Dobell avatar Sep 05 '14 12:09 Benjamin-Dobell

@Benjamin-Dobell I pushed an update that drops two of the commits and contains just the functional fixes. I should have split out the comment and err message changes etc after I referenced specific issue numbers. I do think some are useful but I'll do a another pull request so those can be discussed there. I'd prefer option 1 BTW :)

sshimko avatar Sep 05 '14 14:09 sshimko

@sshimko Thanks for that. I'll have to do some testing on some of the older devices I have access to; but otherwise I'm happy with how the patch looks and I'll gladly merge it.

Benjamin-Dobell avatar Sep 05 '14 17:09 Benjamin-Dobell

thank you for submitting this patch @sshimko, will merge and test

utkanos avatar Sep 06 '14 00:09 utkanos

@sshimko I've tested this across all the devices I have access to. It does not cause problems for older devices but breaks support for the SM-N900 (International Note 3).

Unfortunately I don't have an S5 at this point, which will make further investigation difficult. However, I'll see what I can come up with.

Benjamin-Dobell avatar Sep 07 '14 17:09 Benjamin-Dobell

@Benjamin-Dobell I should have access to that Note 3 tomorrow and can also regression test against an S5. What firmware version? What operation were you performing? Anything interesting in the logs?

sshimko avatar Sep 07 '14 22:09 sshimko

@sshimko the hlte needs to have taken a 4.4 OTA from Samsung to be impacted best I can tell, firmware level depends on which hlte you have but any 4.4 firmware level should work to test with.

utkanos avatar Sep 08 '14 01:09 utkanos

@utkanos @Benjamin-Dobell I just tested it on a N900V w/ 4.4.2 hlte firmware and it is working for me. Any other info llike logs would be greatly appreciated.

sshimko avatar Sep 08 '14 16:09 sshimko

FYI, I can flash firmware to my G900F with this patch, but still get lots of

 WARNING: Empty bulk transfer after sending packet failed. Continuing anyway...

warnings.

(Thanks a lot for this - I've had my smartphone softbricked and had no Windows PC around..)

phillipberndt avatar Sep 15 '14 08:09 phillipberndt

This patch worked for me on an SM-G900F with no apparent problems.

promovicz avatar Sep 19 '14 15:09 promovicz

Another vote for merging this patch - couldn't flash my G900A without it, worked like a charm after pulling this and recompiling.

ejegg avatar Sep 25 '14 00:09 ejegg

While this patch works for me on a SM-G900F it seems to break PIT download on the SM-G900H (which is the 3G version with an Exynos5, so pretty different).

Note that heimdall from master works for me on this device.

Here is the log:

prom@horsey:~$ sudo heimdall print-pit
Heimdall v1.4.1

Copyright (c) 2010-2014 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...
Claiming interface...
Attempt failed. Detaching driver...
Claiming interface again...
Setting up interface...

Initialising protocol...
Protocol initialisation successful.

Beginning session...

Some devices may take up to 2 minutes to respond.
Please be patient!

Session begun.

Downloading device's PIT file...
ERROR: Failed to receive PIT file part #0!
ERROR: Failed to download PIT file!
Ending session...
ERROR: Failed to receive session end confirmation!
Releasing device interface...
Re-attaching kernel driver...

promovicz avatar Sep 27 '14 02:09 promovicz

This fixes functionality on the trltetmo (T-Mobile Note 4) without the need for the CM instructions to disable a bunch of USB interfaces (which is a terrible idea)

AbandonedCart avatar Oct 20 '14 15:10 AbandonedCart

Off topic:

Cool my VZW Note 4 should be here in the next few days :)

sshimko avatar Oct 20 '14 17:10 sshimko

I tried this patch after seeing it referenced in #241 and this is what I get with this patch:

[phil@rider ~]$ sudo /usr/local/bin/heimdall print-pit --no-reboot --verbose
Heimdall v1.4.1

Copyright (c) 2010-2014 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: "Sasmsung"
           Product: "MSM8960"

            length: 18
      device class: 2
               S/N: 0
           VID:PID: 04E8:685D
         bcdDevice: 0100
   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: 82
           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: 01
           max packet size: 0200
          polling interval: 00
Claiming interface...
ERROR: Claiming interface failed!

Same for a flash attempt.

jaymzh avatar Nov 22 '14 07:11 jaymzh

The first error you posted in #241 appears to be before this patch, and this one that is posted both here and in #241 appears to be the phone not being detected as connected in bootloader mode. Did you make sure to put the phone into bootloader mode THEN connect it to USB and attempt to flash? A common issue is having the phone connected before entering bootloader and the system considers the USB port occupied and doesn't flush the current driver to load the new one.

AbandonedCart avatar Nov 22 '14 13:11 AbandonedCart

Yup, lsusb showed:

Bus 005 Device 020: ID 04e8:685d Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II] (Download mode)

You can see it's in download mode there. And yes, it's an S5, not an S2. :) Verizon, if it matters.

FWIW, I merged this and #240 onto master since both seem to have fixes for this (the one line that conflicted I took from the other PR), and it still didn't work.

Also, in download mode it says that the produce name is SM-G900V, as expected.

jaymzh avatar Nov 22 '14 22:11 jaymzh

Also, I printed out the actual result from libusb_set_interface_alt_setting(), it's -5, which according to http://libusb.sourceforge.net/api-1.0/group__misc.html is LIBUSB_ERROR_NOT_FOUND = -5

But, interestingly if we don't setup the interface alt setting (I comment out that call), it gets much further:

[phil@rider ~]$ sudo /usr/local/bin/heimdall print-pit --no-reboot --verbose
Heimdall v1.4.1

Copyright (c) 2010-2014 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: "Sasmsung"
           Product: "MSM8960"

            length: 18
      device class: 2
               S/N: 0
           VID:PID: 04E8:685D
         bcdDevice: 0100
   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: 82
           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: 01
           max packet size: 0200
          polling interval: 00
Claiming interface...
Initialising protocol...
Protocol initialisation successful.

Beginning session...

Some devices may take up to 2 minutes to respond.
Please be patient!

Session begun.

Downloading device's PIT file...
PIT file data received, read 'empty' packet...
PIT file data receive completed, send kRequestEndTransfer...
PIT file download successful.

Entry Count: 30
Unknown 1: 1598902083
Unknown 2: 844251476
Unknown 3: 21325
Unknown 4: 14413
Unknown 5: 14137
Unknown 6: 52
Unknown 7: 0
Unknown 8: 0


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


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


--- Entry #2 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 3
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 156544
Partition Block Count: 1024
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: SBL1
Flash Filename: sbl1.mbn
FOTA Filename: 


--- Entry #3 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 4
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 157568
Partition Block Count: 128
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: DBI
Flash Filename: sdi.mbn
FOTA Filename: 


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


--- Entry #5 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 6
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 157760
Partition Block Count: 4096
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: ABOOT
Flash Filename: aboot.mbn
FOTA Filename: 


--- Entry #6 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 7
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 161856
Partition Block Count: 1024
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: RPM
Flash Filename: rpm.mbn
FOTA Filename: 


--- Entry #7 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 8
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 162880
Partition Block Count: 1024
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: TZ
Flash Filename: tz.mbn
FOTA Filename: 


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


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


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


--- Entry #11 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 12
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size/Offset: 204800
Partition Block Count: 28672
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: EFS
Flash Filename: efs.img.ext4
FOTA Filename: 


--- Entry #12 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 13
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 233472
Partition Block Count: 6144
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: MODEMST1
Flash Filename: nvrebuild1.bin
FOTA Filename: 


--- Entry #13 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 14
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 239616
Partition Block Count: 6144
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: MODEMST2
Flash Filename: nvrebuild2.bin
FOTA Filename: 


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


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


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


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


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


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


--- Entry #20 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 21
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size/Offset: 344064
Partition Block Count: 16384
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: PERSIST
Flash Filename: persist.img.ext4
FOTA Filename: 


--- Entry #21 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 22
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size/Offset: 360448
Partition Block Count: 18432
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: PERSDATA
Flash Filename: persdata.img.ext4
FOTA Filename: 


--- Entry #22 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 23
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size/Offset: 378880
Partition Block Count: 6144000
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: SYSTEM
Flash Filename: system.img.ext4
FOTA Filename: 


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


--- Entry #24 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 25
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size/Offset: 8620032
Partition Block Count: 20480
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: CARRIER
Flash Filename: carrier.img.ext4
FOTA Filename: 


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


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


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


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


--- Entry #29 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 73
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 30777311
Partition Block Count: 33
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: SGPT
Flash Filename: sgpt.img
FOTA Filename: 

Ending session...
ERROR: libusb error -7 whilst receiving bulk transfer. Retrying...

Releasing device interface...

jaymzh avatar Nov 23 '14 00:11 jaymzh

But I can't flash using that, I get:

Claiming interface...
Initialising protocol...
ERROR: Failed to receive handshake response. Result: -7
ERROR: Protocol initialisation failed!

Releasing device interface...

jaymzh avatar Nov 23 '14 00:11 jaymzh

Even with this patch, I could not flash twice back to back. I did not use the other patch you referenced, though. I'm not sure if my setup will help since it is a Mac and a Note 4, neither of which match up to yours.

AbandonedCart avatar Nov 23 '14 02:11 AbandonedCart

I seem to have having slightly different problems. I'll open up a separate issue.

jaymzh avatar Nov 27 '14 05:11 jaymzh

Actually, trying a different machine let me get past the other issues I was seeing and now I got the issue described by here and I get the WARNING: Empty bulk transfer after sending packet failed. Continuing anyway... - so thanks :)

jaymzh avatar Nov 27 '14 05:11 jaymzh

I'm getting the same error as jaymzh got "ERROR: Claiming interface failed!" for the International Note 4 (Exynos 5433). I didn't try any additional patches besides the one listed in this pull request.

zeroepoch avatar Dec 19 '14 18:12 zeroepoch

unfortunately, this doesn't fix flashing on n900a (at&t note 3)

Initialising protocol...
ERROR: Failed to receive handshake response. Result: -7
ERROR: Protocol initialisation failed!

benwaffle avatar Dec 26 '14 02:12 benwaffle

@benwaffle et al, I had fixes for the Note 3, but it was at that point I noticed conflicts beween host operating system behavior and stopped working chasing down fixes for indidividual phones. Basically, fixes to get it working on OSX broke things in Linux, fixing the Note 3 in Linux broke it in OSX.

I'll try to find those patches though since, even though they're device/host-specific and shouldn't be in master, others might find them useful. I'll update this issue if I I find them.

sshimko avatar Dec 26 '14 14:12 sshimko

I've resorted to adb push and adb shell + dd in recovery

benwaffle avatar Dec 26 '14 19:12 benwaffle

I tried the patch and it worked with download-pit and print-pit, BUT i have to disconnect the USB-cable afterwards and reconnect.

Device: Note 10.1 LTE, SM-P605, P605XXUCNJ1 lsusb: Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II] (Download mode) On: x86_64 GNU/Linux

locomanolo avatar Jan 07 '15 18:01 locomanolo

@locomanolo disconnect and reconnect at which point in the process?

sshimko avatar Jan 07 '15 19:01 sshimko