From 6b4f37b5c9b3262fd220f354b986a4080c91968a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Mon, 16 Aug 2021 19:08:24 +0100 Subject: [PATCH] Improve flashing STM32 with JTAG - Add sleep before connecting to device. --- nanoFirmwareFlasher/StmJtagDevice.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nanoFirmwareFlasher/StmJtagDevice.cs b/nanoFirmwareFlasher/StmJtagDevice.cs index caf32446..fb831613 100644 --- a/nanoFirmwareFlasher/StmJtagDevice.cs +++ b/nanoFirmwareFlasher/StmJtagDevice.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; +using System.Threading; namespace nanoFramework.Tools.FirmwareFlasher { @@ -100,6 +101,9 @@ public ExitCodes FlashHexFiles(IList files) return ExitCodes.E5003; } + // need a couple of seconds before issuing next command + Thread.Sleep(2000); + // try to connect to device with RESET var cliOutput = RunSTM32ProgrammerCLI($"-c port=SWD sn={DeviceId} mode=NORMAL"); @@ -229,8 +233,11 @@ public ExitCodes FlashBinFiles(IList files, IList addresses) } } + // need a couple of seconds before issuing next command + Thread.Sleep(2000); + // try to connect to device with RESET - var cliOutput = RunSTM32ProgrammerCLI($"-c port=SWD sn={DeviceId} mode=UR"); + var cliOutput = RunSTM32ProgrammerCLI($"-c port=SWD sn={DeviceId} mode=NORMAL"); if (!cliOutput.Contains("Connected via SWD.")) {