Skip to content

Commit b64356e

Browse files
authored
Remove buffer fill in dfu upload (#32)
1 parent c047262 commit b64356e

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

source/nanoFirmwareFlasher/StDfu.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ private static void EraseSector(
855855
returnValue = STDFU_GetStatus(ref hDevice, ref dfuStatus);
856856
}
857857

858-
if (dfuStatus.bState != STDFU_NOERROR)
858+
if (returnValue != STDFU_NOERROR)
859859
{
860860
throw new DownloadException("STDFU_Dnload returned " + returnValue.ToString("X8"));
861861
}
@@ -934,10 +934,10 @@ internal static void WriteBlock(
934934

935935
returnValue = STDFU_Dnload(ref hDevice, data, (uint)data.Length, (ushort)(blockNumber + 2));
936936

937-
if (STDFU_GetStatus(ref hDevice, ref dfuStatus) != STATE_DFU_DOWNLOAD_BUSY)
937+
STDFU_GetStatus(ref hDevice, ref dfuStatus);
938+
if (dfuStatus.bState != STATE_DFU_DOWNLOAD_BUSY)
938939
{
939940
throw new DownloadException("STDFU_Dnload returned " + returnValue.ToString("X8"));
940-
941941
}
942942

943943
while (dfuStatus.bState != STATE_DFU_IDLE)

source/nanoFirmwareFlasher/StmDfuDevice.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,6 @@ public void FlashDfuFile(string filePath)
247247
// grab data for write and store it into a 2048 byte buffer
248248
byte[] buffer = dfuElement.Data.Skip((int)(_maxWriteBlockSize * blockNumber)).Take(_maxWriteBlockSize).ToArray();
249249

250-
if (buffer.Length < _maxWriteBlockSize)
251-
{
252-
var i = buffer.Length;
253-
Array.Resize(ref buffer, _maxWriteBlockSize);
254-
255-
// Pad with 0xFF so our CRC matches the ST Bootloader and STLink's CRC
256-
for (; i < _maxWriteBlockSize; i++)
257-
{
258-
buffer[i] = 0xFF;
259-
}
260-
}
261-
262250
StDfu.WriteBlock(_hDevice, dfuElement.Address, buffer, blockNumber);
263251
}
264252
}

0 commit comments

Comments
 (0)