Skip to content

Commit 2434645

Browse files
authored
Fix relative path file for bin files in JLink (#278)
***NO_CI***
1 parent 0d2f7b4 commit 2434645

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

nanoFirmwareFlasher.Library/JLinkCli.cs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,13 @@ public ExitCodes ExecuteFlashBinFiles(
136136
IList<string> addresses,
137137
string probeId)
138138
{
139-
// check file existence
140-
if (files.Any(f => !File.Exists(f)))
139+
List<string> shadowFiles = [];
140+
141+
var processFileResult = ProcessFilePaths(files, shadowFiles);
142+
143+
if (processFileResult != ExitCodes.OK)
141144
{
142-
return ExitCodes.E5004;
145+
return processFileResult;
143146
}
144147

145148
// perform check on address(es)
@@ -179,10 +182,6 @@ public ExitCodes ExecuteFlashBinFiles(
179182
}
180183
}
181184

182-
List<string> shadowFiles = [];
183-
184-
ProcessFilePaths(files, shadowFiles);
185-
186185
// erase flash
187186
if (DoMassErase)
188187
{
@@ -284,7 +283,7 @@ public ExitCodes ExecuteFlashBinFiles(
284283
return ExitCodes.OK;
285284
}
286285

287-
private void ProcessFilePaths(IList<string> files, List<string> shadowFiles)
286+
private ExitCodes ProcessFilePaths(IList<string> files, List<string> shadowFiles)
288287
{
289288
// J-Link can't handle diacritc chars
290289
// developer note: reported to Segger (Case: 60276735) and can be removed if this is fixed/improved
@@ -295,6 +294,12 @@ private void ProcessFilePaths(IList<string> files, List<string> shadowFiles)
295294
Environment.CurrentDirectory,
296295
binFile);
297296

297+
// check file existence
298+
if (!File.Exists(binFilePath))
299+
{
300+
return ExitCodes.E5004;
301+
}
302+
298303
if (!binFilePath.IsNormalized(NormalizationForm.FormD)
299304
|| binFilePath.Contains(' '))
300305
{
@@ -315,8 +320,9 @@ private void ProcessFilePaths(IList<string> files, List<string> shadowFiles)
315320
// copy file to shadow list
316321
shadowFiles.Add(binFile);
317322
}
318-
319323
}
324+
325+
return ExitCodes.OK;
320326
}
321327

322328
/// <summary>
@@ -329,15 +335,14 @@ public ExitCodes ExecuteFlashHexFiles(
329335
IList<string> files,
330336
string probeId)
331337
{
332-
// check file existence
333-
if (files.Any(f => !File.Exists(f)))
334-
{
335-
return ExitCodes.E5004;
336-
}
337-
338338
List<string> shadowFiles = [];
339339

340-
ProcessFilePaths(files, shadowFiles);
340+
var processFileResult = ProcessFilePaths(files, shadowFiles);
341+
342+
if (processFileResult != ExitCodes.OK)
343+
{
344+
return processFileResult;
345+
}
341346

342347
// erase flash
343348
if (DoMassErase)

0 commit comments

Comments
 (0)