Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeout when calling libusb libusb_set_interface_alt_setting with some devices #497

Open
gentooza opened this issue Nov 8, 2021 · 8 comments

Comments

@gentooza
Copy link

gentooza commented Nov 8, 2021

Hi,

I've been suffering this error with my samsung mini plus (GT-S5570i)
https://wiki.postmarketos.org/wiki/Samsung_Galaxy_Pop_Plus_(samsung-s5570i)

The only solution is to comment out the call to libusb_set_al_interface function, as said here #340 by @joshgav.

As it seems not possible to detect phone's flaky bootloaders, because linux kernel driver seems to be samsung generic (no device specific), a possible solution could be to set a command line parameter to bypass this function call. So if we execute heimdall and crash here, heimdall can hint to try out again with this bypass command.

The feedback and tests I've got from libusb hackers are here:
libusb/libusb#1024

I hope to be useful :-)

cheers!

@Grimler91
Copy link

Hi @gentooza, heimdall seem to be working well without libusb_set_interface_alt_setting as far as I can tell on newer devices as well, so maybe we can remove it altogether.

Could you at some point try flashing with this heimdall (built from this branch). It will print the actual error code from libusb, and we can then, hopefully, tell heimdall to ignore that particular error code and carry on.

@gentooza
Copy link
Author

Hi @Grimler91

Ok, already cloned I'll test it and tell you

cheers

@Grimler91
Copy link

@gentooza thanks! (Note that there are two branches in the repo, the master branch and the alt_setting-error branch. alt_setting-error contains the commit with prints the libusb error code)

@gentooza
Copy link
Author

Hi @Grimler91, I paste what I get:

$ ./heimdall flash --RECOVERY /home/joa/dev/phones/samsung/galaxy\ mini\ s\ -\ gts5570i/boot.img 
Heimdall v1.4.2

Copyright (c) 2010-2017 Benjamin Dobell, Glass Echidna
https://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:
https://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
Claiming interface...
Setting up interface...
libusb: error [op_set_interface] setintf failed error -1 errno 110
ERROR: Setting up interface failed with error code -99!
Releasing device interface...

$ git branch
* alt_setting-error
  master

$ git status
En la rama alt_setting-error
Tu rama está actualizada con 'origin/alt_setting-error'.

nada para hacer commit, el árbol de trabajo está limpio

$ git remote -v
origin	https://git.sr.ht/~grimler/Heimdall (fetch)
origin	https://git.sr.ht/~grimler/Heimdall (push)

Sorry, I've Spanish locale set in my GNU/Linux, the last commands are git orders simply to show I'm working in origin/alt_setting-error branch.

with libusb folks we were already trying to debug this and finally thought it's the flaky bootloader in the device.

ps: error -99 seems to be LIBUSB_ERROR_OTHER (https://libusb.sourceforge.io/api-1.0/group__libusb__misc.html)

@Grimler91
Copy link

Yeah, -99 wasn't very helpful. I've added a commit here to just skip libusb_set_interface_alt_setting if alt_setting is 0, I think that is what tormodvolden meant in the libusb discussion.

@Grimler91
Copy link

For future reference: the same issue was reported here: https://gitlab.com/BenjaminDobell/Heimdall/-/issues/517, and a similar fix (don't run libusb_set_interface_alt_setting if alt_setting is 0) was suggested.

@gentooza
Copy link
Author

the related merge request seems promising!
It has been approved? (sorry my head's going to explode between github, bitbucket, savannah, gitlab... GUIs)

cheers!

@amo13
Copy link

amo13 commented Dec 14, 2021

I have created a fork and merged a few crucial pull requests. Feel free to create further pull requests there if need be.

algitbot pushed a commit to alpinelinux/aports that referenced this issue Dec 17, 2021
Original repository is not maintained anymore. Main fixes/features in
fork compared to original repo consists of:

* A check so that partition is not smaller than file size has been
  added, to make it a bit harder to overwrite things on the emmc by
  accident [1] (devices from 2014 or newer seem to have a safety check
  for this built-in)

* The information is the PIT header has been described more fully [2]

* libusb_reset_device patch that was contained in this repo has been
  merged (though it seems the patch is only needed on ubuntu) [3]

* Skip running libusb_set_interface_alt_setting if altsetting is
  0 [4]. It does not do anything in this case, and causes issues on some
  older devices [5]

* Support for flashing images larger than 3.5 GB [6]

* Some compilation issues that should only be relevant for
  other distros (BSD, android, mac) has been fixed, and various things
  cleaned up

Also switch aports maintainer to myself while we are at it.

[1] https://git.sr.ht/~grimler/Heimdall/commit/60ab9bbaffe3
[2] https://git.sr.ht/~grimler/Heimdall/commit/e51c9119f1ff
[3] https://git.sr.ht/~grimler/Heimdall/commit/07a14d4aa8ad
[4] https://git.sr.ht/~grimler/Heimdall/commit/2ecc98020c60
[5] Benjamin-Dobell/Heimdall#497
[6] https://git.sr.ht/~grimler/Heimdall/commit/c87f5bf210b0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants