2025-11-26 2:36 PM - edited 2025-11-26 2:37 PM
Hello,
STM32L4+, CubeProgrammer 2.21, ST-Link V2, Windows 10
I need to do:
* Full flash erase
* Write Application image (.hex or .bin)
* Write Bootloader image (.hex or .bin)
* Set RDP level 1
* Start the application at the Bootloader start address.
-
I am successfully doing this with the CubeProgrammer GUI, but I fail to get it to work with CLI.
The "-e all" command works and says "Mass erase successfully achieved":
C:\"Program Files"\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe -c port=SWD ap=0 -e all
-
However, I have tried numerous variants of the following command (and its separate parts alone) without success:
C:\"Program Files"\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe -c port=SWD freq=3900 ap=0 -e all -w C:\SVN\Path\More_path\hex\Application.elf -w C:\SVN\Path\More_path\hex\Bootloader.hex -ob rdp=0xBB -s 0x08000000
I have also tried with .bin files and their respective start addresses.
The only response I get is the header:
-------------------------------------------------------------------
STM32CubeProgrammer v2.21.0
-------------------------------------------------------------------
-
The command "-c port=SWD freq=3900 ap=0 -s 0x08000000" gives a complete (failure) response:
-------------------------------------------------------------------
STM32CubeProgrammer v2.21.0
-------------------------------------------------------------------
ST-LINK SN : 36FF6C064D59303612251543
ST-LINK FW : V2J46S7
Board : --
Voltage : 3.17V
SWD freq : 1800 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x470
Revision ID : Rev V
Device name : STM32L4Rxxx/STM32L4Sxxx
Flash size : 2 MBytes
Device type : MCU
Device CPU : Cortex-M4
BL Version : 0x95
Debug in Low Power mode enabled
RUNNING Program ...
Address: : 0x8000000
Warning: failed to run application!
Warning: The core is kept under Reset!
Error: Start operation failed
-
I have tried to find a tutorial or a list of CLI command examples but um2237 is a wee bit brief and I haven't found much on the internet.
Grateful for your input.
BR
Niclas
2025-11-26 2:42 PM
> I need to do:
> * Full flash erase
> * Write Application image (.hex or .bin)
> * Write Bootloader image (.hex or bin)
> * Set RDP level 1
> * Start the application at the Bootloader start address.
It's not possible to do the last step. You can't run flash in RDP 1 in debug mode. The chip needs to boot up normally.
2025-11-27 2:33 AM
Thank you TDK,
So, I need to do:
> * Full flash erase
> * Write Application image (.hex or .bin)
> * Write Bootloader image (.hex or bin)
> * Start the application at the Bootloader start address.
This works in the STM32CubeProgrammer 2.21.0 GUI. (And setting RDP to level 1 as an individual step.)
The log from the GUI using JLINK (omitting the RDP change) is:
11:24:13 : UR connection mode is defined with the SWrst reset mode
11:24:13 : 506000727
11:24:13 : Device=Cortex-M4
11:24:13 : Device ID : 0x470
11:24:13 : Voltage : 3.26V
11:24:13 : UPLOADING OPTION BYTES DATA ...
11:24:13 : Bank : 0x00
11:24:13 : Address : 0x40022020
11:24:13 : Size : 20 Bytes
11:24:13 : Bank : 0x01
11:24:13 : Address : 0x40022044
11:24:13 : Size : 16 Bytes
11:24:13 : UPLOADING ...
11:24:13 : Size : 1024 Bytes
11:24:13 : Address : 0x8000000
11:24:13 : Read progress:
11:24:13 : Data read successfully
11:24:13 : Time elapsed during the read operation is: 00:00:00.012
11:24:17 : Opening and parsing file: Application.elf
11:24:17 : Memory Programming ...
11:24:17 : File : Application.elf
11:24:17 : Size : 513.84 KB
11:24:17 : Address : 0x08009000
11:24:17 : Erasing memory corresponding to segment 0:
11:24:17 : Erasing internal memory sectors [9 137]
11:24:20 : Download in Progress:
11:24:31 : File download complete
11:24:31 : Time elapsed during download operation: 00:00:13.552
11:24:37 : Opening and parsing file: Bootloader.elf
11:24:37 : Memory Programming ...
11:24:37 : File : Bootloader.elf
11:24:37 : Size : 93.74 KB
11:24:37 : Address : 0x08000000
11:24:37 : Erasing memory corresponding to segment 0:
11:24:37 : Erasing internal memory sectors [0 2]
11:24:37 : Erasing memory corresponding to segment 1:
11:24:37 : Erasing internal memory sector 3
11:24:37 : Erasing memory corresponding to segment 2:
11:24:37 : Erasing internal memory sectors [256 277]
11:24:38 : Download in Progress:
11:24:40 : File download complete
11:24:40 : Time elapsed during download operation: 00:00:02.785
11:24:40 : RUNNING Program ...
11:24:40 : Address: : 0x08000000
11:24:40 : Application is running, Please Hold on...
11:24:40 : Start operation achieved successfully
11:24:53 : Disconnected from device.
It should be mentioned that both when using ST-Link V2 and JLINK Ultra+, I now sometimes need to do the above procedure twice to get it to actually succeed with "Run after programming".
-
I've continued testing various approaches with CLI without success:
* CubeProgrammer 2.17.0, 2.20.0, and 2.21.0 with ST-Link v2 (latest FW)
* .elf (with and without address) and .bin, .hex, and .srec with address
* Segger JLINK ULTRA+ (latest FW)
* Files generated by CubeIDE 2.0.0 in both debug config (debug level 3, no optimization) and release (no debug info, optimization for size)
The common behaviour is that the commands that don't involve -w seem to be accepted and processed.
-
Just issuing
C:\"Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe"
doesn't respond at all (although some internet sources claim that this should respond with a list of possible actions).
2025-11-27 3:59 AM
The MCU is STM32L4S7ZIT6.