Skip to content

Commit ee1263c

Browse files
authored
Merge pull request #34 from nanoframework/release-v1.12.1
Release release-v1.12.1
2 parents ecd4665 + 2e99970 commit ee1263c

File tree

8 files changed

+50
-25
lines changed

8 files changed

+50
-25
lines changed

source/nanoFirmwareFlasher.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ VisualStudioVersion = 16.0.29806.167
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nanoFirmwareFlasher", "nanoFirmwareFlasher\nanoFirmwareFlasher.csproj", "{762BA2A1-B3E9-4E26-9491-AE11D1F1C1EA}"
77
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9FD8C426-A16A-49DB-952D-747C3AD96C42}"
9+
ProjectSection(SolutionItems) = preProject
10+
NuGet.Config = NuGet.Config
11+
version.json = version.json
12+
EndProjectSection
13+
EndProject
814
Global
915
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1016
Debug|x64 = Debug|x64

source/nanoFirmwareFlasher/EspTool.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ internal EspTool(
163163
test.Open();
164164
test.Close();
165165
}
166-
catch(IOException)
166+
catch
167167
{
168-
// presume any IOException here is caused by the serial not existing or not possible to open
169-
return;
168+
// presume any exception here is caused by the serial not existing or not possible to open
169+
throw new EspToolExecutionException();
170170
}
171171
}
172172

source/nanoFirmwareFlasher/Exceptions/EspToolExecutionException.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ internal class EspToolExecutionException : Exception
1919
/// </summary>
2020
public string ExecutionError;
2121

22+
public EspToolExecutionException() : base()
23+
{
24+
25+
}
26+
2227
public EspToolExecutionException(string message) : base(message)
2328
{
2429
ExecutionError = message;

source/nanoFirmwareFlasher/ExitCodes.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public enum ExitCodes : int
7777
[Display(Name = "Failed to read from ESP32 flash.")]
7878
E4004 = 4004,
7979

80+
/// <summary>
81+
/// Can't open COM port.
82+
/// </summary>
83+
[Display(Name = "Failed to open specified COM port.")]
84+
E4005 = 4005,
8085

8186
////////////////////
8287
// ST Link Errors //

source/nanoFirmwareFlasher/Program.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,22 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
220220
_exitCode = ExitCodes.E6001;
221221
return;
222222
}
223+
224+
EspTool espTool;
223225

224-
var espTool = new EspTool(
225-
o.SerialPort,
226-
o.BaudRate,
227-
o.Esp32FlashMode,
228-
o.Esp32FlashFrequency);
226+
try
227+
{
228+
espTool = new EspTool(
229+
o.SerialPort,
230+
o.BaudRate,
231+
o.Esp32FlashMode,
232+
o.Esp32FlashFrequency);
233+
}
234+
catch(Exception)
235+
{
236+
_exitCode = ExitCodes.E4005;
237+
return;
238+
}
229239

230240
EspTool.DeviceInfo esp32Device;
231241

source/nanoFirmwareFlasher/StDfu.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,12 @@ private static void EraseSector(
852852
while (dfuStatus.bState != STATE_DFU_IDLE)
853853
{
854854
STDFU_ClrStatus(ref hDevice);
855-
STDFU_GetStatus(ref hDevice, ref dfuStatus);
855+
returnValue = STDFU_GetStatus(ref hDevice, ref dfuStatus);
856+
}
857+
858+
if (returnValue != STDFU_NOERROR)
859+
{
860+
throw new DownloadException("STDFU_Dnload returned " + returnValue.ToString("X8"));
856861
}
857862
}
858863
else
@@ -912,23 +917,29 @@ internal static void WriteBlock(
912917
byte[] data,
913918
uint blockNumber)
914919
{
920+
uint returnValue;
915921
DfuStatus dfuStatus = new DfuStatus();
916922

917923
if (0 == blockNumber)
918924
{
919925
SetAddressPointer(hDevice, address);
920926
}
921927

922-
STDFU_GetStatus(ref hDevice, ref dfuStatus);
928+
returnValue = STDFU_GetStatus(ref hDevice, ref dfuStatus);
923929
while (dfuStatus.bState != STATE_DFU_IDLE)
924930
{
925931
STDFU_ClrStatus(ref hDevice);
926932
STDFU_GetStatus(ref hDevice, ref dfuStatus);
927933
}
928934

929-
STDFU_Dnload(ref hDevice, data, (uint)data.Length, (ushort)(blockNumber + 2));
935+
returnValue = STDFU_Dnload(ref hDevice, data, (uint)data.Length, (ushort)(blockNumber + 2));
930936

931937
STDFU_GetStatus(ref hDevice, ref dfuStatus);
938+
if (dfuStatus.bState != STATE_DFU_DOWNLOAD_BUSY)
939+
{
940+
throw new DownloadException("STDFU_Dnload returned " + returnValue.ToString("X8"));
941+
}
942+
932943
while (dfuStatus.bState != STATE_DFU_IDLE)
933944
{
934945
STDFU_ClrStatus(ref hDevice);

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
}

source/version.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "1.11.0",
2+
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3+
"version": "1.12.1",
44
"assemblyVersion": {
55
"precision": "revision"
66
},

0 commit comments

Comments
 (0)