Compare commits
25 Commits
size_check
...
master
Author | SHA1 | Date |
---|---|---|
Henrik Grimler | 02b577ec77 | |
Henrik Grimler | 14f3521a6b | |
Henrik Grimler | 0cf817a591 | |
Henrik Grimler | c3516307d2 | |
Henrik Grimler | f6c4698c8b | |
Henrik Grimler | d81e0f5bc2 | |
Henrik Grimler | 62368adc7d | |
Henrik Grimler | 0f1843c93c | |
Henrik Grimler | 172ab65cbe | |
Henrik Grimler | 1e7ff3b659 | |
Henrik Grimler | e916c679ed | |
Henrik Grimler | e9a68f6862 | |
Henrik Grimler | 990ce68f5c | |
Antony Cherepanov | c939ab18d1 | |
Antony Cherepanov | 1385b183d2 | |
Henrik Grimler | 95e5c1cdcb | |
Henrik Grimler | 622067f284 | |
Henrik Grimler | 9b0e9ff174 | |
Henrik Grimler | 225164f87e | |
Henrik Grimler | 91802883a0 | |
Henrik Grimler | 40be58b43e | |
Henrik Grimler | 60ab9bbaff | |
Henrik Grimler | e51c9119f1 | |
Henrik Grimler | 31745c287a | |
Henrik Grimler | cedfcd8c80 |
17
README.md
17
README.md
|
@ -1,5 +1,9 @@
|
||||||
# Heimdall
|
# Heimdall
|
||||||
|
|
||||||
|
[![builds.sr.ht status](https://builds.sr.ht/~grimler/Heimdall/commits/ubuntu.yml.svg)](https://builds.sr.ht/~grimler/Heimdall/commits/ubuntu.yml?)
|
||||||
|
[![builds.sr.ht status](https://builds.sr.ht/~grimler/Heimdall/commits/archlinux.yml.svg)](https://builds.sr.ht/~grimler/Heimdall/commits/archlinux.yml?)
|
||||||
|
[![builds.sr.ht status](https://builds.sr.ht/~grimler/Heimdall/commits/alpine.yml.svg)](https://builds.sr.ht/~grimler/Heimdall/commits/alpine.yml?)
|
||||||
|
|
||||||
Heimdall is a cross-platform open-source tool suite used to flash
|
Heimdall is a cross-platform open-source tool suite used to flash
|
||||||
firmware (aka ROMs) onto Samsung mobile devices.
|
firmware (aka ROMs) onto Samsung mobile devices.
|
||||||
|
|
||||||
|
@ -20,7 +24,7 @@ Heimdall communicate via the custom Samsung-developed protocol
|
||||||
typically referred to as the 'Odin 3 protocol'.
|
typically referred to as the 'Odin 3 protocol'.
|
||||||
|
|
||||||
USB communication in Heimdall is handled by the popular open-source
|
USB communication in Heimdall is handled by the popular open-source
|
||||||
USB library, [libusb](http://libusb.info).
|
USB library, [libusb](https://libusb.info).
|
||||||
|
|
||||||
## Free & Open Source
|
## Free & Open Source
|
||||||
|
|
||||||
|
@ -40,12 +44,17 @@ refer to the appropriate platform specific README:
|
||||||
|
|
||||||
#### Linux
|
#### Linux
|
||||||
|
|
||||||
- Linux/README ([online](https://raw.githubusercontent.com/Benjamin-Dobell/Heimdall/master/Linux/README))
|
- Linux/README ([online](Linux/README))
|
||||||
|
|
||||||
#### OS X
|
#### OS X
|
||||||
|
|
||||||
- OSX/README.txt ([online](https://raw.githubusercontent.com/Benjamin-Dobell/Heimdall/master/OSX/README.txt))
|
- OSX/README.txt ([online](OSX/README.txt))
|
||||||
|
|
||||||
#### Windows
|
#### Windows
|
||||||
|
|
||||||
- Win32/README.txt ([online](https://raw.githubusercontent.com/Benjamin-Dobell/Heimdall/master/Win32/README.txt))
|
- Win32/README.txt ([online](Win32/README.txt))
|
||||||
|
|
||||||
|
### Odin protocol and PIT format
|
||||||
|
|
||||||
|
For more details on the Odin protocol, and the PIT files, see the
|
||||||
|
external project [samsung-loki/samsung-docs](https://samsung-loki.github.io/samsung-docs/).
|
||||||
|
|
Binary file not shown.
|
@ -20,7 +20,7 @@ Driver Installation Instructions:
|
||||||
|
|
||||||
1. Put your device into download mode and plug it in.
|
1. Put your device into download mode and plug it in.
|
||||||
|
|
||||||
2. Run zadig.exe included in the Drivers subdirectory.
|
2. Download zadig from https://zadig.akeo.ie/downloads/, and run zadig.exe.
|
||||||
|
|
||||||
3. From the menu chose Options -> List All Devices.
|
3. From the menu chose Options -> List All Devices.
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Heimdall Frontend</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Heimdall Frontend</span></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Version 1.4.2</p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Version 2.0.2</p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright © 2010-2017 Benjamin Dobell, Glass Echidna</p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright © 2010-2017 Benjamin Dobell, Glass Echidna</p>
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Heimdall (command line)</span></p>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Heimdall (command line)</span></p>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
// C Standard Library
|
// C Standard Library
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
// libusb
|
// libusb
|
||||||
#include <libusb.h>
|
#include <libusb.h>
|
||||||
|
@ -80,16 +81,17 @@ int BridgeManager::FindDeviceInterface(void)
|
||||||
Interface::Print("Detecting device...\n");
|
Interface::Print("Detecting device...\n");
|
||||||
|
|
||||||
struct libusb_device **devices;
|
struct libusb_device **devices;
|
||||||
int deviceCount = libusb_get_device_list(libusbContext, &devices);
|
unsigned int deviceCount = libusb_get_device_list(libusbContext, &devices);
|
||||||
|
|
||||||
for (int deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
|
for (unsigned int deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
|
||||||
{
|
{
|
||||||
libusb_device_descriptor descriptor;
|
libusb_device_descriptor descriptor;
|
||||||
libusb_get_device_descriptor(devices[deviceIndex], &descriptor);
|
libusb_get_device_descriptor(devices[deviceIndex], &descriptor);
|
||||||
|
|
||||||
for (int i = 0; i < BridgeManager::kSupportedDeviceCount; i++)
|
for (int i = 0; i < BridgeManager::kSupportedDeviceCount; i++)
|
||||||
{
|
{
|
||||||
if (descriptor.idVendor == supportedDevices[i].vendorId && descriptor.idProduct == supportedDevices[i].productId)
|
if (descriptor.idVendor == supportedDevices[i].vendorId &&
|
||||||
|
descriptor.idProduct == supportedDevices[i].productId)
|
||||||
{
|
{
|
||||||
heimdallDevice = devices[deviceIndex];
|
heimdallDevice = devices[deviceIndex];
|
||||||
libusb_ref_device(heimdallDevice);
|
libusb_ref_device(heimdallDevice);
|
||||||
|
@ -310,14 +312,20 @@ bool BridgeManager::InitialiseProtocol(void)
|
||||||
memcpy(dataBuffer, "ODIN", 4);
|
memcpy(dataBuffer, "ODIN", 4);
|
||||||
memset(dataBuffer + 4, 0, 1);
|
memset(dataBuffer + 4, 0, 1);
|
||||||
|
|
||||||
if (libusb_reset_device(deviceHandle))
|
#ifdef OS_LINUX
|
||||||
|
if (IsUbuntu())
|
||||||
{
|
{
|
||||||
Interface::PrintError("Failed to reset device!");
|
Interface::Print("Resetting device...\n");
|
||||||
|
if (libusb_reset_device(deviceHandle))
|
||||||
|
{
|
||||||
|
Interface::PrintError("Failed to reset device!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!SendBulkTransfer(dataBuffer, 4, 1000))
|
if (!SendBulkTransfer(dataBuffer, 4, 1000))
|
||||||
{
|
{
|
||||||
Interface::PrintError("Failed to send handshake!");
|
Interface::PrintError("Failed to send handshake!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expect "LOKE"
|
// Expect "LOKE"
|
||||||
|
@ -407,29 +415,8 @@ bool BridgeManager::DetectDevice(void)
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup libusb log level.
|
// Set libusb log level.
|
||||||
switch (usbLogLevel)
|
SetUsbLogLevel(usbLogLevel);
|
||||||
{
|
|
||||||
case UsbLogLevel::None:
|
|
||||||
libusb_set_option(libusbContext, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_NONE);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UsbLogLevel::Error:
|
|
||||||
libusb_set_option(libusbContext, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_ERROR);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UsbLogLevel::Warning:
|
|
||||||
libusb_set_option(libusbContext, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_WARNING);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UsbLogLevel::Info:
|
|
||||||
libusb_set_option(libusbContext, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_INFO);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UsbLogLevel::Debug:
|
|
||||||
libusb_set_option(libusbContext, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_DEBUG);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get handle to Galaxy S device
|
// Get handle to Galaxy S device
|
||||||
struct libusb_device **devices;
|
struct libusb_device **devices;
|
||||||
|
@ -442,7 +429,8 @@ bool BridgeManager::DetectDevice(void)
|
||||||
|
|
||||||
for (int i = 0; i < BridgeManager::kSupportedDeviceCount; i++)
|
for (int i = 0; i < BridgeManager::kSupportedDeviceCount; i++)
|
||||||
{
|
{
|
||||||
if (descriptor.idVendor == supportedDevices[i].vendorId && descriptor.idProduct == supportedDevices[i].productId)
|
if (descriptor.idVendor == supportedDevices[i].vendorId &&
|
||||||
|
descriptor.idProduct == supportedDevices[i].productId)
|
||||||
{
|
{
|
||||||
libusb_free_device_list(devices, deviceCount);
|
libusb_free_device_list(devices, deviceCount);
|
||||||
|
|
||||||
|
@ -468,34 +456,13 @@ int BridgeManager::Initialise(bool resume)
|
||||||
if (result != LIBUSB_SUCCESS)
|
if (result != LIBUSB_SUCCESS)
|
||||||
{
|
{
|
||||||
Interface::PrintError("Failed to initialise libusb. libusb error: %d\n", result);
|
Interface::PrintError("Failed to initialise libusb. libusb error: %d\n", result);
|
||||||
Interface::Print("Failed to connect to device!");
|
Interface::Print("Failed to connect to device!\n");
|
||||||
return (BridgeManager::kInitialiseFailed);
|
return (BridgeManager::kInitialiseFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup libusb log level.
|
// Setup libusb log level.
|
||||||
switch (usbLogLevel)
|
SetUsbLogLevel(usbLogLevel);
|
||||||
{
|
|
||||||
case UsbLogLevel::None:
|
|
||||||
libusb_set_option(libusbContext, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_NONE);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UsbLogLevel::Error:
|
|
||||||
libusb_set_option(libusbContext, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_ERROR);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UsbLogLevel::Warning:
|
|
||||||
libusb_set_option(libusbContext, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_WARNING);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UsbLogLevel::Info:
|
|
||||||
libusb_set_option(libusbContext, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_INFO);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UsbLogLevel::Debug:
|
|
||||||
libusb_set_option(libusbContext, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_DEBUG);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = FindDeviceInterface();
|
result = FindDeviceInterface();
|
||||||
|
|
||||||
if (result != BridgeManager::kInitialiseSucceeded)
|
if (result != BridgeManager::kInitialiseSucceeded)
|
||||||
|
@ -749,7 +716,7 @@ bool BridgeManager::ReceivePacket(InboundPacket *packet, int timeout, int emptyT
|
||||||
if (receivedSize < 0)
|
if (receivedSize < 0)
|
||||||
return (false);
|
return (false);
|
||||||
|
|
||||||
if (receivedSize != packet->GetSize() && !packet->IsSizeVariable())
|
if (static_cast<unsigned int>(receivedSize) != packet->GetSize() && !packet->IsSizeVariable())
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
Interface::PrintError("Incorrect packet size received - expected size = %d, received size = %d.\n", packet->GetSize(), receivedSize);
|
Interface::PrintError("Incorrect packet size received - expected size = %d, received size = %d.\n", packet->GetSize(), receivedSize);
|
||||||
|
@ -949,7 +916,7 @@ int BridgeManager::ReceivePitFile(unsigned char **pitBuffer) const
|
||||||
}
|
}
|
||||||
|
|
||||||
int receiveEmptyTransferFlags = (i == transferCount - 1) ? kEmptyTransferAfter : kEmptyTransferNone;
|
int receiveEmptyTransferFlags = (i == transferCount - 1) ? kEmptyTransferAfter : kEmptyTransferNone;
|
||||||
|
|
||||||
ReceiveFilePartPacket *receiveFilePartPacket = new ReceiveFilePartPacket();
|
ReceiveFilePartPacket *receiveFilePartPacket = new ReceiveFilePartPacket();
|
||||||
success = ReceivePacket(receiveFilePartPacket, kDefaultTimeoutReceive, receiveEmptyTransferFlags);
|
success = ReceivePacket(receiveFilePartPacket, kDefaultTimeoutReceive, receiveEmptyTransferFlags);
|
||||||
|
|
||||||
|
@ -1277,3 +1244,32 @@ void BridgeManager::SetUsbLogLevel(UsbLogLevel usbLogLevel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef OS_LINUX
|
||||||
|
bool BridgeManager::IsUbuntu()
|
||||||
|
{
|
||||||
|
std::ifstream os_release("/etc/os-release");
|
||||||
|
std::string line, entry, os;
|
||||||
|
int pos;
|
||||||
|
while (std::getline(os_release, line))
|
||||||
|
{
|
||||||
|
pos = line.find("=");
|
||||||
|
entry = line.substr(0, pos);
|
||||||
|
if (entry == "ID")
|
||||||
|
{
|
||||||
|
os = line.substr(pos+1);
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Interface::Print("Linux distro ID: %s\n",
|
||||||
|
os.c_str());
|
||||||
|
}
|
||||||
|
if (os == "ubuntu")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -166,7 +166,9 @@ namespace Heimdall
|
||||||
bool SendFile(FILE *file, unsigned int destination, unsigned int deviceType, unsigned int fileIdentifier = 0xFFFFFFFF) const;
|
bool SendFile(FILE *file, unsigned int destination, unsigned int deviceType, unsigned int fileIdentifier = 0xFFFFFFFF) const;
|
||||||
|
|
||||||
void SetUsbLogLevel(UsbLogLevel usbLogLevel);
|
void SetUsbLogLevel(UsbLogLevel usbLogLevel);
|
||||||
|
#ifdef OS_LINUX
|
||||||
|
bool IsUbuntu(void);
|
||||||
|
#endif
|
||||||
UsbLogLevel GetUsbLogLevel(void) const
|
UsbLogLevel GetUsbLogLevel(void) const
|
||||||
{
|
{
|
||||||
return usbLogLevel;
|
return usbLogLevel;
|
||||||
|
|
|
@ -148,7 +148,7 @@ int DownloadPitAction::Execute(int argc, char **argv)
|
||||||
|
|
||||||
if (fileSize > 0)
|
if (fileSize > 0)
|
||||||
{
|
{
|
||||||
if (fwrite(pitBuffer, 1, fileSize, outputPitFile) != fileSize)
|
if (fwrite(pitBuffer, 1, fileSize, outputPitFile) != static_cast<size_t>(fileSize))
|
||||||
{
|
{
|
||||||
Interface::PrintError("Failed to write PIT data to output file.\n");
|
Interface::PrintError("Failed to write PIT data to output file.\n");
|
||||||
success = false;
|
success = false;
|
||||||
|
|
|
@ -48,10 +48,11 @@ Arguments:\n\
|
||||||
--repartition --pit <filename> [--<partition name> <filename> ...]\n\
|
--repartition --pit <filename> [--<partition name> <filename> ...]\n\
|
||||||
[--<partition identifier> <filename> ...] [--verbose] [--no-reboot]\n\
|
[--<partition identifier> <filename> ...] [--verbose] [--no-reboot]\n\
|
||||||
[--resume] [--stdout-errors] [--usb-log-level <none/error/warning/debug>]\n\
|
[--resume] [--stdout-errors] [--usb-log-level <none/error/warning/debug>]\n\
|
||||||
[--tflash]\n\
|
[--tflash] [--skip-size-check]\n\
|
||||||
Description: Flashes one or more firmware files to your phone. Partition names\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\
|
(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\
|
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\
|
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\
|
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\
|
download mode, then the following action must specify the --resume flag.\n\
|
||||||
|
@ -62,11 +63,13 @@ struct PartitionFile
|
||||||
{
|
{
|
||||||
const char *argumentName;
|
const char *argumentName;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
unsigned long fileSize;
|
||||||
|
|
||||||
PartitionFile(const char *argumentName, FILE *file)
|
PartitionFile(const char *argumentName, FILE *file, unsigned long fileSize)
|
||||||
{
|
{
|
||||||
this->argumentName = argumentName;
|
this->argumentName = argumentName;
|
||||||
this->file = file;
|
this->file = file;
|
||||||
|
this->fileSize = fileSize;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -113,14 +116,17 @@ static bool openFiles(Arguments& arguments, vector<PartitionFile>& partitionFile
|
||||||
{
|
{
|
||||||
const StringArgument *stringArgument = static_cast<const StringArgument *>(*it);
|
const StringArgument *stringArgument = static_cast<const StringArgument *>(*it);
|
||||||
FILE *file = FileOpen(stringArgument->GetValue().c_str(), "rb");
|
FILE *file = FileOpen(stringArgument->GetValue().c_str(), "rb");
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
Interface::PrintError("Failed to open file \"%s\"\n", stringArgument->GetValue().c_str());
|
Interface::PrintError("Failed to open file \"%s\"\n", stringArgument->GetValue().c_str());
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
partitionFiles.push_back(PartitionFile(argumentName.c_str(), file));
|
FileSeek(file, 0, SEEK_END);
|
||||||
|
unsigned long fileSize = (unsigned long)FileTell(file);
|
||||||
|
FileRewind(file);
|
||||||
|
|
||||||
|
partitionFiles.push_back(PartitionFile(argumentName.c_str(), file, fileSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,9 +157,7 @@ static bool sendTotalTransferSize(BridgeManager *bridgeManager, const vector<Par
|
||||||
|
|
||||||
for (vector<PartitionFile>::const_iterator it = partitionFiles.begin(); it != partitionFiles.end(); it++)
|
for (vector<PartitionFile>::const_iterator it = partitionFiles.begin(); it != partitionFiles.end(); it++)
|
||||||
{
|
{
|
||||||
FileSeek(it->file, 0, SEEK_END);
|
totalBytes += it->fileSize;
|
||||||
totalBytes += (unsigned long)FileTell(it->file);
|
|
||||||
FileRewind(it->file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repartition)
|
if (repartition)
|
||||||
|
@ -284,7 +288,7 @@ static bool flashFile(BridgeManager *bridgeManager, const PartitionFlashInfo& pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool flashPartitions(BridgeManager *bridgeManager, const vector<PartitionFile>& partitionFiles, const PitData *pitData, bool repartition)
|
static bool flashPartitions(BridgeManager *bridgeManager, const vector<PartitionFile>& partitionFiles, const PitData *pitData, bool repartition, bool skip_size_check)
|
||||||
{
|
{
|
||||||
vector<PartitionFlashInfo> partitionFlashInfos;
|
vector<PartitionFlashInfo> partitionFlashInfos;
|
||||||
|
|
||||||
|
@ -292,6 +296,28 @@ static bool flashPartitions(BridgeManager *bridgeManager, const vector<Partition
|
||||||
if (!setupPartitionFlashInfo(partitionFiles, pitData, partitionFlashInfos))
|
if (!setupPartitionFlashInfo(partitionFiles, pitData, partitionFlashInfos))
|
||||||
return (false);
|
return (false);
|
||||||
|
|
||||||
|
/* Verify that the files we want to flash fit in partitions */
|
||||||
|
if (!skip_size_check)
|
||||||
|
{
|
||||||
|
for (vector<PartitionFile>::const_iterator it = partitionFiles.begin(); it != partitionFiles.end(); it++)
|
||||||
|
{
|
||||||
|
const PitEntry *part = pitData->FindEntry(it->argumentName);
|
||||||
|
if (part->GetDeviceType() != PitEntry::kDeviceTypeMMC &&
|
||||||
|
part->GetDeviceType() != PitEntry::kDeviceTypeUFS)
|
||||||
|
continue;
|
||||||
|
unsigned long partitionSize = part->GetBlockCount();
|
||||||
|
unsigned int blockSize = 512;
|
||||||
|
if (part->GetDeviceType() == PitEntry::kDeviceTypeUFS)
|
||||||
|
blockSize = 4096;
|
||||||
|
if (partitionSize > 0 && it->fileSize > partitionSize*blockSize)
|
||||||
|
{
|
||||||
|
Interface::PrintError("%s partition is too small for given file. Use --skip-size-check to flash anyways.\n",
|
||||||
|
it->argumentName);
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we're repartitioning then we need to flash the PIT file first (if it is listed in the PIT file).
|
// If we're repartitioning then we need to flash the PIT file first (if it is listed in the PIT file).
|
||||||
if (repartition)
|
if (repartition)
|
||||||
{
|
{
|
||||||
|
@ -431,6 +457,7 @@ int FlashAction::Execute(int argc, char **argv)
|
||||||
argumentTypes["stdout-errors"] = kArgumentTypeFlag;
|
argumentTypes["stdout-errors"] = kArgumentTypeFlag;
|
||||||
argumentTypes["usb-log-level"] = kArgumentTypeString;
|
argumentTypes["usb-log-level"] = kArgumentTypeString;
|
||||||
argumentTypes["tflash"] = kArgumentTypeFlag;
|
argumentTypes["tflash"] = kArgumentTypeFlag;
|
||||||
|
argumentTypes["skip-size-check"] = kArgumentTypeFlag;
|
||||||
|
|
||||||
argumentTypes["pit"] = kArgumentTypeString;
|
argumentTypes["pit"] = kArgumentTypeString;
|
||||||
shortArgumentAliases["pit"] = "pit";
|
shortArgumentAliases["pit"] = "pit";
|
||||||
|
@ -459,6 +486,7 @@ int FlashAction::Execute(int argc, char **argv)
|
||||||
bool resume = arguments.GetArgument("resume") != nullptr;
|
bool resume = arguments.GetArgument("resume") != nullptr;
|
||||||
bool verbose = arguments.GetArgument("verbose") != nullptr;
|
bool verbose = arguments.GetArgument("verbose") != nullptr;
|
||||||
bool tflash = arguments.GetArgument("tflash") != nullptr;
|
bool tflash = arguments.GetArgument("tflash") != nullptr;
|
||||||
|
bool skip_size_check = arguments.GetArgument("skip-size-check") != nullptr;
|
||||||
|
|
||||||
if (arguments.GetArgument("stdout-errors") != nullptr)
|
if (arguments.GetArgument("stdout-errors") != nullptr)
|
||||||
Interface::SetStdoutErrors(true);
|
Interface::SetStdoutErrors(true);
|
||||||
|
@ -560,7 +588,9 @@ int FlashAction::Execute(int argc, char **argv)
|
||||||
PitData *pitData = getPitData(bridgeManager, pitFile, repartition);
|
PitData *pitData = getPitData(bridgeManager, pitFile, repartition);
|
||||||
|
|
||||||
if (pitData)
|
if (pitData)
|
||||||
success = flashPartitions(bridgeManager, partitionFiles, pitData, repartition);
|
success = flashPartitions(bridgeManager, partitionFiles,
|
||||||
|
pitData, repartition,
|
||||||
|
skip_size_check);
|
||||||
else
|
else
|
||||||
success = false;
|
success = false;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ using namespace Heimdall;
|
||||||
map<string, Interface::ActionInfo> actionMap;
|
map<string, Interface::ActionInfo> actionMap;
|
||||||
bool stdoutErrors = false;
|
bool stdoutErrors = false;
|
||||||
|
|
||||||
const char *version = "v1.4.2";
|
const char *version = "v2.0.2";
|
||||||
const char *actionUsage = "Usage: heimdall <action> <action arguments>\n";
|
const char *actionUsage = "Usage: heimdall <action> <action arguments>\n";
|
||||||
|
|
||||||
const char *releaseInfo = "Heimdall %s\n\n\
|
const char *releaseInfo = "Heimdall %s\n\n\
|
||||||
|
@ -207,16 +207,11 @@ void Interface::PrintDeviceDetectionFailed(void)
|
||||||
|
|
||||||
void Interface::PrintPit(const PitData *pitData)
|
void Interface::PrintPit(const PitData *pitData)
|
||||||
{
|
{
|
||||||
|
Interface::Print("--- PIT Header ---\n");
|
||||||
Interface::Print("Entry Count: %d\n", pitData->GetEntryCount());
|
Interface::Print("Entry Count: %d\n", pitData->GetEntryCount());
|
||||||
|
Interface::Print("Unknown string: %s\n", pitData->GetComTar2());
|
||||||
Interface::Print("Unknown 1: %d\n", pitData->GetUnknown1());
|
Interface::Print("CPU/bootloader tag: %s\n", pitData->GetCpuBlId());
|
||||||
Interface::Print("Unknown 2: %d\n", pitData->GetUnknown2());
|
Interface::Print("Logic unit count: %d\n", pitData->GetLUCount());
|
||||||
Interface::Print("Unknown 3: %d\n", pitData->GetUnknown3());
|
|
||||||
Interface::Print("Unknown 4: %d\n", pitData->GetUnknown4());
|
|
||||||
Interface::Print("Unknown 5: %d\n", pitData->GetUnknown5());
|
|
||||||
Interface::Print("Unknown 6: %d\n", pitData->GetUnknown6());
|
|
||||||
Interface::Print("Unknown 7: %d\n", pitData->GetUnknown7());
|
|
||||||
Interface::Print("Unknown 8: %d\n", pitData->GetUnknown8());
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pitData->GetEntryCount(); i++)
|
for (unsigned int i = 0; i < pitData->GetEntryCount(); i++)
|
||||||
{
|
{
|
||||||
|
@ -262,6 +257,10 @@ void Interface::PrintPit(const PitData *pitData)
|
||||||
Interface::Print("All (?)");
|
Interface::Print("All (?)");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PitEntry::kDeviceTypeUFS:
|
||||||
|
Interface::Print("UFS");
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Interface::Print("Unknown");
|
Interface::Print("Unknown");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace Heimdall
|
||||||
memset(data, 0, size);
|
memset(data, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Packet()
|
virtual ~Packet()
|
||||||
{
|
{
|
||||||
delete [] data;
|
delete [] data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,17 +66,10 @@ PitData::PitData()
|
||||||
{
|
{
|
||||||
entryCount = 0;
|
entryCount = 0;
|
||||||
|
|
||||||
unknown1 = 0;
|
com_tar2[0] = '\0';
|
||||||
unknown2 = 0;
|
cpu_bl_id[0] = '\0';
|
||||||
|
|
||||||
unknown3 = 0;
|
luCount = 0;
|
||||||
unknown4 = 0;
|
|
||||||
|
|
||||||
unknown5 = 0;
|
|
||||||
unknown6 = 0;
|
|
||||||
|
|
||||||
unknown7 = 0;
|
|
||||||
unknown8 = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PitData::~PitData()
|
PitData::~PitData()
|
||||||
|
@ -98,17 +91,14 @@ bool PitData::Unpack(const unsigned char *data)
|
||||||
|
|
||||||
entries.resize(entryCount);
|
entries.resize(entryCount);
|
||||||
|
|
||||||
unknown1 = PitData::UnpackInteger(data, 8);
|
if (!memcpy(com_tar2, &data[8], 8))
|
||||||
unknown2 = PitData::UnpackInteger(data, 12);
|
return (false);
|
||||||
|
com_tar2[8]='\0';
|
||||||
|
if (!memcpy(cpu_bl_id, &data[16], 8))
|
||||||
|
return (false);
|
||||||
|
cpu_bl_id[8]='\0';
|
||||||
|
|
||||||
unknown3 = PitData::UnpackShort(data, 16);
|
luCount = PitData::UnpackShort(data, 24);
|
||||||
unknown4 = PitData::UnpackShort(data, 18);
|
|
||||||
|
|
||||||
unknown5 = PitData::UnpackShort(data, 20);
|
|
||||||
unknown6 = PitData::UnpackShort(data, 22);
|
|
||||||
|
|
||||||
unknown7 = PitData::UnpackShort(data, 24);
|
|
||||||
unknown8 = PitData::UnpackShort(data, 26);
|
|
||||||
|
|
||||||
unsigned int integerValue;
|
unsigned int integerValue;
|
||||||
unsigned int entryOffset;
|
unsigned int entryOffset;
|
||||||
|
@ -160,17 +150,10 @@ void PitData::Pack(unsigned char *data) const
|
||||||
|
|
||||||
PitData::PackInteger(data, 4, entryCount);
|
PitData::PackInteger(data, 4, entryCount);
|
||||||
|
|
||||||
PitData::PackInteger(data, 8, unknown1);
|
memcpy(&data[8], com_tar2, 8);
|
||||||
PitData::PackInteger(data, 12, unknown2);
|
memcpy(&data[16], cpu_bl_id, 8);
|
||||||
|
|
||||||
PitData::PackShort(data, 16, unknown3);
|
PitData::PackShort(data, 24, luCount);
|
||||||
PitData::PackShort(data, 18, unknown4);
|
|
||||||
|
|
||||||
PitData::PackShort(data, 20, unknown5);
|
|
||||||
PitData::PackShort(data, 22, unknown6);
|
|
||||||
|
|
||||||
PitData::PackShort(data, 24, unknown7);
|
|
||||||
PitData::PackShort(data, 26, unknown8);
|
|
||||||
|
|
||||||
int entryOffset;
|
int entryOffset;
|
||||||
|
|
||||||
|
@ -201,9 +184,10 @@ void PitData::Pack(unsigned char *data) const
|
||||||
|
|
||||||
bool PitData::Matches(const PitData *otherPitData) const
|
bool PitData::Matches(const PitData *otherPitData) const
|
||||||
{
|
{
|
||||||
if (entryCount == otherPitData->entryCount && unknown1 == otherPitData->unknown1 && unknown2 == otherPitData->unknown2
|
if (entryCount == otherPitData->entryCount &&
|
||||||
&& unknown3 == otherPitData->unknown3 && unknown4 == otherPitData->unknown4 && unknown5 == otherPitData->unknown5
|
(strncmp(com_tar2, otherPitData->com_tar2, 8) == 0) &&
|
||||||
&& unknown6 == otherPitData->unknown6 && unknown7 == otherPitData->unknown7 && unknown8 == otherPitData->unknown8)
|
(strncmp(cpu_bl_id, otherPitData->cpu_bl_id, 8) == 0) &&
|
||||||
|
luCount == otherPitData->luCount)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < entryCount; i++)
|
for (unsigned int i = 0; i < entryCount; i++)
|
||||||
{
|
{
|
||||||
|
@ -223,17 +207,11 @@ void PitData::Clear(void)
|
||||||
{
|
{
|
||||||
entryCount = 0;
|
entryCount = 0;
|
||||||
|
|
||||||
unknown1 = 0;
|
com_tar2[0] = '\0';
|
||||||
unknown2 = 0;
|
|
||||||
|
|
||||||
unknown3 = 0;
|
cpu_bl_id[0] = '\0';
|
||||||
unknown4 = 0;
|
|
||||||
|
|
||||||
unknown5 = 0;
|
luCount = 0;
|
||||||
unknown6 = 0;
|
|
||||||
|
|
||||||
unknown7 = 0;
|
|
||||||
unknown8 = 0;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < entries.size(); i++)
|
for (unsigned int i = 0; i < entries.size(); i++)
|
||||||
delete entries[i];
|
delete entries[i];
|
||||||
|
|
|
@ -61,14 +61,15 @@ namespace libpit
|
||||||
kDeviceTypeOneNand = 0,
|
kDeviceTypeOneNand = 0,
|
||||||
kDeviceTypeFile, // FAT
|
kDeviceTypeFile, // FAT
|
||||||
kDeviceTypeMMC,
|
kDeviceTypeMMC,
|
||||||
kDeviceTypeAll // ?
|
kDeviceTypeAll, // ?
|
||||||
|
kDeviceTypeUFS = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
kAttributeWrite = 1,
|
kAttributeWrite = 1,
|
||||||
kAttributeSTL = 1 << 1/*,
|
kAttributeSTL = 1 << 1
|
||||||
kAttributeBML = 1 << 2*/ // ???
|
/* kAttributeBML = 1 << 2 */ // ???
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -261,17 +262,11 @@ namespace libpit
|
||||||
private:
|
private:
|
||||||
|
|
||||||
unsigned int entryCount; // 0x04
|
unsigned int entryCount; // 0x04
|
||||||
unsigned int unknown1; // 0x08
|
char com_tar2[8+1]; // 0x08
|
||||||
unsigned int unknown2; // 0x0C
|
|
||||||
|
|
||||||
unsigned short unknown3; // 0x10
|
char cpu_bl_id[8+1]; // 0x10
|
||||||
unsigned short unknown4; // 0x12
|
|
||||||
|
|
||||||
unsigned short unknown5; // 0x14
|
unsigned short luCount; // 0x18
|
||||||
unsigned short unknown6; // 0x16
|
|
||||||
|
|
||||||
unsigned short unknown7; // 0x18
|
|
||||||
unsigned short unknown8; // 0x1A
|
|
||||||
|
|
||||||
// Entries start at 0x1C
|
// Entries start at 0x1C
|
||||||
std::vector<PitEntry *> entries;
|
std::vector<PitEntry *> entries;
|
||||||
|
@ -370,44 +365,19 @@ namespace libpit
|
||||||
return paddedSize;
|
return paddedSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetUnknown1(void) const
|
const char * GetComTar2(void) const
|
||||||
{
|
{
|
||||||
return unknown1;
|
return com_tar2;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetUnknown2(void) const
|
const char * GetCpuBlId(void) const
|
||||||
{
|
{
|
||||||
return unknown2;
|
return cpu_bl_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short GetUnknown3(void) const
|
unsigned int GetLUCount(void) const
|
||||||
{
|
{
|
||||||
return unknown3;
|
return luCount;
|
||||||
}
|
|
||||||
|
|
||||||
unsigned short GetUnknown4(void) const
|
|
||||||
{
|
|
||||||
return unknown4;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned short GetUnknown5(void) const
|
|
||||||
{
|
|
||||||
return unknown5;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned short GetUnknown6(void) const
|
|
||||||
{
|
|
||||||
return unknown6;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned short GetUnknown7(void) const
|
|
||||||
{
|
|
||||||
return unknown7;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned short GetUnknown8(void) const
|
|
||||||
{
|
|
||||||
return unknown8;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue