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
2026-01-28 3:29 AM
Unfortunately, the RESET switch approach doesn't work when an RDP level change is done.
The Option bytes must be re-read and re-loaded, which happens at a Power On Reset (POR) or when bit FLASH->CR OBL_LAUNCH is set. The latter is not accessible via SWD/JTAG after RDP has been changed to 0xBB or 0xCC.
There is hope that a usable sequence can be achieved by changing RDP to 0xBB and setting bit FLASH->CR OBL_LAUNCH from program code.