diff --git a/LICENSE b/LICENSE
index 2f8bd981..94286c94 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2019 nanoFramework
+Copyright (c) .NET Foundation and Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index c238d7b7..0fed9a74 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[](https://opensource.org/licenses/MIT) [](https://github.com/nanoframework/Home/blob/master/CONTRIBUTING.md) [](https://dev.azure.com/nanoframework/nanoFirmwareFlasher/_build/latest?definitionId=45&branchName=develop) [](https://www.nuget.org/packages/nanoFirmwareFlasher/) [](https://discord.gg/gCyBu8T)
+[](LICENSE) [](https://github.com/nanoframework/Home/blob/master/CONTRIBUTING.md) [](https://dev.azure.com/nanoframework/nanoFirmwareFlasher/_build/latest?definitionId=45&branchName=develop) [](https://www.nuget.org/packages/nanoFirmwareFlasher/) [](https://discord.gg/gCyBu8T)

@@ -168,7 +168,7 @@ nanoff -v q
## Exit codes
-The exit codes can be checked in [this source file](https://github.com/nanoframework/nanoFirmwareFlasher/blob/develop/source/nanoFirmwareFlasher/ExitCodes.cs).
+The exit codes can be checked in [this source file](https://github.com/nanoframework/nanoFirmwareFlasher/blob/develop/nanoFirmwareFlasher/ExitCodes.cs).
## Feedback and documentation
@@ -182,9 +182,13 @@ The list of contributors to this project can be found at [CONTRIBUTORS](https://
## License
-The **nanoFramework** firmware flasher tool is licensed under the [MIT license](https://opensource.org/licenses/MIT).
+The **nanoFramework** firmware flasher tool is licensed under the [MIT license](LICENSE).
## Code of Conduct
-This project has adopted the code of conduct defined by the [Contributor Covenant](https://github.com/nanoframework/.github/blob/master/CODE_OF_CONDUCT.md)
-to clarify expected behavior in our community.
+This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community.
+For more information see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).
+
+### .NET Foundation
+
+This project is supported by the [.NET Foundation](https://dotnetfoundation.org).
diff --git a/nanoFirmwareFlasher/BintrayPackageInfo.cs b/nanoFirmwareFlasher/BintrayPackageInfo.cs
index 3075d7e4..d30a16d0 100644
--- a/nanoFirmwareFlasher/BintrayPackageInfo.cs
+++ b/nanoFirmwareFlasher/BintrayPackageInfo.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/CC13x26x2Device.cs b/nanoFirmwareFlasher/CC13x26x2Device.cs
index e429ab65..0077d47c 100644
--- a/nanoFirmwareFlasher/CC13x26x2Device.cs
+++ b/nanoFirmwareFlasher/CC13x26x2Device.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2020 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/CC13x26x2Firmware.cs b/nanoFirmwareFlasher/CC13x26x2Firmware.cs
index b897b0e2..7ad67dab 100644
--- a/nanoFirmwareFlasher/CC13x26x2Firmware.cs
+++ b/nanoFirmwareFlasher/CC13x26x2Firmware.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/CC13x26x2Operations.cs b/nanoFirmwareFlasher/CC13x26x2Operations.cs
index 4f1ee3c9..ea69992f 100644
--- a/nanoFirmwareFlasher/CC13x26x2Operations.cs
+++ b/nanoFirmwareFlasher/CC13x26x2Operations.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Esp32Firmware.cs b/nanoFirmwareFlasher/Esp32Firmware.cs
index e5adde8d..6775f2ca 100644
--- a/nanoFirmwareFlasher/Esp32Firmware.cs
+++ b/nanoFirmwareFlasher/Esp32Firmware.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Esp32Operations.cs b/nanoFirmwareFlasher/Esp32Operations.cs
index 8edca633..8e5137b7 100644
--- a/nanoFirmwareFlasher/Esp32Operations.cs
+++ b/nanoFirmwareFlasher/Esp32Operations.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/EspTool.cs b/nanoFirmwareFlasher/EspTool.cs
index ec26b6dc..b423b6fb 100644
--- a/nanoFirmwareFlasher/EspTool.cs
+++ b/nanoFirmwareFlasher/EspTool.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Exceptions/CantConnectToJtagDeviceException.cs b/nanoFirmwareFlasher/Exceptions/CantConnectToJtagDeviceException.cs
index 53f0f432..29c40049 100644
--- a/nanoFirmwareFlasher/Exceptions/CantConnectToJtagDeviceException.cs
+++ b/nanoFirmwareFlasher/Exceptions/CantConnectToJtagDeviceException.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2020 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Exceptions/CantOpenDfuDeviceException.cs b/nanoFirmwareFlasher/Exceptions/CantOpenDfuDeviceException.cs
index fd296931..24dcd59e 100644
--- a/nanoFirmwareFlasher/Exceptions/CantOpenDfuDeviceException.cs
+++ b/nanoFirmwareFlasher/Exceptions/CantOpenDfuDeviceException.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2020 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Exceptions/DfuFileDoesNotExistException.cs b/nanoFirmwareFlasher/Exceptions/DfuFileDoesNotExistException.cs
index 5303e701..7968dd70 100644
--- a/nanoFirmwareFlasher/Exceptions/DfuFileDoesNotExistException.cs
+++ b/nanoFirmwareFlasher/Exceptions/DfuFileDoesNotExistException.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2020 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Exceptions/DfuOperationFailedException.cs b/nanoFirmwareFlasher/Exceptions/DfuOperationFailedException.cs
index 63be5676..cef4c993 100644
--- a/nanoFirmwareFlasher/Exceptions/DfuOperationFailedException.cs
+++ b/nanoFirmwareFlasher/Exceptions/DfuOperationFailedException.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2020 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Exceptions/EraseEsp32FlashException.cs b/nanoFirmwareFlasher/Exceptions/EraseEsp32FlashException.cs
index 0e45018a..ddb4c640 100644
--- a/nanoFirmwareFlasher/Exceptions/EraseEsp32FlashException.cs
+++ b/nanoFirmwareFlasher/Exceptions/EraseEsp32FlashException.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Exceptions/EspToolExecutionException.cs b/nanoFirmwareFlasher/Exceptions/EspToolExecutionException.cs
index edbd17ba..5da9ab89 100644
--- a/nanoFirmwareFlasher/Exceptions/EspToolExecutionException.cs
+++ b/nanoFirmwareFlasher/Exceptions/EspToolExecutionException.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Exceptions/ReadEsp32FlashException.cs b/nanoFirmwareFlasher/Exceptions/ReadEsp32FlashException.cs
index 7b72a455..b3a2b6c7 100644
--- a/nanoFirmwareFlasher/Exceptions/ReadEsp32FlashException.cs
+++ b/nanoFirmwareFlasher/Exceptions/ReadEsp32FlashException.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Exceptions/StLinkCliExecutionException.cs b/nanoFirmwareFlasher/Exceptions/StLinkCliExecutionException.cs
index 5bf11cf6..fb57a22c 100644
--- a/nanoFirmwareFlasher/Exceptions/StLinkCliExecutionException.cs
+++ b/nanoFirmwareFlasher/Exceptions/StLinkCliExecutionException.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2020 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Exceptions/UniflashCliExecutionException.cs b/nanoFirmwareFlasher/Exceptions/UniflashCliExecutionException.cs
index 5a5ad058..e55f5dca 100644
--- a/nanoFirmwareFlasher/Exceptions/UniflashCliExecutionException.cs
+++ b/nanoFirmwareFlasher/Exceptions/UniflashCliExecutionException.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2020 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Exceptions/WriteEsp32FlashException.cs b/nanoFirmwareFlasher/Exceptions/WriteEsp32FlashException.cs
index d2892ac8..d3f27b27 100644
--- a/nanoFirmwareFlasher/Exceptions/WriteEsp32FlashException.cs
+++ b/nanoFirmwareFlasher/Exceptions/WriteEsp32FlashException.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/ExitCodes.cs b/nanoFirmwareFlasher/ExitCodes.cs
index 54e997c3..a5b9e6c6 100644
--- a/nanoFirmwareFlasher/ExitCodes.cs
+++ b/nanoFirmwareFlasher/ExitCodes.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Extensions/AttributeExtensions.cs b/nanoFirmwareFlasher/Extensions/AttributeExtensions.cs
index b6f5402b..85474547 100644
--- a/nanoFirmwareFlasher/Extensions/AttributeExtensions.cs
+++ b/nanoFirmwareFlasher/Extensions/AttributeExtensions.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/Extensions/CommandLineExtensions.cs b/nanoFirmwareFlasher/Extensions/CommandLineExtensions.cs
index 11a6c3ef..f140261a 100644
--- a/nanoFirmwareFlasher/Extensions/CommandLineExtensions.cs
+++ b/nanoFirmwareFlasher/Extensions/CommandLineExtensions.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/FirmwarePackage.cs b/nanoFirmwareFlasher/FirmwarePackage.cs
index 3dae74af..aa7185f4 100644
--- a/nanoFirmwareFlasher/FirmwarePackage.cs
+++ b/nanoFirmwareFlasher/FirmwarePackage.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
@@ -7,8 +7,10 @@
using System;
using System.IO;
using System.IO.Compression;
+using System.Linq;
using System.Net;
using System.Net.Http;
+using System.Text.RegularExpressions;
namespace nanoFramework.Tools.FirmwareFlasher
{
@@ -64,132 +66,243 @@ protected FirmwarePackage(string targetName, string fwVersion, bool stable)
/// a dictionary which keys are the start addresses and the values are the complete filenames (the bin files)
protected async System.Threading.Tasks.Task DownloadAndExtractAsync()
{
+ string fwFileName = null;
+
// reference targets
var repoName = _stable ? _refTargetsStableRepo : _refTargetsDevRepo;
string requestUri = $"{_bintrayApiPackages}/{repoName}/{_targetName}";
- if (Verbosity >= VerbosityLevel.Normal)
+ // flag to signal if the work-flow step was successful
+ bool stepSuccesful = false;
+
+ // flag to skip download if the fw package exists and it's recent
+ bool skipDownload = false;
+
+ // setup download folder
+ // set download path
+ LocationPath = Path.Combine(
+ Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
+ ".nanoFramework");
+
+ try
{
- Console.Write($"Trying to find {_targetName} in {(_stable ? "stable" : "developement")} repository...");
+ // create home directory
+ Directory.CreateDirectory(LocationPath);
+
+ // add readme file
+ File.WriteAllText(
+ Path.Combine(
+ LocationPath,
+ "README.txt"),
+ _readmeContent);
+
+ // set location path to target folder
+ LocationPath = Path.Combine(
+ Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
+ ".nanoFramework",
+ _targetName);
}
+ catch
+ {
+ Console.WriteLine("");
- HttpResponseMessage response = await _bintrayClient.GetAsync(requestUri);
+ return ExitCodes.E9006;
+ }
- if (response.StatusCode == HttpStatusCode.NotFound)
+ var fwFiles = Directory.EnumerateFiles(LocationPath, $"{_targetName}-*.zip").OrderByDescending(f => f).ToList();
+
+ if (fwFiles.Any())
{
- if (Verbosity >= VerbosityLevel.Normal)
+ // get file creation date (from the 1st one)
+ if ((DateTime.UtcNow - File.GetLastWriteTimeUtc(fwFiles.First())).TotalHours < 4)
{
- Console.WriteLine("");
- Console.Write($"Trying to find {_targetName} in community targets repository...");
+ // fw package has less than 4 hours
+ // skip download
+ skipDownload = true;
}
+ }
+
+ if (!skipDownload)
+ {
+ // try to perform request
+ try
+ {
+ if (Verbosity >= VerbosityLevel.Normal)
+ {
+ Console.Write($"Trying to find {_targetName} in {(_stable ? "stable" : "developement")} repository...");
+ }
- // try with community targets
- requestUri = $"{_bintrayApiPackages}/{_communityTargetsepo}/{_targetName}";
- repoName = _communityTargetsepo;
+ HttpResponseMessage response = await _bintrayClient.GetAsync(requestUri);
- response = await _bintrayClient.GetAsync(requestUri);
+ if (response.StatusCode == HttpStatusCode.NotFound)
+ {
+ if (Verbosity >= VerbosityLevel.Normal)
+ {
+ Console.WriteLine("");
+ Console.Write($"Trying to find {_targetName} in community targets repository...");
+ }
+
+ // try with community targets
+ requestUri = $"{_bintrayApiPackages}/{_communityTargetsepo}/{_targetName}";
+ repoName = _communityTargetsepo;
+
+ response = await _bintrayClient.GetAsync(requestUri);
+
+ if (response.StatusCode == HttpStatusCode.NotFound)
+ {
+ if (Verbosity >= VerbosityLevel.Normal)
+ {
+ Console.WriteLine("");
+ }
+
+ // can't find this target
+ return ExitCodes.E9005;
+ }
+ }
- if (response.StatusCode == HttpStatusCode.NotFound)
- {
if (Verbosity >= VerbosityLevel.Normal)
{
- Console.WriteLine("");
+ Console.WriteLine($"OK");
}
- // can't find this target
- return ExitCodes.E9005;
- }
- }
+ // read and parse response
+ string responseBody = await response.Content.ReadAsStringAsync();
+ BintrayPackageInfo packageInfo = JsonConvert.DeserializeObject(responseBody);
- if (Verbosity >= VerbosityLevel.Normal)
- {
- Console.WriteLine($"OK");
+ // if no specific version was requested, use latest available
+ if (string.IsNullOrEmpty(_fwVersion))
+ {
+ _fwVersion = packageInfo.LatestVersion;
+ }
- Console.Write($"Downloading firmware package...");
+ // set exposed property
+ Version = _fwVersion;
+
+ stepSuccesful = true;
+ }
+ catch
+ {
+ // exception with download, assuming it's something with network connection or Bintray API
+ }
}
- // read and parse response
- string responseBody = await response.Content.ReadAsStringAsync();
- BintrayPackageInfo packageInfo = JsonConvert.DeserializeObject(responseBody);
+ // cleanup any fw file in the folder
+ var filesToDelete = Directory.EnumerateFiles(LocationPath, "*.bin").ToList();
+ filesToDelete.AddRange(Directory.EnumerateFiles(LocationPath, "*.hex").ToList());
+ filesToDelete.AddRange(Directory.EnumerateFiles(LocationPath, "*.s19").ToList());
+ filesToDelete.AddRange(Directory.EnumerateFiles(LocationPath, "*.dfu").ToList());
- // if no specific version was requested, use latest available
- if (string.IsNullOrEmpty(_fwVersion))
+ foreach (var file in filesToDelete)
{
- _fwVersion = packageInfo.LatestVersion;
+ File.Delete(file);
}
- // set exposed property
- Version = _fwVersion;
-
- // setup download folder
- try
+ // check for file existence or download one
+ if (stepSuccesful &&
+ !skipDownload)
{
- // set download path
- LocationPath = Path.Combine(
- Path.GetTempPath(),
- Guid.NewGuid().ToString());
+ // reset flag
+ stepSuccesful = false;
- // create directory
- Directory.CreateDirectory(LocationPath);
+ fwFileName = $"{_targetName}-{_fwVersion}.zip";
- if (Verbosity >= VerbosityLevel.Normal)
+ // check if we already have the file
+ if (!File.Exists(
+ Path.Combine(
+ LocationPath,
+ fwFileName)))
{
- Console.WriteLine("OK");
+ if (Verbosity >= VerbosityLevel.Normal)
+ {
+ Console.Write($"Downloading firmware package...");
+ }
+
+ try
+ {
+ // setup and perform download request
+ requestUri = $"https://dl.bintray.com/nfbot/{repoName}/{fwFileName}";
+
+ using (var fwFileResponse = await _bintrayClient.GetAsync(requestUri))
+ {
+ if (fwFileResponse.IsSuccessStatusCode)
+ {
+ using (var readStream = await fwFileResponse.Content.ReadAsStreamAsync())
+ {
+ using (var fileStream = new FileStream(
+ Path.Combine(LocationPath, fwFileName),
+ FileMode.Create, FileAccess.Write))
+ {
+ await readStream.CopyToAsync(fileStream);
+ }
+ }
+ }
+ else
+ {
+ return ExitCodes.E9007;
+ }
+ }
+
+ if (Verbosity >= VerbosityLevel.Normal)
+ {
+ Console.WriteLine("OK");
+ }
+
+ stepSuccesful = true;
+ }
+ catch
+ {
+ // exception with download, assuming it's something with network connection or Bintray API
+ }
}
else
{
- Console.WriteLine("");
+ // file already exists
+ stepSuccesful = true;
}
-
- if (Verbosity >= VerbosityLevel.Detailed)
- {
- Console.WriteLine($"Download location is {LocationPath}");
- }
-
- // add readme file
- File.WriteAllText(
- Path.Combine(
- LocationPath,
- "README.txt"),
- _readmeContent);
}
- catch
+
+ if (!stepSuccesful)
{
- Console.WriteLine("");
+ // couldn't download the fw file
+ // check if there is one available
+ fwFiles = Directory.EnumerateFiles(LocationPath, $"{_targetName}-*.zip").OrderByDescending(f => f).ToList();
- return ExitCodes.E9006;
- }
+ if (fwFiles.Any())
+ {
+ // take the 1st one
+ fwFileName = fwFiles.First();
- // setup and perform download request
- string fwFileName = $"{_targetName}-{_fwVersion}.zip";
- requestUri = $"https://dl.bintray.com/nfbot/{repoName}/{fwFileName}";
+ // get the version form the file name
+ var pattern = @"(\d+\.\d+\.\d+)(\.\d+|-.+)(?=\.zip)";
+ var match = Regex.Matches(fwFileName, pattern, RegexOptions.IgnoreCase);
- using (var fwFileResponse = await _bintrayClient.GetAsync(requestUri))
- {
- if (fwFileResponse.IsSuccessStatusCode)
- {
- using (var readStream = await fwFileResponse.Content.ReadAsStreamAsync())
+ // set property
+ Version = match[0].Value;
+
+ if (Verbosity >= VerbosityLevel.Normal)
{
- using (var fileStream = new FileStream(
- Path.Combine(LocationPath, fwFileName),
- FileMode.Create, FileAccess.Write))
- {
- await readStream.CopyToAsync(fileStream);
- }
+ Console.WriteLine("Using cached firmware package");
}
}
else
{
+ // no fw file available
+
+ if (Verbosity >= VerbosityLevel.Normal)
+ {
+ Console.WriteLine("Failure to download package and couldn't find one in the cache.");
+ }
+
return ExitCodes.E9007;
}
}
- Console.WriteLine($"Updating to {_fwVersion}");
+ // got here, must have a file!
// unzip the firmware
if (Verbosity >= VerbosityLevel.Detailed)
{
- Console.Write($"Extracting {fwFileName}...");
+ Console.Write($"Extracting {Path.GetFileName(fwFileName)}...");
}
ZipFile.ExtractToDirectory(
@@ -198,9 +311,21 @@ protected async System.Threading.Tasks.Task DownloadAndExtractAsync()
if (Verbosity >= VerbosityLevel.Detailed)
{
- Console.WriteLine("");
+ Console.WriteLine("OK");
}
+ // be nice to the user and delete any fw packages other than the last one
+ var allFwFiles = Directory.EnumerateFiles(LocationPath, "*.zip").OrderByDescending(f => f).ToList();
+ if (allFwFiles.Count > 1)
+ {
+ foreach (var file in allFwFiles.Skip(1))
+ {
+ File.Delete(file);
+ }
+ }
+
+ Console.WriteLine($"Updating to {Version}");
+
return ExitCodes.OK;
}
diff --git a/nanoFirmwareFlasher/Options.cs b/nanoFirmwareFlasher/Options.cs
index e787f2c1..a0ab882c 100644
--- a/nanoFirmwareFlasher/Options.cs
+++ b/nanoFirmwareFlasher/Options.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
@@ -142,7 +142,7 @@ public class Options
'v',
"verbosity",
Required = false,
- Default = "n",
+ Default = "d",
HelpText = "Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. Not supported in every command; see specific command page to determine if this option is available.")]
public string Verbosity { get; set; }
diff --git a/nanoFirmwareFlasher/Program.cs b/nanoFirmwareFlasher/Program.cs
index c22bf78d..e5fc240d 100644
--- a/nanoFirmwareFlasher/Program.cs
+++ b/nanoFirmwareFlasher/Program.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
@@ -473,7 +473,10 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
return;
}
- if (!string.IsNullOrEmpty(o.DfuFile))
+ var connectedStDfuDevices = StmDfuDevice.ListDfuDevices();
+ var connectedStJtagDevices = StmJtagDevice.ListDevices();
+
+ if (!string.IsNullOrEmpty(o.DfuFile) && connectedStDfuDevices.Count != 0)
{
// there is a DFU file argument, so follow DFU path
var dfuDevice = new StmDfuDevice(o.DfuDeviceId);
@@ -522,7 +525,9 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
}
else if (
o.BinFile.Any() &&
- o.HexFile.Any())
+ o.HexFile.Any() &&
+ connectedStJtagDevices.Count != 0
+ )
{
// this has to be a JTAG connected device
diff --git a/nanoFirmwareFlasher/Stm32Firmware.cs b/nanoFirmwareFlasher/Stm32Firmware.cs
index 61d5e133..63ec6cf4 100644
--- a/nanoFirmwareFlasher/Stm32Firmware.cs
+++ b/nanoFirmwareFlasher/Stm32Firmware.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
@@ -40,11 +40,8 @@ public Stm32Firmware(string targetName, string fwVersion, bool stable)
{
DfuPackage = dfuFile.FirstOrDefault();
}
- else
- {
- nanoBooterFile = Directory.EnumerateFiles(LocationPath, "nanoBooter.hex").FirstOrDefault();
- nanoCLRFile = Directory.EnumerateFiles(LocationPath, "nanoCLR.hex").FirstOrDefault();
- }
+ nanoBooterFile = Directory.EnumerateFiles(LocationPath, "nanoBooter.hex").FirstOrDefault();
+ nanoCLRFile = Directory.EnumerateFiles(LocationPath, "nanoCLR.hex").FirstOrDefault();
}
return executionResult;
diff --git a/nanoFirmwareFlasher/Stm32Operations.cs b/nanoFirmwareFlasher/Stm32Operations.cs
index 2fd57532..38b94334 100644
--- a/nanoFirmwareFlasher/Stm32Operations.cs
+++ b/nanoFirmwareFlasher/Stm32Operations.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
@@ -85,8 +85,11 @@ internal static async System.Threading.Tasks.Task UpdateFirmwareAsync
}
}
+ var connectedStDfuDevices = StmDfuDevice.ListDfuDevices();
+ var connectedStJtagDevices = StmJtagDevice.ListDevices();
+
// need DFU or JTAG device
- if (firmware.HasDfuPackage)
+ if (firmware.HasDfuPackage && connectedStDfuDevices.Count !=0)
{
// DFU package
dfuDevice = new StmDfuDevice(dfuDeviceId);
@@ -120,7 +123,7 @@ internal static async System.Threading.Tasks.Task UpdateFirmwareAsync
return ExitCodes.E1003;
}
}
- else
+ else if (connectedStJtagDevices.Count != 0)
{
// JATG device
jtagDevice = new StmJtagDevice(jtagId);
@@ -162,6 +165,11 @@ internal static async System.Threading.Tasks.Task UpdateFirmwareAsync
return programResult;
}
+ else
+ {
+ // no device was found to update.
+ return ExitCodes.E7000;
+ }
}
internal static ExitCodes ResetMcu(
diff --git a/nanoFirmwareFlasher/StmDfuDevice.cs b/nanoFirmwareFlasher/StmDfuDevice.cs
index 2499a9e6..daefce5c 100644
--- a/nanoFirmwareFlasher/StmDfuDevice.cs
+++ b/nanoFirmwareFlasher/StmDfuDevice.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2019 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/StmJtagDevice.cs b/nanoFirmwareFlasher/StmJtagDevice.cs
index 5575a20a..4275dc7e 100644
--- a/nanoFirmwareFlasher/StmJtagDevice.cs
+++ b/nanoFirmwareFlasher/StmJtagDevice.cs
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2020 The nanoFramework project contributors
+// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
diff --git a/nanoFirmwareFlasher/nanoFirmwareFlasher.csproj b/nanoFirmwareFlasher/nanoFirmwareFlasher.csproj
index 0ff36aff..7dba33e1 100644
--- a/nanoFirmwareFlasher/nanoFirmwareFlasher.csproj
+++ b/nanoFirmwareFlasher/nanoFirmwareFlasher.csproj
@@ -10,7 +10,7 @@
nanoFramework.Tools.FirmwareFlasher
nanoFramework project contributors
nanoFramework Firmware Flasher
- Copyright (c) 2019 nanoFramework project contributors
+ Copyright (c) .NET Foundation and Contributors
nanoFramework
git
https://github.com/nanoframework/nanoFirmwareFlasher
diff --git a/nanoFirmwareFlasher/update_esptool.ps1 b/nanoFirmwareFlasher/update_esptool.ps1
index d0d251c0..bfc60009 100644
--- a/nanoFirmwareFlasher/update_esptool.ps1
+++ b/nanoFirmwareFlasher/update_esptool.ps1
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2019 The nanoFramework project contributors
+# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
#
diff --git a/version.json b/version.json
index a553c8a1..1b242364 100644
--- a/version.json
+++ b/version.json
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
- "version": "1.15.0",
+ "version": "1.16.1",
"assemblyVersion": {
"precision": "revision"
},