Skip to content

Commit 0b69689

Browse files
Merge branch 'main' into test-pipeline-build
2 parents a13595f + 0d2f7b4 commit 0b69689

19 files changed

+44
-86
lines changed

nanoFirmwareFlasher.Library/CC13x26x2Firmware.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// See LICENSE file in the project root for full license information.
44
//
55

6-
using System.IO;
7-
using System.Linq;
8-
96
namespace nanoFramework.Tools.FirmwareFlasher
107
{
118
/// <summary>

nanoFirmwareFlasher.Library/CC13x26x2Operations.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Collections.Generic;
88
using System.Diagnostics;
99
using System.IO;
10-
using System.Linq;
1110

1211
namespace nanoFramework.Tools.FirmwareFlasher
1312
{
@@ -119,15 +118,15 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
119118

120119
ExitCodes programResult = ExitCodes.OK;
121120
// write HEX files to flash
122-
if (filesToFlash.Any(f => f.EndsWith(".hex")))
121+
if (filesToFlash.Exists(f => f.EndsWith(".hex")))
123122
{
124123
programResult = ccDevice.FlashHexFiles(filesToFlash);
125124
}
126125

127126
if (programResult == ExitCodes.OK && isApplicationBinFile)
128127
{
129128
// now program the application file
130-
programResult = ccDevice.FlashBinFiles(new[] { applicationPath }, new[] { deploymentAddress });
129+
programResult = ccDevice.FlashBinFiles([applicationPath], [deploymentAddress]);
131130
}
132131

133132
if (updateFw)

nanoFirmwareFlasher.Library/Esp32Firmware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal class Esp32Firmware : FirmwarePackage
2424
/// <summary>
2525
/// ESP32 nanoCLR is available for 2MB, 4MB, 8MB and 16MB flash sizes
2626
/// </summary>
27-
private List<int> SupportedFlashSizes => new() { 0x200000, 0x400000, 0x800000, 0x1000000 };
27+
private List<int> SupportedFlashSizes => [0x200000, 0x400000, 0x800000, 0x1000000];
2828

2929
internal string BootloaderPath;
3030

nanoFirmwareFlasher.Library/Esp32Operations.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
504504

505505
int configPartitionAddress = 0;
506506
int configPartitionSize = 0;
507-
string configPartitionBackup = Path.GetTempFileName();
507+
string configPartitionBackup = Path.GetRandomFileName();
508508

509509
// if mass erase wasn't requested, backup config partitition
510510
if (!massErase)
@@ -613,7 +613,6 @@ public static async System.Threading.Tasks.Task<ExitCodes> DeployApplicationAsyn
613613
VerbosityLevel verbosity,
614614
PartitionTableSize? partitionTableSize)
615615
{
616-
var operationResult = ExitCodes.OK;
617616
uint address = 0;
618617

619618
// perform sanity checks for the specified target against the connected device details
@@ -688,7 +687,7 @@ public static async System.Threading.Tasks.Task<ExitCodes> DeployApplicationAsyn
688687
}
689688

690689
// write to flash
691-
operationResult = espTool.WriteFlash(firmware.FlashPartitions);
690+
ExitCodes operationResult = espTool.WriteFlash(firmware.FlashPartitions);
692691

693692
if (operationResult == ExitCodes.OK)
694693
{

nanoFirmwareFlasher.Library/FileDeployment/FileDeploymentManager.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
using nanoFramework.Tools.Debugger;
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
using nanoFramework.Tools.Debugger;
27
using nanoFramework.Tools.Debugger.Extensions;
38
using Newtonsoft.Json;
49
using System;
5-
using System.Collections.Generic;
610
using System.IO;
7-
using System.Linq;
8-
using System.Runtime;
9-
using System.Text;
1011
using System.Threading.Tasks;
1112

1213
namespace nanoFramework.Tools.FirmwareFlasher.FileDeployment
@@ -16,9 +17,9 @@ namespace nanoFramework.Tools.FirmwareFlasher.FileDeployment
1617
/// </summary>
1718
public class FileDeploymentManager
1819
{
19-
private FileDeploymentConfiguration _configuration;
20-
private VerbosityLevel _verbosity;
21-
private string _serialPort;
20+
private readonly FileDeploymentConfiguration _configuration;
21+
private readonly VerbosityLevel _verbosity;
22+
private readonly string _serialPort;
2223

2324
/// <summary>
2425
/// Creates an instance of FileDeploymentManager.

nanoFirmwareFlasher.Library/FirmwarePackage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public static List<CloudSmithPackageDetail> GetTargetList(
158158
// Because new stable releases are published on a regular basis and preview very rarely, we query for stable versions published in past month and preview versions published during the past 6 months.
159159
string requestUri = $"{repoName}/?page_size=500&q=uploaded:'>{(preview ? "6" : "1")} month ago' {(platform.HasValue ? "AND tag:" + platform.Value : "")}";
160160

161-
List<CloudSmithPackageDetail> targetPackages = new();
161+
List<CloudSmithPackageDetail> targetPackages = [];
162162

163163
if (verbosity > VerbosityLevel.Normal)
164164
{
@@ -246,7 +246,7 @@ internal async Task<ExitCodes> DownloadAndExtractAsync()
246246
return ExitCodes.E9006;
247247
}
248248

249-
List<FileInfo> fwFiles = new();
249+
List<FileInfo> fwFiles = [];
250250

251251
if (_preview)
252252
{

nanoFirmwareFlasher.Library/JLinkDevice.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public static List<string> ListDevices()
151151
if (jlinkMatches.Count == 0)
152152
{
153153
// no J-Link probe found
154-
return new List<string>();
154+
return [];
155155
}
156156

157157
return jlinkMatches.Cast<Match>().Select(i => i.Value).ToList();

nanoFirmwareFlasher.Library/JLinkOperations.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
6969
}
7070

7171
// setup files to flash
72-
var filesToFlash = new List<string>();
72+
List<string> filesToFlash = [];
7373

7474
if (updateFw)
7575
{
@@ -153,15 +153,15 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
153153
jlinkDevice.Verbosity = verbosity;
154154

155155
// write HEX files to flash
156-
if (filesToFlash.Any(f => f.EndsWith(".hex")))
156+
if (filesToFlash.Exists(f => f.EndsWith(".hex")))
157157
{
158158
operationResult = jlinkDevice.FlashHexFiles(filesToFlash);
159159
}
160160

161161
if (operationResult == ExitCodes.OK && isApplicationBinFile)
162162
{
163163
// now program the application file
164-
operationResult = jlinkDevice.FlashBinFiles(new[] { applicationPath }, new[] { deploymentAddress });
164+
operationResult = jlinkDevice.FlashBinFiles([applicationPath], [deploymentAddress]);
165165
}
166166

167167
return operationResult;
@@ -178,7 +178,7 @@ public static ExitCodes MassErase(
178178
VerbosityLevel verbosity)
179179
{
180180
// J-Link device
181-
JLinkDevice jlinkDevice = new JLinkDevice(probeId);
181+
JLinkDevice jlinkDevice = new(probeId);
182182

183183
if (!jlinkDevice.DevicePresent)
184184
{

nanoFirmwareFlasher.Library/NanoDeviceOperations.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,6 @@ public ExitCodes GetDeviceDetails(
163163
// report issue
164164
throw new CantConnectToNanoDeviceException("Couldn't connect to specified nano device.");
165165
}
166-
167-
if (nanoDevice is null)
168-
{
169-
throw new ArgumentNullException(nameof(nanoDevice));
170-
}
171-
172-
return ExitCodes.E2000;
173166
}
174167

175168
/// <summary>

nanoFirmwareFlasher.Library/Stm32Operations.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
215215
if (operationResult == ExitCodes.OK && isApplicationBinFile)
216216
{
217217
// now program the application file
218-
operationResult = dfuDevice.FlashBinFiles(new[] { applicationPath }, new[] { deploymentAddress });
218+
operationResult = dfuDevice.FlashBinFiles([applicationPath], [deploymentAddress]);
219219
}
220220

221221
if (
@@ -282,7 +282,7 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
282282
if (operationResult == ExitCodes.OK && isApplicationBinFile)
283283
{
284284
// now program the application file
285-
operationResult = jtagDevice.FlashBinFiles(new[] { applicationPath }, new[] { deploymentAddress });
285+
operationResult = jtagDevice.FlashBinFiles([applicationPath], [deploymentAddress]);
286286
}
287287

288288
if (

nanoFirmwareFlasher.Library/StmDfuDevice.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public ExitCodes StartExecution(string startAddress)
222222
if (dfuMatches.Count == 0)
223223
{
224224
// no DFU device found
225-
return new List<(string serial, string device)>();
225+
return [];
226226
}
227227

228228
return dfuMatches.Cast<Match>().Select(i => (serial: i.Groups["serial"].Value, device: i.Groups["device"].Value)).ToList();

nanoFirmwareFlasher.Library/StmJtagDevice.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public static List<string> ListDevices()
208208
if (jtagMatches.Count == 0)
209209
{
210210
// no JTAG found
211-
return new List<string>();
211+
return [];
212212
}
213213

214214
return jtagMatches.Cast<Match>().Select(i => i.Value).ToList();

nanoFirmwareFlasher.Library/nanoFirmwareFlasher.Library.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>library</OutputType>
5-
<TargetFrameworks>net6.0;net472</TargetFrameworks>
5+
<TargetFrameworks>net8.0;net472</TargetFrameworks>
66
<PlatformTarget>AnyCPU</PlatformTarget>
77
<LangVersion>latest</LangVersion>
88
<RootNamespace>nanoFramework.Tools.FirmwareFlasher</RootNamespace>

nanoFirmwareFlasher.Library/packages.lock.json

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263
"contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ=="
264264
}
265265
},
266-
"net6.0": {
266+
"net8.0": {
267267
"Microsoft.ApplicationInsights": {
268268
"type": "Direct",
269269
"requested": "[2.22.0, )",
@@ -413,10 +413,7 @@
413413
"Microsoft.Extensions.Primitives": {
414414
"type": "Transitive",
415415
"resolved": "8.0.0",
416-
"contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g==",
417-
"dependencies": {
418-
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
419-
}
416+
"contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g=="
420417
},
421418
"Microsoft.NETCore.Platforms": {
422419
"type": "Transitive",
@@ -1016,11 +1013,6 @@
10161013
"Microsoft.NETCore.Targets": "1.1.0"
10171014
}
10181015
},
1019-
"System.Runtime.CompilerServices.Unsafe": {
1020-
"type": "Transitive",
1021-
"resolved": "6.0.0",
1022-
"contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg=="
1023-
},
10241016
"System.Runtime.Extensions": {
10251017
"type": "Transitive",
10261018
"resolved": "4.3.0",
@@ -1247,17 +1239,13 @@
12471239
"System.Text.Encodings.Web": {
12481240
"type": "Transitive",
12491241
"resolved": "8.0.0",
1250-
"contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ==",
1251-
"dependencies": {
1252-
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
1253-
}
1242+
"contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ=="
12541243
},
12551244
"System.Text.Json": {
12561245
"type": "Transitive",
12571246
"resolved": "8.0.0",
12581247
"contentHash": "OdrZO2WjkiEG6ajEFRABTRCi/wuXQPxeV6g8xvUJqdxMvvuCCEk86zPla8UiIQJz3durtUEbNyY/3lIhS0yZvQ==",
12591248
"dependencies": {
1260-
"System.Runtime.CompilerServices.Unsafe": "6.0.0",
12611249
"System.Text.Encodings.Web": "8.0.0"
12621250
}
12631251
},

nanoFirmwareFlasher.Tool/Options.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,7 @@ public class Options
353353

354354
[Usage(ApplicationAlias = "nanoff")]
355355
public static IEnumerable<Example> Examples =>
356-
new List<Example>
357-
{
356+
[
358357
new("- Update ESP32 WROVER Kit device with latest available firmware", new Options { TargetName = "ESP_WROVER_KIT", Update = true }),
359358
new("- Update specific STM32 device (ST_STM32F769I_DISCOVERY) with latest available firmware, using JTAG interface", new Options { TargetName = "ST_STM32F769I_DISCOVERY" , Update = true, JtagUpdate = true}),
360359
new("- Update ESP32 device with latest available firmware (stable version), device is connected to COM31", new Options { Platform = SupportedPlatform.esp32, Update = true, SerialPort = "COM31" }),
@@ -364,6 +363,6 @@ public class Options
364363
new("- Install STM32 JTAG drivers", new Options { InstallJtagDrivers = true}),
365364
new("- List all available STM32 targets", new Options { ListTargets = true, Platform = SupportedPlatform.stm32 }),
366365
new("- List all available COM ports", new Options { ListComPorts = true }),
367-
};
366+
];
368367
}
369368
}

nanoFirmwareFlasher.Tool/Program.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ internal class Program
3232
private static CopyrightInfo _copyrightInfo;
3333
private static NanoDeviceOperations _nanoDeviceOperations;
3434

35-
internal static string ExecutingPath;
36-
3735
public static async Task<int> Main(string[] args)
3836
{
3937
// take care of static fields
@@ -49,7 +47,7 @@ public static async Task<int> Main(string[] args)
4947
// need this to be able to use ProcessStart at the location where the .NET Core CLI tool is running from
5048
string codeBase = Assembly.GetExecutingAssembly().Location;
5149
var fullPath = Path.GetFullPath(codeBase);
52-
ExecutingPath = Path.GetDirectoryName(fullPath);
50+
var ExecutingPath = Path.GetDirectoryName(fullPath);
5351

5452
// grab AppInsights connection string to setup telemetry client
5553
IConfigurationRoot appConfigurationRoot = new ConfigurationBuilder()
@@ -67,7 +65,7 @@ public static async Task<int> Main(string[] args)
6765
// because of short-comings in CommandLine parsing
6866
// need to customize the output to provide a consistent output
6967
var parser = new Parser(config => config.HelpWriter = null);
70-
var result = parser.ParseArguments<Options>(new[] { "", "" });
68+
var result = parser.ParseArguments<Options>(new string[] { "", "" });
7169

7270
var helpText = new HelpText(
7371
new HeadingInfo(_headerInfo),
@@ -309,7 +307,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
309307
{
310308
var connectedDevices = _nanoDeviceOperations.ListDevices(_verbosityLevel > VerbosityLevel.Normal);
311309

312-
if (connectedDevices.Count() == 0)
310+
if (!connectedDevices.Any())
313311
{
314312
Console.ForegroundColor = ConsoleColor.Yellow;
315313
Console.WriteLine("No devices found");
@@ -692,7 +690,7 @@ private static void DisplayNoOperationMessage()
692690
// because of short-comings in CommandLine parsing
693691
// need to customize the output to provide a consistent output
694692
var parser = new Parser(config => config.HelpWriter = null);
695-
var result = parser.ParseArguments<Options>(new[] { "", "" });
693+
var result = parser.ParseArguments<Options>(new string[] { "", "" });
696694

697695
var helpText = new HelpText(
698696
new HeadingInfo(_headerInfo),

nanoFirmwareFlasher.Tool/SilabsManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public async Task<ExitCodes> ProcessAsync()
126126
else if (!string.IsNullOrEmpty(_options.DeploymentImage) && _options.Deploy)
127127
{
128128
var exitCode = jlinkDevice.FlashBinFiles(
129-
new List<string>() { _options.DeploymentImage },
129+
[_options.DeploymentImage],
130130
_options.FlashAddress);
131131

132132
if (exitCode != ExitCodes.OK)

nanoFirmwareFlasher.Tool/nanoFirmwareFlasher.Tool.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<PackageIconUrl></PackageIconUrl>
1919
<Description>.NET nanoFirmwareFlasher tool to flash firmware images to target devices.</Description>
2020
<!-- need this to allow async Main() -->
21-
<LangVersion>latest</LangVersion>
2221
<PackAsTool>true</PackAsTool>
2322
<PlatformTarget>AnyCPU</PlatformTarget>
2423
<Platforms>AnyCPU;x64</Platforms>
@@ -29,7 +28,7 @@
2928
</PropertyGroup>
3029

3130
<PropertyGroup Condition="$(VSCodeExtensionBuild) == '' or $(VSCodeExtensionBuild) == 'False'">
32-
<TargetFrameworks>net6.0</TargetFrameworks>
31+
<TargetFrameworks>net8.0</TargetFrameworks>
3332
</PropertyGroup>
3433
<PropertyGroup Condition="$(VSCodeExtensionBuild) == 'True'">
3534
<TargetFrameworks>net472</TargetFrameworks>
@@ -87,8 +86,8 @@
8786
</Target>
8887

8988
<PropertyGroup>
90-
<!-- set this to 'net6.0\' to package contents in this TFM folder -->
91-
<PackageTfmSubFolder>net6.0\</PackageTfmSubFolder>
89+
<!-- set this to 'net8.0\' to package contents in this TFM folder -->
90+
<PackageTfmSubFolder>net8.0\</PackageTfmSubFolder>
9291
</PropertyGroup>
9392

9493
<Import Project="..\nanoFirmwareFlasher.Library\nugetcontent.targets" />

0 commit comments

Comments
 (0)