mirror of
https://github.com/MobileTooling/UnifiedFlashingPlatform.git
synced 2026-07-27 12:48:47 -07:00
fix: ffu flash algo
This commit is contained in:
@@ -219,7 +219,7 @@ namespace UnifiedFlashingPlatform
|
|||||||
|
|
||||||
const string Header = "NOKXFS";
|
const string Header = "NOKXFS";
|
||||||
Buffer.BlockCopy(System.Text.Encoding.ASCII.GetBytes(Header), 0, Request, 0, Header.Length);
|
Buffer.BlockCopy(System.Text.Encoding.ASCII.GetBytes(Header), 0, Request, 0, Header.Length);
|
||||||
Buffer.BlockCopy(BigEndian.GetBytes((int)FfuProtocol.ProtocolSyncV2, 2), 0, Request, 0x06, 2); // Protocol version = 0x0001
|
Buffer.BlockCopy(BigEndian.GetBytes((int)FfuProtocol.ProtocolAsyncV1, 2), 0, Request, 0x06, 2); // Protocol version = 0x0001
|
||||||
Request[0x08] = 0; // Progress = 0%
|
Request[0x08] = 0; // Progress = 0%
|
||||||
Request[0x0B] = 1; // Subblock count = 1
|
Request[0x0B] = 1; // Subblock count = 1
|
||||||
|
|
||||||
@@ -440,10 +440,6 @@ namespace UnifiedFlashingPlatform
|
|||||||
|
|
||||||
FfuFile.Seek(position, SeekOrigin.Begin);
|
FfuFile.Seek(position, SeekOrigin.Begin);
|
||||||
|
|
||||||
byte[] FfuHeader = new byte[CombinedFFUHeaderSize];
|
|
||||||
FfuFile.Read(FfuHeader, 0, (int)CombinedFFUHeaderSize);
|
|
||||||
SendFfuHeaderV1(FfuHeader, Options);
|
|
||||||
|
|
||||||
ulong Position = CombinedFFUHeaderSize;
|
ulong Position = CombinedFFUHeaderSize;
|
||||||
byte[] Payload;
|
byte[] Payload;
|
||||||
int ChunkCount = 0;
|
int ChunkCount = 0;
|
||||||
@@ -451,6 +447,10 @@ namespace UnifiedFlashingPlatform
|
|||||||
if ((Info.SecureFfuSupportedProtocolMask & (ushort)FfuProtocol.ProtocolSyncV2) == 0)
|
if ((Info.SecureFfuSupportedProtocolMask & (ushort)FfuProtocol.ProtocolSyncV2) == 0)
|
||||||
{
|
{
|
||||||
// Protocol v1
|
// Protocol v1
|
||||||
|
byte[] FfuHeader = new byte[CombinedFFUHeaderSize];
|
||||||
|
FfuFile.Read(FfuHeader, 0, (int)CombinedFFUHeaderSize);
|
||||||
|
SendFfuHeaderV1(FfuHeader, Options);
|
||||||
|
|
||||||
Payload = new byte[chunkSize];
|
Payload = new byte[chunkSize];
|
||||||
|
|
||||||
while (Position < (ulong)FfuFile.Length)
|
while (Position < (ulong)FfuFile.Length)
|
||||||
@@ -466,6 +466,23 @@ namespace UnifiedFlashingPlatform
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Protocol v2
|
// Protocol v2
|
||||||
|
byte[] FfuHeader = new byte[Info.WriteBufferSize];
|
||||||
|
|
||||||
|
uint HeaderPosition = 0;
|
||||||
|
while (HeaderPosition < CombinedFFUHeaderSize)
|
||||||
|
{
|
||||||
|
uint PayloadSize = Info.WriteBufferSize;
|
||||||
|
if ((CombinedFFUHeaderSize - Position) < PayloadSize)
|
||||||
|
{
|
||||||
|
PayloadSize = (uint)(CombinedFFUHeaderSize - Position);
|
||||||
|
FfuHeader = new byte[PayloadSize];
|
||||||
|
}
|
||||||
|
|
||||||
|
FfuFile.Read(FfuHeader, 0, (int)PayloadSize);
|
||||||
|
SendFfuHeaderV2((uint)CombinedFFUHeaderSize, HeaderPosition, FfuHeader, Options);
|
||||||
|
HeaderPosition += PayloadSize;
|
||||||
|
}
|
||||||
|
|
||||||
Payload = new byte[Info.WriteBufferSize];
|
Payload = new byte[Info.WriteBufferSize];
|
||||||
|
|
||||||
while (Position < (ulong)FfuFile.Length)
|
while (Position < (ulong)FfuFile.Length)
|
||||||
|
|||||||
Reference in New Issue
Block a user