Activating device KO, please verify the boot mode configuration and check the serial port configuration. Using C# “Process”

  Kiến thức lập trình

I’m encountering an issue while executing my batch file with parameters. Below is the relevant code snippet:

Process process = new Process();
string batchFilePathDynamically = new FileInfo("STprogrammer1.bat").FullName.ToString();
process.StartInfo.FileName = batchFilePathDynamically;
process.StartInfo.WorkingDirectory = Path.GetDirectoryName(batchFilePathDynamically);
comToBatch = cbCOM.Text.ToString();
baudRateToBatch = cbBaudRate.Text.ToString();
if (g_ConfigForm_SimulationfileName.Contains(' '))
   g_ConfigForm_SimulationfileName = '"' + g_ConfigForm_SimulationfileName + '"';
process.StartInfo.Arguments = comToBatch + " " + baudRateToBatch + " " + g_ConfigForm_SimulationfileName;

And here’s the content of my batch file (without parameters built in):

@echo on

“C:Program FilesSTMicroelectronicsSTM32CubeSTM32CubeProgrammerbinSTM32_Programmer_CLI.exe” -c port=”%1″ br=”%2″ -e 0 -w “%~3” 0x08000000 -v -log logoutput.prg

This code works initially. However, after turning off the device and then turning it on again, I encounter the error: “Activating device KO, please verify the boot mode configuration and check the serial port configuration”. To resolve this, I need to turn off the device, turn it on again, and connect via STM32CubeProgrammer to my COM port. After doing this, my batch file works as expected.

It’s worth noting that when I run the batch file directly from CMD, it works without any issues, regardless of whether parameters are included or not. I even attempted to modify my batch file and run it with built-in parameters, but unfortunately, it didn’t resolve the issue.

Any insights or suggestions on how to resolve this issue would be greatly appreciated.


New contributor

user25082777 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.