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/V2 or J-Link may require manual installation via STSW-LINK009.
  • 🔹 Administrator rights: On Windows installer requires rights admin to 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.

📊 What OS do you use to work with STM32?
  • 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) or Page 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 limit 24 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.

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). Supports SWD And JTAG.
  • 🔗 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, if SWD/JTAG not available. Requires prior activation of the bootloader (jumper Boot0=1).

To connect via ST-Link:

  1. Connect the board to the USB port (for Nucleo use the connector CN1).
  2. B STM32CubeProgrammer select Connect (button in the upper right corner).
  3. If the connection fails, check:
    • 🔋 Is the board powered (LED LD1 should light green).
    • 🔌 Is it connected? ST-Link correct (check in Device Manager availability STMicroelectronics ST-Link).
    • 🔄 Is the chip blocked by an option? RDP Level 2 (requires complete erasure).
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:

  1. Install jumper Boot0=1 (on boards Nucleo this is SB13 ON).
  2. Connect the board to the COM port (default speed is 115200 baud).
  3. B STM32CubeProgrammer select UART in the connection menu and specify the correct port.
⚠️ Attention: When working through UART Bootloader cannot be used Full chip erase - this will lead to the loss of the bootloader. Use only Page erase for 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 Browse in the tab Erasing & Programming and select the file.
  • For .hex-files, the program will automatically determine the start address (0x08000000 for Flash).
  • If you use .bin, enter the starting address manually (for example, 0x08000000 for 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 1 or Bank 2 depending 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 to 4 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 0x08000004 should point to Reset_Handler).
    • 🔘 Clock settings in the firmware (inconsistency HSI/HSE may block the start).
💡

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), settings Boot0/Boot1.
  • Core supply voltage (VDD): critical for STM32H7, where incorrect settings can lead to unstable operation.

To change option bytes:

  1. Go to the tab Option Bytes.
  2. Select the desired level RDP (For example, Level 1 to protect against firmware copying).
  3. Configure other settings (for example, User Configuration for IWDG or Stop Mode).
  4. Click Apply - this will erase the chip and write new settings.
⚠️ Attention: Installation RDP Level 2 irreversibly blocks memory access via JTAG/SWD. The only way to unlock is to completely erase the chip through Full chip erase, which requires filing NRST on a special frequency. For STM32F1 this is 1.8V on NRST, for STM32F4/H73.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:

  1. Go to the tab AdvancedQSPI Memory.
  2. Specify the external memory address (for example, 0x90000000 for STM32H7).
  3. Download the firmware file and configure settings QSPI (mode 1-1-1, 1-1-2, 1-2-2 or 4-4-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 Advanced select Batch Mode and specify the path to the folder.
  • 📊 Set up logging of results (file report.txt will contain the status of each board).

When working with OSPI (for example, in STM32H7A3):

  • 🔧 Use the mode Octo-SPI for maximum speed (up to 133 MHz).
  • 🔄 Customize Dummy Cycles in accordance with the datasheet for external memory.
  • ⚠️ Check the supply voltage (VCC) - some chips OSPI require 1.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.
  • Check your connection ST-Link (green indicator in the program).
  • Make sure the chip is receiving power (3.3V or 5V depending on model).
  • Try a different cable or USB port.
Error: Flash Download failed Problems with writing to Flash (incorrect addresses, write protection).
  • Check the starting address of the firmware (for STM32F4 this is 0x08000000).
  • Reduce baud rate to 4 MHz.
  • Execute Full chip erase before the firmware.
Error: Option Bytes programming failed Incorrect settings Option Bytes or the chip is blocked.
  • Check the level RDP (must be Level 0 or Level 1).
  • For RDP Level 2 requires complete erasing NRST.
  • Make sure the supply voltage matches the datasheet.
Warning: Device ID not recognized The programmer cannot determine the chip model.
  • Check your connection SWD (signals CLK, DIO, GND).
  • Update the firmware ST-Link.
  • Make sure the chip is not able to Low Power.

If the chip stops responding ("brick"), try the following steps:

  1. Check supply voltage - some STM32 (For example, STM32L4) are sensitive to drawdowns below 3.0V.
  2. Use UART Bootloader:
    • Install Boot0=1.
    • Connect via USART at speed 115200.
    • Execute EraseProgram.
  • For chips with 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” through NRST never apply a reset voltage higher than 3.6V - this may damage the chip. For STM32F1 use 1.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:

    1. UART Bootloader: Requires jumper Boot0=1 and a program like STM32FlashLoader.
    2. J-Link: Supported in STM32CubeProgrammer (select J-Link in the connection menu).
    3. OpenOCD: Open tool for working through SWD/JTAG.
    4. 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 MHz in settings ST-Link.
    • 🗃️ Firmware size: For .bin files >1 MB, use compression or split into parts.
    • 🔄 Erase mode: Full chip erase takes longer than Page erase.
    • 🔌 Memory type: External QSPI Flashing 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:

    1. Connect ST-Link to the board.
    2. Serve 3.3V on NRST (for STM32F11.8V).
    3. B STM32CubeProgrammer select Connect under reset.
    4. Execute Full chip erase.
    5. Relieve tension from NRST and 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: MCUXpresso or J-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).