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

Heimdall does not use SET_CONFIGURATION, which breaks flashing Samsung devices with Qualcomm SOCs #542

Open
kauwua opened this issue May 23, 2024 · 2 comments

Comments

@kauwua
Copy link

kauwua commented May 23, 2024

Hello,

When working on a Samsung Galaxy Z Flip3 (SM-F711U1) with @max-r-b, we could not flash the device using Heimdall compared to Odin.

When the host sends "ODIN", the device should answer by "LOKE" but wasn't.

After some research using Wireshark and a USB sniffer, we noticed that the SET_CONFIGURATION request is missing and instead a SET_INTERFACE request is used.

We propose the following WIP patch #543, that solves the issue for Qualcomm-based devices but breaks the Mediatek ones apparently (like a SM-A225F (Samsung Galaxy A22)). SetupDeviceInterface should probably be called only for Mediatek devices.

The SET_CONFIGURATION request is mandatory because it puts the device in the "Configured" state before it is used (Universal Serial Bus Specification Revision 2.0, 9.1.1.5 Configured). While SET_INTERFACE also resets some of the internal state of the device, the device might only fully reset and prepare for requests when SET_CONFIGURATION is called.

Maybe related : #533, #278

Thanks

@kauwua
Copy link
Author

kauwua commented May 23, 2024

image

This is a capture made with the USB sniffer, after adding a SET CONFIGURATION. The device still does not answer, and we had to remove SET INTERFACE as well for it to work.

@kauwua kauwua changed the title Heimdall does not use SET_CONFIGURATION, which breaks Samsung devices with Qualcomm SOCs Heimdall does not use SET_CONFIGURATION, which breaks flashing Samsung devices with Qualcomm SOCs May 23, 2024
@Grimler91
Copy link

Grimler91 commented Jun 28, 2024

Nice investigation!

Which libusb version did you test with, and on what OS? On my archlinux machine (with libusb 1.0.27) set_configuration seems to be run automatically when device is connected to the computer:
image

Looking at some of my older logs it seems to have been the same since at least beginning of 2021 (libusb 1.0.24). If set_configuration is not run automatically on all OS'es we should definitely add it though.

I guess you have a filter in wireshark screenshot so that responses are not shown? Are those GET DESCRIPTOR, SET CONFIGURATION and SET INTERFACE really done by heimdall? They look similar to what I get automatically when device is connnected (as in above screenshot). Could you share the .cap/.pcapng file(s) of failed and succeeded flashes? (In private if preferred, henrik at grimler dot se)

I mainly have exynos devices to test with, and two older qcom phones (msm8916-a5lte (2015) and galaxy s4 (2013)). Seems like flashing works fine with or without an added libusb_set_configuration() on all of them, with the patch https://git.sr.ht/~grimler/Heimdall/commit/2ecc98020c607631d1371c8596d20cce84586047.

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

2 participants