STM32CubeProgrammer Quick Start Guide

STM32CubeProgrammer is a powerful tool with many useful functions for programming and debugging STM32 devices. Its sophistication, however, introduces a moderate learning curve which may frustrate first-time users who just wish to perform a simple programming task. That is, its not immediately obvious how to use the tool to program the internal flash memory of an STM32 device with the contents of a given executable/binary image file (e.g., .elf files, .hex files, and .bin files). In fact, there are multiple ways to accomplish this task. The following tutorial demonstrates what’s arguably the simplest method for those wishing to get started quickly.

Procedure

This tutorial utilizes the latest version (version 2.12.0 at the time of writing) of STM32CubeProgrammer. It describes a very common and basic operation which shouldn’t require changing any of the application’s default settings. Those with more advanced use cases who wish to learn more about these settings and/or the higher capabilities of the tool should review the STM32CubeProgrammer User Manual (UM2237).

  1. Connect the ST-LINK probe to the PC with an appropriate USB cable. If you are working with an STM32 Nucleo, Discovery, or Eval kit; the ST-LINK is embedded on the board and there should be a USB port labeled “ST-LINK”, “STLK”, or similar (see Figure 1). See the user manual for your board if you’re not sure which connection to make.


    Figure 1: Example locations of the ST-LINK USB port on the STM32 Nucleo, Discovery, and Eval boards. The port should be labeled “ST-LINK”, “STLK”, or similar.

  2. Open the STM32CubeProgrammer application. On the right-hand side, “ST-LINK” should by default be selected as the target interface in the target configuration panel (shown in Figure 2). Leave the connection settings at their default values and click the green Connect button. The board should connect successfully.

    1_connect
    Figure 2: Connecting to an STM32 development board using the default ST-LINK interface.

  3. Click on the + tab and choose “Open File” as demonstrated in Figure 3. Use the file browser to choose the file you wish to be programmed to the board. The file formats supported by STM32CubeProgrammer are binary files (.bin), ELF files (.elf, .axf, .out), Intel hex files (.hex) and Motorola S-record files (.Srec).


    Figure 3: Opening a file, the contents of which will be programmed to the STM32 device.

    Note: If you select a binary (.bin) file as the source file, you must specify the download address by clicking the drop-down arrow next to the Download button and supplying the starting address in the Address field (see Figure 4a). If you select another file type (e.g., .elf or .hex), the Address field in this drop-down menu is grayed out and cannot be modified (see Figure 4b).

    bin_addressField
    a) The opened file is a binary file

    notBin_addressField
    b) The opened file is not a binary file

    Figure 4: The Address field is modifiable if the opened file is a binary (.bin) file.

  4. Click the Download button to begin programming, as shown below in Figure 5.


    Figure 5: Click the download button (not the drop-down arrow next to it) to program the STM32 device.

  5. Once the STM32 MCU programming is complete, click OK to close the message box and click the green Disconnect button as indicated in Figure 6. You may have to press the Reset button on the development board to start the application.


    Figure 6: The result of a successful programming operation.

Thank you. I used STM32Cube a few years ago. I also wrote a tutorial on it. But I don’t know why, I faced some troubles integrating STM32Cube with Keil.