summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2017-05-11 20:34:19 +0200
committerBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2017-05-11 20:34:19 +0200
commit663bb80f22575b096a98ff44a5afe0cb2b9b0f66 (patch)
tree1ed4498ffbc45a18c234eb821ae624dd88395401
parentIt's 2017. Where did the years go? (diff)
parentRefactor T-Flash implementation before merging. (diff)
downloadHeimdall-663bb80f22575b096a98ff44a5afe0cb2b9b0f66.tar
Heimdall-663bb80f22575b096a98ff44a5afe0cb2b9b0f66.tar.gz
Heimdall-663bb80f22575b096a98ff44a5afe0cb2b9b0f66.tar.bz2
Heimdall-663bb80f22575b096a98ff44a5afe0cb2b9b0f66.tar.lz
Heimdall-663bb80f22575b096a98ff44a5afe0cb2b9b0f66.tar.xz
Heimdall-663bb80f22575b096a98ff44a5afe0cb2b9b0f66.tar.zst
Heimdall-663bb80f22575b096a98ff44a5afe0cb2b9b0f66.zip
-rw-r--r--heimdall/source/EnableTFlashPacket.h39
-rw-r--r--heimdall/source/FlashAction.cpp47
-rw-r--r--heimdall/source/SessionSetupPacket.h3
3 files changed, 88 insertions, 1 deletions
diff --git a/heimdall/source/EnableTFlashPacket.h b/heimdall/source/EnableTFlashPacket.h
new file mode 100644
index 0000000..7b22ebd
--- /dev/null
+++ b/heimdall/source/EnableTFlashPacket.h
@@ -0,0 +1,39 @@
+/* Copyright (c) 2010-2017 Benjamin Dobell, Glass Echidna
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.*/
+
+#ifndef ENABLETFLASHPACKET_H
+#define ENABLETFLASHPACKET_H
+
+// Heimdall
+#include "SessionSetupPacket.h"
+
+namespace Heimdall
+{
+ class EnableTFlashPacket : public SessionSetupPacket
+ {
+ public:
+
+ EnableTFlashPacket() : SessionSetupPacket(SessionSetupPacket::kEnableTFlash)
+ {
+ }
+ };
+}
+
+#endif
diff --git a/heimdall/source/FlashAction.cpp b/heimdall/source/FlashAction.cpp
index ca154da..5cc85fc 100644
--- a/heimdall/source/FlashAction.cpp
+++ b/heimdall/source/FlashAction.cpp
@@ -24,6 +24,7 @@
// Heimdall
#include "Arguments.h"
#include "BridgeManager.h"
+#include "EnableTFlashPacket.h"
#include "EndModemFileTransferPacket.h"
#include "EndPhoneFileTransferPacket.h"
#include "FlashAction.h"
@@ -47,8 +48,10 @@ Arguments:\n\
--repartition --pit <filename> [--<partition name> <filename> ...]\n\
[--<partition identifier> <filename> ...] [--verbose] [--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\
(or identifiers) can be obtained by executing the print-pit action.\n\
+ T-Flash mode allows to flash the inserted SD-card instead of the internal MMC.\n\
Note: --no-reboot causes the device to remain in download mode after the action\n\
is completed. If you wish to perform another action whilst remaining in\n\
download mode, then the following action must specify the --resume flag.\n\
@@ -379,6 +382,40 @@ static PitData *getPitData(BridgeManager *bridgeManager, FILE *pitFile, bool rep
return (pitData);
}
+static bool enableTFlash(BridgeManager *bridgeManager)
+{
+ bool success;
+
+ EnableTFlashPacket *enableTFlashPacket = new EnableTFlashPacket();
+ success = bridgeManager->SendPacket(enableTFlashPacket);
+ delete enableTFlashPacket;
+
+ if (!success)
+ {
+ Interface::PrintError("Failed to send T-Flash packet!\n");
+ return false;
+ }
+
+ SessionSetupResponse *enableTFlashResponse = new SessionSetupResponse();
+ success = bridgeManager->ReceivePacket(enableTFlashResponse, 5000);
+ unsigned int result = enableTFlashResponse->GetResult();
+ delete enableTFlashResponse;
+
+ if (!success)
+ {
+ Interface::PrintError("Failed to receive T-Flash response!\n");
+ return false;
+ }
+
+ if (result)
+ {
+ Interface::PrintError("Unexpected T-Flash response!\nExpected: 0\nReceived: %d\n", result);
+ return false;
+ }
+
+ return true;
+}
+
int FlashAction::Execute(int argc, char **argv)
{
// Setup argument types
@@ -393,6 +430,7 @@ int FlashAction::Execute(int argc, char **argv)
argumentTypes["verbose"] = kArgumentTypeFlag;
argumentTypes["stdout-errors"] = kArgumentTypeFlag;
argumentTypes["usb-log-level"] = kArgumentTypeString;
+ argumentTypes["tflash"] = kArgumentTypeFlag;
argumentTypes["pit"] = kArgumentTypeString;
shortArgumentAliases["pit"] = "pit";
@@ -420,6 +458,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 tflash = arguments.GetArgument("tflash") != nullptr;
if (arguments.GetArgument("stdout-errors") != nullptr)
Interface::SetStdoutErrors(true);
@@ -506,6 +545,14 @@ int FlashAction::Execute(int argc, char **argv)
return (1);
}
+ if (tflash && !enableTFlash(bridgeManager))
+ {
+ closeFiles(partitionFiles, pitFile);
+ delete bridgeManager;
+
+ return (1);
+ }
+
bool success = sendTotalTransferSize(bridgeManager, partitionFiles, pitFile, repartition);
if (success)
diff --git a/heimdall/source/SessionSetupPacket.h b/heimdall/source/SessionSetupPacket.h
index 04351e2..b1d2426 100644
--- a/heimdall/source/SessionSetupPacket.h
+++ b/heimdall/source/SessionSetupPacket.h
@@ -36,7 +36,8 @@ namespace Heimdall
kDeviceType = 1, // ?
kTotalBytes = 2,
//kEnableSomeSortOfFlag = 3,
- kFilePartSize = 5
+ kFilePartSize = 5,
+ kEnableTFlash = 8
};
private: