From af22227142e987f460d552b1879fbde94e5e4554 Mon Sep 17 00:00:00 2001 From: Gus Date: Tue, 9 Apr 2019 13:06:38 +0200 Subject: [PATCH] Fixed #1 --- FlashingPayloadGenerator.cs | 9 +++++++-- Img2Ffu.csproj | 1 - StoreHeader.cs | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/FlashingPayloadGenerator.cs b/FlashingPayloadGenerator.cs index d7b163f..6b8229c 100644 --- a/FlashingPayloadGenerator.cs +++ b/FlashingPayloadGenerator.cs @@ -86,7 +86,12 @@ internal static FlashingPayload[] GetOptimizedPayloads(FlashPart[] flashParts, U flashPart.Stream.Read(buffer, 0, (Int32)chunkSize); byte[] hash = crypto.ComputeHash(buffer); - if (flashingPayloads.Any(x => ByteOperations.Compare(x.ChunkHashes.First(), hash))) + byte[] emptyness = new byte[] { 0xFA, 0x43, 0x23, 0x9B, 0xCE, 0xE7, 0xB9, 0x7C, 0xA6, 0x2F, 0x00, 0x7C, 0xC6, 0x84, 0x87, 0x56, 0x0A, 0x39, 0xE1, 0x9F, 0x74, 0xF3, 0xDD, 0xE7, 0x48, 0x6D, 0xB3, 0xF9, 0x8D, 0xF8, 0xE4, 0x71 }; + + if (!ByteOperations.Compare(emptyness, hash)) + flashingPayloads.Add(new FlashingPayload(1, new byte[][] { hash }, new UInt32[] { ((UInt32)flashPart.StartLocation / chunkSize) + i }, new UInt32[] { j }, new Int64[] { position })); + + /*if (flashingPayloads.Any(x => ByteOperations.Compare(x.ChunkHashes.First(), hash))) { var payloadIndex = flashingPayloads.FindIndex(x => ByteOperations.Compare(x.ChunkHashes.First(), hash)); var locationList = flashingPayloads[payloadIndex].TargetLocations.ToList(); @@ -96,7 +101,7 @@ internal static FlashingPayload[] GetOptimizedPayloads(FlashPart[] flashParts, U else { flashingPayloads.Add(new FlashingPayload(1, new byte[][] { hash }, new UInt32[] { ((UInt32)flashPart.StartLocation / chunkSize) + i }, new UInt32[] { j }, new Int64[] { position })); - } + }*/ CurrentProcess1++; ShowProgress(CurrentProcess1, TotalProcess1, startTime); diff --git a/Img2Ffu.csproj b/Img2Ffu.csproj index 2034274..3cd9b1e 100644 --- a/Img2Ffu.csproj +++ b/Img2Ffu.csproj @@ -71,7 +71,6 @@ - diff --git a/StoreHeader.cs b/StoreHeader.cs index 17a0624..fa8934c 100644 --- a/StoreHeader.cs +++ b/StoreHeader.cs @@ -43,10 +43,10 @@ public class StoreHeader public UInt32 ValidateDescriptorCount = 0; public UInt32 ValidateDescriptorLength = 0; public UInt32 InitialTableIndex = 0; - public UInt32 InitialTableCount = 1; + public UInt32 InitialTableCount = 0; public UInt32 FlashOnlyTableIndex = 0; // Should be the index of the critical partitions, but for now we don't implement that - public UInt32 FlashOnlyTableCount = 1; + public UInt32 FlashOnlyTableCount = 0; public UInt32 FinalTableIndex; //= WriteDescriptorCount - FinalTableCount; - public UInt32 FinalTableCount = 2; + public UInt32 FinalTableCount = 0; } }