Compare commits

..

5 Commits

Author SHA1 Message Date
Henrik Grimler 02b577ec77
v2.0.2
* Fix segfault when file to flash does not exist

* Rename some fields in the flashing protocol, MMC4096 seem to be UFS,
  and what I thought was the protocol number seem to be the number of
  logical units in the storage
2022-07-12 17:42:55 +02:00
Henrik Grimler 14f3521a6b
FlashAction: fix FileOpen check
Check needs to be right after it is opened, before we try to seek in
it.  Before this fix, heimdall segfaults if file does not exist.

Fixes commit 60ab9bbaff ("FlashAction: Make sure file fit partition
before flashing")
2022-07-12 17:23:21 +02:00
Henrik Grimler 0cf817a591
libpit: MMC4096 is really UFS
Change name to better describe the hardware.
2022-05-04 13:12:31 +02:00
Henrik Grimler c3516307d2
libpit: last number in PIT header is the "LUN count"
Where LUN probably stands for Logical Unit Number.  Previous
assumption that it was the odin protocol version was wrong, so let's
fix this.
2022-05-04 13:12:28 +02:00
Henrik Grimler f6c4698c8b
Revert "PIT: unknown version in PIT header has to be protocol version"
This assumption was wrong.  The number is really the number of logical
units in the storage, which tends to increase over time as the storage
space is increased I suppose.

This reverts commit e916c679ed.
2022-05-04 13:11:18 +02:00
6 changed files with 29 additions and 32 deletions

View File

@ -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 2.0.1</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>

View File

@ -1088,15 +1088,12 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int
delete sendFilePartResponse; delete sendFilePartResponse;
if (filePartIndex == 0) if (!success)
{ {
// Hack Interface::PrintErrorSameLine("\n");
success = true; Interface::PrintError("Failed to receive file part response!\n");
receivedPartIndex = filePartIndex;
} for (int retry = 0; retry < 4; retry++)
else
{
for (int retry = 0; retry < 4; ++retry)
{ {
Interface::PrintErrorSameLine("\n"); Interface::PrintErrorSameLine("\n");
Interface::PrintError("Retrying..."); Interface::PrintError("Retrying...");
@ -1109,7 +1106,7 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int
if (!success) if (!success)
{ {
Interface::PrintErrorSameLine("\n"); Interface::PrintErrorSameLine("\n");
Interface::PrintError("Failed to send file part packet 2!\n"); Interface::PrintError("Failed to send file part packet!\n");
return (false); return (false);
} }

View File

@ -116,16 +116,16 @@ 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");
FileSeek(file, 0, SEEK_END);
unsigned long fileSize = (unsigned long)FileTell(file);
FileRewind(file);
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);
} }
FileSeek(file, 0, SEEK_END);
unsigned long fileSize = (unsigned long)FileTell(file);
FileRewind(file);
partitionFiles.push_back(PartitionFile(argumentName.c_str(), file, fileSize)); partitionFiles.push_back(PartitionFile(argumentName.c_str(), file, fileSize));
} }
} }
@ -303,11 +303,11 @@ static bool flashPartitions(BridgeManager *bridgeManager, const vector<Partition
{ {
const PitEntry *part = pitData->FindEntry(it->argumentName); const PitEntry *part = pitData->FindEntry(it->argumentName);
if (part->GetDeviceType() != PitEntry::kDeviceTypeMMC && if (part->GetDeviceType() != PitEntry::kDeviceTypeMMC &&
part->GetDeviceType() != PitEntry::kDeviceTypeMMC4096) part->GetDeviceType() != PitEntry::kDeviceTypeUFS)
continue; continue;
unsigned long partitionSize = part->GetBlockCount(); unsigned long partitionSize = part->GetBlockCount();
unsigned int blockSize = 512; unsigned int blockSize = 512;
if (part->GetDeviceType() == PitEntry::kDeviceTypeMMC4096) if (part->GetDeviceType() == PitEntry::kDeviceTypeUFS)
blockSize = 4096; blockSize = 4096;
if (partitionSize > 0 && it->fileSize > partitionSize*blockSize) if (partitionSize > 0 && it->fileSize > partitionSize*blockSize)
{ {

View File

@ -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 = "v2.0.1"; 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\
@ -211,7 +211,7 @@ void Interface::PrintPit(const PitData *pitData)
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 string: %s\n", pitData->GetComTar2());
Interface::Print("CPU/bootloader tag: %s\n", pitData->GetCpuBlId()); Interface::Print("CPU/bootloader tag: %s\n", pitData->GetCpuBlId());
Interface::Print("Protocol version: 0x%04x\n", pitData->GetProtocolVersion()); Interface::Print("Logic unit count: %d\n", pitData->GetLUCount());
for (unsigned int i = 0; i < pitData->GetEntryCount(); i++) for (unsigned int i = 0; i < pitData->GetEntryCount(); i++)
{ {
@ -257,8 +257,8 @@ void Interface::PrintPit(const PitData *pitData)
Interface::Print("All (?)"); Interface::Print("All (?)");
break; break;
case PitEntry::kDeviceTypeMMC4096: case PitEntry::kDeviceTypeUFS:
Interface::Print("MMC 4096"); Interface::Print("UFS");
break; break;
default: default:

View File

@ -69,7 +69,7 @@ PitData::PitData()
com_tar2[0] = '\0'; com_tar2[0] = '\0';
cpu_bl_id[0] = '\0'; cpu_bl_id[0] = '\0';
protocol_version = 0; luCount = 0;
} }
PitData::~PitData() PitData::~PitData()
@ -98,7 +98,7 @@ bool PitData::Unpack(const unsigned char *data)
return (false); return (false);
cpu_bl_id[8]='\0'; cpu_bl_id[8]='\0';
protocol_version = PitData::UnpackShort(data, 24); luCount = PitData::UnpackShort(data, 24);
unsigned int integerValue; unsigned int integerValue;
unsigned int entryOffset; unsigned int entryOffset;
@ -153,7 +153,7 @@ void PitData::Pack(unsigned char *data) const
memcpy(&data[8], com_tar2, 8); memcpy(&data[8], com_tar2, 8);
memcpy(&data[16], cpu_bl_id, 8); memcpy(&data[16], cpu_bl_id, 8);
PitData::PackShort(data, 24, protocol_version); PitData::PackShort(data, 24, luCount);
int entryOffset; int entryOffset;
@ -187,7 +187,7 @@ bool PitData::Matches(const PitData *otherPitData) const
if (entryCount == otherPitData->entryCount && if (entryCount == otherPitData->entryCount &&
(strncmp(com_tar2, otherPitData->com_tar2, 8) == 0) && (strncmp(com_tar2, otherPitData->com_tar2, 8) == 0) &&
(strncmp(cpu_bl_id, otherPitData->cpu_bl_id, 8) == 0) && (strncmp(cpu_bl_id, otherPitData->cpu_bl_id, 8) == 0) &&
protocol_version == otherPitData->protocol_version) luCount == otherPitData->luCount)
{ {
for (unsigned int i = 0; i < entryCount; i++) for (unsigned int i = 0; i < entryCount; i++)
{ {
@ -211,7 +211,7 @@ void PitData::Clear(void)
cpu_bl_id[0] = '\0'; cpu_bl_id[0] = '\0';
protocol_version = 0; luCount = 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];

View File

@ -62,7 +62,7 @@ namespace libpit
kDeviceTypeFile, // FAT kDeviceTypeFile, // FAT
kDeviceTypeMMC, kDeviceTypeMMC,
kDeviceTypeAll, // ? kDeviceTypeAll, // ?
kDeviceTypeMMC4096 = 8 // block size 4096 kDeviceTypeUFS = 8
}; };
enum enum
@ -261,12 +261,12 @@ namespace libpit
private: private:
unsigned int entryCount; // 0x04 unsigned int entryCount; // 0x04
char com_tar2[8+1]; // 0x08 char com_tar2[8+1]; // 0x08
char cpu_bl_id[8+1]; // 0x10 char cpu_bl_id[8+1]; // 0x10
unsigned short protocol_version; // 0x18 unsigned short luCount; // 0x18
// Entries start at 0x1C // Entries start at 0x1C
std::vector<PitEntry *> entries; std::vector<PitEntry *> entries;
@ -375,9 +375,9 @@ namespace libpit
return cpu_bl_id; return cpu_bl_id;
} }
unsigned int GetProtocolVersion(void) const unsigned int GetLUCount(void) const
{ {
return protocol_version; return luCount;
} }
}; };
} }