summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2013-01-22 13:53:30 +0100
committerBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2013-01-22 13:53:30 +0100
commit31b1b0b2b0c9312e597ad35e26729474c21b20b9 (patch)
tree7cf1870cd39bc8510d7cd1db60c5bdb55bcbcdbb
parentFixed --repartition flag parsing bug. (diff)
downloadHeimdall-31b1b0b2b0c9312e597ad35e26729474c21b20b9.tar
Heimdall-31b1b0b2b0c9312e597ad35e26729474c21b20b9.tar.gz
Heimdall-31b1b0b2b0c9312e597ad35e26729474c21b20b9.tar.bz2
Heimdall-31b1b0b2b0c9312e597ad35e26729474c21b20b9.tar.lz
Heimdall-31b1b0b2b0c9312e597ad35e26729474c21b20b9.tar.xz
Heimdall-31b1b0b2b0c9312e597ad35e26729474c21b20b9.tar.zst
Heimdall-31b1b0b2b0c9312e597ad35e26729474c21b20b9.zip
Diffstat (limited to '')
-rw-r--r--heimdall/source/BridgeManager.cpp73
-rw-r--r--heimdall/source/Heimdall.h4
-rw-r--r--heimdall/source/Interface.cpp2
-rw-r--r--libpit/Source/libpit.cpp8
-rw-r--r--libpit/Source/libpit.h25
5 files changed, 51 insertions, 61 deletions
diff --git a/heimdall/source/BridgeManager.cpp b/heimdall/source/BridgeManager.cpp
index fa83b1c..2bc96cf 100644
--- a/heimdall/source/BridgeManager.cpp
+++ b/heimdall/source/BridgeManager.cpp
@@ -591,14 +591,40 @@ bool BridgeManager::BeginSession(void)
if (!ReceivePacket(&beginSessionResponse))
return (false);
- unsigned int result = beginSessionResponse.GetResult();
+ unsigned int deviceDefaultPacketSize = beginSessionResponse.GetResult();
- if (result != 0) // Assume 0 means don't care, otherwise use the response as the fileTransferPacketSize.
- fileTransferPacketSize = result;
+ if (deviceDefaultPacketSize != 0) // 0 means changing the packet size is not supported.
+ {
+ Interface::Print("\nThis device may take up to 2 minutes to respond.\nPlease be patient!\n\n");
+ Sleep(2000); // Give the user time to read the message.
+
+ fileTransferSequenceTimeout = 120000; // 2 minutes!
+ fileTransferPacketSize = 1048576; // 1 MiB
+ fileTransferSequenceMaxLength = 100; // 100 MiB per sequence. Which is the same as the default of 800 * 131072.
+
+ FilePartSizePacket filePartSizePacket(fileTransferPacketSize);
+
+ if (!SendPacket(&filePartSizePacket))
+ {
+ Interface::PrintError("Failed to send file part size packet!\n");
+ return (false);
+ }
+
+ SessionSetupResponse filePartSizeResponse;
+
+ if (!ReceivePacket(&filePartSizeResponse))
+ return (false);
+
+ if (filePartSizeResponse.GetResult() != 0)
+ {
+ Interface::PrintError("Unexpected file part size response!\nExpected: 0\nReceived: %d\n", filePartSizeResponse.GetResult());
+ return (false);
+ }
+ }
// -------------------- KIES DOESN'T DO THIS --------------------
- DeviceTypePacket deviceTypePacket;
+ /*DeviceTypePacket deviceTypePacket;
if (!SendPacket(&deviceTypePacket))
{
@@ -626,39 +652,7 @@ bool BridgeManager::BeginSession(void)
if (verbose)
Interface::Print("Session begun with device of type: %d.\n\n", deviceType);
else
- Interface::Print("Session begun.\n\n", deviceType);
-
- if (deviceType == 30)
- {
- Interface::Print("In certain situations this device may take up to 2 minutes to respond.\nPlease be patient!\n\n", deviceType);
- Sleep(2000); // Give the user time to read the message.
-
- // The SGH-I727 is very unstable/unreliable using the default settings. Flashing
- // seems to be much more reliable using the following setup.
-
- fileTransferSequenceMaxLength = 30;
- fileTransferSequenceTimeout = 120000; // 2 minutes!
- fileTransferPacketSize = 1048576; // 1 MiB
-
- FilePartSizePacket filePartSizePacket(fileTransferPacketSize); // 1 MiB
-
- if (!SendPacket(&filePartSizePacket))
- {
- Interface::PrintError("Failed to send file part size packet!\n");
- return (false);
- }
-
- SessionSetupResponse filePartSizeResponse;
-
- if (!ReceivePacket(&filePartSizeResponse))
- return (false);
-
- if (filePartSizeResponse.GetResult() != 0)
- {
- Interface::PrintError("Unexpected file part size response!\nExpected: 0\nReceived: %d\n", filePartSizeResponse.GetResult());
- return (false);
- }
- }
+ Interface::Print("Session begun.\n\n");
return (true);
@@ -666,7 +660,10 @@ bool BridgeManager::BeginSession(void)
Interface::PrintError("Unexpected device info response!\nExpected: 0, 3, 30, 180 or 190\nReceived:%d\n", deviceType);
return (false);
- }
+ }*/
+
+ Interface::Print("Session begun.\n\n");
+ return (true);
}
bool BridgeManager::EndSession(bool reboot) const
diff --git a/heimdall/source/Heimdall.h b/heimdall/source/Heimdall.h
index 1cb2eaa..88969c2 100644
--- a/heimdall/source/Heimdall.h
+++ b/heimdall/source/Heimdall.h
@@ -37,8 +37,4 @@
#endif
-#ifndef nullptr
-#define nullptr 0
-#endif
-
#endif
diff --git a/heimdall/source/Interface.cpp b/heimdall/source/Interface.cpp
index 67f1bee..bbe1472 100644
--- a/heimdall/source/Interface.cpp
+++ b/heimdall/source/Interface.cpp
@@ -299,7 +299,7 @@ void Interface::PrintPit(const PitData *pitData)
Interface::Print("\n");
}
- Interface::Print("Partition Block Size: %d\n", entry->GetBlockSize());
+ Interface::Print("Partition Block Size/Offset: %d\n", entry->GetBlockSizeOrOffset());
Interface::Print("Partition Block Count: %d\n", entry->GetBlockCount());
Interface::Print("File Offset (Obsolete): %d\n", entry->GetFileOffset());
diff --git a/libpit/Source/libpit.cpp b/libpit/Source/libpit.cpp
index 56903f9..a1138b5 100644
--- a/libpit/Source/libpit.cpp
+++ b/libpit/Source/libpit.cpp
@@ -30,7 +30,7 @@ PitEntry::PitEntry()
identifier = 0;
attributes = 0;
updateAttributes = 0;
- blockSize = 0;
+ blockSizeOrOffset = 0;
blockCount = 0;
fileOffset = 0;
fileSize = 0;
@@ -47,7 +47,7 @@ PitEntry::~PitEntry()
bool PitEntry::Matches(const PitEntry *otherPitEntry) const
{
if (binaryType == otherPitEntry->binaryType && deviceType == otherPitEntry->deviceType && identifier == otherPitEntry->identifier
- && attributes == otherPitEntry->attributes && updateAttributes == otherPitEntry->updateAttributes && blockSize == otherPitEntry->blockSize
+ && attributes == otherPitEntry->attributes && updateAttributes == otherPitEntry->updateAttributes && blockSizeOrOffset == otherPitEntry->blockSizeOrOffset
&& blockCount == otherPitEntry->blockCount && fileOffset == otherPitEntry->fileOffset && fileSize == otherPitEntry->fileSize
&& strcmp(partitionName, otherPitEntry->partitionName) == 0 && strcmp(flashFilename, otherPitEntry->flashFilename) == 0
&& strcmp(fotaFilename, otherPitEntry->fotaFilename) == 0)
@@ -135,7 +135,7 @@ bool PitData::Unpack(const unsigned char *data)
entries[i]->SetUpdateAttributes(integerValue);
integerValue = PitData::UnpackInteger(data, entryOffset + 20);
- entries[i]->SetBlockSize(integerValue);
+ entries[i]->SetBlockSizeOrOffset(integerValue);
integerValue = PitData::UnpackInteger(data, entryOffset + 24);
entries[i]->SetBlockCount(integerValue);
@@ -186,7 +186,7 @@ void PitData::Pack(unsigned char *data) const
PitData::PackInteger(data, entryOffset + 16, entries[i]->GetUpdateAttributes());
- PitData::PackInteger(data, entryOffset + 20, entries[i]->GetBlockSize());
+ PitData::PackInteger(data, entryOffset + 20, entries[i]->GetBlockSizeOrOffset());
PitData::PackInteger(data, entryOffset + 24, entries[i]->GetBlockCount());
PitData::PackInteger(data, entryOffset + 28, entries[i]->GetFileOffset());
diff --git a/libpit/Source/libpit.h b/libpit/Source/libpit.h
index 40c7da5..7d6f346 100644
--- a/libpit/Source/libpit.h
+++ b/libpit/Source/libpit.h
@@ -25,12 +25,8 @@
#pragma warning(disable : 4996)
#endif
-#ifndef nullptr
-#define nullptr 0
-#endif
-
-// C Standard Library
-#include <string.h>
+// C/C++ Standard Library
+#include <string>
#include <vector>
namespace libpit
@@ -81,7 +77,7 @@ namespace libpit
unsigned int attributes;
unsigned int updateAttributes;
- unsigned int blockSize;
+ unsigned int blockSizeOrOffset;
unsigned int blockCount;
unsigned int fileOffset; // Obsolete
@@ -147,15 +143,16 @@ namespace libpit
{
this->updateAttributes = updateAttributes;
}
-
- unsigned int GetBlockSize(void) const
+
+ // Different versions of Loke (secondary bootloaders) on different devices intepret this differently.
+ unsigned int GetBlockSizeOrOffset(void) const
{
- return blockSize;
+ return blockSizeOrOffset;
}
- void SetBlockSize(unsigned int blockSize)
+ void SetBlockSizeOrOffset(unsigned int blockSizeOrOffset)
{
- this->blockSize = blockSize;
+ this->blockSizeOrOffset = blockSizeOrOffset;
}
unsigned int GetBlockCount(void) const
@@ -253,8 +250,8 @@ namespace libpit
unsigned int unknown1; // 0x08
unsigned int unknown2; // 0x0C
- unsigned short unknown3; // 0x10 (7508 = I9000, 7703 = I9100 & P1000)?
- unsigned short unknown4; // 0x12 (Always 65, probably attributes of some sort)
+ unsigned short unknown3; // 0x10
+ unsigned short unknown4; // 0x12
unsigned short unknown5; // 0x14
unsigned short unknown6; // 0x16