summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--heimdall-frontend/Source/mainwindow.cpp52
-rw-r--r--heimdall-frontend/mainwindow.ui6
-rw-r--r--heimdall/source/BridgeManager.cpp26
-rw-r--r--heimdall/source/BridgeManager.h9
-rw-r--r--heimdall/source/Interface.cpp5
-rw-r--r--heimdall/source/Interface.h2
-rw-r--r--heimdall/source/main.cpp20
7 files changed, 90 insertions, 30 deletions
diff --git a/heimdall-frontend/Source/mainwindow.cpp b/heimdall-frontend/Source/mainwindow.cpp
index b71aef1..f3732c4 100644
--- a/heimdall-frontend/Source/mainwindow.cpp
+++ b/heimdall-frontend/Source/mainwindow.cpp
@@ -571,9 +571,26 @@ void MainWindow::SelectPartitionName(int index)
unsigned int newPartitionIndex = unusedPartitionIds[index];
unusedPartitionIds.removeAt(index);
- FileInfo& partitionInfo = workingPackageData.GetFirmwareInfo().GetFileInfos()[partitionsListWidget->currentRow()];
- unusedPartitionIds.append(partitionInfo.GetPartitionId());
- partitionInfo.SetPartitionId(newPartitionIndex);
+ FileInfo& fileInfo = workingPackageData.GetFirmwareInfo().GetFileInfos()[partitionsListWidget->currentRow()];
+ unusedPartitionIds.append(fileInfo.GetPartitionId());
+ fileInfo.SetPartitionId(newPartitionIndex);
+
+ if (!fileInfo.GetFilename().isEmpty())
+ {
+ PitEntry *pitEntry = currentPitData.FindEntry(newPartitionIndex);
+ QString partitionFilename = pitEntry->GetFilename();
+ int lastPeriod = partitionFilename.lastIndexOf(QChar('.'));
+
+ if (lastPeriod >= 0)
+ {
+ QString partitionFileExtension = partitionFilename.mid(lastPeriod + 1);
+
+ lastPeriod = fileInfo.GetFilename().lastIndexOf(QChar('.'));
+
+ if (lastPeriod < 0 || fileInfo.GetFilename().mid(lastPeriod + 1) != partitionFileExtension)
+ Alerts::DisplayWarning(QString("%1 partition expects files with file extension \"%2\".").arg(pitEntry->GetPartitionName(), partitionFileExtension));
+ }
+ }
partitionNameComboBox->clear();
@@ -588,9 +605,25 @@ void MainWindow::SelectPartitionFile(void)
{
QString path = PromptFileSelection();
- if (path != "" && !IsArchive(path))
+ if (path != "")
{
- workingPackageData.GetFirmwareInfo().GetFileInfos()[partitionsListWidget->currentRow()].SetFilename(path);
+ FileInfo& fileInfo = workingPackageData.GetFirmwareInfo().GetFileInfos()[partitionsListWidget->currentRow()];
+ PitEntry *pitEntry = currentPitData.FindEntry(fileInfo.GetPartitionId());
+
+ QString partitionFilename = pitEntry->GetFilename();
+ int lastPeriod = partitionFilename.lastIndexOf(QChar('.'));
+
+ if (lastPeriod >= 0)
+ {
+ QString partitionFileExtension = partitionFilename.mid(lastPeriod + 1);
+
+ lastPeriod = path.lastIndexOf(QChar('.'));
+
+ if (lastPeriod < 0 || path.mid(lastPeriod + 1) != partitionFileExtension)
+ Alerts::DisplayWarning(QString("%1 partition expects files with file extension \"%2\".").arg(pitEntry->GetPartitionName(), partitionFileExtension));
+ }
+
+ fileInfo.SetFilename(path);
partitionFileLineEdit->setText(path);
pitBrowseButton->setEnabled(true);
@@ -1050,9 +1083,16 @@ void MainWindow::HandleHeimdallReturned(int exitCode, QProcess::ExitStatus exitS
if (exitStatus == QProcess::NormalExit && byteExitCode >= 0)
{
if (heimdallState == MainWindow::kHeimdallStateFlashing)
- flashLabel->setText("Flash completed sucessfully!");
+ {
+ if (byteExitCode == 1)
+ flashLabel->setText("Failed to detect compatible device!");
+ else
+ flashLabel->setText("Flash completed sucessfully!");
+ }
else if (heimdallState == MainWindow::kHeimdallStateDetectingDevice)
+ {
deviceDetectedRadioButton->setChecked(byteExitCode == 0);
+ }
}
else
{
diff --git a/heimdall-frontend/mainwindow.ui b/heimdall-frontend/mainwindow.ui
index 984f4ba..4aaf6fa 100644
--- a/heimdall-frontend/mainwindow.ui
+++ b/heimdall-frontend/mainwindow.ui
@@ -414,9 +414,9 @@
</property>
<property name="geometry">
<rect>
- <x>310</x>
+ <x>320</x>
<y>130</y>
- <width>311</width>
+ <width>301</width>
<height>31</height>
</rect>
</property>
@@ -451,7 +451,7 @@
<rect>
<x>10</x>
<y>130</y>
- <width>291</width>
+ <width>301</width>
<height>21</height>
</rect>
</property>
diff --git a/heimdall/source/BridgeManager.cpp b/heimdall/source/BridgeManager.cpp
index f58c4e2..00bdf29 100644
--- a/heimdall/source/BridgeManager.cpp
+++ b/heimdall/source/BridgeManager.cpp
@@ -143,11 +143,11 @@ bool BridgeManager::DetectDevice(void)
libusb_free_device_list(devices, deviceCount);
- Interface::Print("Failed to detect compatible device\n");
+ Interface::PrintDeviceDetectionFailed();
return (false);
}
-bool BridgeManager::Initialise(void)
+int BridgeManager::Initialise(void)
{
Interface::Print("Initialising connection...\n");
@@ -157,7 +157,7 @@ bool BridgeManager::Initialise(void)
{
Interface::PrintError("Failed to initialise libusb. libusb error: %d\n", result);
Interface::Print("Failed to connect to device!");
- return (false);
+ return (BridgeManager::kInitialiseFailed);
}
Interface::Print("Detecting device...\n");
@@ -189,15 +189,15 @@ bool BridgeManager::Initialise(void)
if (!heimdallDevice)
{
- Interface::PrintError("Failed to detect device!\n");
- return (false);
+ Interface::PrintDeviceDetectionFailed();
+ return (BridgeManager::kInitialiseDeviceNotDetected);
}
result = libusb_open(heimdallDevice, &deviceHandle);
if (result != LIBUSB_SUCCESS)
{
Interface::PrintError("Failed to access device. libusb error: %d\n", result);
- return (false);
+ return (BridgeManager::kInitialiseFailed);
}
libusb_device_descriptor deviceDescriptor;
@@ -205,12 +205,13 @@ bool BridgeManager::Initialise(void)
if (result != LIBUSB_SUCCESS)
{
Interface::PrintError("Failed to retrieve device description\n");
- return (false);
+ return (BridgeManager::kInitialiseFailed);
}
if (verbose)
{
unsigned char stringBuffer[128];
+
if (libusb_get_string_descriptor_ascii(deviceHandle, deviceDescriptor.iManufacturer,
stringBuffer, 128) >= 0)
{
@@ -241,10 +242,11 @@ bool BridgeManager::Initialise(void)
libusb_config_descriptor *configDescriptor;
result = libusb_get_config_descriptor(heimdallDevice, 0, &configDescriptor);
+
if (result != LIBUSB_SUCCESS || !configDescriptor)
{
Interface::PrintError("Failed to retrieve config descriptor\n");
- return (false);
+ return (BridgeManager::kInitialiseFailed);
}
int interfaceIndex = -1;
@@ -301,7 +303,7 @@ bool BridgeManager::Initialise(void)
if (result != LIBUSB_SUCCESS)
{
Interface::PrintError("Failed to find correct interface configuration\n");
- return (false);
+ return (BridgeManager::kInitialiseFailed);
}
Interface::Print("Claiming interface...\n");
@@ -323,7 +325,7 @@ bool BridgeManager::Initialise(void)
if (result != LIBUSB_SUCCESS)
{
Interface::PrintError("Claiming interface failed!\n");
- return (false);
+ return (BridgeManager::kInitialiseFailed);
}
Interface::Print("Setting up interface...\n");
@@ -332,12 +334,12 @@ bool BridgeManager::Initialise(void)
if (result != LIBUSB_SUCCESS)
{
Interface::PrintError("Setting up interface failed!\n");
- return (false);
+ return (BridgeManager::kInitialiseFailed);
}
Interface::Print("\n");
- return (true);
+ return (BridgeManager::kInitialiseSucceeded);
}
bool BridgeManager::BeginSession(void) const
diff --git a/heimdall/source/BridgeManager.h b/heimdall/source/BridgeManager.h
index b488ea6..d87f67d 100644
--- a/heimdall/source/BridgeManager.h
+++ b/heimdall/source/BridgeManager.h
@@ -61,6 +61,13 @@ namespace Heimdall
enum
{
+ kInitialiseSucceeded = 0,
+ kInitialiseFailed,
+ kInitialiseDeviceNotDetected
+ };
+
+ enum
+ {
kVidSamsung = 0x04E8
};
@@ -98,7 +105,7 @@ namespace Heimdall
~BridgeManager();
bool DetectDevice(void);
- bool Initialise(void);
+ int Initialise(void);
bool BeginSession(void) const;
bool EndSession(bool reboot) const;
diff --git a/heimdall/source/Interface.cpp b/heimdall/source/Interface.cpp
index bb0f30b..b2677cc 100644
--- a/heimdall/source/Interface.cpp
+++ b/heimdall/source/Interface.cpp
@@ -419,6 +419,11 @@ void Interface::PrintFullInfo(void)
Print(extraInfo);
}
+void Interface::PrintDeviceDetectionFailed(void)
+{
+ Print("Failed to detect compatible download-mode device.\n");
+}
+
void Interface::PrintPit(const PitData *pitData)
{
Interface::Print("Entry Count: %d\n", pitData->GetEntryCount());
diff --git a/heimdall/source/Interface.h b/heimdall/source/Interface.h
index 338445b..4474a2a 100644
--- a/heimdall/source/Interface.h
+++ b/heimdall/source/Interface.h
@@ -285,6 +285,8 @@ namespace Heimdall
static void PrintReleaseInfo(void);
static void PrintFullInfo(void);
+ static void PrintDeviceDetectionFailed(void);
+
static void PrintPit(const PitData *pitData);
static string& GetPitArgument(void)
diff --git a/heimdall/source/main.cpp b/heimdall/source/main.cpp
index f5bf173..a3ae962 100644
--- a/heimdall/source/main.cpp
+++ b/heimdall/source/main.cpp
@@ -244,7 +244,7 @@ void closeFiles(map<string, FILE *> argumentfileMap)
argumentfileMap.clear();
}
-bool getDeviceInfo(BridgeManager *bridgeManager)
+bool retrieveDeviceInfo(BridgeManager *bridgeManager)
{
// ---------- GET DEVICE INFORMATION ----------
@@ -271,6 +271,8 @@ bool getDeviceInfo(BridgeManager *bridgeManager)
Interface::PrintError("Unexpected device info response!\nExpected: 180, 0 or 3\nReceived:%d\n", deviceInfoResult);
return (false);
}
+
+ return (true);
}
int downloadPitFile(BridgeManager *bridgeManager, unsigned char **pitBuffer)
@@ -643,10 +645,12 @@ int main(int argc, char **argv)
Interface::PrintReleaseInfo();
Sleep(1000);
- if (!bridgeManager->Initialise())
+ int initialiseResult = bridgeManager->Initialise();
+
+ if (initialiseResult != 0)
{
delete bridgeManager;
- return (0);
+ return ((initialiseResult == BridgeManager::kInitialiseDeviceNotDetected) ? 1 : 0);
}
bool success;
@@ -666,7 +670,7 @@ int main(int argc, char **argv)
return (0);
}
- if (!bridgeManager->BeginSession() || !getDeviceInfo(bridgeManager))
+ if (!bridgeManager->BeginSession() || !retrieveDeviceInfo(bridgeManager))
{
closeFiles(argumentFileMap);
delete bridgeManager;
@@ -686,7 +690,7 @@ int main(int argc, char **argv)
case Interface::kActionClosePcScreen:
{
- if (!bridgeManager->BeginSession() || !getDeviceInfo(bridgeManager))
+ if (!bridgeManager->BeginSession() || !retrieveDeviceInfo(bridgeManager))
{
delete bridgeManager;
return (-1);
@@ -713,7 +717,7 @@ int main(int argc, char **argv)
return (0);
}
- if (!bridgeManager->BeginSession() || !getDeviceInfo(bridgeManager))
+ if (!bridgeManager->BeginSession() || !retrieveDeviceInfo(bridgeManager))
{
delete bridgeManager;
fclose(outputPitFile);
@@ -764,7 +768,7 @@ int main(int argc, char **argv)
int chipId = atoi(argumentMap.find(Interface::actions[Interface::kActionDump].valueArguments[Interface::kDumpValueArgChipId])->second.c_str());
- if (!bridgeManager->BeginSession() || !getDeviceInfo(bridgeManager))
+ if (!bridgeManager->BeginSession() || !retrieveDeviceInfo(bridgeManager))
{
fclose(dumpFile);
@@ -783,7 +787,7 @@ int main(int argc, char **argv)
case Interface::kActionPrintPit:
{
- if (!bridgeManager->BeginSession() || !getDeviceInfo(bridgeManager))
+ if (!bridgeManager->BeginSession() || !retrieveDeviceInfo(bridgeManager))
{
delete bridgeManager;
return (-1);