Skip to content

Commit 9dd53a4

Browse files
authored
Add option to disable pre-check validation (#75)
1 parent bea597b commit 9dd53a4

File tree

6 files changed

+86
-42
lines changed

6 files changed

+86
-42
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ To install the XDS110 USB drivers.
191191
nanoff --installxdsdrivers
192192
```
193193

194+
### Pre-check if target fits connected device
195+
196+
The tool tries to make a best effort sanity check on whether the requested target fits the connected target.
197+
Sometimes that's not possible because of the differences and variations on the target names, or lack of details provided by the connected device or even (like with DFU connected devices) because it's not possible to determine exactly what device is connected at all.
198+
This doesn't necessarily mean that the firmware wont' work, so take this as an advice only.
199+
200+
To disable this validation add `--nofitcheck` option to the command line.
201+
194202
### Tool output verbosity
195203

196204
The tool output verbosity can be set through the `v|verbosity` option.

nanoFirmwareFlasher/Esp32Operations.cs

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ internal static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync
9393
string applicationPath,
9494
string deploymentAddress,
9595
string clrFile,
96+
bool fitCheck,
9697
VerbosityLevel verbosity,
9798
PartitionTableSize? partitionTableSize)
9899
{
@@ -106,45 +107,48 @@ internal static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync
106107
targetName = _esp32TargetName;
107108
}
108109

109-
// perform sanity checks for the specified target agains the connected device details
110-
if(esp32Device.ChipType != "ESP32")
110+
if (fitCheck)
111111
{
112-
// connected to a device not supported
113-
Console.ForegroundColor = ConsoleColor.Yellow;
114-
Console.WriteLine("");
115-
Console.WriteLine("************************************** WARNING *************************************");
116-
Console.WriteLine("Seems that the device that you have connected is not supported by .NET nanoFramework");
117-
Console.WriteLine("Most likely it won't boot");
118-
Console.WriteLine("************************************************************************************");
119-
Console.WriteLine("");
120-
}
112+
// perform sanity checks for the specified target agains the connected device details
113+
if (esp32Device.ChipType != "ESP32")
114+
{
115+
// connected to a device not supported
116+
Console.ForegroundColor = ConsoleColor.Yellow;
117+
Console.WriteLine("");
118+
Console.WriteLine("******************************* WARNING *******************************");
119+
Console.WriteLine("Seems that the connected device is not supported by .NET nanoFramework");
120+
Console.WriteLine("Most likely it won't boot");
121+
Console.WriteLine("************************************************************************");
122+
Console.WriteLine("");
123+
}
121124

122-
if (targetName.Contains("ESP32_WROOM_32_V3") &&
123-
(esp32Device.ChipName.Contains("revision 0") ||
124-
esp32Device.ChipName.Contains("revision 1") ||
125-
esp32Device.ChipName.Contains("revision 2")))
126-
{
127-
// trying to use a target that's not compatible with the connected device
128-
Console.ForegroundColor = ConsoleColor.Yellow;
129-
Console.WriteLine("");
130-
Console.WriteLine("***************************************** WARNING ****************************************");
131-
Console.WriteLine("Seems that you're about to use a firmware image for a revision 3 device, but the");
132-
Console.WriteLine($"connected device is {esp32Device.ChipName}. You should use the 'ESP32_WROOM_32' instead.");
133-
Console.WriteLine("******************************************************************************************");
134-
Console.WriteLine("");
135-
}
125+
if (targetName.Contains("ESP32_WROOM_32_V3") &&
126+
(esp32Device.ChipName.Contains("revision 0") ||
127+
esp32Device.ChipName.Contains("revision 1") ||
128+
esp32Device.ChipName.Contains("revision 2")))
129+
{
130+
// trying to use a target that's not compatible with the connected device
131+
Console.ForegroundColor = ConsoleColor.Yellow;
132+
Console.WriteLine("");
133+
Console.WriteLine("***************************************** WARNING ****************************************");
134+
Console.WriteLine("Seems that the firmware image that's about to be used is for a revision 3 device, but the");
135+
Console.WriteLine($"connected device is {esp32Device.ChipName}. You should use the 'ESP32_WROOM_32' instead.");
136+
Console.WriteLine("******************************************************************************************");
137+
Console.WriteLine("");
138+
}
136139

137-
if (targetName.Contains("BLE") &&
138-
!esp32Device.Features.Contains(", BT,"))
139-
{
140-
// trying to use a traget with BT and the connected device doens't have support for it
141-
Console.ForegroundColor = ConsoleColor.Yellow;
142-
Console.WriteLine("");
143-
Console.WriteLine("******************************************* WARNING ********************************************");
144-
Console.WriteLine("Seems that you're about to use a firmware image that includes Bluetooth, but the");
145-
Console.WriteLine($"connected device does not have support for it. You should use a target without BLE in the name.");
146-
Console.WriteLine("************************************************************************************************");
147-
Console.WriteLine("");
140+
if (targetName.Contains("BLE") &&
141+
!esp32Device.Features.Contains(", BT,"))
142+
{
143+
// trying to use a traget with BT and the connected device doens't have support for it
144+
Console.ForegroundColor = ConsoleColor.Yellow;
145+
Console.WriteLine("");
146+
Console.WriteLine("******************************************* WARNING *******************************************");
147+
Console.WriteLine("Seems that the firmware image that's about to be used includes Bluetooth features, but the");
148+
Console.WriteLine($"connected device does not have support for it. You should use a target without BLE in the name.");
149+
Console.WriteLine("************************************************************************************************");
150+
Console.WriteLine("");
151+
}
148152
}
149153

150154
Esp32Firmware firmware = new Esp32Firmware(

nanoFirmwareFlasher/Options.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,13 @@ public class Options
271271
HelpText = "Perform reset on connected device after all other requested operations are successfully performed.")]
272272
public bool ResetMcu { get; set; }
273273

274+
[Option(
275+
"nofitcheck",
276+
Required = false,
277+
Default = false,
278+
HelpText = "Skip execution of sanity check if the requested target fits the connected device. This is a best effort validation and it's NOT guaranted to be fail safe.")]
279+
public bool FitCheck { get; set; }
280+
274281
#endregion
275282

276283

nanoFirmwareFlasher/Program.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,13 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
316316

317317
if (_verbosityLevel >= VerbosityLevel.Normal)
318318
{
319+
Console.ForegroundColor = ConsoleColor.Cyan;
320+
319321
Console.WriteLine("");
320322
Console.WriteLine($"Connected to:");
321323
Console.WriteLine($"{ esp32Device }");
324+
325+
Console.ForegroundColor = ConsoleColor.White;
322326
}
323327

324328
// set verbosity
@@ -377,6 +381,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
377381
o.DeploymentImage,
378382
null,
379383
o.Esp32ClrFile,
384+
!o.FitCheck,
380385
_verbosityLevel,
381386
o.Esp32PartitionTableSize);
382387

@@ -438,6 +443,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
438443
o.DeploymentImage,
439444
appFlashAddress,
440445
null,
446+
!o.FitCheck,
441447
_verbosityLevel,
442448
o.Esp32PartitionTableSize);
443449

@@ -715,6 +721,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
715721
appFlashAddress,
716722
o.DfuDeviceId,
717723
o.JtagDeviceId,
724+
!o.FitCheck,
718725
updateInterface,
719726
_verbosityLevel);
720727

@@ -772,6 +779,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
772779
appFlashAddress,
773780
o.DfuDeviceId,
774781
o.JtagDeviceId,
782+
!o.FitCheck,
775783
updateInterface,
776784
_verbosityLevel);
777785

nanoFirmwareFlasher/Stm32Operations.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ internal static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync
2222
string deploymentAddress,
2323
string dfuDeviceId,
2424
string jtagId,
25+
bool fitCheck,
2526
Interface updateInterface,
2627
VerbosityLevel verbosity)
2728
{
@@ -150,10 +151,23 @@ internal static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync
150151
return ExitCodes.E1000;
151152
}
152153

154+
if (fitCheck)
155+
{
156+
Console.ForegroundColor = ConsoleColor.Yellow;
157+
158+
Console.WriteLine("");
159+
Console.WriteLine("It's not possible to perform fit check for devices connected with DFU");
160+
Console.WriteLine("");
161+
162+
Console.ForegroundColor = ConsoleColor.White;
163+
}
164+
153165
if (verbosity >= VerbosityLevel.Normal)
154166
{
155167
Console.ForegroundColor = ConsoleColor.Cyan;
168+
156169
Console.WriteLine($"Connected to DFU device with ID { dfuDevice.DeviceId }");
170+
157171
Console.ForegroundColor = ConsoleColor.White;
158172
}
159173

@@ -196,7 +210,10 @@ internal static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync
196210
Console.ForegroundColor = ConsoleColor.White;
197211
}
198212

199-
PerformTargetCheck(targetName, jtagDevice);
213+
if (fitCheck)
214+
{
215+
PerformTargetCheck(targetName, jtagDevice);
216+
}
200217

201218
ExitCodes operationResult = ExitCodes.OK;
202219

@@ -242,10 +259,10 @@ private static void PerformTargetCheck(string target, StmJtagDevice jtagDevice)
242259
Console.ForegroundColor = ConsoleColor.Yellow;
243260

244261
Console.WriteLine("");
245-
Console.WriteLine("******************************************* WARNING ***************************************");
246-
Console.WriteLine("It wasn't possible to validate if the firmware image that you're about to use works on the");
262+
Console.WriteLine("******************************************* WARNING ************************ *************");
263+
Console.WriteLine("It wasn't possible to validate if the firmware image that's about to be used works on the");
247264
Console.WriteLine($"target connected. But this doesn't necessarily mean that it won't work.");
248-
Console.WriteLine("*******************************************************************************************");
265+
Console.WriteLine("******************************************************************************************");
249266
Console.WriteLine("");
250267

251268
Console.ForegroundColor = ConsoleColor.White;
@@ -261,7 +278,7 @@ private static void PerformTargetCheck(string target, StmJtagDevice jtagDevice)
261278

262279
Console.WriteLine("");
263280
Console.WriteLine("******************************************* WARNING ***************************************");
264-
Console.WriteLine("It seems that the firmware image that you're about to use isn't the appropriate one for the");
281+
Console.WriteLine("It seems that the firmware image that's about to be used isn't the appropriate one for the");
265282
Console.WriteLine($"target connected. But this doesn't necessarily mean that it won't work.");
266283
Console.WriteLine("*******************************************************************************************");
267284
Console.WriteLine("");

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "1.23",
3+
"version": "1.24",
44
"assemblyVersion": {
55
"precision": "minor"
66
},

0 commit comments

Comments
 (0)