From 259f5f89732131cfb423c2f1802d804e718e9dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Basse?= Date: Sat, 24 Dec 2016 14:33:39 +0100 Subject: add T-Flash option in FlashAction --- heimdall/source/FlashAction.cpp | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'heimdall/source/FlashAction.cpp') diff --git a/heimdall/source/FlashAction.cpp b/heimdall/source/FlashAction.cpp index d9203b0..3a9b180 100644 --- a/heimdall/source/FlashAction.cpp +++ b/heimdall/source/FlashAction.cpp @@ -30,6 +30,8 @@ #include "Heimdall.h" #include "Interface.h" #include "SessionSetupResponse.h" +#include "TFlashModePacket.h" +#include "TFlashModeResponse.h" #include "TotalBytesPacket.h" #include "Utility.h" @@ -47,8 +49,10 @@ Arguments:\n\ --repartition --pit [-- ...]\n\ [-- ...] [--verbose] [--no-reboot]\n\ [--resume] [--stdout-errors] [--usb-log-level ]\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 +383,40 @@ static PitData *getPitData(BridgeManager *bridgeManager, FILE *pitFile, bool rep return (pitData); } +static bool setTFlashMode(BridgeManager *bridgeManager) +{ + bool success; + + TFlashModePacket *tFlashModePacket = new TFlashModePacket(); + success = bridgeManager->SendPacket(tFlashModePacket); + delete tFlashModePacket; + + if (!success) + { + Interface::PrintError("Failed to request T-Flash mode!\n"); + return false; + } + + TFlashModeResponse *tFlashModeResponse = new TFlashModeResponse(); + success = bridgeManager->ReceivePacket(tFlashModeResponse); + unsigned int result = tFlashModeResponse->GetResult(); + delete tFlashModeResponse; + + if (!success) + { + Interface::PrintError("Failed to receive T-Flash mode result!\n"); + return false; + } + + if(result) + { + Interface::PrintError("Failed to set T-Flash mode (received: %d)!\n", result); + return false; + } + + return true; +} + int FlashAction::Execute(int argc, char **argv) { // Setup argument types @@ -393,6 +431,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 +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 tflash_mode = arguments.GetArgument("tflash") != nullptr; if (arguments.GetArgument("stdout-errors") != nullptr) Interface::SetStdoutErrors(true); @@ -506,6 +546,14 @@ int FlashAction::Execute(int argc, char **argv) return (1); } + if (tflash_mode && !setTFlashMode(bridgeManager)) + { + closeFiles(partitionFiles, pitFile); + delete bridgeManager; + + return (1); + } + bool success = sendTotalTransferSize(bridgeManager, partitionFiles, pitFile, repartition); if (success) -- cgit v1.2.3 From aa40b07450d6f8c78729ff1c70011a18aaf61700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Basse?= Date: Sat, 24 Dec 2016 18:55:56 +0100 Subject: allow higher timeout when switching to t-flash due to sd card initialization --- heimdall/source/FlashAction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'heimdall/source/FlashAction.cpp') diff --git a/heimdall/source/FlashAction.cpp b/heimdall/source/FlashAction.cpp index 3a9b180..a3ab85b 100644 --- a/heimdall/source/FlashAction.cpp +++ b/heimdall/source/FlashAction.cpp @@ -398,7 +398,7 @@ static bool setTFlashMode(BridgeManager *bridgeManager) } TFlashModeResponse *tFlashModeResponse = new TFlashModeResponse(); - success = bridgeManager->ReceivePacket(tFlashModeResponse); + success = bridgeManager->ReceivePacket(tFlashModeResponse, 5000); unsigned int result = tFlashModeResponse->GetResult(); delete tFlashModeResponse; -- cgit v1.2.3 From bf891c9366a86cc06831ab70a7a85ce5673b71e1 Mon Sep 17 00:00:00 2001 From: Benjamin Dobell Date: Fri, 12 May 2017 04:28:11 +1000 Subject: Refactor T-Flash implementation before merging. --- heimdall/source/FlashAction.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'heimdall/source/FlashAction.cpp') diff --git a/heimdall/source/FlashAction.cpp b/heimdall/source/FlashAction.cpp index a3ab85b..b0f19e0 100644 --- a/heimdall/source/FlashAction.cpp +++ b/heimdall/source/FlashAction.cpp @@ -24,14 +24,13 @@ // Heimdall #include "Arguments.h" #include "BridgeManager.h" +#include "EnableTFlashPacket.h" #include "EndModemFileTransferPacket.h" #include "EndPhoneFileTransferPacket.h" #include "FlashAction.h" #include "Heimdall.h" #include "Interface.h" #include "SessionSetupResponse.h" -#include "TFlashModePacket.h" -#include "TFlashModeResponse.h" #include "TotalBytesPacket.h" #include "Utility.h" @@ -383,34 +382,34 @@ static PitData *getPitData(BridgeManager *bridgeManager, FILE *pitFile, bool rep return (pitData); } -static bool setTFlashMode(BridgeManager *bridgeManager) +static bool enableTFlash(BridgeManager *bridgeManager) { bool success; - TFlashModePacket *tFlashModePacket = new TFlashModePacket(); - success = bridgeManager->SendPacket(tFlashModePacket); - delete tFlashModePacket; + EnableTFlashPacket *enableTFlashPacket = new EnableTFlashPacket(); + success = bridgeManager->SendPacket(enableTFlashPacket); + delete enableTFlashPacket; if (!success) { - Interface::PrintError("Failed to request T-Flash mode!\n"); + Interface::PrintError("Failed to send T-Flash packet!\n"); return false; } - TFlashModeResponse *tFlashModeResponse = new TFlashModeResponse(); - success = bridgeManager->ReceivePacket(tFlashModeResponse, 5000); - unsigned int result = tFlashModeResponse->GetResult(); - delete tFlashModeResponse; + 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 mode result!\n"); + Interface::PrintError("Failed to receive T-Flash response!\n"); return false; } - if(result) + if (result) { - Interface::PrintError("Failed to set T-Flash mode (received: %d)!\n", result); + Interface::PrintError("Unexpected T-Flash response!\nExpected: 0\nReceived: %d\n", result); return false; } @@ -459,7 +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_mode = arguments.GetArgument("tflash") != nullptr; + bool tflash = arguments.GetArgument("tflash") != nullptr; if (arguments.GetArgument("stdout-errors") != nullptr) Interface::SetStdoutErrors(true); @@ -546,7 +545,7 @@ int FlashAction::Execute(int argc, char **argv) return (1); } - if (tflash_mode && !setTFlashMode(bridgeManager)) + if (tflash && !enableTFlash(bridgeManager)) { closeFiles(partitionFiles, pitFile); delete bridgeManager; -- cgit v1.2.3