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 SET_CONFIGURATION mandatory request #543

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
31 changes: 27 additions & 4 deletions heimdall/source/BridgeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,26 @@ bool BridgeManager::ClaimDeviceInterface(void)
return (true);
}

bool BridgeManager::SetupDeviceConfiguration(void)
{
Interface::Print("Setting up configuration...\n");

int result = libusb_set_configuration(deviceHandle, 1);
// libusb_clear_halt(deviceHandle, 0x81);
// libusb_clear_halt(deviceHandle, 1);
// libusb_clear_halt(deviceHandle, 0x82);


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

Interface::Print("\n");
return (true);
}

bool BridgeManager::SetupDeviceInterface(void)
{
Interface::Print("Setting up interface...\n");
Expand Down Expand Up @@ -483,18 +503,21 @@ int BridgeManager::Initialise(bool resume)
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_DEBUG);
break;
}

result = FindDeviceInterface();

if (result != BridgeManager::kInitialiseSucceeded)
return (result);

if (!ClaimDeviceInterface())
if(!SetupDeviceConfiguration())
return (BridgeManager::kInitialiseFailed);

if (!SetupDeviceInterface())
if (!ClaimDeviceInterface())
return (BridgeManager::kInitialiseFailed);

// if (!SetupDeviceInterface())
// return (BridgeManager::kInitialiseFailed);

if (!resume)
{
if (!InitialiseProtocol())
Expand Down Expand Up @@ -709,7 +732,7 @@ bool BridgeManager::SendPacket(OutboundPacket *packet, int timeout, int emptyTra
}

if (!SendBulkTransfer(packet->GetData(), packet->GetSize(), timeout))
return (false);
return (false);

if (emptyTransferFlags & kEmptyTransferAfter)
{
Expand Down
1 change: 1 addition & 0 deletions heimdall/source/BridgeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ namespace Heimdall
UsbLogLevel usbLogLevel;

int FindDeviceInterface(void);
bool SetupDeviceConfiguration(void);
bool ClaimDeviceInterface(void);
bool SetupDeviceInterface(void);
void ReleaseDeviceInterface(void);
Expand Down