Benjamin-Dobell / Heimdall

Heimdall is a cross-platform open-source tool suite used to flash firmware (aka ROMs) onto Samsung Galaxy devices.
MIT License
2.62k stars 587 forks source link

ERROR: Protocol initialisation failed! #413

Open ghost opened 7 years ago

ghost commented 7 years ago

Have been trying for 3 hours to flash TWRP to a SMA500FU, and I don't know if it's a problem with the fact it's an A5, or if it's the build I'm using or what?

Here's the output of detect, and download-pit.

aliensonneptune@tinfoilhats:/$ sudo heimdall detect
Device detected
aliensonneptune@tinfoilhats:/$ sudo heimdall download-pit --output pit.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...
Setting up interface...

Initialising protocol...
ERROR: Protocol initialisation failed!

Releasing device interface...

aliensonneptune@tinfoilhats:/$ 

Can anyone help me?

PS, I'm an android noob, only been using it for 4 weeks.

PPS, I'm on a USB3, and the phone is on the 6.0.1 UD.

JonnyTech commented 7 years ago

Use version 1.4.2 - I recommend compiling yourself

ghost commented 7 years ago

@JonnyTech I've built it from the repo, and I still get 1.4.1, built yesterday? When was 1.4.2 pushed?

ghost commented 7 years ago

Okay, somehow built 1.4.2 from source, and now I'm detecting the device, but now I get this output, so I think it is the same error that I was getting before.

Heimdall v1.4.2

Copyright (c) 2010-2017 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...
Setting up interface...

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

Releasing device interface...
JonnyTech commented 7 years ago

Have you tried rebooting the phone and another USB port and/or cable?

Which version of libusb do you have installed? Version 1.0.21 works for me:

user@computer:~$ dpkg -l libusb-1*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  libusb-1.0-0:a 2:1.0.21-2   amd64        userspace USB programming library
ii  libusb-1.0-0-d 2:1.0.21-2   amd64        userspace USB programming library
ii  libusb-1.0-doc 2:1.0.21-2   all          documentation for userspace USB p

Make sure that you do not run Heimdall as root/sudo - I have had problems:

user@computer:~/Heimdall-master/build/bin$ ./heimdall info
Heimdall v1.4.2

Copyright (c) 2010-2017 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/

Heimdall utilises libusbx for all USB communication:
    http://www.libusb.org/

libusbx is licensed under the LGPL-2.1:
    http://www.gnu.org/licenses/licenses.html#LGPL

What are the output of these commands:

user@computer:~/Heimdall-master/build/bin$ ./heimdall detect
user@computer:~/Heimdall-master/build/bin$ ./heimdall download-pit --output pit.pit
user@computer:~/Heimdall-master/build/bin$ cat pit.pit
ghost commented 7 years ago

Tried reboot, other USB cable, ./heimdall detect came up with nothing, tried the 1st one again, and like before it detected on the original cable. Turns out my backup cable is faulty. After a complete sudo apt update && sudo apt upgrade, IT GOT THE PIT FILE! Here's my proof, though the .pit looks messy as hell, don't know if that's good?

aliensonneptune@tinfoilhats:~/musicphone/Heimdall/bin$ ./heimdall detect
Device detected

aliensonneptune@tinfoilhats:~/musicphone/Heimdall/bin$  dpkg -l libusb-1*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                    Version          Architecture     Description
+++-=======================-================-================-====================================================
ii  libusb-1.0-0:amd64      2:1.0.20-1       amd64            userspace USB programming library
ii  libusb-1.0-0-dbg:amd64  2:1.0.20-1       amd64            userspace USB programming library development files
ii  libusb-1.0-0-dev:amd64  2:1.0.20-1       amd64            userspace USB programming library development files
ii  libusb-1.0-doc          2:1.0.20-1       all              documentation for userspace USB programming

aliensonneptune@tinfoilhats:~/musicphone/Heimdall/bin$ ./heimdall download-pit --output pit.pit
Heimdall v1.4.2

Copyright (c) 2010-2017 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...
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...
PIT file download successful.

Ending session...
Rebooting device...
Releasing device interface...

aliensonneptune@tinfoilhats:~/musicphone/Heimdall/bin$ cat pit.pit
v�4COM_TAR2MSM8916 xAPNHLOSNON-HLOS.bin���MODEMmodem.bin�cSBL1sbl1.mbn�g@DDR�gABOOTaboot.mbn�wRPMrpm.mbn�{QSEEtz.mbn�QHEEhyp.mbn ��FSG
�� secsec.dat
                �� TPAD
@pEFSefs.img.ext4�MODEMST1nvrebuild1.bin�MODEMST2nvrebuild2.bin�hBOOTboot.imgHxRECOVERYrecovery.img�(FOTA��7BACKUP�FSC�7SSD8@PERSISTpersist.img.ext4xHPERSDATApersdata.img.ext4�KSYSTEMsystem.img.ext4�P@CACHEcache.img.ext4W@HIDDENhidden.img.ext4@]USERDATAuserdata.img.ext4remainedF"PGPTpgpt.imgG"PITMSM8974.pitH2 MD5md5.imgI���!SGPTsgpt.imgI�W!����%C��4=��
                                                            ��o!���p�%�<\T��Rq�
                                                                                      �I']enw��T?8�Z�{E��cV    ��E7O&���Q��B��4��4�����=
                         ό�'d�T}?��O���28��~�ڐe�V)G��<��`���y���d�"���A�9e�!Q�'���)�&!ũ��Գ�M��Mq}�iah���H�
�2�樦E�<�K6��OP�`G8�qА�?Ȁ ؖ,���ͫ����d5�+����0�
JonnyTech commented 7 years ago

So, the software is working correctly, you have a good connection to the device, the PIT file looks fine (it is not meant to be plain text, just wanted to make sure that you got something).

Assuming that you have the correct IMG file for your device (not an Odin tar file - extract the IMG if you do) then you need to reboot your phone back into bootloader mode and do something like:

aliensonneptune@tinfoilhats:~/musicphone/Heimdall/bin$ ./heimdall flash RECOVERY recovery.img

Note that RECOVERY is in uppercase (according the the label in your PIT file), and replace recovery.img with the correct filename.

Can you post the complete console output, including the command line.

ghost commented 7 years ago

I sent pretty much that command to my phone, and it rebooted, actually I tried doing it using -- instead of partition name, and accidentally flashed to 18, which was BACKUP, the phone still boots though. Here is the output of the console command, now how do I boot into the recovery?

aliensonneptune@tinfoilhats:~/musicphone/Heimdall$ ./bin/heimdall flash --RECOVERY ort.img 
Heimdall v1.4.2

Copyright (c) 2010-2017 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...
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...
PIT file download successful.

Uploading RECOVERY
100%
RECOVERY upload successful

Ending session...
Rebooting device...
Releasing device interface...

aliensonneptune@tinfoilhats:~/musicphone/Heimdall$ 

PS Sorry for being late to reply.

JonnyTech commented 7 years ago

Well done! To boot to recovery after flashing press Power, Volume Up and Home Buttons at the same time. If the phone boots normally then you pressed the buttons too late. At this point your newly flashed firmware has been overwritten by the system. So you need to flash it again from Heimdall in bootloader mode then hold the the buttons as it finished and restarts.

Or you can use the --no-reboot flag to not reboot automatically which makes it easier to get ready and power down the device manually and boot up holding down the keys mentioned above.

ghost commented 7 years ago

I have tried booting, but it just shows the boot logo of my phone normally and some text in the top left. I thought it was loading TWRP in, but I left it for 20-25 mins then lost hope and held down all the buttons to boot normally? Is it the image or what? PS I'm using the latest image from here, have no idea if that's what I'm meant to be using?

ghost commented 7 years ago

Okay, found an Odin-flashable TWRP .tar.md5, unpacked it, and found an .img file, whick looked flashable. Flashed it, worked flawlessly, booted TWRP, found my SuperSU .zip, installed.... aaaaaaaaand now I'm stuck on the loading screen :/

spmp commented 7 years ago

Has anyone else got this issue? I am having exactly the same thing:

./heimdall print-pit --verbose --no-reboot
...
--- Entry #28 ---
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 73
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 61071327
Partition Block Count: 33
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: SGPT
Flash Filename: sgpt.img
FOTA Filename: 

Ending session...
WARNING: Empty bulk transfer after sending packet failed. Continuing anyway...
ERROR: libusb error -7 whilst receiving bulk transfer. Retrying...

Releasing device interface...

And my libusb

ii  libusb-0.1-4:amd64                                          2:0.1.12-30                                       amd64        userspace USB programming library
ii  libusb-1.0-0:amd64                                          2:1.0.21-1                                        amd64        userspace USB programming library
ii  libusb-1.0-0:i386                                           2:1.0.21-1                                        i386         userspace USB programming library
ii  libusb-1.0-0-dev:amd64                                      2:1.0.21-1                                        amd64        userspace USB programming library development files
ii  libusb-1.0-doc                                              2:1.0.21-1                                        all          documentation for userspace USB programming
ii  libusb-dev                                                  2:0.1.12-30                                       amd64        userspace USB programming library development files

Heimdall buit from git, ubuntu 17.04.

The phone is a Samsung Galaxy Note 3, SM-N900V. Any other solution would be amazing!

ghost commented 7 years ago

Wiped dalvik/cache/tried hard resetting, SOMEBODY HELP, PLEASE, MY PHONE ISN'T LOADING IN.

JonnyTech commented 7 years ago

Did it boot after flashing TWRP, before installing SuperSU?

ghost commented 7 years ago

Yes, and in the time since I last commented, I figured out that if TWRP still booted in, I could use ADB sideload to load in a new ROM, which could either solve my problems or make them worse.

I'm an optimist.

SO.

I sideloaded a Lineage OS 14 ROM for the A500xx series, crossed my fingers and booted. Soon enough I was greeted by the amazing sight of a Lineage OS welcome screen. Currently sideloading opengapps for my device.

Somehow flashing TWRP to root, and failing, then trying to fix it gave me face unlock and a stock (finally) theme? Anyway, couldn't have done it without your help, thanks a lot @JonnyTech

JonnyTech commented 7 years ago

@aliensonneptune - great result, glad that I could help, please close this issue now

@spmp - do not hijack issues, please start your own using the new issue button

spmp commented 7 years ago

@JonnyTech Sorry buddy, I thought it was the same issue as having the same error etc. Will start a new issue 8)

dandv commented 7 years ago

Same problem here, "Protocol initialisation failed".

I've noticed though that the first heimdall command did execute successfully... so I kept rebooting the phone out of download mode (hold all buttons for ~5 seconds) then back into download mode, then issue the next heimdall command.

TL;DR only the first command after booting into download mode works!

AchrafKassioui commented 7 years ago

Thanks dandv! Indeed, only first command after booting into download works.

NacreousDawn596 commented 3 years ago

um, help? I have the same error but I'm trying with the kernel sudo heimdall flash --kernel zImage but it told me :

Initialising protocol...
ERROR: Failed to send handshake!ERROR: Protocol initialisation failed!

Releasing device interface...

is there any solution please? I'm trying to root my samsung A2 core

JonnyTech commented 3 years ago

Did you issue that command directly after booting the phone into download mode? If you read this thread you will learn that only one command after each reboot works.

NacreousDawn596 commented 3 years ago

owh, okay

NacreousDawn596 commented 3 years ago

I have tried everything here, I always get:

Initialising protocol...
ERROR: Protocol initialisation failed!

Releasing device interface...
JonnyTech commented 3 years ago

Are you sure that you are in odin/download mode?: https://www.androidsettings.net/samsung-galaxy-a2-core-download-mode/

download-mode-samsung-galaxy-android-device

amo13 commented 3 years ago

You might also want to try a newer build from a fork with a few fixes. It may or may not help...

NacreousDawn596 commented 3 years ago

Are you sure that you are in odin/download mode?: https://www.androidsettings.net/samsung-galaxy-a2-core-download-mode/

download-mode-samsung-galaxy-android-device

surely

JonnyTech commented 3 years ago

Bootloader unlocked? Tried different cables and USB ports?

NacreousDawn596 commented 3 years ago

oops, I forgot to unlock the bootloader, but still the same problem 😕

Le mer. 6 oct. 2021 à 23:25, JonnyTech @.***> a écrit :

Bootloader unlocked? Tried different cables and USB ports?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Benjamin-Dobell/Heimdall/issues/413#issuecomment-937261568, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR72PF4FRMRRHZT7V5L22HDUFTEFRANCNFSM4DYBGFIA .

PsySc0rpi0n commented 9 months ago

I am trying "only" to print-pit for now a Samsung Galaxy S21 (G991B), under Debian Bookworm, and I also get the same libusb errors:

Initialising protocol...
ERROR: libusb error -7 whilst sending bulk transfer. Retrying...
ERROR: libusb error -7 whilst sending bulk transfer. Retrying...
ERROR: libusb error -7 whilst sending bulk transfer. Retrying...
ERROR: libusb error -7 whilst sending bulk transfer. Retrying...
ERROR: libusb error -7 whilst sending bulk transfer. Retrying...
ERROR: libusb error -7 whilst sending bulk transfer.
ERROR: Failed to send handshake!ERROR: Failed to receive handshake response. Result: -7
ERROR: Protocol initialisation failed!

Heimdall version 1.4.2

$ heimdall version
v1.4.2
$

and libusb versions:

$ dpkg -l libusb*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                     Version      Architecture Description
+++-========================-============-============-=====================================================================
ii  libusb-0.1-4:amd64       2:0.1.12-32  amd64        userspace USB programming library
ii  libusb-1.0-0:amd64       2:1.0.26-1   amd64        userspace USB programming library
ii  libusb-1.0-0-dev:amd64   2:1.0.26-1   amd64        userspace USB programming library development files
ii  libusb-1.0-doc           2:1.0.26-1   all          documentation for userspace USB programming
ii  libusb-dev               2:0.1.12-32  amd64        userspace USB programming library development files
ii  libusbredirhost1:amd64   0.13.0-2     amd64        Implementing the usb-host (*) side of a usbredir connection (runtime)
ii  libusbredirparser1:amd64 0.13.0-2     amd64        Parser for the usbredir protocol (runtime)

Heimdall can see the device:

$ heimdall detect
Device detected

A bit weird here but it's there
$ lsusb
Bus 002 Device 008: ID 04e8:685d Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II] (Download mode)

Anything else I can try?

julianfoad commented 6 months ago

I have written more about this error here: Troubleshooting: Heimdall Fails at Initialising Protocol

In short:

julianfoad commented 6 months ago

Possibly same issue as fixed by PR #478