diff options
author | Benjamin Dobell <benjamin.dobell+git@glassechidna.com.au> | 2017-05-11 20:28:11 +0200 |
---|---|---|
committer | Benjamin Dobell <benjamin.dobell+git@glassechidna.com.au> | 2017-05-11 20:32:20 +0200 |
commit | bf891c9366a86cc06831ab70a7a85ce5673b71e1 (patch) | |
tree | f450c11ad2f39a56f0672cf17f42af57c1e50565 /heimdall/source | |
parent | allow higher timeout when switching to t-flash due to sd card initialization (diff) | |
download | Heimdall-bf891c9366a86cc06831ab70a7a85ce5673b71e1.tar Heimdall-bf891c9366a86cc06831ab70a7a85ce5673b71e1.tar.gz Heimdall-bf891c9366a86cc06831ab70a7a85ce5673b71e1.tar.bz2 Heimdall-bf891c9366a86cc06831ab70a7a85ce5673b71e1.tar.lz Heimdall-bf891c9366a86cc06831ab70a7a85ce5673b71e1.tar.xz Heimdall-bf891c9366a86cc06831ab70a7a85ce5673b71e1.tar.zst Heimdall-bf891c9366a86cc06831ab70a7a85ce5673b71e1.zip |
Diffstat (limited to '')
-rw-r--r-- | heimdall/source/EnableTFlashPacket.h (renamed from heimdall/source/TFlashModeResponse.h) | 31 | ||||
-rw-r--r-- | heimdall/source/FlashAction.cpp | 31 | ||||
-rw-r--r-- | heimdall/source/SessionSetupPacket.h | 3 | ||||
-rw-r--r-- | heimdall/source/TFlashModePacket.h | 65 |
4 files changed, 23 insertions, 107 deletions
diff --git a/heimdall/source/TFlashModeResponse.h b/heimdall/source/EnableTFlashPacket.h index a9a3558..7b22ebd 100644 --- a/heimdall/source/TFlashModeResponse.h +++ b/heimdall/source/EnableTFlashPacket.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2014 Benjamin Dobell, Glass Echidna +/* 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 @@ -18,39 +18,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ -#ifndef TFLASHMODERESPONSE_H -#define TFLASHMODERESPONSE_H +#ifndef ENABLETFLASHPACKET_H +#define ENABLETFLASHPACKET_H // Heimdall -#include "ResponsePacket.h" +#include "SessionSetupPacket.h" namespace Heimdall { - class TFlashModeResponse : public ResponsePacket + class EnableTFlashPacket : public SessionSetupPacket { - private: - - unsigned int result; - public: - TFlashModeResponse() : ResponsePacket(ResponsePacket::kResponseTypeSessionSetup) - { - } - - unsigned int GetResult(void) const + EnableTFlashPacket() : SessionSetupPacket(SessionSetupPacket::kEnableTFlash) { - return (result); - } - - bool Unpack(void) - { - if (!ResponsePacket::Unpack()) - return (false); - - result = UnpackInteger(ResponsePacket::kDataSize); - - return (true); } }; } 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; diff --git a/heimdall/source/SessionSetupPacket.h b/heimdall/source/SessionSetupPacket.h index 055e701..0d7cf75 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: diff --git a/heimdall/source/TFlashModePacket.h b/heimdall/source/TFlashModePacket.h deleted file mode 100644 index 4d5bc07..0000000 --- a/heimdall/source/TFlashModePacket.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (c) 2010-2014 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 TFLASHMODEPACKET_H -#define TFLASHMODEPACKET_H - -// Heimdall -#include "ControlPacket.h" - -namespace Heimdall -{ - class TFlashModePacket : public ControlPacket - { - public: - - enum - { - kRequestTFlashMode = 0x08 - }; - - protected: - - enum - { - kDataSize = ControlPacket::kDataSize + 4 - }; - - private: - - unsigned int subcmd = TFlashModePacket::kRequestTFlashMode; - - public: - - TFlashModePacket(void) : ControlPacket(ControlPacket::kControlTypeSession) - { - - } - - virtual void Pack(void) - { - ControlPacket::Pack(); - - PackInteger(ControlPacket::kDataSize, subcmd); - } - }; -} - -#endif |