STM32 ST-LINK Utility User Manual
STM32 ST-LINK Utility User Manual
User manual
STM32 ST-LINK Utility software description
Introduction
The STM32 ST-LINK Utility software facilitates fast in-system programming of the STM32
microcontroller families in development environments via the tools, ST-LINK and
ST-LINK/V2.
This is the STM32 ST-LINK Utility user manual, describing its software functions. When
working with the STM32 ST-LINK Utility, you are encouraged to download the ST-LINK
in-circuit debugger/programmer user manual (UM0627) or the ST-LINK/V2 in-circuit
debugger/programmer user manual (UM1075) for the STM8 and STM32 which provide
more information about the ST-LINK tools.
Note: The part number of STM32 ST-LINK Utility software is: STSW-LINK004
Contents
1 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1 System requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 Hardware requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Installing the STM32 ST-LINK Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Uninstalling the STM32 ST-LINK Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
5 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
List of tables
List of figures
1 Getting started
This section describes the requirements and procedures to install the STM32 Root part
number 1 Utility software.
7LWOHEDU
0HQXEDU
0DLQZLQGRZ
6WDWXVEDU
069
The main window is composed of three zones and three bars as illustrated in Figure 1:
Memory display zone
Device information zone
Memory contents zone
– LiveUpdate checkbox to update Memory data in real time
(This feature is described in more detail in Section 3.2)
Title bar: name of the current menu
Menu bar: Use the menu bar to access the following STM32 ST-LINK Utility functions:
– File menu
– Edit menu
– View menu
– Target menu
– Help menu
These menus are described in more detail in Section 2.2.
Status window: The status bar displays:
– Connection status and debug interface
– Device ID
– Core State (active only when LiveUpdate feature is active and memory grid is
selected)
The STM32 ST-LINK Utility user interface also provides additional forms and descriptive
pop-up error messages.
Saves the content of the memory panel into a binary, Intel Hex or Motorola S-
Save file as…
record.
Compares two binary, hex, or srec files. The difference is colored in red in the file
Compare two files panel. If a file contains a section with an address range that is unavailable in the
other file, this section will be colored in violet.
Paste Paste the copied cells in the selected position in file or memory grid.
Find Data Find data in binary or Hex format in file or memory grid.
Fill file or memory grid with the chosen data starting from the chosen
Fill Memory
address.
Connects to the target device and displays the Device Type, Device ID and
Connect
Flash memory size in the device information zone.
Performs a Flash memory mass erase and then displays the Flash memory
Erase Chip
content in the memory panel.
Erases bank 1 of the Flash memory. This menu is enabled only when
Erase Bank1
connected to an XL-density device.
Erases bank 2 of the Flash memory. This menu is enabled only when
Erase Bank2
connected to an XL-density device.
Selects sector(s) to erase using the erase sectors dialog window (see
Erase Sectors…
Section 3.3: Flash memory erase for more details).
Loads a binary, Intel Hex or Motorola S-record file into the device memory
(Flash or RAM). To do this, select a binary, Intel Hex or Motorola S-record file,
Program… enter the start address (where to put the file in the device) in the program
dialog window and then click on program button (see Section 3.4: Device
programming).
Loads a binary, Intel Hex or Motorola S-record file into the device memory
Program & Verify…
(Flash or RAM) then performs a verification of the programmed data.
Verifies that the STM32 Flash memory is blank. If the Flash memory is not
Blank Check
blank, the first address with data is highlighted in a prompt message.
Compare device Compares the MCU device memory content with a binary, hex, or srec file. The
memory with file difference is colored in red in the file panel.
Opens the Option Bytes dialog window (See Section 3.5: Option bytes
Option Bytes…
configuration for more details).
Opens the MCU Core dialog window (See Section 3.6: MCU core functions for
MCU Core…
more details).
Opens the Automatic mode dialog window (See Section 3.7: Automatic mode
Automatic Mode...
functions for more details).
Opens the Settings dialog box to select the debug interface (JTAG or SWD).
The “connect under reset” option allows you to connect to the target before
executing any instruction.
This is useful in many cases like when the target contains a code that disables
the JTAG/SWD pins.
The “HotPlug” option allows you to connect to the target without halt or reset.
This is useful to update RAM addresses or IP registers while application is
Settings... running.
When connecting to the target via an ST-LINK/V2, the “Supply voltage” combo
box displays the target voltage.
When connecting to an STM32 F2 or STM32 F4 device using an ST-LINK, the
“Supply voltage” combo allows you to select the supply voltage of your target to
be able to correctly program the Flash memory.
The "Enable debug in Low power mode" option allows you to connect to a
device in low-power mode.
Note: The “connect under reset” option is available only with ST-LINK/V2 and in SWD mode.
For JTAG mode, “connect under reset” is available since ST-LINK/V2 firmware
Version V2J15Sx.
The RESET pin of the JTAG connector (pin 15) should be connected to the device reset pin.
The “HotPlug” option is available in SWD mode.
For JTAG mode, “HotPlug” has been available since ST-LINK firmware Version V2J15Sx.
The STM32 ST-LINK Utility includes the Add External Loader submenu which allows to
select the external loaders to be used by the ST-LINK Utility to read, program or erase
external memories.
The external loaders must be added in the ExternalLoader directory located under the ST-
LINK Utility directory (see Section 3.8: Developing custom loaders for external memory for
more details on how to create a custom loader).
When the external loaders have been selected in the External Loader dialog box (see
Figure 8: External Loader window), new submenus are displayed, one per each external
loader selected. They offer all the functions (Program, Sector Erase...) available in the
corresponding external loader (see Figure 9: External Loader submenus).
The contents of the external memory is displayed in the External Memory grid (see
Figure 10: External memory grid).
Selecting the Close external memory grid submenu shuts down the External Memory
grid window.
STM32 ST-LINK Utility User Manual Opens the STM32 ST-LINK Utility User Manual.
This section provides a detailed description of how to use STM32 ST-LINK Utility features:
Device information
Memory display and modification
Flash memory erase
Device programming
Option bytes configuration
MCU core functions
Automatic mode functions.
Family of the connected STM32 device. Each device type includes many
Device: devices with different characteristics such as Flash memory size, RAM size
and peripherals.
Device ID: MCU device ID code located in the external PPB memory map
Memory data: This zone displays the data read from a file or the memory content of a
connected device. You can modify the content of the file before downloading.
To use this zone to display the content of a binary, Intel Hex or Motorola S-record file,
go to File | Open file...
To use this zone to read and display memory content of a connected device, enter the
memory start Address, data Size and the Data Width in the Memory display zone and
then press Enter.
After reading data, you can also modify each value merely by double-clicking on the
concerned cell as illustrated by Figure 13. You can also save the device memory
content into a binary, Intel Hex or Motorola S-record file using the menu File | Save file
as...
When LiveUpdate feature is used the device memory grid will be updated in real time
and the data that have been modified will be colored in red.
Note: When the Memory data zone displays device memory contents, any modification is
automatically applied to the chip. You can modify user Flash memory, RAM memory and
peripherals registers.
For the STM32 F2 and STM32 F4 devices, you can modify the OTP area directly from the
memory data zone.
Note: To erase the Flash data memory sector of the ultralow power STM32 L1 devices, select the
data memory box at the end of the list and click Apply.
2. Select a binary, Intel Hex or Motorola S-record file and click on the Open button.
3. Specify the address from which to start programming as shown in Figure 16, it may be
a Flash or RAM address.
For more details, please refer to the Option Bytes section in the Flash programming manual
and reference manual available from [Link].
Note: The PC and MSP registers can be modified from this panel.
Note: If the user deselects Flash programming action while the STM32 Flash memory is readout
protected, it will be automatically unprotected.
If the user deselects Flash programming action while some or all STM32 Flash memory are
write-protected, they will be automatically unprotected and restored after programming
operation.
Connection to the device should be established to be able to select the option Bytes
configuration using the configure button.
The connected devices should be derivatives of the same STM32 family and will be all
connected in the same mode (JTAG or SWD).
These examples are available for three toolchains: MDK-ARM, EWARM and TrueSTUDIO.
The development of the custom loaders can be performed using one of the three toolchains
keeping the same compiler/linker configurations as the examples.
To create a new external memory loader, follow the steps below:
1. Update the device information in StorageInfo structure in the Dev_Inf.c file with the
correct information concerning the external memory.
2. Rewrite the corresponding functions code in the Loader_Src.c file.
3. Change the output file name.
Note: Some functions are mandatory and cannot be omitted (see functions description in the
Loader_Src.c file).
Linker or scatter files should not be modified.
The Loader_Src.c functions must always return ‘1’ when the operation succeeded or ‘0’ if it
failed.
After building the external loader project, the output file extension must be changed to ‘.stldr’
and the file must be copied under ExternalLoader directory.
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
(expressed in bytes).
Note: Some SWV bytes could be lost during transfer due to ST-LINK hardware buffer size
limitation.
-Q
Description: Enable quiet mode. No progress bar displayed.
-w8
Description: Writes 8-bit data to the specified memory address.
Syntax: -w8 <Address> <data>
Example: -w8 0x20000000 0xAA
Note: -w8 supports writing to Flash memory, OTP, SRAM and R/W registers.
-w32
Description: Writes 32-bit data to the specified memory address.
Syntax: -w32 <Address> <data>
-r8
Description: Reads <NumBytes> memory.
Syntax: -r8 <Address> <NumBytes>
Example: -r8 0x20000000 0x100
-HardRst
Description:Hardware reset.
Syntax: -HardRst
Note: -HardRst command is available only with ST-LINK/V2. The RESET pin of the JTAG
connector (pin 15) should be connected to the device reset pin.
-Run
Description: Sets the Program Counter and Stack pointer as defined at user application
and performs a run operation. This is useful if the user application is loaded
with an offset (e.g. 0x08003000). If the address is not specified,
0x08000000 is used.
Syntax:-Run [<Address>]
Example: -run 0x08003000
–Halt
Description: Halts the core.
Syntax: -Halt
–Step
Description: Executes Step core instruction.
Syntax:-Step
–SetBP
Description: Sets the software or hardware breakpoint at a specific address. If an
address is not specified, 0x08000000 is used.
Syntax: -SetBP [<Address>]
Example: -SetBP 0x08003000
–ClrBP
Description: Clears all hardware breakpoints, if any.
Syntax: -ClrBP
–CoreReg
Description: Reads the Core registers.
Syntax: -CoreReg
–SCore
Description: Detects the Core status.
Syntax: -SCore
-SE
Description: Erase Flash sector(s).
Syntax: -SE <Start_Sector> [<End_Sector>]
Example:-SE 0 => Erase sector 0
-SE 2 12 => Erase sectors from 2 to 12
*For STM32L series, the following cmd erases data eeprom:
-SE ed1 => Erases data eeprom at 0x08080000
-SE ed2 => Erases data eeprom at 0x08081800
-P
Description: Load binary, Intel Hex or Motorola S-record file into device memory without
verification. For hex and srec format, the address is relevant.
-V
Description: Verifies that the programming operation was performed successfully.
Syntax: -V [while_programming/after_programming]
Example: -P *C:\[Link]* -V "after_programming"
Note: If no argument is provided the while_programming verification method will be performed.
-CmpFile
Description: Compares a binary, Intel Hex or Motorola S-record file with device memory
and displays the address of the 1st different value.
Syntax: -CmpFile <File_Path> [<Address>]
Example1: -CmpFile "c:\\[Link]" 0x08000000
Example2: -CmpFile "c:\\[Link]
You can also compare the file content with an external memory. The path of the external
memory loader should be specified by the -EL cmd.
Example1: -CmpFile "c:\[Link]" 0x64000000 -EL "c:\[Link]"
-OB
Description: Configures the option bytes. This command:
– sets the Read Protection Level to Level 0 (no protection)
– sets the IWDG_SW option to ‘1’ (watchdog enabled by software)
– sets the nRST_STOP option to ‘0’ (reset generated when entering
Standby mode)
– sets the Data0 option byte
RDP=<Level>:
RDP=<Level> sets the Flash memory read protection level.
The <Level> could be one of the following levels:
0: Protection disabled
1: Protection enabled
2: Protection enabled (debug and boot in SRAM features are DISABLED)
Note: Level 2 is available on STM32 F0, STM32 F2, STM32 F3, STM32 F4 and STM32 L1 series
only.
BOR_LEV=<Level>:
BOR_LEV sets the Brownout Reset threshold level.
For STM32 L1 series:
0: BOR OFF, 1.45 to 1.55 V voltage range
1: 1.69 to 1.8 V voltage range
2: 1.94 to 2.1 V voltage range
3: 2.3 to 2.49 V voltage range
4: 2.54 to 2.74 V voltage range
5: 2.77 to 3.0 V voltage range
For STM32 F2 and STM32 F4 series:
0: BOR OFF, 1.8 to 2.10 V voltage range
1: 2.10 to 2.40 V voltage range
2: 2.40 to 2.70 V voltage range
3: 2.70 to 3.60 V voltage range
IWDG_SW=<Value>:
The <Value> should be 0 or 1:
0: Hardware-independent watchdog
1: Software-independent watchdog
nRST_STOP=<Value>:
The <Value> should be 0 or 1:
0: Reset generated when CPU enters the Stop mode
1: No reset generated.
nRST_STDBY=<Value>:
The <Value> should be 0 or 1:
0: Reset generated when CPU enters the Standby mode
1: No reset generated.
nBFB2=<Value>:
The <Value> should be 0 or 1:
0: Boot from Flash bank 2 when boot pins are set in boot from user Flash position
(default)
1: Boot from Flash bank 1 when boot pins are set in boot from user Flash position
(default).
Note: nBFB2 is available only on devices containing two Flash banks.
nBoot0_SW_Cfg=<Value>:
Only for STM32F04x
The <Value> should be 0 or 1:
0 : It allows user to disable BOOT0 hardware pin completely and use User Option
bit 11 (nBoot0).
1 : The BOOT0 pin is bonded to GPIO pin (PB8 on LQFP32 and smaller
packages, PF11 for QFN32 and bigger packages).
nBoot0=<Value>:
Only for STM32F04x and only when nBoot0_SW_Cfg is set.
The <Value> should be 0 or 1
Select the Boot mode together with nBoot1 (See table below)
nBoot1=<Value>:
Only for STM32 F0 and STM32 F3
The <Value> should be 0 or 1:
STM32F04x:
nBoot1 nBoot0 BOOT0 pin nBoot0_SW_Cfg Flash Empty Boot Mode
nSRAM_Parity=<Value>:
This bit allows the user to enable the SRAM hardware parity check.
The <Value> should be 0 or 1.
Note: nSRAM_Parity is available only on STM32 F0 and STM32 F3.
SDADC12_VDD=<Value>:
It selects the analog monitoring (comparison with Bgap 1.2V voltage) on SDADC12_VDD
Power source.
The <Value> should be 0 or 1.
Note: SDADC12_VDD is available only on STM32F37x devices.
Data0=<Value>:
Data0 sets the Data0 option byte.
The <Value> should be in [0..0xFF].
Note: Not available on STM32 F0, STM32 F2, STM32 F3, STM32 F4 and STM32 L1 devices.
Data1=<Value>:
Data1 sets the Data1 option byte.
The <Value> should be in [0..0xFF].
Note: Not available on STM32 F0, STM32 F2, STM32 F3, STM32 F4 and STM32 L1 devices.
SPRMOD =<Value>:
Selection of Protection Mode of WPRi bits:
The <Value> should be 0 or 1.
0: WPRi bits used for Write Protection on sector i (Default).
1: WPRi bits used for PCRoP Protection (read protection) on sector i (Sector)
Note: Available only on devices supporting PCRop feature.
WRP=<Value>:
WRP enables/disables the write protection of the MCU Flash sectors.
Each bit will enable/disable the write protection of one sector or more depending on the
connected device.
For STM32 L1 devices, WRP[i] = 0: Flash sector(s) is protected.
For other devices, WRP[i] = 1: Flash sector(s) is protected.
This command is sufficient to enable/disable all Flash sector protection, except for STM32
L1 medium density plus and High density where WRP2 and WRP3 and WRP4 commands
can be mandatory.
For STM32 F4 series, each bit of WRP enables/disables the write protection of one sector.
The <Value> should be in [0..0xFFFFFFFF]
Note: For devices supporting PCRop feature, WRP controls the read protection of the MCU Flash
sectors when SPRMOD = 1.
WRP2=<Value>:
WRP2 is available only for STM32 L1 medium density plus, high density and high density
plus devices to enable/disable the protection of Flash sectors from page 512 to 1023.
The <Value> should be in [0..0xFFFFFFFF].
Note: For devices supporting PCRop feature, WRP controls the read protection of the MCU Flash
sectors when SPRMOD = 1.
WRP3=<Value>:
WRP3 is available only for STM32 L1 high density and high density plus devices to
enable/disable the protection of Flash sectors from page 1024 to 1535.
The <Value> should be in [0..0xFFFFFFFF]
WRP4=<Value>:
WRP4 is available only on STM32 L1 high density plus devices to enable/disable the
protection of flash sectors from sector 1536 to sector 2047.
The <Value> should be in [0..0xFFFFFFFF]
DB1M =<Value>:
Dual-Bank on 1 MB Flash:
The <Value> should be 0 or 1.
Note: Available on STM32F42x/STM32F43x 1-MByte devices supporting dual bank swap.
5 Revision history
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
ST PRODUCTS ARE NOT DESIGNED OR AUTHORIZED FOR USE IN: (A) SAFETY CRITICAL APPLICATIONS SUCH AS LIFE
SUPPORTING, ACTIVE IMPLANTED DEVICES OR SYSTEMS WITH PRODUCT FUNCTIONAL SAFETY REQUIREMENTS; (B)
AERONAUTIC APPLICATIONS; (C) AUTOMOTIVE APPLICATIONS OR ENVIRONMENTS, AND/OR (D) AEROSPACE APPLICATIONS
OR ENVIRONMENTS. WHERE ST PRODUCTS ARE NOT DESIGNED FOR SUCH USE, THE PURCHASER SHALL USE PRODUCTS AT
PURCHASER’S SOLE RISK, EVEN IF ST HAS BEEN INFORMED IN WRITING OF SUCH USAGE, UNLESS A PRODUCT IS
EXPRESSLY DESIGNATED BY ST AS BEING INTENDED FOR “AUTOMOTIVE, AUTOMOTIVE SAFETY OR MEDICAL” INDUSTRY
DOMAINS ACCORDING TO ST PRODUCT DESIGN SPECIFICATIONS. PRODUCTS FORMALLY ESCC, QML OR JAN QUALIFIED ARE
DEEMED SUITABLE FOR USE IN AEROSPACE BY THE CORRESPONDING GOVERNMENTAL AGENCY.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.