1
0
mirror of https://git.sr.ht/~grimler/Heimdall synced 2025-02-27 18:27:04 +00:00

heimdall: add new --wait arg

If used, then Heimdall will wait until a compatible device is found,
rather than exiting instantly with an error.

Note that this is default behaviour of fastboot, so this change should
make life a little bit easier for people writing scripts that support
flashing to different types of devices.  Exiting instantly is still
default behaviour though, for backward compatibility.
This commit is contained in:
Henrik Grimler
2024-07-05 14:09:17 +02:00
parent 6cb882b528
commit 1440255c6c
5 changed files with 30 additions and 16 deletions

@ -104,7 +104,7 @@ int ClosePcScreenAction::Execute(int argc, char **argv)
// Download PIT file from device.
BridgeManager *bridgeManager = new BridgeManager(verbose);
BridgeManager *bridgeManager = new BridgeManager(verbose, false);
bridgeManager->SetUsbLogLevel(usbLogLevel);
if (bridgeManager->Initialise(resume) != BridgeManager::kInitialiseSucceeded || !bridgeManager->BeginSession())

@ -29,9 +29,11 @@ using namespace std;
using namespace Heimdall;
const char *DetectAction::usage = "Action: detect\n\
Arguments: [--verbose] [--stdout-errors]\n\
Arguments: [--wait] [--verbose] [--stdout-errors]\n\
[--usb-log-level <none/error/warning/debug>]\n\
Description: Indicates whether or not a download mode device can be detected.\n";
Description: Indicates whether or not a download mode device can be detected.\n\
Returns instantly per default, or waits until device is found\n\
when --wait argument is used.\n";
int DetectAction::Execute(int argc, char **argv)
{
@ -39,6 +41,7 @@ int DetectAction::Execute(int argc, char **argv)
map<string, ArgumentType> argumentTypes;
argumentTypes["verbose"] = kArgumentTypeFlag;
argumentTypes["wait"] = kArgumentTypeFlag;
argumentTypes["stdout-errors"] = kArgumentTypeFlag;
argumentTypes["usb-log-level"] = kArgumentTypeString;
@ -50,8 +53,10 @@ int DetectAction::Execute(int argc, char **argv)
return (0);
}
bool waitForDevice = arguments.GetArgument("wait") != nullptr;
bool verbose = arguments.GetArgument("verbose") != nullptr;
if (arguments.GetArgument("stdout-errors") != nullptr)
Interface::SetStdoutErrors(true);
@ -93,7 +98,7 @@ int DetectAction::Execute(int argc, char **argv)
// Download PIT file from device.
BridgeManager *bridgeManager = new BridgeManager(verbose);
BridgeManager *bridgeManager = new BridgeManager(verbose, waitForDevice);
bridgeManager->SetUsbLogLevel(usbLogLevel);
bool detected = bridgeManager->DetectDevice();

@ -33,9 +33,10 @@ using namespace Heimdall;
const char *DownloadPitAction::usage = "Action: download-pit\n\
Arguments: --output <filename> [--verbose] [--no-reboot] [--stdout-errors]\n\
[--usb-log-level <none/error/warning/debug>]\n\
[--wait] [--usb-log-level <none/error/warning/debug>]\n\
Description: Downloads the connected device's PIT file to the specified\n\
output file.\n\
output file. If --wait is used Heimdall waits until a compatible device is\n\
connected.\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";
@ -49,6 +50,7 @@ int DownloadPitAction::Execute(int argc, char **argv)
argumentTypes["no-reboot"] = kArgumentTypeFlag;
argumentTypes["resume"] = kArgumentTypeFlag;
argumentTypes["verbose"] = kArgumentTypeFlag;
argumentTypes["wait"] = kArgumentTypeFlag;
argumentTypes["stdout-errors"] = kArgumentTypeFlag;
argumentTypes["usb-log-level"] = kArgumentTypeString;
@ -69,10 +71,11 @@ int DownloadPitAction::Execute(int argc, char **argv)
return (0);
}
bool waitForDevice = arguments.GetArgument("wait") == nullptr;
bool reboot = arguments.GetArgument("no-reboot") == nullptr;
bool resume = arguments.GetArgument("resume") != nullptr;
bool verbose = arguments.GetArgument("verbose") != nullptr;
if (arguments.GetArgument("stdout-errors") != nullptr)
Interface::SetStdoutErrors(true);
@ -130,7 +133,7 @@ int DownloadPitAction::Execute(int argc, char **argv)
// Download PIT file from device.
BridgeManager *bridgeManager = new BridgeManager(verbose);
BridgeManager *bridgeManager = new BridgeManager(verbose, waitForDevice);
bridgeManager->SetUsbLogLevel(usbLogLevel);
if (bridgeManager->Initialise(resume) != BridgeManager::kInitialiseSucceeded || !bridgeManager->BeginSession())

@ -43,14 +43,15 @@ Arguments:\n\
[--<partition name> <filename> ...]\n\
[--<partition identifier> <filename> ...]\n\
[--pit <filename>] [--verbose] [--no-reboot] [--resume] [--stdout-errors]\n\
[--usb-log-level <none/error/warning/debug>]\n\
[--usb-log-level <none/error/warning/debug>] [--skip-size-check] [--wait]\n\
or:\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] [--skip-size-check]\n\
[--tflash] [--skip-size-check] [--wait]\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\
With --wait Heimdall waits until a compatible device is connected.\n\
T-Flash mode allows to flash the inserted SD-card instead of the internal MMC.\n\
Use --skip-size-check to not verify that files fit in the specified partition.\n\
Note: --no-reboot causes the device to remain in download mode after the action\n\
@ -478,6 +479,7 @@ int FlashAction::Execute(int argc, char **argv)
argumentTypes["verbose"] = kArgumentTypeFlag;
argumentTypes["stdout-errors"] = kArgumentTypeFlag;
argumentTypes["usb-log-level"] = kArgumentTypeString;
argumentTypes["wait"] = kArgumentTypeFlag;
argumentTypes["tflash"] = kArgumentTypeFlag;
argumentTypes["skip-size-check"] = kArgumentTypeFlag;
@ -508,6 +510,7 @@ int FlashAction::Execute(int argc, char **argv)
bool resume = arguments.GetArgument("resume") != nullptr;
bool verbose = arguments.GetArgument("verbose") != nullptr;
bool tflash = arguments.GetArgument("tflash") != nullptr;
bool waitForDevice = arguments.GetArgument("wait") != nullptr;
// If we are flashing to sdcard we can ignore size of partition in PIT
bool skipSizeCheck = (arguments.GetArgument("skip-size-check") != nullptr) || tflash;
@ -585,7 +588,7 @@ int FlashAction::Execute(int argc, char **argv)
// Perform flash
BridgeManager *bridgeManager = new BridgeManager(verbose);
BridgeManager *bridgeManager = new BridgeManager(verbose, waitForDevice);
bridgeManager->SetUsbLogLevel(usbLogLevel);
if (bridgeManager->Initialise(resume) != BridgeManager::kInitialiseSucceeded || !bridgeManager->BeginSession())

@ -34,10 +34,11 @@ using namespace Heimdall;
const char *PrintPitAction::usage = "Action: print-pit\n\
Arguments: [--file <filename>] [--verbose] [--no-reboot] [--stdout-errors]\n\
[--usb-log-level <none/error/warning/debug>]\n\
[--usb-log-level <none/error/warning/debug>] [--wait]\n\
Description: Prints the contents of a PIT file in a human readable format. If\n\
a filename is not provided then Heimdall retrieves the PIT file from the \n\
connected device.\n\
connected device. If --wait is used then Heimdall waits until a compatible\n\
device is connected.\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";
@ -51,6 +52,7 @@ int PrintPitAction::Execute(int argc, char **argv)
argumentTypes["no-reboot"] = kArgumentTypeFlag;
argumentTypes["resume"] = kArgumentTypeFlag;
argumentTypes["verbose"] = kArgumentTypeFlag;
argumentTypes["wait"] = kArgumentTypeFlag;
argumentTypes["stdout-errors"] = kArgumentTypeFlag;
argumentTypes["usb-log-level"] = kArgumentTypeString;
@ -67,7 +69,8 @@ int PrintPitAction::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 waitForDevice = arguments.GetArgument("wait") != nullptr;
if (arguments.GetArgument("stdout-errors") != nullptr)
Interface::SetStdoutErrors(true);
@ -156,7 +159,7 @@ int PrintPitAction::Execute(int argc, char **argv)
{
// Print PIT from a device.
BridgeManager *bridgeManager = new BridgeManager(verbose);
BridgeManager *bridgeManager = new BridgeManager(verbose, waitForDevice);
bridgeManager->SetUsbLogLevel(usbLogLevel);
if (bridgeManager->Initialise(resume) != BridgeManager::kInitialiseSucceeded || !bridgeManager->BeginSession())