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
5 changed files with 23 additions and 23 deletions

View File

@ -114,7 +114,7 @@
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;">
<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="-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>

View File

@ -116,16 +116,16 @@ static bool openFiles(Arguments& arguments, vector<PartitionFile>& partitionFile
{
const StringArgument *stringArgument = static_cast<const StringArgument *>(*it);
FILE *file = FileOpen(stringArgument->GetValue().c_str(), "rb");
FileSeek(file, 0, SEEK_END);
unsigned long fileSize = (unsigned long)FileTell(file);
FileRewind(file);
if (!file)
{
Interface::PrintError("Failed to open file \"%s\"\n", stringArgument->GetValue().c_str());
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));
}
}
@ -303,11 +303,11 @@ static bool flashPartitions(BridgeManager *bridgeManager, const vector<Partition
{
const PitEntry *part = pitData->FindEntry(it->argumentName);
if (part->GetDeviceType() != PitEntry::kDeviceTypeMMC &&
part->GetDeviceType() != PitEntry::kDeviceTypeMMC4096)
part->GetDeviceType() != PitEntry::kDeviceTypeUFS)
continue;
unsigned long partitionSize = part->GetBlockCount();
unsigned int blockSize = 512;
if (part->GetDeviceType() == PitEntry::kDeviceTypeMMC4096)
if (part->GetDeviceType() == PitEntry::kDeviceTypeUFS)
blockSize = 4096;
if (partitionSize > 0 && it->fileSize > partitionSize*blockSize)
{

View File

@ -42,7 +42,7 @@ using namespace Heimdall;
map<string, Interface::ActionInfo> actionMap;
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 *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("Unknown string: %s\n", pitData->GetComTar2());
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++)
{
@ -257,8 +257,8 @@ void Interface::PrintPit(const PitData *pitData)
Interface::Print("All (?)");
break;
case PitEntry::kDeviceTypeMMC4096:
Interface::Print("MMC 4096");
case PitEntry::kDeviceTypeUFS:
Interface::Print("UFS");
break;
default:

View File

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

View File

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