From e916c679ed04f5ba44cc5a9cbf340c8bf96b92fb Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Sat, 1 Jan 2022 20:31:32 +0100 Subject: [PATCH] PIT: unknown version in PIT header has to be protocol version And in that case there now exists a fifth version of the Odin protocol, seen on Galaxy S9 and newer. In total we have seen these versions (as of January 2022): * 0, on devices from around 2014 or older * 3, on devices from around 2015 * 4, on devices from around 2016 - 2017 * 5, on devices from around 2018 or newer --- heimdall/source/Interface.cpp | 2 +- libpit/source/libpit.cpp | 10 +++++----- libpit/source/libpit.h | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/heimdall/source/Interface.cpp b/heimdall/source/Interface.cpp index ecaefd2..057718d 100644 --- a/heimdall/source/Interface.cpp +++ b/heimdall/source/Interface.cpp @@ -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("Version(?): 0x%04x\n", pitData->GetUnknown()); + Interface::Print("Protocol version: 0x%04x\n", pitData->GetProtocolVersion()); for (unsigned int i = 0; i < pitData->GetEntryCount(); i++) { diff --git a/libpit/source/libpit.cpp b/libpit/source/libpit.cpp index e372a91..a6799e6 100644 --- a/libpit/source/libpit.cpp +++ b/libpit/source/libpit.cpp @@ -69,7 +69,7 @@ PitData::PitData() com_tar2[0] = '\0'; cpu_bl_id[0] = '\0'; - unknown_version = 0; + protocol_version = 0; } PitData::~PitData() @@ -98,7 +98,7 @@ bool PitData::Unpack(const unsigned char *data) return (false); cpu_bl_id[8]='\0'; - unknown_version = PitData::UnpackShort(data, 24); + protocol_version = 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, unknown_version); + PitData::PackShort(data, 24, protocol_version); 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) && - unknown_version == otherPitData->unknown_version) + protocol_version == otherPitData->protocol_version) { for (unsigned int i = 0; i < entryCount; i++) { @@ -211,7 +211,7 @@ void PitData::Clear(void) cpu_bl_id[0] = '\0'; - unknown_version = 0; + protocol_version = 0; for (unsigned int i = 0; i < entries.size(); i++) delete entries[i]; diff --git a/libpit/source/libpit.h b/libpit/source/libpit.h index 0faac39..e900237 100644 --- a/libpit/source/libpit.h +++ b/libpit/source/libpit.h @@ -261,12 +261,12 @@ namespace libpit private: - unsigned int entryCount; // 0x04 - char com_tar2[8+1]; // 0x08 + unsigned int entryCount; // 0x04 + char com_tar2[8+1]; // 0x08 - char cpu_bl_id[8+1]; // 0x10 + char cpu_bl_id[8+1]; // 0x10 - unsigned short unknown_version; // 0x18 + unsigned short protocol_version; // 0x18 // Entries start at 0x1C std::vector entries; @@ -375,9 +375,9 @@ namespace libpit return cpu_bl_id; } - unsigned int GetUnknown(void) const + unsigned int GetProtocolVersion(void) const { - return unknown_version; + return protocol_version; } }; }