Dm00403500-Stm32cubeprogrammer-Software-Description-Stmicroelectronics (1) - Compressed
Dm00403500-Stm32cubeprogrammer-Software-Description-Stmicroelectronics (1) - Compressed
Dm00403500-Stm32cubeprogrammer-Software-Description-Stmicroelectronics (1) - Compressed
User manual
STM32CubeProgrammer software description
Introduction
STM32CubeProgrammer (STM32CubeProg) provides an all-in-one software tool to
program STM32 devices in any environment: multi-OS, graphical user interface or
command line interface, and supports a wide choice of connections (JTAG, SWD, USB,
UART, SPI, CAN, I2C), with manual operation or automation through scripting.
This document details the hardware and software environment prerequisites, as well as the
available STM32CubeProgrammer software features.
Contents
1 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.1 System requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
1.2 Installing STM32CubeProgrammer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
1.2.1 Linux install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.2.2 Windows install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.2.3 macOS install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.2.4 DFU driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.2.5 ST-LINK driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3 Updater . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.1 Update steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.2 Proxy settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.3 Check for updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
List of tables
List of figures
Figure 101. Sub-menu displayed from “Read” combo-box in device memory tab . . . . . . . . . . . . . . . . . 89
Figure 102. Sub-menu displayed with right click on “Device memory” tab . . . . . . . . . . . . . . . . . . . . . . 89
Figure 103. Sub-menu displayed with right click on the cell of grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Figure 104. Sub-menu displayed with add tab button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Figure 105. Sub-menu displayed with right click on the opened file tab . . . . . . . . . . . . . . . . . . . . . . . . 90
Figure 106. Sub-menu displayed from “Download” combo-box displayed in file tab . . . . . . . . . . . . . . . 90
Figure 107. Data width: 32 bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Figure 108. Data width: 16 bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Figure 109. Data width: 8 bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Figure 110. Multiple comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Figure 111. Live update of data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Figure 112. Calculator window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Figure 113. STM32CubeProgrammer: available commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Figure 114. Connect operation using RS232 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Figure 115. Enabling COM DTR pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Figure 116. Connect operation using USB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Figure 117. Connect operation using USB DFU options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Figure 118. Connect operation using SWD debug port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Figure 119. Connect operation using SPI port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Figure 120. Connect operation using CAN port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Figure 121. Connect operation using I2C port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Figure 122. Download operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Figure 123. Read 32-bit operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Figure 124. List of available serial ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Figure 125. Verbosity command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Figure 126. Log command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Figure 127. Log file content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Figure 128. Safety lib command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Figure 129. Flash memory mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Figure 130. Flash memory mapping example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Figure 131. SWV command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Figure 132. startswv command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Figure 133. Output of unlockchip command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Figure 134. Disable security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Figure 135. Configure option bytes to their default values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Figure 136. Example of -ssigfoxc command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Figure 137. Example 1 of -wsigfoxc command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Figure 138. Example 2 of -wsigfoxc command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Figure 139. Read core and MCU registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Figure 140. Fault analyzer CLI view when Hard Fault is detected. . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Figure 141. Example of File checksum command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Figure 142. Checksum command output for the internal flash memory. . . . . . . . . . . . . . . . . . . . . . . . 136
Figure 143. Checksum command output for an external memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Figure 144. Checksum command output at the end of file download . . . . . . . . . . . . . . . . . . . . . . . . . 137
Figure 145. OBKey provisioning example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Figure 146. Discovery log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Figure 147. Debug authentication with password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Figure 148. Debug authentication with certificate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Figure 149. STM32CubeProgrammer main window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Figure 150. TSV programming window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Figure 151. OTP MPU window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Figure 152. Edit denial for locked words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
1 Getting started
a. Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
Note: When using USB DFU interface or ST-LINK interface on a Windows 7 PC, ensure that all
the drivers of the USB 3.0 controller drivers are updated. Older versions of the drivers may
have bugs that prevent access or cause connection problems with USB devices.
1.3 Updater
STM32CubeProgrammer updater allows users to make automatic updates of the software
and its associated packages. The updater is available in all supported operating systems,
namely Windows 10/11, Linux, and macOS.
If there is a new version available, an update button appears in the main menu (Figure 8).
Note: If the user has already updated the STM32CubeProgrammer, the hyperlink button is no
longer displayed at startup.
If a new version is available, the user can make updates through the updater window.
This window displays:
• The current version of the STM32CubeProgrammer
• The available version in server of STM32CubeProgrammer
• Change log (contains the main changes delivered in the new package)
• License
• Last update (contains the date of the last update, or the message “No previous updates
are done”)
• The current version of the updater tool
• Refresh button (used to check if there is a new version)
• Close button (used to stop the installation of the new version)
Note: Administrator rights are required to download the new package. Once the update is done,
the updater window displays only the new version.
The main window is composed of the parts described in the following sections.
ST-LINK settings
• Serial number: this field contains the serial numbers of all connected ST-LINK probes.
The user can choose one of them, based on its serial number.
• Port: ST-LINK probe supports two debug protocols, JTAG and SWD.
Note: JTAG is not available on all embedded ST-LINK in the STM32 Nucleo or Discovery boards.
• Frequency: the JTAG or SWD clock frequency
• Access port: selects the access port to connect to. Most of the STM32 devices have
only one access port, which is Access port 0.
• Mode:
– Normal: with “Normal” connection mode, the target is reset then halted. The type
of reset is selected using the “Reset Mode” option.
– Connect under reset: this mode enables connection to the target using a reset
vector catch before executing any instructions. This is useful in many cases, for
example when the target contains a code that disables the JTAG/SWD pins.
– Hot plug: enables connection to the target without a halt or reset. This is useful for
updating the RAM addresses or the IP registers while the application is running.
– Power down: used to put the target in debug mode, even if the application has not
started since the target power-up. The hardware reset signal must be connected
between ST-LINK and the target. This feature can be not fully effective on some
boards (MB1360, MB1319, MB1361, MB1355) with STMPS2141 power switch.
• Reset mode:
– Software system reset: resets all STM32 components except the Debug via the
Cortex-M application interrupt and reset control register (AIRCR).
– Hardware reset: resets the STM32 device via the nRST pin. The RESET pin of
the JTAG connector (pin 15) must be connected to the device reset pin.
– Core reset: resets only the Cortex-M via the AIRCR.
• Speed (Cortex-M33 only):
– Reliable: allows the user to connect with a slow mode.
– Fast: allows the user to connect with a fast mode.
• Shared: enables shared mode allowing connection of two or more instances of
STM32CubeProgrammer or other debugger to the same ST-LINK probe.
• Debug in low-power mode (STM32U5/WB/L4 series only): sets the bits in
DBGMCU_CR to 1.
• External loader: displays the name of the external memory loader selected in the
“External loaders” panel accessible from the main menu (Hamburger menu).
• Target voltage: target voltage is measured and displayed.
• Firmware version: displays the ST-LINK firmware version. The firmware upgrade
button allows you to upgrade the ST-LINK firmware.
UART settings
• Port: selects the com port to which the target STM32 is connected. Use the refresh
button to recheck the available com port on the PC.
Note: The STM32 must boot in bootloader mode using boot pins and/or the option bits. Check
AN2606 “STM32 microcontroller system memory boot mode”, available on www.st.com, for
more information on the STM32 bootloader.
• Baudrate: selects the UART baud rate.
• Parity: selects the parity (even, odd, none), must be ”even” for all STM32 devices.
• Data bits: must be always 8, only 8-bit data is supported by the STM32.
• Stop bits: must be always 1, only 1-bit stop is supported by the STM32.
• Flow control: must be always off.
• RTS (request to send): sets the COM RTS pin to either high or low level.
• DTR (data terminal ready): sets the COM DTR pin to either high or low level.
USB settings
• Port: selects the USB devices in DFU mode connected to the PC. You can use the
refresh button to recheck the available devices.
Note: The STM32 must boot in bootloader mode using boot pins and/or the option bits. Check
AN2606, available on www.st.com, for more information.
Once the correct interface settings are set, click on the “Connect” button to connect to the
target interface. If the connection succeeds, it is shown in the indicator above the button,
which turns to green.
Once connected, the target information is displayed in the device information section below
the settings section, which is then disabled as in Figure 14.
SPI settings
• Serial number: this field contains the serial numbers of all connected ST-LINK-V3
probes in case of use of SPI bootloader.
• Port: selects the SPI devices connected to the PC. Use the refresh button to recheck
the available devices.
• Baudrate: selects the SPI baud rate.
• nss: slave select software or hardware.
• nsspulse: the slave selection signal can operate in a pulse mode, where the master
generates pulses on nss output signal between data frames for a duration of one SPI
clock period when there is a continuous transfer period.
• Delay: used to insert a delay of several microseconds between data.
• Direction: must be always Full-duplex, both data lines are used, and synchronous data
flows in both directions.
CAN settings
• Serial number: this field contains the serial numbers of all connected ST-LINK-V3
probes in case to use CAN bootloader.
• Port: selects the CAN devices connected to the PC. You can use the refresh button to
recheck the available devices.
• Baudrate: selects the CAN baud rate.
• Assigned FIFO: selects the receive FIFO memory to store incoming messages.
• Filter mode: selects the type of the filter, MASK, or LIST.
• Filter scale: selects the width of the filter bank, 16 or 32 bits.
• Filter bank: values between 0 and 13, to choose the filter bank number.
I2C settings
• Serial number: this field contains the serial numbers of all connected ST-LINK-V3
probes when using the I2C bootloader.
• Port: selects the I2C devices connected to the PC. You can use the refresh button to
recheck the available devices.
• Baudrate: selects the I2C baud rate.
• Address: adds the address of the slave bootloader in hex format.
• Speed mode: selects the speed mode of the transmission Standard or Fast.
• Rise time: chooses values according to Speed mode, 0-1000 (STANDARD), 0-300
(FAST).
• Fall time: chooses values according to Speed mode, 0-300 (STANDARD), 0-400
(FAST).
After target connection, the STM32 target memory can be read using this panel. To do this,
specify the address and the size of the data to be read, then press the Read button in the
top-left corner. Data can be displayed in different formats (8-, 16-, and 32-bit) using the
“Data width” combo box.
The user can read all the flash memory using the “Read All” button, save the device memory
content in a .bin, .hex, or .srec file using the “Save As...” menu from the tab contextual menu
or the action button.
Multiple device memory tabs can be opened to display different locations of the target
memory. To do this, click on the “+” tab to display a contextual menu that allows you to add
a new “Device memory” tab, or to open a file and display it in a “File” tab.
The address field can be modified to display the file content starting from an offset. Using
the tab contextual menu or the action button, the file can be downloaded using the
“Download” button/menu. For a binary file, specify the download address in the “Address”
menu. The user can verify if the file is downloaded using the “Verify” menu, and save it in
another format (.bin, .hex or .srec).
As for the “Device memory” tab, the user can display the file memory content in different
formats (8-, 16-, and 32-bit), using the “Data width” combo box.
Memory erasing
Once connected to a target, the memory sectors are displayed in the right-hand panel,
showing the start address and the size of each sector. To erase one or more sectors, select
them in the first column, and then click on the “Erase selected sectors” button.
Select 'Full Flash memory checksum' to enable checksum calculation at the end of the
download file.
The “Full chip erase” button erases the whole memory.
Memory programming
To program a memory, go through the following steps:
1. Click on the browse button and select the file to be programmed. The supported
formats are binary files (.bin), ELF files (.elf, .axf, .out), Intel hex files (.hex) and
Motorola S-record files (.Srec).
2. In case of programming a binary file, the address must be set.
3. Select the programming options:
– Verify after programming: read back the programmed memory and compare it byte
per byte with the file.
– Skip flash memory erase before programming: if checked, the memory is not
erased before programming. This option must be checked only when you are sure
that the target memory is already erased.
– Run after programming: start the application just after programming.
4. Click on the “Start programming” button to start programming.
The progress bar on the bottom of the window shows the progress of the erase and
programming operations.
Loader_Src.c file
The development of an external loader for a memory, based on a specific IP, requires the
following functions:
• Init
Defines the used GPIO pins connecting the external memory to the device, and
initializes the clock of the used IPs.
Returns 1 if success, and 0 if failure.
int Init (void)
• Write
Programs a buffer defined by an address in the RAM range.
Returns 1 if success, and 0 if failure.
int Write (uint32_t Address, uint32_t Size, uint8_t* buffer)
• SectorErase
Erases the memory specified sectors.
Returns 1 if success, and 0 if failure.
int SectorErase (uint32_t StartAddress, uint32_t EndAddress)
Where “StartAddress” equals the address of the first sector to be erased and
“EndAddress” equals the address of the end sector to be erased.
Note: This function is not used in case of an external SRAM loader.
It is imperative to define the functions mentioned above in an external loader. They are used
by the tool to erase and program the external memory. For instance, if the user clicks on the
program button from the external loader menu, the tool performs the following actions:
• Automatically calls the Init function to initialize the interface (such as QSPI, FMC)
and the flash memory
• Calls SectorErase() to erase the needed flash memory sectors
• Calls the Write() function to program the memory
In addition to these functions, you can also define the functions below:
• Read function
The Read function is used to read a specific range of memory, and returns the reading
in a buffer in the RAM.
Returns 1 if success, and 0 if failure.
int Read (uint32_t Address, uint32_t Size, uint16_t* buffer)
Where “Address” = start address of read operation, “Size” is the size of the read
operation and “buffer” is the pointer to data read.
Note: For Quad-/Octo-SPI memories, the memory mapped mode can be defined in the Init
function; in that case, the Read function is useless, as data can be read directly from
JTAG/SWD interface.
• Verify function
The Verify function is called when selecting the “verify while programming” mode.
This function checks if the programmed memory corresponds to the buffer defined in
the RAM. It returns an uint64 defined as follows:
Return value = ((checksum<<32) + AddressFirstError)
where AddressFirstError is the address of the first mismatch, and checksum is the
checksum value of the programmed buffer.
uint64_t Verify (uint32_t FlashAddr, uint32_t RAMBufferAddr,
uint32_t Size)
• MassErase function
The MassErase function erases the full memory.
Returns 1 if success, and 0 if failure.
int MassErase (void)
• A checksum function
All the functions described return 1 in case of a successful operation, 0 in case of a fail.
Dev_Inf.c file
The StorageInfo structure defined in this file provides information on the external memory.
An example of the type of information defined by this structure is given below:
#if defined (__ICCARM__)
__root struct StorageInfo const StorageInfo = {
#else
struct StorageInfo const StorageInfo = {
#endif
”External_Loader_Name”, // Device Name + version number
MCU_FLASH, // Device Type
0x08000000, // Device Start Address
For more details refer to the option bytes section in the programming and reference
manuals, available from www.st.com.
When switching PRODUCT_STATE from 0xED (open) to values different from 0x17
(provisioning), the user is asked to pass by the provisioning state first (Figure 27).
Figure 27. Configuration when switching product state to values different from 0x17
If the user chooses to provision a default DA configuration, the tool provisions the OBK file
under the “bin/ DA_Default_Config” directory. To perform debug authentication, the files
under “bin/DA_Default_Config” directory are required.
When switching PRODUCT_STATE from 0xED (open) to values different from 0x17
(provisioning), the tool checks if there is a password provisioned in OTP. If not, the user is
asked to pass by the provisioning state first.
All automatic mode traces are indicated in the Log panel (see Figure 31), to show the
process evolution and user intervention messages.
Graphical guide
• Connection to a first target must be established before performing automatic mode to
collect connection parameters values associated to all next devices.
• If the Download file is checked, the system takes all Download file options in
consideration, otherwise any Download option is performed.
• If the Option bytes commands is checked, the text field is activated, then the user can
insert option bytes commands (like CLI commands), and make sure that there are no
white spaces at the beginning:
-ob [OptionByte=value] [OptionByte=value] [OptionByte=value] …
• Example of Option bytes command: “–ob BOR_LEV=0 nBOOT0=1”
• If the Start automatic mode button is pressed, the system enters in a loop, until a
system stop is called.
• While the automatic mode is in execution state, all graphical objects are disabled.
• The user can stop the process at any time by pressing Cancel or Stop automatic mode
buttons.
Log messages
• “Starting Automatic Mode...”
Indicates that the system successfully entered the automatic process.
• “More than one ST-LINK probe detected! Keep only one ST-LINK probe! “
The automatic mode cannot be used if more than one ST-LINK probe is connected to
the computer when using JTAG/SWD interfaces. A message is displayed, asking the
user to keep only one ST-LINK probe connected to continue using this mode.
• “More than one ST-LINK Bridge detected! Keep only one ST-LINK Bridge!”
The automatic mode cannot be used if more than one ST-LINK bridge is connected to
the computer when using bootloader interface SPI/CAN/I2C interfaces. A message is
displayed, asking the user to keep only one ST-LINK bridge connected to continue
using this mode.
• “More than one ST-LINK USB DFU detected! Keep only one USB DFU!”
The automatic mode cannot be used if more than one USB DFU is connected to the
computer when using USB bootloader interface. A message is displayed, asking the
user to keep only one USB DFU connected to continue using this mode.
• “More UART ports detected than last connection!”
During the first connection the automatic mode calculates the number of the available
serial ports, and puts it as a reference, to detect correctly that only one port UART is
used for each STM32 device.
• “Please disconnect device and connect the next...”
If the system finishes the first process, and whatever the result, disconnect the current
device to prepare the second device connection.
• “Waiting for device...”
Once the connection to the previous device is correctly lost, the system keeps
searching for a new device.
• “Automatic Mode is stopped.”
Indicates that there is a cancel request, and the system stops the process.
Connected target
STLINK DFU UART SPI CAN I2C
Start
Error Checked
Full chip erase
No
Full chip erase
Stop
Checked No
Download file Skip erase
Stop No Checked
Sector erase
OB commands
Download file
No
Option bytes
programming Checked
Verify
Stop
No
Verify after
programming
Disconnect
Checked
Run
No
Start
Stop
Waiting
Stop
MS51811V1
To download WB stacks and FUS from www.st.com, press on the logo, as shown in
Figure 38.
User authentication
FUS window allows a user authentication key to be stored through the update key button
(Figure 40).
Once the user authentication key is installed, it can be changed, unless the lock user
authentication key button is selected (see Figure 41). Once the authentication key is
installed, the install or upgrade services must be done with the double signed FUS/Stack, or
it is rejected.
For more information about the customer key storage, refer to AN5185 “ST firmware
upgrade services for STM32WB Series”. For complete documentation on STM32WBxx
products visit the dedicated pages on www.st.com.
After specifying the SWV configuration, SWV reception can be started or stopped using the
“Start” and “Stop” buttons. The SWO data is displayed in the dedicated area, which can be
cleared by using the “Clear” button.
The SWV information bar displays useful information on the current SWV transfer, such as
the SWO frequency (deduced from the system clock frequency), and the received printf data
number (expressed in bytes).
Note: Some SWV bytes can be lost during transfer, due to ST-LINK hardware buffer size limitation.
2.9.1 Introduction
This window facilitates STM32CubeProgrammer CLI commands for secure programming:
• RDP regression with password feature: available for STM32U5 series
• SFI/SFIx feature: available for STM32H7, STM32U5 and STM32L5 series
2.9.3 SFI/SFIx
SFI GUI
1. Use STM32CubeProgrammer (version 2.11 or higher)
2. Access the SWD/bootloader interface
3. Open Secure Programming interface, then SFI tab (Figure 50)
4. Select the license source (from a license file or directly from your connected HSM)
5. Select the sfi file, once selected, the sfi parsed info is displayed as in Figure 52
6. Select the RSSe file (if needed)
7. Start sfi sequence (see Figure 51)
Note: To open TPC to generate the sfi file, press on the TPC logo, as shown in Figure 53.
SFIx GUI
To perform a successful sfix operation using this graphical interface, perform the same
steps described in SFI GUI, with two minor modifications:
1. Select an sfix (not an sfi).
2. Select the external loader via External loaders window. Once done, the name is
displayed automatically in the text field below (Figure 54).
Then you can start the sfix sequence.
2.9.4 SSP
STM32CubeProgrammer user interface (UI) exports several capabilities that can be used to
execute the SSP flow.
To open the SSP window, connect an MPU device via DFU interface, click on security panel,
and then choose the SSP tab. The window contains the graphical components needed to
perform SSP operations.
HSM section
This section allows the user to read HSM information when the smart card is detected in the
slot selected by the user. With this tab it is also possible to get a license from HSM.
Press “Refresh” button to read and display the related information for the plugged HSM.
Device section
This part allows to get the product ID of the connected device, needed to choose the correct
personalization package to be provisioned in the HSM card by the STM32Trusted Package
Creator.
If the device is not in a configuration adequate to get the chip certificate, it is mandatory to
provide a tfa-ssp file in the “SSP inputs” section. STM32CubeProgrammer will then set the
device in the correct state.
The current phase ID is displayed to highlight the device configuration.
Input license
The user must select the source of the license to be used in the SSP flow. Possible sources:
• From file: to select a binary file already generated by the HSM.
• From HSM: the SSP procedure extracts the license directly from the HSM.
Notes
At the end of the flow STM32CubeProgrammer does not make any verification step for the
OTP fused words.
If the mentioned tfa-ssp is not the adequate one, the SSP flow fails.
OBKey file generation is managed by STM32 Trusted Package Creator. For more
information, refer to UM2238.
Using command line interface (CLI): in this script we can use all CLI supported by STM32
MCUs (see Section 3).
Using specific Script Manager macros, to analyze, display and modify data, each macro
starts with #. Supported macros are described below.
#Write macro:
#Write32(Address,data)
#Write16(Address,data)
#Write8(Address,data)
#WriteX(Address,#var) (where X is 8/16/32)
Description: Downloads the specified (32/16/8-bit) data into flash memory starting from a
specified address.
#Read macro:
#Read(Address)
#variable=#Read(Address)
Description: Reads 32-bit data memory from a specified address or reads 32-bit data
memory from a specified address, and puts it in the used variable.
#Display macro:
#Display(“message”)
#Display(#errorLevel)
#Display(#variable)
Description: Displays any message, data, error level and the content of variables already
used in the script.
#Delay macro:
#Delay(Time)
Description: Allows user to put the system in standby for a period in (ms).
Calculate macro:
#variable=[var1] op [var2]
#variable=var1 shift (number of bits to shifted)
Description: Calculates with mathematical and logical operations in script manager.
Disconnection command
--scriptdisconnect
Description: Allows user to disconnect the device and reconnect to another port in the same
script.
Note: Comments in the Script Manager can be added by using “//”, as shown in the examples.
Script Manager example 1 (CLI and Script macro), see Figure 63
-c port=swd
-e 0 1
#Write32(0x08000000,0xAAAABBBB)
#var0=#Read(0x08000000)
#Display(#var0)
Script Manager example 2, see Figure 64
-c port=swd
#Write32(0x08000000,0xAAAABBBB)
--scriptdisconnect
#Delay(5000)
-c port=COM17
#Write16(0x08000004,0xCCCC)
#Display(#var0)
#Write32(0x08000004,#var0)
#Delay(3000)
#Write16(0x08000008,0xCCCC)
#Read(0x08000004)
#Display(#errorLevel)
#var1=#Read(0x08000008)
#Display(#var1)
#Write8(0x08000010,0xDD)
#Delay(5000)
#var2=#Read(0x08000010)
#Display(#var2)
#var3=(((0xbb*1)+(1-1))/1)
#Display(#var3)
#Write8(0x08000014,#var3)
#var4=((0xbb & 0xaa)| 0xbb )
#Display(#var4)
#var5=((0xbb && 0xaa) || 0xbb )
#Display(#var5)
#var6=(0xbb >>1)
#Display(#var6)
-e 0 1
-w32 0x08000000 0xAAAAAAAA
-r32 0x08000000 0x50
To use the conditional statements (if, else) and the loopings (While, for), begin with #Start,
and finish with #End.
#Start
if (#x > 0x1000)
{
#Display("Condition 1")
#Display(#x)
#Write32(0x08000000,0x1123)
}
else
{
#Display("Condition 2")
#Display(#x)
#Write32(0x08000008,0x1124)
}
#End
For loop
-c port=swd
#ADD=0x08000004
#x=#Read(0x08000004)
#Start
#Display(#x)
for(#ADD=0x08000000;#ADD<0x0800000C;#ADD=#ADD+4)
{
#x=#Read(#ADD)
#Display(#x)
}
#End
#Start
while(#x!=0xCCCCCCCC)
{
#Display(#x)
#ADD=([#ADD]+(4))
#x=#Read(#ADD)
}
#End
-e 0
#Write32(0x08000000,0xAAAAAAAA,0xBBBBBBBB,0xCCCCCCCC,0xDDDDDDDD)
#ADD=0x08000000
#x=#Read(#ADD)
#Display(#x)
#Start
while(#x!=0xDDDDDDDD)
{
#Display(#x)
#ADD=([#ADD]+(4))
#x=#Read(#ADD)
}
#End
Note: For CLI mode check the Section 3.2.1: Connect command.
2.14.1 Description
The STM32CubeProgrammer Fault analyzer feature interprets information extracted from
the Cortex-M based device to identify the reasons that caused a fault.
This information is visualized in the Fault analyzer window in GUI mode or in CLI mode. It
helps to identify system faults occurring when the CPU is driven into a fault condition by the
application software.
Possible detected fault exceptions:
• Hard Fault: default exception, can be triggered by an error during exception processing
by Bus Fault, Memory Management Fault, or Usage Fault if their handler cannot be
executed.
• Memory Management Fault: detects memory access violations to regions defined in
the memory management unit (MPU), such as code execution from a memory region
with read/write access only.
• Bus Fault: detects memory access errors on instruction fetch, data read/write, interrupt
vector fetch, and register stacking (save/restore) on interrupt (entry/exit).
• Usage Fault: detects execution of undefined instructions, unaligned memory access for
load/store multiple. When enabled, divide-by-zero and other unaligned memory
accesses are detected.
• Secure Fault: provides information about security related faults for Cortex-M33 based
devices.
Note: Fault analyzer is available only for ST-LINK interfaces.
As shown in Figure 69, the Fault Analyzer window has five main sections.
1. Hard Faults details: indicates the type of occurred fault, locates the instruction and the
called function addresses.
2. Bus Faults details: shows the status of bus errors resulting from instruction fetches and
data accesses and indicates memory access faults detected during a bus operation. An
address should be displayed on the BFAR text field.
3. Usage Faults details: contains the status for some instruction execution faults, and for
data access.
4. Memory Management Faults details: indicates a memory access violation detected by
the MPU. If this fault was triggered by a faulty address, access is displayed on the
MMFAR text field.
5. CPU capture during exception: shows the CPU state when an exception was
generated to have an overview for CPU registers and some helpful information.
c) NVIC position: indicates the number of the interrupt imposing the error, if it is “-“
the interrupt/exception vector has no specific position.
d) Execution mode: indicates the operation mode Handler/Thread.
e) Stack memory region: indicates the used stack memory during the fault, Main or
Process stack.
2.14.2 Example
Develop a simple application that generates a usage fault, set an instruction making a divide
by zero (a non-permitted operation) in the main program function.
int a = 4, b = 0, c = 0;
c = a / b;
Open the Fault Analyzer window, press the “Start Analysis” button to start the fault detection
algorithm, the reason of the error is displayed.
In this example, it displays “Hard Fault Detected”, and the label “divide by zero
(DIVBYZERO)” is highlighted with additional informations:
• Faulty instruction address: 0x8000FF0
• Faulty called function address: 0x8000D40, indicates the address calling the faulty
instruction
• NVIC position: 0, window watchdog interrupt
• Execution mode: handler
• Stack memory region: main stack
Figure 70. Fault analyzer GUI view when Hard Fault is detected
NONBASETHRDENA
USERSETMPEND
UNALIGN_TRP
BFHFNMIGN
DIV_0_TRP
STKALIGN
Reserved
Reserved Reserved
The following bits of the CCR control the behavior of the Usage Fault:
• DIV_0_TRP: Enable Usage Fault when the processor executes an SDIV or UDIV
instruction with a 0 divider.
– 0 = do not trap divide by 0; a divide by 0 returns a quotient of 0.
– 1 = trap divide by 0.
• UNALIGN_TRP: enable usage fault when a memory access to unaligned addresses is
performed.
– 0 = do not trap unaligned half-word and word accesses
– 1 = trap unaligned half-word and word accesses; an unaligned access generates a
usage fault.
Note that unaligned accesses with LDM, STM, LDRD, and STRD instructions always
generate a usage fault, even when UNALIGN_TRP is set to 0.
STM32CubeProgrammer enables the required bits at the analysis startup, if no fault is
detected an informative popup is displayed to indicate that you must reproduce the scenario
and restart the analysis.
• LSPERR: Indicates that an SAU or IDAU violation occurred during the lazy
preservation of floating-point state.
• SFARVALID: this bit is set when the SFAR register contains a valid value.
• LSERR: indicates that an error occurred during lazy state activation or deactivation.
• SFAR: indicates the address value when a secure fault is raised.
• Example 1:
STM32_Programmer_CLI.exe -c port=swd -fillmemory 0x08000000
size=0x10 pattern=0XAA datawidth=16 (Figure 72)
• Example 2:
STM32_Programmer_CLI.exe -c port=swd -fillmemory 0x08000000
size= 0x10 pattern=0XCC datawidth=32 (Figure 73)
Figure 75. Sub-menu displayed with right click on “Device memory” tab
Figure 76. Sub-menu displayed with right click on the cell of grid
Note: In addition to sub-menus to display this window, user can open it directly by using the key
combination “Ctrl+M”.
After clicking on “Fill memory” option, a window is displayed so that the user can initialize
the parameters of the operation (see Figure 77).
Figure 81. Sub-menu displayed with right click on “Device memory” tab
Figure 82. Sub-menu displayed with right click on the cell of grid
Note: In addition to sub-menus to display this window, user can launch the operation directly by
using the key combination Ctrl+L.
After clicking on “Blank check” sub-menu, the process starts to verify that the STM32 flash
memory is blank. If the flash memory is not blank, the first address with data is highlighted in
a message, as shown in Figure 83.
The expected results are shown in figures 84 and 85.
Figure 87. Sub-menu displayed with right click on “Device memory” tab
Figure 88. Sub-menu displayed with right click on the cell of grid
Figure 90. Sub-menu displayed with right click on the opened file tab
Figure 91. Sub-menu displayed from “Download” combo-box displayed in file tab
Note: In addition to sub-menus to display this window, the user can launch the operation directly
by using the key combination Ctrl+T.
After launching the comparison between the flash memory and file, and the edit of data in
the memory, the user must make an update in the comparison tab using the read button.
Example 3: Update comparison between flash memory and file after editing
Note: The user can make multiple comparisons between flash memory and files.
Figure 101. Sub-menu displayed from “Read” combo-box in device memory tab
Figure 102. Sub-menu displayed with right click on “Device memory” tab
Figure 103. Sub-menu displayed with right click on the cell of grid
Figure 105. Sub-menu displayed with right click on the opened file tab
Figure 106. Sub-menu displayed from “Download” combo-box displayed in file tab
Note: In addition to sub-menus to display this window, the user can open it directly by using the
key combination Ctrl+F.
Example: Difference between two files of the same type and different sizes
2.22 Calculator
Description: The Calculator window, created for general purposes, is always available,
even if the device is not connected. The user interface has three main goals:
1. Number converter
– Composed by several graphical components, to facilitate the number conversion
between decimal, hexadecimal, and binary formats.
– Use the 32 check boxes, representing a word of 32 bits, to activate or deactivate
the relevant bit(s).
– Use the “Reset” button to reinitialize the number to 0.
– Any time a bit is changed, the number value is updated.
2. Checksum calculation
– To calculate the checksum value, based on addition algorithm applicable on the
file content or on the flash memory.
– File Checksum: choose your binary file and click on “Calculate” button to display
the corresponding result on the log panel.
– Flash Memory Checksum: calculates the checksum value of a region (based on
start address and size of the desired region) once the device is connected.
– To calculate the full flash memory checksum retrieve the memory size, displayed
in the “Flash size” field.
3. Memory programming
– To expose the generic memory edition options
– Fill memory: see Section 2.16
– Blank check: see Section 2.18
Number converter and File checksum can be used even if there is no device connected.
Flash Memory Checksum, Fill Memory, and Blank Check are applicable only if a device is
already connected.
• ST-LINK options
[freq=<frequency>] Frequency (in kHz) used in connection. Default value is 4000 kHz
for SWD port, and 9000 kHz for JTAG port.
[reset=<mode>] Reset mode. Possible values are {SWrst/HWrst/Crst}. The default
value is SWrst. When using UR connection mode, the reset mode
is HWrst.
HWrst Hardware reset. Performed by the STLink, which physically drives
the NRST pin of the MCU. The NRST pin of the STLink must be
connected to the MCU.
SWrst Software reset (a system reset via Cortex registers)
Crst Core reset (via Cortex registers)
Note: The entered frequency values are rounded to correspond to those supported by ST-LINK
probe.
• I2C options
[add=<ownadd>] Slave address: address in hex format
Note: I2C address option must be always inserted, otherwise the connection is not established.
• CAN options
[br=<rbaudrate>] Baudrate: 125, 250..., default 125.
[mode=<canmode>] Mode: NORMAL, LOOPBACK..., default NORMAL.
Note: The software must request the hardware to enter Normal mode to synchronize on the CAN
bus and start reception and transmission between the Host and the CAN device. Normal
mode is recommended.
• Using UART
./STM32_Programmer.sh -c port=/dev/ttyS0 br=115200
The result of this example is shown in Figure 114.
Note: When using a USB interface, all the configuration parameters (for example baud rate, parity,
data-bits, frequency, index) are ignored. To connect using a UART interface the port
configuration (baudrate, parity, data-bits, stopbits and flow-control) must have a valid
combination, depending on the used device.
Note: The default value of product ID and vendor ID are ST products values (PID = 0xDF11,
VID = 0x0483).
The corresponding command line for this example is –c port=SWD freq=3900 ap=0
Note: Make sure that the device being used supports a SPI bootloader when trying to connect
through the SPI.
There are other parameters used in connection with SPI port that have default values, and
some others must have specific values (see the help menu of the tool for more information).
Note: Not all devices implement this feature, make sure the one you are using supports a CAN
bootloader.
There are other parameters used in connection with CAN port that have default values and
some others must have specific values (see the help menu of the tool for more information).
Note: For each I2C connection operation the address parameter is mandatory.
Note: Not all devices implement this feature, make sure that the device supports an I2C
bootloader.
There are other parameters used in connection with I2C port that have default values and
some others must have specific values (see the help menu of the tool for more information).
Note: For the parallel programming of more than one STM32 device using multiple instances of
STM32CubeProgrammer, it is mandatory to add the serial number of each device in the
suitable instance, as shown in the following example:
• “ –c port=swd/usb sn=SN1” (instance 1 of STM32CubeProgrammer)
• “ –c port=swd/usb sn=SN2” (instance 2 of STM32CubeProgrammer)
• “ –c port=swd/usb sn=SN3” (instance 3 of STM32CubeProgrammer)
Syntax:
[all] Erase all sectors. EEPROM area is excluded.
[<sectorsCodes>] Erase the sectors identified by codes (for example 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,
for example -e [5 10].
Example
./STM32_Programmer.sh --connect port=/dev/ttyS0 -e 2 4
This command erases only sectors 2 and 4.
Note: In the case of multiplicity of external loaders, the first selected is the one that will be taken
into account during erasing of the external memory.
Example
-c port=COM4 -w RefSMI_MDK/All_Flash_0x1234_256K.bin 0x08008000
This command programs the binary file “All_Flash_0x1234_256K.bin” at address
0x08008000.
The result of this example is shown in Figure 122.
Note: To verify that the download has been successful, call the verify option (-v or –verify) just
after the write command, otherwise the verify option is ignored.
Example
./STM32_Programmer.sh -c port=/dev/ttyS0 br=9600 -w32 0x08000000
0x12345678 0xAABBCCFF 0x12AB34CD –-verify
Note: This command makes it possible to write the 32 data bits (0x12345678, 0xAABBCCFF,
0x12AB34CD) into the flash memory starting from address 0x08000000.
Example:
/STM32_Programmer_CLI.exe -c port=swd –w64 0x08000000 0x12345678AABBCCFF
Example
./STM32_Programmer.sh -c port=/dev/ttyS0 br=9600 --upload
0x20007000 2000 “/local/ benayedh/Binaries/read2000.bin”
This command makes it possible to read 2000 bytes, starting from address 0x20007000,
and uploads the content to a binary file “/local/benayedh/Binaries/read2000.bin”
-r32
Description: Read 32-bit data memory.
Syntax: -r32 <start_address> <size>
Example
./STM32_Programmer.sh -c port=SWD –r32 0x08000000 0x100
Note: The maximum size allowed with the –r32 command is 32 Kbytes.
-rst
Description: Executes a software system reset;
Syntax: -rst
-hardRst
Description: Generates a hardware reset through the RESET pin in the debug connector.
The RESET pin of the JTAG connector (pin 15) must be connected to the device reset pin.
Syntax: -hardRst
-halt
Description: Halts the core.
Syntax: -halt
-step
Description: Executes one instruction.
Syntax: -step
-score
Description: Displays the Cortex-M core status.
The core status can be one of the following: ”Running”, ”Halted”, ”Locked up”, ”Reset”,
”Locked up” or ”Kept under reset”
Syntax: -score
-coreReg
Description: Read/write Cortex-M core registers. The core is halted before a read/write
operation.
Syntax: -coreReg [<core_register>]
R0/../R15/PC/LR/PSP/MSP/XPSR/APSR/IPSR/EPSR/PRIMASK/BASEPRI/
FAULTMASK/CONTROL
[core_reg=<value>]: The value to write in the core register for a write operation. Multiple
registers can be handled at once.
Example
-coreReg This command displays the current values of the core registers.
-coreReg R0 R8 This command displays the current values of R0 and R8.
-coreReg R0=5 R8=10 This command modifies the values of R0 and R8.
Example
./STM32_Programmer.sh –c port=/dev/ttyS0 br=115200 –log trace.log
The result of this example is shown in Figure 126.
The log file trace.log contains verbose messages, as shown in Figure 127.
As a consequence the implementation of these function inside the external loader must be
slightly modified to be synchronized with input parameters.
Example of Sector erase function after modification:
Example
STM32_Programmer_CLI.exe –sl TestCRC.axf 0x8000000 0x8010000 0x400
The result is shown in Figure 128.
The flash program memory is divided into slices, whose size is given as a parameter to the
safety lib command as shown in the example above. For each slice a CRC value is
computed and placed in the CRC area. The CRC area is placed at the end of the memory,
as shown in Figure 129.
CRC area
Flash memory
Program area
MSv48697V1.
The address and size of the CRCs area are determined as follows:
CRCs_Area_Size = Flash_Size / Slice_Size * 4 bytes
CRCs_Start_Address = Flash_End_Address - CRCs_Area_Size
The CRC values in the CRC area are placed according to the position(s) of the user
program in the flash memory, see Figure 130.
CRC 3
CRC area CRC 2
CRC 1
User program 3
Flash memory
Program area
User program 2
User program 1
MSv48698V1.
The address of a CRCs region inside the CRCs area is calculated as:
UserProg_Start_Address – Flash_Start_Address
@ = CRCs_Start_Address + ⎛ -------------------------------------------------------------------------------------------------------------------------------- ⋅ 4 bytes⎞
⎝ Slice_Size ⎠
The tool checks the syntax and the processing of the command, and marks a failure if there
is a parameters mismatch or a problem in the CRC calculation by displaying various error
message:
• “Invalid file path or wrong file extension”
<file_path> has an unrecognized extension: .bin .binary .hex .srec .s19 .elf .axf .out
• “The safety lib command is missing parameters”
The passed command does not respect the parameters number
• “Invalid flash start address”
<start_address> is not correct (exceeds 0xFFFFFFFF as max value) or is not in
hexadecimal format
• “Invalid flash end address”
<end_address> is not correct (exceeds 0xFFFFFFFF as max value) or is not in
hexadecimal format
• “Invalid slice size”
<slice_size > is not correct (exceeds 0xFFFFF as max value) or is not in hexadecimal
format
• “Invalid pattern”
<pattern> is not in the range [0x00 to 0xFF] or is not in hexadecimal format
• “The slice size is larger than the flash size”
<slice_size> is larger than the dedicated flash size (<end_address> - <start_address>)
• “The slice size is invalid”
The dedicated flash memory is not aligned (based on <slice_size>)
• “File is Read Only”
The input file <file_path> is not editable.
• “No segments in this file”
The input <file_path> does not contain any data segment
• “The segment {x} of {y} does not start at the beginning of a flash slice”
The current treated segment does not start at the beginning of the flash slice
-rsse, --rsse
Description: This command allows the user to select the root secure services extension
library (RSSe). Mandatory for devices using RSSe to make secure firmware install (SFI).
The RSSe binary file can be found in STM32CubeProgrammer bin/RSSe folder.
Syntax: -rsse <file_path>
<file_path> Path of RSSe file
-a, --abort
Description: This command allows the user to clean a not properly finished process. The
currently ongoing operation stops and the system returns to idle state.
Syntax: -a
-mcsv, --mcsv
Description: This command allows the user to select the modules file including the list of
modules to be installed with SFI. This option is mandatory when the SFI image integrates at
least one module (area of type m).
-el --extload Selects a custom external memory-loader, only for the JTAG/SWD
interfaces
<file_path> External memory-loader file path
-elbl --extloadbl Selects a custom external memory-loader for the bootloader interface
-rsse, --rsse
Description: This command allows the user to select the root secure services extension
library (RSSe). Mandatory for devices using RSSe to make secure firmware install (SFI).
The RSSe binary file can be found in STM32CubeProgrammer bin/RSSe folder.
Syntax: -rsse <file_path>
<file_path> Path of RSSe file
-a, --abort
Description: This command allows the user to clean a not properly finished process. The
ongoing operation stops and the system returns to idle state.
Syntax: -a
Note: The ExternalLoader is different for SFIx use case, as some initializations are already done
by RSS, and it is marked with –SFIX at the end of the External FlashLoader name.
-mcsv, --mcsv
Description: This command allows the user to select the modules file including the list of
modules to be installed with SFI. This option is mandatory when the SFI image integrates at
least one module (area of type m).
Syntax: -mcsv <module_path.mcsv>
<module_path.mcsv> : Path of mcsv file
-hsmgetcounter
Description: Reads the current value of the license counter
Syntax: -hsmgetcounter [slot=<SlotID>]
-hsmgetfwid
-hsmgetstatus
Description: Reads the current card life-cycle state
Syntax: -hsmgetstatus [slot=<SlotID>]
-hsmgetlicense
Description: Gets a license for the current chip if counter is not null
Syntax: -hsmgetlicense <file_path> [slot=<SlotID>] [protocol=<Ptype>]
-hsmgetlicensefromcertifbin, -hsmglfcb
Description: Gets a license for the current certificate binary file if counter is not null.
Syntax: -hsmglfcb <certif_file_path.bin> <license_file_path.bin>
[slot=<SlotID>] [protocol=<Ptype>]
Syntax: -antirollback
-startfus
Description: Start the FUS
Syntax: -startfus
-getuid64
Description: Read the device unique identifier (UID)
Syntax: -getuid64
-fusgetstate
Description: Read the FUS state
Syntax: -fusgetstate
-fusopgetversion
Description: Read the FUS o//perator version
Syntax: -fusgetversion
Note: FUS operator version is not available via bootloader interfaces.
-fwdelete
Description: Delete the BLE stack firmware
Syntax: -fwdelete
-fwupgrade
Description: Upgrade of BLE stack firmware or FUS firmware.
Syntax: -fwupgrade <file_path> <address> [firstinstall=0|1]
[startstack=0|1] [-v]
-startwirelessstack
Description: Start the wireless stack
Syntax: -startwirelessstack
-authkeyupdate
Description: Authentication key update
Syntax: -authkeyupdate <file_path>
-authkeylock
Description: Authentication key lock
Once locked, it is no longer possible to change it using -authkeyupdate command
Syntax: -authkeylock
-wusrkey
For more information about the customer key storage, refer to already cited AN5185.
Syntax: -wusrkey <file_path> <keytype=1|2|3>
<file.path>: customer key in binary format
<keytype=1|2|3>: User key type values: 1 (simple), 2 (master) or 3 (encrypted)
-startwirelessstack
Description: Starts the wireless stack
Syntax: -startwirelessstack
Note: These commands are available only through SWD, USB DFU and UART interfaces.
Note: Under Reset mode is mandatory.
-startswv
Description: This command allows the user to access the serial wire viewer console mode.
Syntax: startswv <freq=<frequency>> <portnumber=0-32>
[<file_Path.log>]
After the execution of these commands, go through a power OFF / power ON sequence.
These two commands allow the user to unlock the board in case of inability to change option
bytes using the usual method.
Figure 134 and Figure 135 show the results of these command lines.
If the user locks the board and is unable to unlock it with these two commands, there are
specific scripts to unlock it. These scripts are under “../bin/STM32WLScripts”, they contain a
command line using –wdbg option to write directly scripts in the OPTR register.
The folder STM32Scripts contains two files and the Readme.txt:
1. “SetRDPLevelCM0.bat” to unlock the board via Cortex M0+
2. “SetRDPLevelCM4.bat” to unlock the board via Cortex M4
Note: If SFI command finishes with a fail, the STM32WL chip must be set in its default status using
the disable security command line (-dsecurity), then the set default option byte command
line (-setdefaultob).
-wsigfoxc
Description: This command allows to user to write the chip certificate at address
0x0803E500
Syntax: -wsigfoxc <binary_file_path> <address> [The address is optional, by
default is 0x0803E500]
Example 1: STM32_Programmer_CLI.exe -c port=swd -wsigfoxc
“/local/user/sigfox_data.bin”0x0803E500
Example
Using the same example as GUI mode (division by 0).
Command: -c port=swd mode=hotplug -hf
From the command line output, a Green message indicates a “Hard Fault Detected” and
“The processor has executed a SDIV or UDIV instruction with a divisor of 0”.
Useful informations can be extracted:
• Faulty instruction address: 0x80002E4
• Faulty instruction called by a function located at this address: 0x800022D
• NVIC position: 0, Window watchdog interrupt
• Execution mode: Handler
• Core registers capture
Figure 140. Fault analyzer CLI view when Hard Fault is detected
<file_path> The input file path to deploy (supports files with multiple segments)
Figure 142. Checksum command output for the internal flash memory
- lockRDP1
Description: Allows the user to lock the RDP regression from level 1 with a password.
Syntax: - lockRDP1 <Password first 32 bits> <Password second 32 bits>
Example:
STM32_Programmer_CLI -c port=swd mode=hotplug -lockRDP1 0x12345678
0xDEADBEEF
- lockRDP2
Description: This command allows the user to lock the RDP regression from level 2 with a
password.
Syntax: - lockRDP2 <Password first 32 bits> <Password second 32 bits>
Example:
STM32_Programmer_CLI -c port=swd mode=hotplug – lockRDP2 0x12345678
0xDEADBEEF
- unlockRDP1
Description: This command allows to unlock the RDP regression from level 1 with a
password.
Syntax: - unlockRDP1 <Password first 32 bits> <Password second 32
bits>
Example:
- unlockRDP2
Description: This command allows the user to unlock the RDP regression from level 2 with
a password.
Syntax: - unlockRDP2 <Password first 32 bits> <Password second 32
bits>
Example:
STM32_Programmer_CLI -c port=swd mode=hotplug – unlockRDP2
0x12345678 0xDEADBEEF
Note: After unlocking the RDP, the user must perform an RDP regression, as the listed commands
do not include the RDP regression operation.
Note: To remove RDP regression with password, the user must use the Lock command and a
password with value 0xFFFFFFFF 0xFFFFFFFF, such as STM32_Programmer_CLI -c
port=swd mode=hotplug -lockRDP1 0xFFFFFFFF 0xFFFFFFFF.
Example:
STM32_Programmer_CLI.exe -c port=swd -pwd value=1mc4l path=C:\my_folder
The password size must be between 4 and 16 bytes.
Once the target is successfully provisioned, the “password.bin” file is generated, to be used
while performing debug authentication.
Password programming can be executed only once for each target.
[Debugauth=<value>]
Discovery: debugauth=2
Launches discovery, to display information about the target.
Example:
/STM32_Programmer_CLI.exe -c port=swd debugauth=2
Authentication: debugauth=1
Performs debug authentication using credential files.
Credential files (passwords, keys, and certificates) are generated by STM32 Trusted
Package Creator.
Syntax: pwd=[password_path.bin] debugauth=1 (authentication with password)
Example:
STM32_Programmer_CLI.exe -c port=swd pwd=C:\password.bin debugauth=1
Update module
Syntax: updateipmodule <file_path> <address>
Example:
STM32_Programmer_CLI.exe -c port=swd mode=hotplug ap=1 -updateipmodule
C:\Users\User\module_update.smu 0x8174000
If the sequence ends successfully, IP update install done successfully is displayed.
The main window allows the user to select the interface used to connect to STM32MP1
BootROM, possible interfaces are USB-DFU and UART (programming through stlink
interface is not possible with STM32MP1 series). Once connected (using connect button)
available partitions are displayed, the user is able to open a TSV file for programming.
To perform TSV files programming the user must perform the following operations:
• Open a TSV file by using “Open file” tab, if TSV file format is correct then TSV content
is displayed in the main window. TSV Files are available in STM32MP1 Linux
distributions, refer to STM32MP1 wiki for more details.
• Specify binaries path in “Binaries path” text box.
• Select the list of partitions to be programmed in “select” column, by default all partitions
are selected.
• Launch download using “Download” button.
For more details concerning flashing operations refer to AN5275, available on www.st.com.
After modification, press “Apply” button and confirm the operation to start the update and
refresh the table view.
If the operation is successful, the table view is disabled for all “Lock” columns.
Example
Using UART:
./STM32_Programmer.sh -c port=/dev/ttyS0 p=none
The result of this example is shown in Figure 158.
Note: When using the USB interface, all the configuration parameters (such as baudrate, parity,
data-bits, frequency, index) are ignored.
Note: To connect using UART interface, the port configuration (baudrate, parity, data-bits,
stop-bits and flow-control) must have a valid combination.
[file_path] File path to be downloaded (bin, stm32, vfat, jffs2, ubi, ext2/3/4 and
img file extensions).
[partition_ID] Partition ID to be downloaded.
Example
./STM32_Programmer.sh -c port=/dev/ttyS0 p=none -d atf.stm32 0x01
This command allows the user to download the atf binary file at Atf partition (partition ID:
0x01).
The result of this example is shown in Figure 159.
Note: For U-boot with USB interface, to program the nonvolatile memory (NVM) with the loaded
partition using download command, the user must execute a start command with the
partition ID. Besides, to execute an application loaded in the NVM, the start address. must
be specified
Example: Download and manifestation on alternate 0x1
./STM32_Programmer.sh -c port=usb0 -w atf.stm32 0x1 –s 0x01
Example
./STM32_Programmer.sh -c port=/dev/ttyS0 p=none br=115200 -d
Flashlayout.tsv
Note: While programming the Flashlayout.tsv file, U-boot can spend a long time to start correctly,
for this reason configure the timeout value by using the timeout command (-tm <timeout>).
<partition_ID> Partition ID
[offset_address] Offset address of read
<size> Size of memory content to be read
<file_path> Binary file path to upload the memory content
Example:
./STM32_Programmer.sh -c port=/dev/ttyS0 p=none br=115200 -rp 0x01 0x200
0x1000 readPart1.bin
This command allows the user to read 0x1000 bytes from the sebl1 partition at offset
address 0x200 and to upload its content to a binary file “readPart1.bin”
Example:
./STM32_Programmer.sh –list uart
OTP structure 1
Programming SAFMEM
Description: This command allows the user to program SAFMEM memory by modifying the
OTP words.
Syntax: -otp program [wordID=(value)] [value=(value)]
[sha_rsl=(value)] [sha_wsl=(value)] [sl=(value)] [pl=(value)]
[wordID=(value)] This field contains the shadow register number (between 0 and 95).
Value must be written in hexadecimal form.
[value=(value)] Loads value into the chosen OTP shadow register.
Value must be written in hexadecimal form.
[sha_rsl=(value)] Loads value into the corresponding shadow read sticky lock bit.
Value can be either 0 or 1.
[sha_wsl=(value)] Loads value into the corresponding shadow write sticky lock bit.
Value can be either 0 or 1.
[sl=(value)] Loads value into the corresponding programming sticky lock bit.
Value can be either 0 or 1.
[pl=(value)] Loads value into the corresponding programming permanent lock
bit. Value can be either 0 or 1.
Example
./STM32_Programmer.sh --connect port=usb1 –otp program wordID=0x00
value=0x3f sl=1 wordID=0x08 value=0x18
Display command
Description: This command allows the user to display all or parts of the OTP structure.
[upper] Option to display the loaded upper OTP shadow registers values and status.
[lower] Loads value into the chosen OTP shadow register. Value must be written in
hexadecimal form.
[ctrl] Option to display the loaded BSEC control registers.
Example
./STM32_Programmer.sh --connect port=usb1 –otp displ
Note: At the execution time the tool displays the operation to be performed, and prompts a
message for confirmation. To skip the prompt confirmation, use the (-y or --yes) command.
OTP structure 2
Programming SAFMEM
Description: This command allows the user to program SAFMEM memory by modifying the
OTP words. Able to write up to 96 words in the same command line.
Syntax: -otp write {lock} {word=[index] value=[val]…}
{lock} Optional, to indicate that a lock has been requested. If lock option is
mentioned, all words passed in line are locked.
– With lock: writes the word, then performs permanent lock.
– Without lock: updates the word.
[index] The word index can be written in decimal or hex format.
[val] The value option accepts hex values.
The tool prints the requests, the user can verify the operation before going on. It will then
prompt a confirmation message, the user can press yes/y or no/n to, respectively, continue
or stop the write operation.
Example
STM32_Programmer_CLI.exe --connect port=usb1 –otp write word=52
value=0xAAAAAAA word=0x50 value=0xBBBBBBBB
The tool prints the requested modifications, and the user can verify the operation before
going ahead (use yes/y or no/n to continue or to stop)
Example
STM32_Programmer_CLI.exe --connect port=usb1 –otp lock word=20 word=0x30
Display command
Description: This command allows the user to display all or parts of the OTP structure.
Syntax: -otp displ {word=[index]…}
Example
STM32_Programmer_CLI.exe --connect port=usb1 –otp displ
word=8 word=0x10
Example
Program a PKH binary file starting from word number 24
STM32_Programmer_CLI.exe --connect port=usb1 -otp fwrite lock
/user/home/pkh.bin word=24
-ssp, --ssp
Description: Program an SSP file
Syntax: -ssp <ssp_file_path> <ssp-fw-path> <hsm=0|1>
<license_path|slot=slotID>
If there is any faulty input the SSP process is aborted, and an error message is displayed to
indicate the root cause of the issue.
In addition to the graphical user interface and to the command line interface
STM32CubeProgrammer offers a C++ API that can be used to develop your application and
benefit of the wide range of features to program the memories embedded in STM32
microcontrollers, either over the debug interface or the bootloader interface (USB DFU,
UART, I2C, SPI and CAN).
For more information about the C++ API, read the help file provided within the
STM32CubeProgrammer package under API\doc folder.
7 Revision history
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and
improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on
ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order
acknowledgment.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or
the design of purchasers’ products.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. For additional information about ST trademarks, refer to www.st.com/trademarks. All other product
or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.