cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeProgrammer Wrong erase parameter causing DEV_CONNECT_ERR

Windows 11, STM32CubeProgrammer v2.15 and ST Link

In the past we have used the older STLink software for programming ST micro's on our test stations and have moved to the STM32CubeProgrammer. Running the command from a standard command line window(based on commands seen here) seems to always kick out some form of parameter error.

"C:/Program Files/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/STM32_Programmer_CLI.exe" -c port=swd -e all controller_01_15.hex -rst
-------------------------------------------------------------------
STM32CubeProgrammer v2.15.0
-------------------------------------------------------------------

ST-LINK SN : 38FF6806304E4B3019122243
ST-LINK FW : V2J29S7
Board : --
Voltage : 3.24V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x460
Revision ID : Rev B
Device name : STM32G07x/STM32G08x
Flash size : 128 KBytes
Device type : MCU
Device CPU : Cortex-M0+
BL Version : 0xB2
Debug in Low Power mode enabled

Error: Wrong erase parameter: "controller_01_15.hex"

 

If you ditch the erase parameter completely, it then complains about the connection parameter

"C:/Program Files/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/STM32_Programmer_CLI.exe" -c port=swd C:\Python\furnace_control\hex_files_for_programming\controller_01_15.hex -rst
-------------------------------------------------------------------
STM32CubeProgrammer v2.15.0
-------------------------------------------------------------------

Warning: Wrong connect parameter: "controller_01_15.hex"
ST-LINK SN : 38FF6806304E4B3019122243
ST-LINK FW : V2J29S7
Board : --
Voltage : 3.25V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x460
Revision ID : Rev B
Device name : STM32G07x/STM32G08x
Flash size : 128 KBytes
Device type : MCU
Device CPU : Cortex-M0+
BL Version : 0xB2
Debug in Low Power mode enabled

MCU Reset

Software reset is performed

 

Hopefully there is a simple answer as the parameters used seem to match the command line help usage.

 

Thanks

3 REPLIES 3

Just thought I'd update this. It appears STM32_Programmer_CLI.exe command line parsing is not the best. If you add a "-w" in front of the file name, the command will run without issue.

The reason for requesting help on this was that we have recently tried using the STM32_Programmer_CLI.exe in our test stations for programming production boards. The test stations use Python Popen() calls for the board programming using ST-LINK_CLI.exe. When we moved to a new test station and tried using the STM32_Programmer_CLI.exe, after 10-20 successful programming attempts, the Popen() call would fail with a DEV_CONNECT_ERR. 

We have tried numerous different command line options in an attempt to use STM32_Programmer_CLI.exe(currently using the -q option for minimal text output), but the Popen() call will eventually fail. What seems odd is that the Popen() call will return a success and then the next will fail with the DEV_CONNECT_ERR.

 If we ever figure out what is going on we will post back here but until then we will fall back to using the ST-LINK_CLI.exe as we have run out of time trying to troubleshoot this.

We think we have found the issue using the STM32_Programmer_CLI.exe. Running the following command has run 35 times so far without issue:

"C:/Program Files/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/STM32_Programmer_CLI.exe" -q -c port=swd -e all -w self.fileName 

We removed the "-rst" from the command sent into the Popen() call. In our older use of ST-LINK_CLI.exe command we used a -HardRst for insuring that the processor was reset after the download was complete. Examining the command line help for STM32_Programmer_CLI.exe, there are two "-rst" mentioned:


-rst : Reset system

And

-rst : Reset USB device


The Reset USB is listed under "Beta commands" so we are not sure which one is used. Because we see the USB device driver hang with an error, the assumption is that the command is resetting the USB. We never saw a USB driver failure running STM32_Programmer_CLI.exe from a Command Prompt window, only when running it from a Popen() call in Python.


We will continue testing and update this ticket if we have any failures.

 

It has failed after just over 40 programming cycles. Running it from a Windows Command Prompt never causes the issue. So running this command from Python 3.10.6 will occasionally hang the utility with a DEV_CONNECT_ERR. 

 

 

self.proc = Popen(['C:/Program Files/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/STM32_Programmer_CLI.exe', '-q', '-c', 'port=swd',  '-e', 'all', '-w', self.fileName, '-rst' ], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, universal_newlines=True)