Skip to content

Commit

Permalink
Fix ST devices that cannot handle DFU packages (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
networkfusion authored Mar 13, 2021
1 parent ac13292 commit abb81dc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
9 changes: 7 additions & 2 deletions nanoFirmwareFlasher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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

Expand Down
7 changes: 2 additions & 5 deletions nanoFirmwareFlasher/Stm32Firmware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions nanoFirmwareFlasher/Stm32Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ internal static async System.Threading.Tasks.Task<ExitCodes> 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);
Expand Down Expand Up @@ -120,7 +123,7 @@ internal static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync
return ExitCodes.E1003;
}
}
else
else if (connectedStJtagDevices.Count != 0)
{
// JATG device
jtagDevice = new StmJtagDevice(jtagId);
Expand Down Expand Up @@ -162,6 +165,11 @@ internal static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync

return programResult;
}
else
{
// no device was found to update.
return ExitCodes.E7000;
}
}

internal static ExitCodes ResetMcu(
Expand Down

0 comments on commit abb81dc

Please sign in to comment.