Working with microcontrollers STM32 requires reliable tools for flashing, debugging and configuration. STM32CubeProgrammer - official software from STMicroelectronics, which integrates programming, memory erasing, chip protection and even basic debugging functions via SWD or JTAG. The tool supports all modern families STM32 - from budget STM32F0 to flagship STM32H7 And STM32U5, as well as new lines with cores Cortex-M33 And Cortex-M55.
Despite the intuitive interface, beginners often have questions: how to connect a debug board, why the device is not detected, how to restore a “brick” after unsuccessful firmware, or set up read protection. This article covers all key scenarios for using STM32CubeProgrammer - from installation to advanced functions such as bulk programming or working with external QSPI memory. We will look at common mistakes (for example, Error: No STM32 target found!), optimal settings for different chip families and ways to speed up the firmware of large projects.
Installing STM32CubeProgrammer: system requirements and nuances
Officially STM32CubeProgrammer supports Windows 7/10/11 (32/64-bit), Linux (Ubuntu, Debian) and macOS. However, for stable operation on Windows It is recommended to use version no lower 10 (1809) - in older OS there may be problems with drivers ST-Link. You can download the utility from ST official website (section Get Software). Please note: for Linux/macOS only command version available (STM32_Programmer_CLI).
The installation process is standard, but there are critical points:
- 🔹 ST-Link Drivers: If you are using development boards (Nucleo, Discovery, Eval), the driver for the built-in programmer is installed automatically. For external
ST-Link/V2orJ-Linkmay require manual installation viaSTSW-LINK009. - 🔹 Administrator rights: On Windows installer requires rights
adminto register drivers. Without them, the programmer will not be able to interact with USB devices. - 🔹 Conflict with other IDEs: If you have installed Keil, IAR or STM32CubeIDE, their built-in programmers may block the port. Close all IDEs before starting work.
After installation, check the functionality by connecting the development board and running STM32CubeProgrammer. A green text should appear in the lower right corner of the interface Connected with the name of the connected device (for example, ST-Link (V2J32M26)). If instead you see No target connected, go to the "Solving connection problems" section.
- Windows 10/11
- Linux (Ubuntu/Debian)
- macOS
- Other OS
Program interface: main tabs and their purpose
Interface STM32CubeProgrammer is divided into 5 key tabs, each of which is responsible for a specific functionality. Let's look at them in detail:
| Tab | Purpose | Key Features |
|---|---|---|
Erasing & Programming |
Flashing and erasing memory | Loading .hex/.bin/.elf, selection of memory area (Flash, RAM, OTP), recording speed settings |
Option Bytes |
Option Bytes Configuration | Setting read protection (RDP), security levels, boot loaders (Boot0/Boot1) |
Advanced |
Advanced Features | Mass programming, working with QSPI/OSPI, checksum verification |
OB (Option Bytes) |
View current options | Reading current settings OB, comparison with factory values |
Log |
Transaction Log | Error details, command execution times, debugging information |
The most popular is the tab Erasing & Programming. Here you can:
- 📁 Download firmware in formats
.hex(recommended for debug builds),.bin(for final versions) or.elf(with debugging symbols). - 🔄 Select erasing method:
Full chip erase(complete erase, long) orPage erase(fast, but requires specifying addresses). - ⚡ Adjust the exchange speed: for STM32H7 can be increased to
60 MHz, but for stability it is better to limit24 MHz.
If this is your first time flashing a chip, use Full chip erase — this is guaranteed to clear all memory sectors, including possible “garbage” data from previous firmware.
Microcontroller connection: ST-Link, JTAG and alternative programmers
For communication with microcontroller STM32CubeProgrammer supports several interfaces:
- 🔌 ST-Link (recommended): Built into most development boards (Nucleo, Discovery) or available as an external adapter (
ST-Link/V2,ST-Link/V3). SupportsSWDAndJTAG. - 🔗 JTAG: Used for complex debugging scenarios (such as working with Cortex-M7 in STM32H7). Requires 5 signals:
TDI,TDO,TMS,TCK,GND. - 🔄 UART Bootloader: Alternative method via
USART, ifSWD/JTAGnot available. Requires prior activation of the bootloader (jumperBoot0=1).
To connect via ST-Link:
- Connect the board to the USB port (for Nucleo use the connector
CN1). - B STM32CubeProgrammer select
Connect(button in the upper right corner). - If the connection fails, check:
- 🔋 Is the board powered (LED
LD1should light green). - 🔌 Is it connected?
ST-Linkcorrect (check inDevice ManageravailabilitySTMicroelectronics ST-Link). - 🔄 Is the chip blocked by an option?
RDP Level 2(requires complete erasure).
- 🔋 Is the board powered (LED
What to do if ST-Link is not detected?
If ST-Link is not recognized, try:
1. Reinstall the driver via STSW-LINK009.
2. Connect the board to another USB port (preferably USB 2.0).
3. Check the integrity of the cable (sometimes replacing it with a shorter one helps).
4. Update firmware ST-Link through ST-Link Upgrade.
To connect via UART Bootloader:
- Install jumper
Boot0=1(on boards Nucleo this isSB13 ON). - Connect the board to the COM port (default speed is
115200 baud). - B STM32CubeProgrammer select
UARTin the connection menu and specify the correct port.
⚠️ Attention: When working throughUART Bootloadercannot be usedFull chip erase- this will lead to the loss of the bootloader. Use onlyPage erasefor the required sectors.
Microcontroller firmware: step-by-step instructions
The firmware process in STM32CubeProgrammer consists of 4 main steps. Follow this algorithm to avoid errors:
Check the ST-Link connection (green indicator in the program)|Download the firmware in .hex or .bin format|Make sure the microcontroller is not locked (RDP Level 0)|Close all other programs that use ST-Link (Keil, STM32CubeIDE)-->
1. Downloading the firmware file:
- Click
Browsein the tabErasing & Programmingand select the file. - For
.hex-files, the program will automatically determine the start address (0x08000000for Flash). - If you use
.bin, enter the starting address manually (for example,0x08000000for STM32F4).
2. Erase setting:
- For the first firmware, select
Full chip erase. - To update existing firmware it is enough
Erase sectors(specify address range). - For STM32H7 with dual bank Flash select
Bank 1orBank 2depending on configuration.
3. Launching the firmware:
- Click
Start Programming. - The log window will display the progress:
Erasing...→Programming...→Verifying.... - If an error appears
Error: Flash Download failed, check the baud rate (reduce to4 MHz) or try a different cable.
4. Checking the result:
- After successful firmware it will appear in the log
Verification OK. - Reboot the board (disconnect/reconnect power or press
Reset). - If the microcontroller does not start, check:
- 🔘 Correctness of the reset vector (address
0x08000004should point toReset_Handler). - 🔘 Clock settings in the firmware (inconsistency
HSI/HSEmay block the start).
- 🔘 Correctness of the reset vector (address
Always check the firmware log for warnings like Warning: Option Bytes not programmed. This may mean that security options (for example, RDP) have not been updated and the chip will remain locked.
Working with Option Bytes and Chip Protection
Option bytes (Option Bytes) is a special memory area responsible for the low-level configuration of the microcontroller. Settings are stored here:
- 🔒 Read protection level (
RDP):Level 0(no protection)Level 1(memory read prohibition),Level 2(full blocking, including JTAG). - 🔄 Bootloader configuration: select clock source (
HSI/HSE), settingsBoot0/Boot1. - ⚡ Core supply voltage (
VDD): critical for STM32H7, where incorrect settings can lead to unstable operation.
To change option bytes:
- Go to the tab
Option Bytes. - Select the desired level
RDP(For example,Level 1to protect against firmware copying). - Configure other settings (for example,
User ConfigurationforIWDGorStop Mode). - Click
Apply- this will erase the chip and write new settings.
⚠️ Attention: InstallationRDP Level 2irreversibly blocks memory access viaJTAG/SWD. The only way to unlock is to completely erase the chip throughFull chip erase, which requires filingNRSTon a special frequency. For STM32F1 this is1.8VonNRST, for STM32F4/H7 —3.3V.
For mass programming (e.g. in production) use the tab Advanced:
- 📋 Upload a CSV file with addresses and option byte data.
- 🔄 Select mode
Batch Programming. - 📊 Configure checksum verification (
CRC) for verification.
Advanced features: QSPI, OSPI and mass programming
STM32CubeProgrammer supports work with external memory QSPI/OSPI, which is relevant for chips like STM32H743 or STM32U5, where external Flash is used to store data or code. For programming QSPI:
- Go to the tab
Advanced→QSPI Memory. - Specify the external memory address (for example,
0x90000000for STM32H7). - Download the firmware file and configure settings
QSPI(mode1-1-1,1-1-2,1-2-2or4-4-4). - Click
Start QSPI Programming.
For mass programming (for example, a batch of devices):
- 📂 Prepare a folder with firmware and CSV configuration file.
- 🔄 B
AdvancedselectBatch Modeand specify the path to the folder. - 📊 Set up logging of results (file
report.txtwill contain the status of each board).
When working with OSPI (for example, in STM32H7A3):
- 🔧 Use the mode
Octo-SPIfor maximum speed (up to133 MHz). - 🔄 Customize
Dummy Cyclesin accordance with the datasheet for external memory. - ⚠️ Check the supply voltage (
VCC) - some chipsOSPIrequire1.8V.
How to speed up the firmware of large projects?
To speed up the firmware (for example, .bin size 1 MB+):
1. Use SWD instead of JTAG - it works faster.
2. Increase your transfer speed to 24 MHz (in settings ST-Link).
3. Disable verification (Verify after programming) - this will save up to 30% of time.
4. For STM32H7 use Double Bank Modeto flash both banks in parallel.
Common mistakes and their solutions
Even experienced developers encounter errors when working with STM32CubeProgrammer. Let's look at the most common of them and how to eliminate them:
| Error | Reason | Solution |
|---|---|---|
No STM32 target found! |
There is no connection to the chip or the connection settings are incorrect. |
|
Error: Flash Download failed |
Problems with writing to Flash (incorrect addresses, write protection). |
|
Error: Option Bytes programming failed |
Incorrect settings Option Bytes or the chip is blocked. |
|
Warning: Device ID not recognized |
The programmer cannot determine the chip model. |
|
If the chip stops responding ("brick"), try the following steps:
- Check supply voltage - some STM32 (For example, STM32L4) are sensitive to drawdowns below
3.0V. - Use
UART Bootloader:- Install
Boot0=1. - Connect via
USARTat speed115200. - Execute
Erase→Program.
- Install
RDP Level 2 perform a full erase via NRST:
1. ПодключитеNRSTк3.3Vчерез резистор10k.2. Подайте питание на чип.
3. Запустите
Full chip eraseв STM32CubeProgrammer.
4. ОтключитеNRSTот3.3Vи выполните прошивку.
⚠️ Attention: When restoring a “brick” throughNRSTnever apply a reset voltage higher than3.6V- this may damage the chip. For STM32F1 use1.8V.
FAQ: answers to frequently asked questions
Is it possible to flash STM32 via Arduino IDE?
Yes, but with restrictions. Arduino IDE uses stm32flash or dfu-util for firmware via USART (Bootloader) or DFU. However this method does not support:
- 🔧 Settings
Option Bytes. - 🔒 Work with protected chips (
RDP Level 1/2). - ⚡ External memory firmware
QSPI.
For full operation it is recommended to use STM32CubeProgrammer.
How to flash STM32 without ST-Link?
There are several alternatives:
- UART Bootloader: Requires jumper
Boot0=1and a program likeSTM32FlashLoader. - J-Link: Supported in STM32CubeProgrammer (select
J-Linkin the connection menu). - OpenOCD: Open tool for working through
SWD/JTAG. - DFU: For USB chips (such as STM32F103 in mode
DFU).
The most versatile option - UART Bootloaderbut it works slower ST-Link.
Why does the firmware take too long?
The firmware time depends on:
- 📡 Exchange speeds: Increase to
24 MHzin settingsST-Link. - 🗃️ Firmware size: For
.binfiles >1 MB, use compression or split into parts. - 🔄 Erase mode:
Full chip erasetakes longer thanPage erase. - 🔌 Memory type: External
QSPIFlashing is slower than internal Flash.
To speed things up, disable verification (Verify after programming) and use SWD instead of JTAG.
How to reset RDP Level 2 on STM32?
Chips with RDP Level 2 require complete erasure through a special procedure:
- Connect
ST-Linkto the board. - Serve
3.3VonNRST(for STM32F1 —1.8V). - B STM32CubeProgrammer select
Connect under reset. - Execute
Full chip erase. - Relieve tension from
NRSTand flash the chip again.
If the procedure does not work, check:
- 🔌 Correct connection
NRST(some boards have overvoltage protection). - 🔋 Power stability (use laboratory power supply instead of USB).
Does STM32CubeProgrammer support chips from other manufacturers?
No, STM32CubeProgrammer only works with microcontrollers STM32. For chips from other brands, use:
- 🔹 NXP:
MCUXpressoorJ-Flash. - 🔹 Microchip:
MPLAB IPE. - 🔹 Nordic:
nRF Connect. - 🔹 Espressif:
esptool(for ESP32).
For universal firmware via SWD/JTAG can be used OpenOCD or J-Flash (from Segger).