====STM32CubeProgrammer====
STM32 programming tools are needed when OpenOCD does not
support the target device or for installing binary blobs
using the firmware update services.
===Windows===
==Path==
C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin
==GUI==
STM32CubeProgrammer.exe
==CLI==
STM32_Programmer_CLI.exe
===Linux===
==ARM==
Install [[:tools:box64|Box64]]
==Install==
Install the AMD64 version for Linux of the programmer into /opt
==Path==
setenv BOX64_LD_LIBRARY_PATH /opt/STM32CubeProgrammer
==Help==
/opt/STM32CubeProgrammer/STM32_Programmer_CLI -h
Dynarec for ARM64, with extension: ASIMD CRC32 PageSize:4096 Running on Cortex-A72 with 4 Cores
Will use Hardware counter measured at 54.0 MHz emulating 3.4 GHz
Params database has 89 entries
Box64 with Dynarec v0.3.1 ea807eda built on Sep 1 2024 19:19:03
BOX64: Didn't detect 48bits of address space, considering it's 39bits
Counted 50 Env var
BOX64 LIB PATH: BOX64 BIN PATH: ./:bin/:/usr/local/bin/:/usr/local/sbin/:/sbin/:/bin/:/usr/sbin/:/usr/bin/
Looking for /opt/STM32CubeProgrammer/STM32_Programmer_CLI
argv[1]="-h"
Rename process to "STM32_Programmer_CLI"
Using emulated /opt/STM32CubeProgrammer/libcrypto.so.1.0.0
Using native(wrapped) libusb-1.0.so.0
Using emulated /opt/STM32CubeProgrammer/libSTLinkUSBDriver.so
Using emulated /opt/STM32CubeProgrammer/libhsmp11.so
Using emulated /opt/STM32CubeProgrammer/libpsa_sdm.so
Using emulated /opt/STM32CubeProgrammer/libQt5SerialPort.so.5
Using emulated /opt/STM32CubeProgrammer/libQt5Xml.so.5
Using emulated /opt/STM32CubeProgrammer/libQt5Script.so.5
Using emulated /opt/STM32CubeProgrammer/libQt5Core.so.5
Using native(wrapped) libpthread.so.0
Using emulated /lib/x86_64-linux-gnu/libstdc++.so.6
Using native(wrapped) libm.so.6
Using emulated /lib/x86_64-linux-gnu/libgcc_s.so.1
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libdl.so.2
Using native(wrapped) libutil.so.1
Using native(wrapped) librt.so.1
Using native(wrapped) libbsd.so.0
Using native(wrapped) libz.so.1
Using emulated /opt/STM32CubeProgrammer/libicui18n.so.56
Using emulated /opt/STM32CubeProgrammer/libicuuc.so.56
Using emulated /opt/STM32CubeProgrammer/libicudata.so.56
Using native(wrapped) libgthread-2.0.so.0
Using native(wrapped) libglib-2.0.so.0
-------------------------------------------------------------------
STM32CubeProgrammer v2.14.0
-------------------------------------------------------------------
Usage :
STM32_Programmer_CLI.exe [command_1] [Arguments_1][[command_2] [Arguments_2]...]
Generic commands:
-?, -h, --help : Show this help
-c, --connect : Establish connection to the device
: Interface identifier. ex COM1, /dev/ttyS0, usb1,
JTAG, SWD...)
USB port optional parameters:
[sn=] : Serial number of the usb dfu
[PID=] : Product ID. ex: 0xA38F, etc, default 0xDF11
[VID=] : Vendor ID. ex: 0x0389, etc, default x0483
UART port optional parameters:
[br=] : Baudrate. ex: 115200, 9600, etc, default 115200
[P=] : Parity bit, value in {NONE,ODD,EVEN}, default EVEN
[db=] : Data bit, value in {6, 7, 8} ..., default 8
[sb=] : Stop bit, value in {1, 1.5, 2} ..., default 1
[fc=] : Flow control
Value in {OFF,Hardware,Software} ..., default OFF
rts= : low or high
dtr= : low or high
Not supported for STM32MP
[noinit=noinit_bit]: Set No Init bits, value in {0,1} ..., default 0
[console] : Enter UART console mode
JTAG/SWD debug port optional parameters:
[freq=] : Frequency in KHz. Default frequencies:
4000 SWD 9000 JTAG with STLINKv2
24000 SWD 21333 with STLINKv3
[index=] : Index of the debug probe. default index 0
[sn=]: Serial Number of the debug probe
[ap=] : Access Port index to connect to. default ap 0
[mode=] : Connection mode. Value in {UR/HOTPLUG/NORMAL/POWERDOWN}
default mode: NORMAL
[reset=] : Reset modes: SWrst/HWrst/Crst. Default mode: SWrst
Reset mode with UR connection mode is HWrst
[shared] : Enable shared mode allowing connection of two or more
instances of STM32CubeProgrammer or other debugger
to the same ST-LINK probe.
[tcpport=] : Port used for running ST-Link Server, default 7184
[LPM] : Enable debug in Low Power mode(default mode)
[dLPM] : Disable debug in Low Power mode
[getAuthID] : Get device identification (Option only for STM32U5 series)
[speed=]: Choose flashing Reliable/fast (Option only for STM32U5 series)
SPI port optional parameters:
[br=] : Baudrate.
[cpha=] : 1Edge or 2Edge. default 1Edge
[cpol=] : low or high
[crc=] : enable or disable (0/1).
[crcpol=] : crc polynom value.
[datasize=] : 8bit/16bit
[direction=] : Direction: 2LFullDuplex/2LRxOnly/1LRx/1LTx
[firstbit=] : First Bit: MSB/LSB
[frameformat=]: Frame Format: Motorola/TI
[mode=] : Mode: master/slave
[nss=] : NSS: soft/hard
[nsspulse=] : NSS pulse: Pulse/NoPulse
[delay=] : Delay: Delay/NoDelay, delay of few microseconds
[noinit=noinit_bit]: Set No Init bits, value in {0,1} ..., default 0
CAN port optional parameters:
[br=] : Baudrate : 125, 250, 500, 1000 Kbps, default 125
[mode=] : CAN Mode : NORMAL, LOOPBACK..., default NORMAL
[ide=] : CAN Type : STANDARD or EXTENDED, default STANDARD
[rtr=] : Frame Format: DATA or REMOTE, default DATA
[fifo=] : Msg Receive : FIFO0 or FIFO1, default FIFO0
[fm=] : Filter Scale: 16 or 32, default 32
[fe=] : Filter Activation : ENABLE or DISABLE, default ENABLE
[fbn=] : Filter Bank Number : 0 to 13, default 0
[noinit=noinit_bit]: Set No Init bits, value in {0,1} ..., default 0
I2C port optional parameters:
[add=] : Slave address : address in hex format
[br=] : Baudrate : 100 or 400 Kbps, default 400
[sm=] : Speed Mode : STANDARD or FAST, default FAST
[am=] : Address Mode : 7 or 10 bits, default 7
[af=] : Analog filter : ENABLE or DISABLE, default ENABLE
[df=] : Digital filter : ENABLE or DISABLE, default DISABLE
[dnf=] : Digital noise filter : 0 to 15, default 0
[rt=] : Rise time : 0-1000(STANDARD), 0-300(FAST), default 0
[ft=] : Fall time : 0-300 (STANDARD), 0-300(FAST), default 0
[noinit=noinit_bit]: Set No Init bits, value in {0,1} ..., default 0
-version, --version : Displays the tool's version
-l, --list : List all available communication interfaces
: UART interface
: USB interface
: st-link interface
: Allowing to list all boards connected to other instance(s)
of STM32CubeProgrammer where the shared mode is enabled.
-q, --quietMode : Enable quiet mode. No progress bar displayed
-log, --log : Store the detailed output in log file
[] : Path of the log file,
default path = $HOME/.STM32Programmer/trace.log
-vb, --verbosity : Specify verbosity level
: Verbosity level, value in {1, 2, 3}
-y, --yes : Ignore confirmation prompt message
Available commands for STM32 MCU:
--skipErase : Skip sector erase before programming
-sl, --safelib : Add a segment into a firmware file (elf,bin
hex,srec and s19) containing computed CRC values
To use only with the safety lib component
: File path to be modified
: Flash memory start address
: Flash memory end address
: Size of data per CRC value
: Optional pattern from 0x0 to 0xFF. Default pattern 0x00
-ms, --mergesbsfu : Add a binary header and a sbsfu segment to an elf file
: File path to be modified
: Header file path
: SBSFU file path
-e, --erase : Erase memory pages/sectors devices:
Not supported for STM32MP
[all] : Erase all sectors
[] : Erase the specified sectors identified by sectors
codes. ex: 0, 1, 2 to erase sectors 0, 1 and 2
for EEPROM : ed1 & ed2
[<[start end]>] : Erase the specified sectors starting from
start code to end code, ex: -e [5 10]
-w, --write
-d, --download : Download the content of a file into device memory
: File path name to be downloaded: (bin, hex, srec, s19
elf, stm32 or tsv file)
[] : Start address of download
-w64 : Write a 64-bits data into device memory
: Start address of download
<64-bit_data> : 64-bit data to be downloaded
values should not be separated by space
-w32 : Write a 32-bits data into device memory
: Start address of download
<32-bit_data> : 32-bit data to be downloaded
values should be separated by space
-w16 : Write a 16-bits data into device memory
: Start address of download
<16-bit_data> : 16-bit data to be downloaded
values should be separated by space
-w8 : Write a 8-bits data into device memory
: Start address of download
<8-bit_data> : 8-bit data to be downloaded
values should be separated by space
-v, --verify : Verify if the programming operation is achieved
successfully
-nv, --noverify : Do not verify if the programming operation is achieved
successfully, used with -w32/-w16/-w8 commands
-checksum, --checksum : Memory checksum calculation
: Optional, Start address
: Optional, Size of memory region
: If the parameters and are not indicated, the tool will calculate the full internal Flash
-r32 : Read a 32-bit data from device memory
: Read start address
: Size of data
-r16 : Read a 16-bit data from device memory
: Read start address
: Size of data
-r8 : Read a 8-bit data from device memory
: Read start address
: Size of data
-rst : Reset system
-hardRst : Hardware reset
Available only with JTAG/SWD debug port
-halt : Halt core
-run : Run core
-step : Step core
Available only with JTAG/SWD debug port
-score : Get core status
Available only with JTAG/SWD debug port
-coreReg : Read/Write core registers
[] R0/../R15/PC/LR/PSP/MSP/XPSR/APSR/IPSR/EPSR/
PRIMASK/BASEPRI/FAULTMASK/CONTROL
[core_reg=] value in case of write opration
Note: multiple registers can be handled at once
Available only with JTAG/SWD debug port
-r, --read
-u, --upload : Upload the device memory content to a .bin/.hex/.srec/.s19 file
: Start address of read and upload
: Size of memory content to be read
: file path with .bin/.hex/.srec/.s19 extension
-el, --extload : Select a custom external memory-loader for JTAG/SWD
: External memory-loader file path
-elbl, --extloadbl : Select a custom external memory-loader for Bootloader interface (SFIx only)
: External memory-loader file path
-s, --start
-g, --go : Run the code at the specified address.
[] : Start address
-rdu, --readunprotect: Remove memory's Read Protection by shifting the RDP
level from level 1 to level 0.
-tzenreg, --tzenregression: Remove TrustZone Protection by disabling the TZEN
from 1 to 0.
-ob, --optionbytes : This command allows the user to manipulate the device
's OptionBytes by displaying or modifying them.
[displ] : This option allows the user to display the whole set
of Option Bytes.
[unlockchip] : This option allows the user to unlock the chip in case
of bad Option Bytes already programmed.
[OptByte=] : This option allows the user to program the given
Option Byte.
-force_no_da, --force_no_da
: Froce OB programming if the DA is not already configured.
Available only for STM32H50x devices
-w32dbgmcu : Write a 32-bits data into DBGMCU DBG AUTH HOST register
<32-bit_data> 32-bit data to be downloaded, only for STM32H5xx devices.
-lockRDP1 : Lock RDP level 1
: First 32-bit of password
: Second 32-bit of password
-unlockRDP1 : Unlock RDP level 1
: First 32-bit of password
: Second 32-bit of password
-lockRDP2 : Lock RDP level 2
: First 32-bit of password
: Second 32-bit of password
-unlockRDP2 : Unlock RDP level 2
: First 32-bit of password
: Second 32-bit of password
-ssigfoxc : Save the chip Certificate,
supported for STM32WL devices
: Certificate file path
-wsigfoxc : Write the Sigfox credential,
supported for STM32WL devices
: Certificate file path (binary, header)
: start address for write
-fillmemory : Fill memory with the given pattern from the chosen address.
: Start address for write. The address 0x08000000 is used by default
[size=] : Size of the data to write
[pattern=] : The pattern value to write.
[dataWidth=8|16|32]: The filling data size:
8 bits is selected by default.
-blankcheck : Verifies that the STM32 Flash memory is blank.
If the Flash memory is not blank, the first address with data is highlighted in a message.
-fchecksum, --file-checksum : File checksum calculation
: File path
Beta commands:
-regdump : Read and dump Core and MCU registers
: Log file path
[choice=] : Device number from the list of compatible devices (optional), this list
is displayed if the command is performed without this optional argument
-hf : Hard fault analyzer
Helps to identify system faults that occur when the CPU
is driven into a fault condition by the application code.
-pwr, --power : Perform power ON/OFF, only for STLINK supporting this capability
: Select the power type
[index=] : Index of the debug probe.
Available commands for STM32 MPU:
-c, --connect : Establish connection to the device
: Interface identifer. ex COM1, /dev/ttyS0, usb1)
USB port optional parameters:
[sn=] : Serial number of the usb dfu
[serial] : Activate USB serial Gadget for MPU devices
UART port optional parameters:
[br=] : Baudrate. ex: 115200, 9600, etc, default 115200
[P=] : Parity bit, value in {NONE,ODD,EVEN}, default NONE
[db=] : Data bit, value in {6, 7, 8} ..., default 8
[sb=] : Stop bit, value in {1, 1.5, 2} ..., default 1
[fc=] : Flow control (Not yet supported for STM32MP)
Value in {OFF,Hardware,Software} ..., default OFF
[noinit=noinit_bit]: Set No Init bits, value in {0,1} ..., default 0
-s, --start
-g, --go : Run the code at the specified partition ID.
[] : Partition ID
If not specified, last loaded partition
will be started
[] : Start address
If not specified, last loaded segment address
[] : No acknowledgment required
If not specified, acknowledgment will be required
-detach : Send detach command to DFU
-wb : Write blob
: Blob file path
-pmic : Program PMIC NVM
: PMIC file_path
-gc, --getcertificate : Get the chip Certificate,
supported for devices with security features
: Certificate file path into which the chip
certificate will be uploaded
: Input TFA SSP signed firmware path. Used only with STM32MP devices
-p, --phaseID : Display the current partition ID to be loaded
-w, --write
-d, --download : Download the content of a file into device memory
: File path name to be downloaded: (bin, stm32 file
: Partition ID to be downloaded
-rp, --readPart : Upload a memory partion ID content to a .bin file
: Partion to be read
[] : Offset address of read and upload
: Size of partion content to be read
: Binary file path
-ssp, --ssp : Program an SSP file
: SSP file path to be programmed, bin or ssp extension
: SSP signed firmware path
[hsm=0|1] : Set user option for HSM use
value in {0 (do not use HSM), 1 (use HSM)}
Default value : hsm=0
: Path to the license file (if hsm=0)
or reader slot ID if HSM is used (hsm=1)
-tm : Force timeout
: Number of milliseconds
-rst : Reset USB device
OTP structure v1 commands :
-otp displ : This command allows the user to display all or parts
of the OTP structure
[upper] : Displays the loaded upper OTP shadow registers
values and status
[lower] : Displays the loaded lower OTP shadow registers
values and status
[ctrl] : Displays the loaded BSEC control registers
-otp program : This command allows the user to program SAFMEM
memory by modifying the OTP words
[wordID=] : This field contains the OTP word number
[value=] : Loads value into the chosen OTP word
[sha_rsl=] : Loads value into the corresponding shadow read
sticky lock bit
[sha_wsl=] : Loads value into the corresponding shadow write
sticky lock bit
[sl=] : Loads value into the corresponding programming sticky
lock bit
[pl=] : Loads value into the corresponding programming perma-
nent lock bit
-otp fwrite : This command allows to program a binary file
[lock] : {Optional} indicate the operation type, update or permanent lock
: Binary file path, 32-bits aligned data
[wordid=] : OTP word number in hex/dec format, start word of program
OTP structure v2 commands :
-otp displ : This command allows the user to display all or parts
of the OTP structure
[word=] : {Optional} display a specific OTP registers {values and status}
Up to 96 OTP words [0 to 95], id value in hex/dec format
-otp write : This command allows to fuse or update OTP words
Up to 96 OTP words [0 to 95] at the same command line
[lock] : {Optional} indicate the operation type, update or permanent lock
[word=] : This field contains the OTP word number in hex/dec format
[value=] : Value to be written in hex format
-otp lock : This command allows to fuse permanently OTP words
Up to 96 OTP words [0 to 95] at the same command line
[word=] : This field contains the OTP word number in hex/dec format
-otp fwrite : This command allows to program a binary file
[lock] : {Optional} indicate the operation type, update or permanent lock
: Binary file path, 32-bits aligned data
[word=] : OTP word number in hex/dec format, start word of program
MCU Secure programming specific commands:
-installipmodule, --installipmodule : Install ip module file
: Path of smu file to be programmed
[hsm=0|1] : Set user option for HSM use
value in {0 (do not use HSM), 1 (use HSM)}
Default value : hsm=0
: Path to the license file (if hsm=0)
or reader slot ID if HSM is used (hsm=1)
note that if it is the case of global license,
please use hsm = 0 with license path.
[] : Destination address of the smu module
-updateipmodule, --updateipmodule : update ip module.
: Path of SMU file containing the update.
[] : Destination address of the smu module
-sfi, --sfi : Program an sfi file
[] : Protocol type to be used : static/live
Only static protocol is supported so far
Default value static
: Path of sfi file to be programmed
[hsm=0|1] : Set user option for HSM use
value in {0 (do not use HSM), 1 (use HSM)}
Default value : hsm=0
: Path to the SFI license file (if hsm=0)
or reader slot ID if HSM is used (hsm=1)
[|slot=slotID]: list of the integrated SMI license files paths
if HSM is not used (hsm=0)
Or readers slot IDs list if HSM is used (hsm=1)
Used only in combined case
the list order should correspond to
modules integration order within the SFI file
-ssfi, --ssfi : Program an ssfi file
: Path of ssfi file to be programmed
: RSSe file path
-smi, --smi : Program an smi file
: Protocol type to be used : static/live
Only static protocol is supported so far
Default value static
: Path of smi file to be programmed
[hsm=0|1] : Set user option for HSM use
value in {0 (do not use HSM), 1 (use HSM)}
Default value : hsm=0
[] : Destination address of the smi module
needed only for relocatable SMI
: Path to the SMI license file (if hsm=0)
or reader slot ID if HSM is used (hsm=1)
-rsse, --rsse : Set the RSSe file path,
supported for devices with security extension
: RSSe file path
-mcsv, --mcsv : Set the MCSV file path indicating SFI's modules configuration
supported for STM32H5xx devices
: MCSV file path with .mcsv extension
-a, --abort : This command allows the user
to clean a not properly finished process.
The currently ongoing operation will stop
and the system will return to idle state
-dsecurity : Disable the security for STM32WL
-setdefaultob : Set default Option Bytes for STM32WL
-rssgetversion, --rssgetversion : get the version of RSS
HSM related commands:
-hsmgetinfo : Read the HSM available information
[slot=] : Slot ID of the Smart Card Reader
Default value: slot=1 (the PC integrated SC reader)
-hsmgetcounter : Read the current value of the license counter
[slot=] : Slot ID of the Smart Card Reader
Default value: slot=1 (the PC integrated SC reader)
-hsmgetfwid : Read the Firmware/Module Identifier
[slot=] : Slot ID of the Smart Card Reader
Default value: slot=1 (the PC integrated SC reader)
-hsmgetstatus : Read the current card life-cycle state
[slot=] : Slot ID of the Smart Card Reader
Default value: slot=1 (the PC integrated SC reader)
-hsmgetlicense : Get a license for the current chip
if counter is not null
: File path into which the received license
will be stored
[slot=] : Slot ID of the Smart Card Reader
Default value: slot=1 (the PC integrated SC reader)
[protocol=] : Protocol type to be used : static/live
Only static protocol is supported so far
Default value static
: Input TFA SSP signed firmware path. Used only for STM32MP devices
-hsmgetlicensefromcertifbin, -hsmglfcb : Get a license for the input certificate
if counter is not null
: Input certificate file path
: File path into which the received license
will be stored
[slot=] : Slot ID of the Smart Card Reader
Default value: slot=1 (the PC integrated SC reader)
[protocol=] : Protocol type to be used : static/live
Only static protocol is supported so far
Default value static
STM32WBxx specific commands:
-getuid64 : Read the device UID
-fusgetstate : Read the FUS state
-fusopgetversion : Read the FUS Operator version
-antirollback : Perform the antirollback operation (Only on Bootloader interface)
-startfus : Perform the startfus operation
Firmware Upgrade commands:
-fwdelete : Delete the BLE stack firmware
-fwupgrade : Upgrade the BLE stack firmware or the FUS firmware
: New firmware image file path
: Start address of download
[firstinstall=0|1] : 1 if it is a first install otherwise 0
optional, Default value: firstinstall=0
[startstack=0|1] : 1 to start the stack after the upgrade otherwise 0
optional, Default value: startstack=1
-v : Verify if the download operation is achieved
successfully before starting upgrade
-startwirelessstack : Start the wireless stack
Key management commands:
-authkeyupdate : Authentication key update
: New authentication key file path.
: This is the public key generated by
: STM32TrustedPackageCreator using -sign command.
-authkeylock : Authentication key lock
: Once locked, it's no longuer possible to change it
: using authkeyupdate command
-wusrkey : Write user key
: User key file path
: User key type, values : 1, 2 or 3.
: 1 = simple key, 2 = master key, 3 = encrypted key.
Serial Wire Viewer specific commands:
-swv : Printf via SWO
> : System Clock in MHz
: ITM port number, values : 0-31, or all for All ports
[] : Path of the SWV log file (optional),
: default path = $USER_HOME/STMicroelectronics/STM32Programmer/SWV_Log/swv.log
-RA : Start the reception of swv automatically
-startswv : Printf via SWO & Start the reception of swv automatically
Script Manager command:
-script : Start the execution of Script File
: Path of the script file (.prg)
Provisionning Command:
-sdp : Start the OBKey Provisioning
: OBKey File Path
Provisioning with password :
-pwd : Start Provisioning with password
value= : Password value
path= : location of password file to be used in Debug Authentication
Debug Authentication options:
[debugauth=<1|2>] : to choose starting authentication(1) or discovery(2)
[pwd=] : required in case of authentication with password
[key=] : required in case of authentication with certificate
[cert=] : required in case of authentication with certificate
[per=] : required in case of authentication with certificate. Possible values are a/b/c/d/e/f/g/h :
(a) Full Regression
(b) Partial Regression
(c) Debug Secure L3
(d) Debug Secure L2
(e) Debug Secure L1
(f) Debug Non Secure L3
(g) Debug Non Secure L2
(h) Debug Non Secure L1
===Resources===
[[https://www.st.com/en/development-tools/stm32cubeprog.html|Download page]]