Skip to content

Commit

Permalink
Fix relative path file for bin files in JLink (#278)
Browse files Browse the repository at this point in the history
***NO_CI***
  • Loading branch information
josesimoes authored Jun 18, 2024
1 parent 0d2f7b4 commit 2434645
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions nanoFirmwareFlasher.Library/JLinkCli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,13 @@ public ExitCodes ExecuteFlashBinFiles(
IList<string> addresses,
string probeId)
{
// check file existence
if (files.Any(f => !File.Exists(f)))
List<string> shadowFiles = [];

var processFileResult = ProcessFilePaths(files, shadowFiles);

if (processFileResult != ExitCodes.OK)
{
return ExitCodes.E5004;
return processFileResult;
}

// perform check on address(es)
Expand Down Expand Up @@ -179,10 +182,6 @@ public ExitCodes ExecuteFlashBinFiles(
}
}

List<string> shadowFiles = [];

ProcessFilePaths(files, shadowFiles);

// erase flash
if (DoMassErase)
{
Expand Down Expand Up @@ -284,7 +283,7 @@ public ExitCodes ExecuteFlashBinFiles(
return ExitCodes.OK;
}

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

// check file existence
if (!File.Exists(binFilePath))
{
return ExitCodes.E5004;
}

if (!binFilePath.IsNormalized(NormalizationForm.FormD)
|| binFilePath.Contains(' '))
{
Expand All @@ -315,8 +320,9 @@ private void ProcessFilePaths(IList<string> files, List<string> shadowFiles)
// copy file to shadow list
shadowFiles.Add(binFile);
}

}

return ExitCodes.OK;
}

/// <summary>
Expand All @@ -329,15 +335,14 @@ public ExitCodes ExecuteFlashHexFiles(
IList<string> files,
string probeId)
{
// check file existence
if (files.Any(f => !File.Exists(f)))
{
return ExitCodes.E5004;
}

List<string> shadowFiles = [];

ProcessFilePaths(files, shadowFiles);
var processFileResult = ProcessFilePaths(files, shadowFiles);

if (processFileResult != ExitCodes.OK)
{
return processFileResult;
}

// erase flash
if (DoMassErase)
Expand Down

0 comments on commit 2434645

Please sign in to comment.