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

Add an option to skip libusb_interface_alt_setting in FlashAction #533

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions heimdall/source/BridgeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,19 @@ bool BridgeManager::ClaimDeviceInterface(void)
bool BridgeManager::SetupDeviceInterface(void)
{
Interface::Print("Setting up interface...\n");

if(dont_set_libusb_interface_alt_setting) {
Interface::Print("Skipping alt interface setting...\n");
} else {
int result = libusb_set_interface_alt_setting(deviceHandle, interfaceIndex, altSettingIndex);

int result = libusb_set_interface_alt_setting(deviceHandle, interfaceIndex, altSettingIndex);

if (result != LIBUSB_SUCCESS)
{
Interface::PrintError("Setting up interface failed!\n");
return (false);
if (result != LIBUSB_SUCCESS)
{
Interface::PrintError("Setting up interface failed!\n");
return (false);
}
}

Interface::Print("\n");
return (true);
}
Expand Down Expand Up @@ -341,10 +345,11 @@ bool BridgeManager::InitialiseProtocol(void)
return (false);
}

BridgeManager::BridgeManager(bool verbose)
BridgeManager::BridgeManager(bool verbose, bool dont_set_libusb_interface_alt_setting)
{
this->verbose = verbose;

this->dont_set_libusb_interface_alt_setting = dont_set_libusb_interface_alt_setting;

libusbContext = nullptr;
deviceHandle = nullptr;
heimdallDevice = nullptr;
Expand Down
3 changes: 2 additions & 1 deletion heimdall/source/BridgeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ namespace Heimdall
static const DeviceIdentifier supportedDevices[kSupportedDeviceCount];

bool verbose;
bool dont_set_libusb_interface_alt_setting;

libusb_context *libusbContext;
libusb_device_handle *deviceHandle;
Expand Down Expand Up @@ -145,7 +146,7 @@ namespace Heimdall

public:

BridgeManager(bool verbose);
BridgeManager(bool verbose, bool dont_set_libusb_interface_alt_setting = false);
~BridgeManager();

bool DetectDevice(void);
Expand Down
8 changes: 5 additions & 3 deletions heimdall/source/FlashAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ const char *FlashAction::usage = "Action: flash\n\
Arguments:\n\
[--<partition name> <filename> ...]\n\
[--<partition identifier> <filename> ...]\n\
[--pit <filename>] [--verbose] [--no-reboot] [--resume] [--stdout-errors]\n\
[--pit <filename>] [--verbose] [--dont_set_libusb_interface_alt_setting] [--no-reboot] [--resume] [--stdout-errors]\n\
[--usb-log-level <none/error/warning/debug>]\n\
or:\n\
--repartition --pit <filename> [--<partition name> <filename> ...]\n\
[--<partition identifier> <filename> ...] [--verbose] [--no-reboot]\n\
[--<partition identifier> <filename> ...] [--verbose] [--dont_set_libusb_interface_alt_setting] [--no-reboot]\n\
[--resume] [--stdout-errors] [--usb-log-level <none/error/warning/debug>]\n\
[--tflash]\n\
Description: Flashes one or more firmware files to your phone. Partition names\n\
Expand Down Expand Up @@ -428,6 +428,7 @@ int FlashAction::Execute(int argc, char **argv)
argumentTypes["no-reboot"] = kArgumentTypeFlag;
argumentTypes["resume"] = kArgumentTypeFlag;
argumentTypes["verbose"] = kArgumentTypeFlag;
argumentTypes["dont_set_libusb_interface_alt_setting"] = kArgumentTypeFlag;
argumentTypes["stdout-errors"] = kArgumentTypeFlag;
argumentTypes["usb-log-level"] = kArgumentTypeString;
argumentTypes["tflash"] = kArgumentTypeFlag;
Expand Down Expand Up @@ -458,6 +459,7 @@ int FlashAction::Execute(int argc, char **argv)
bool reboot = arguments.GetArgument("no-reboot") == nullptr;
bool resume = arguments.GetArgument("resume") != nullptr;
bool verbose = arguments.GetArgument("verbose") != nullptr;
bool dont_set_libusb_interface_alt_setting = arguments.GetArgument("dont_set_libusb_interface_alt_setting") != nullptr;
bool tflash = arguments.GetArgument("tflash") != nullptr;

if (arguments.GetArgument("stdout-errors") != nullptr)
Expand Down Expand Up @@ -534,7 +536,7 @@ int FlashAction::Execute(int argc, char **argv)

// Perform flash

BridgeManager *bridgeManager = new BridgeManager(verbose);
BridgeManager *bridgeManager = new BridgeManager(verbose, dont_set_libusb_interface_alt_setting);
bridgeManager->SetUsbLogLevel(usbLogLevel);

if (bridgeManager->Initialise(resume) != BridgeManager::kInitialiseSucceeded || !bridgeManager->BeginSession())
Expand Down