Skip to main content
Lead II
February 21, 2023
Solved

STM32_Programmer_CLI doesn't return errorlevel in case of some errors

  • February 21, 2023
  • 1 reply
  • 1300 views

I use STM32_Programmer_CLI.exe (from STM32CubeMX version 2.11.0) to flash an STM32 with internal and external flash. In some cases the tool prints an error in red in the terminal and exits with errorlevel is set to 0.

If I want to use success or failure as a condition in my script I run into problems.

I have the following simplified script (test.cmd):

@echo off
set "STfilepath=C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe"
"%STfilepath%" -c port=swd -w "elf_file.elf" 0x90000000 -el "stldr_file.stldr"
echo ERRORLEVEL=%ERRORLEVEL%

If my debugger is not plugged or the target is not connected I get ERRORLEVEL=1.

If my debugger and target are both connected, but either the elf file or the stldr file are not found I get an errormessage printed in red in the terminal, but the errorlevel is set to 0.

No programmer connected:

./test.cmd
 -------------------------------------------------------------------
 STM32CubeProgrammer v2.11.0
 -------------------------------------------------------------------
Warning: The external loader file does not exist:
stldr_file.stldr
Error: No debug probe detected.
ERRORLEVEL=1

Debugger and target connected:

./test.cmd
 -------------------------------------------------------------------
 STM32CubeProgrammer v2.11.0
 -------------------------------------------------------------------
 
Warning: The external loader file does not exist:
stldr_file.stldr
ST-LINK SN : 003300193438510734313939
ST-LINK FW : V3J10M3B5S1
Board : STLINK-V3SET
Voltage : 3.31V
SWD freq : 24000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x480
Revision ID : --
Device name : STM32H7A/B
Flash size : 2 MBytes
Device type : MCU
Device CPU : Cortex-M7
BL Version : 0x91
 
Warning: Write address is ignored for hex, Srec, s19 and elf files
 
Memory Programming ...
Error: File does not exist: elf_file.elf
ERRORLEVEL=0

In my opinion this is a bug and needs to be fixed.

This topic has been closed for replies.
Best answer by Aziz BRIGUI

Hello @Community member​,

Thank you for your feedback,

This bug is fixed in the latest version of STM32CubeProgrammer (v2.13) available under this link.

Aziz

1 reply

Aziz BRIGUI
Aziz BRIGUIBest answer
Technical Moderator
February 27, 2023

Hello @Community member​,

Thank you for your feedback,

This bug is fixed in the latest version of STM32CubeProgrammer (v2.13) available under this link.

Aziz

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.