Skip to content

Commit 2365aba

Browse files
authored
Improve flashing STM32 with JTAG (#72)
1 parent 01ddab2 commit 2365aba

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

nanoFirmwareFlasher/StmJtagDevice.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Linq;
1111
using System.Text;
1212
using System.Text.RegularExpressions;
13+
using System.Threading;
1314

1415
namespace nanoFramework.Tools.FirmwareFlasher
1516
{
@@ -100,6 +101,9 @@ public ExitCodes FlashHexFiles(IList<string> files)
100101
return ExitCodes.E5003;
101102
}
102103

104+
// need a couple of seconds before issuing next command
105+
Thread.Sleep(2000);
106+
103107
// try to connect to device with RESET
104108
var cliOutput = RunSTM32ProgrammerCLI($"-c port=SWD sn={DeviceId} mode=NORMAL");
105109

@@ -229,8 +233,11 @@ public ExitCodes FlashBinFiles(IList<string> files, IList<string> addresses)
229233
}
230234
}
231235

236+
// need a couple of seconds before issuing next command
237+
Thread.Sleep(2000);
238+
232239
// try to connect to device with RESET
233-
var cliOutput = RunSTM32ProgrammerCLI($"-c port=SWD sn={DeviceId} mode=UR");
240+
var cliOutput = RunSTM32ProgrammerCLI($"-c port=SWD sn={DeviceId} mode=NORMAL");
234241

235242
if (!cliOutput.Contains("Connected via SWD."))
236243
{

0 commit comments

Comments
 (0)