STM32CubeMX

Table Of Contents

- STM32CubeMX documentation
- CubeMX User Manual
  - 1 STM32Cube overview
  - 2 Getting started with STM32CubeMX
  - 3 Installing and running STM32CubeMX
  - 4 STM32CubeMX user interface
  - 5 STM32CubeMX tools
  - 6 STM32CubeMX C Code generation overview
  - 7 Code generation for dual-core MCUs (STM32H7 dual-core product lines only)
  - 8 Code generation with TrustZone enabled (STM32L5 series only)
  - 9 Device tree generation (STM32MPUs only)
  - 10 Support of additional software components using CMSIS-Pack standard
  - 11 Tutorial 1: From pinout to project C code generation using an MCU of the STM32F4 series
  - 12 Tutorial 2 - Example of FatFs on an SD card using STM32429I-EVAL evaluation board
  - 13 Tutorial 3 - Using the Power Consumption Calculator to optimize the embedded application consumption and more
  - 14 Tutorial 4 - Example of UART communications with an STM32L053xx Nucleo board
  - 15 Tutorial 5: Exporting current project configuration to a compatible MCU
  - 16 Tutorial 6 - Adding embedded software packs to user projects
  - 17 Tutorial 7 - Using the X-Cube-BLE1 software pack
  - 18 Creating LPBAM projects
  - Appendix A STM32CubeMX pin assignment rules
  - Appendix B STM32CubeMX C code generation design choices and limitations
  - Appendix C STM32 microcontrollers power consumption parameters
  - Appendix D STM32Cube embedded software packages
  - Revision history
- Release Notes
  - Release details
  - Release fixes
  - Known limitations
    - Miscellaneous
    - 2.1. When selecting microcontrollers in the STM32C0 series
    - 2.2. When selecting microcontrollers in the STM32G0 series
    - 2.3. When selecting microcontrollers in the STM32G4 series
    - 2.4. When selecting microcontrollers in the STM32H5 series
    - 2.5. When selecting microcontrollers in the STM32H7 series
    - 2.6. When selecting dual-core microcontrollers in the STM32H7 series
    - 2.7. When selecting microcontrollers in the STM32L5 series
    - 3.4. How to improve the wake-up from Stop sequences without relying on the global SystemClock_Config()
    - 3.3. List pinout-compatible microcontrollers
    - 3.2. DDR binaries for the STM32MP1 boards
    - 3.1. Command line authentication required
    - 2.21. Symbolic links on Ubuntu
    - 2.20. User manual
    - 2.19. DDR test suite
    - 2.18. STM32CubeIDE toolchain
    - 2.13. When selecting microcontrollers in the STM32WL series
    - 2.11. When selecting microcontrollers in the STM32WB series
    - 2.17. When using additional software packs
    - 2.16. When using the Example Selector
    - 2.15. When using the Memory Management Tool
    - 2.14. When selecting microprocessors in the STM32MP1 series
    - 2.11.1. When selecting microcontrollers in the STM32WB0 product lines
    - 2.12. When selecting microcontrollers in the STM32WBA series
    - 2.13.1. When selecting microcontrollers in the STM32WL33 product lines
    - 2.10. When selecting microcontrollers in the STM32U5 series
    - 2.9. When selecting microcontrollers in the STM32U3 series
    - 2.8. When selecting microcontrollers in the STM32N6 series
- Running STM32CubeMX in command-line mode
- FAQ
- Community

### On this page

- 2.1 Principles
  - Getting started with STM32CubeMX
- 2.2 Key features
  - Getting started with STM32CubeMX
- 2.3 Rules and limitations

# 2 Getting started with STM32CubeMX

## 2.1 Principles

> Customers need to quickly identify the MCU that best meets their requirements (core architecture, features, memory size, performance…). While board designers main concerns are to optimize the microcontroller pin configuration for their board layout and to fulfill the application requirements (choice of peripherals operating modes), embedded system developers are more interested in developing new applications for a specific target device, and migrating existing designs to different microcontrollers.

The time taken to migrate to new platforms and update the C code to new firmware drivers adds unnecessary delays to the project. STM32CubeMX was developed within STM32Cube initiative which purpose is to meet customer key requirements to maximize software reuse and minimize the time to create the target system:

- Software reuse and application design portability are achieved through STM32Cube firmware solution proposing a common Hardware Abstraction Layer API across STM32 portfolio.

- Optimized migration time is achieved thanks to STM32CubeMX built-in knowledge of STM32 microcontrollers, peripherals and middleware (LwIP and USB communication protocol stacks, FatFs file system for small embedded systems, FreeRTOS).

> STM32CubeMX graphical interface performs the following functions:

- Fast and easy configuration of the MCU pins, clock tree and operating modes for the selected peripherals and middleware

- Generation of pin configuration report for board designers

- Generation of a complete project with all the necessary libraries and initialization C code to set up the device in the user defined operating mode. The project can be directly open in the selected application development environment (for a selection of supported IDEs) to proceed with application development (see Figure 1).

> During the configuration process, STM32CubeMX detects conflicts and invalid settings and highlights them through meaningful icons and useful tool tips.

### Getting started with STM32CubeMX

> Figure 1. Overview of STM32CubeMX C code generation flow

## 2.2 Key features

> STM32CubeMX comes with the following features:

- Project management

  > STM32CubeMX allows the user to create, save, and load previously saved projects:

- When STM32CubeMX is launched, the user can choose to create a new project or to load a previously saved project.

- Saving the project saves user settings and configuration performed within the project in an .ioc file to be used when the project will be loaded in STM32CubeMX again.

> STM32CubeMX also allows the user to import previously saved projects in new ones.

> STM32CubeMX projects come in two flavors:

- MCU configuration only: .ioc file is saved in a dedicated project folder.

- MCU configuration with C code generation: in this case .ioc files are saved in a dedicated project folder along with the generated source C code. There can be only one .ioc file per project.

- Easy project creation starting from an MCU, a board, or an example

  > The new project window allows the user to create a project by selecting a microcontroller, a board, or an example project from STMicroelectronics STM32 portfolio. Different filtering options are available to ease the MCU and board selection. There is also the possibility to select an MCU through the Cross selector tab by comparing characteristics to those of competitors. Comparison criteria can be adjusted. - Easy pinout configuration

- From the Pinout view, the user can select the peripherals from a list and configure the peripheral modes required for the application. STM32CubeMX assigns and configures the pins accordingly.

- For more advanced users, it is also possible to directly map a peripheral function to a physical pin using the Pinout view. The signals can be locked on pins to prevent STM32CubeMX conflict solver from moving the signal to another pin.

- Pinout configuration can be exported as a .csv file.

- Complete project generation

  > The project generation includes pinout, firmware and middleware initialization C code for a set of IDEs. It is based on STM32Cube embedded software libraries. The following actions can be performed:

- Starting from the previously defined pinout, the user can proceed with the configuration of middleware, clock tree, services (such as RNG, CRC) and peripheral parameters. STM32CubeMX generates the corresponding initialization C code. The result is a project directory including generated main.c file and C header files for configuration and initialization, plus a copy of the necessary HAL and middleware libraries as well as specific files for the selected IDE.

- The user can modify the generated source files by adding user-defined C code in user dedicated sections. STM32CubeMX ensures that the user C code is preserved upon next C code generation (the user C code is commented if no longer relevant for the current configuration).

- STM32CubeMX can generate user files by using user-defined freemarker .ftl template files.

### Getting started with STM32CubeMX

- From the Project Settings menu, the user can select the development toolchain

  > (IDE) for which the C code has to be generated. STM32CubeMX ensures that the IDE relevant project files are added to the project folder so that the project can be directly imported as a new project within STM32Cube or third party IDEs (IAR™ EWARM, Keil™ MDK-Arm, KITWARE™ CMake, FSF™ Makefile).

- Power consumption calculation

  > Starting with the selection of a microcontroller part number and a battery type, the user can define a sequence of steps representing the application life cycle and parameters (choice of frequencies, enabled peripherals, step duration). STM32CubeMX Power Consumption Calculator returns the corresponding power consumption and battery life estimates.

- Clock tree configuration

  > STM32CubeMX offers a graphic representation of the clock tree as it can be found in the device reference manual. The user can change the default settings (clock sources, prescaler and frequency values). The clock tree is then updated accordingly. Invalid settings and limitations are highlighted and documented with tool tips. Clock tree configuration conflicts can be solved by using the solver feature. When no exact match is found for a given user configuration, STM32CubeMX proposes the closest solution.

- Automatic updates of STM32CubeMX and STM32Cube MCU packages

  > STM32CubeMX comes with an updater mechanism that can be configured for automatic or on-demand check for updates. It supports self-updates as well as firmware library package updates. The updater mechanism also allows deleting previously installed packages.

- Report generation

  > .pdf and .csv reports can be generated to document the user configuration work.

- Support of embedded software packages in CMSIS-Pack format (Software Packs)

  > STM32CubeMX allows getting and downloading updates of embedded software packages delivered in CMSIS-Pack format. Selected software components belonging to these new releases can then be added to the current project.

- Generating Software Packs with STM32PackCreator

  > STM32PackCreator is a graphical tool installed with STM32CubeMX in the Utilities folder. It allows the user to create Software Packs and STM32Cube Expansion packages enhanced for STM32CubeMX. It can be launched from the ST Tools tab found in the Tools view.

- Contextual help

  > Contextual help windows can be displayed by hovering the mouse over Cores, Series, Peripherals and Middleware. They provide a short description and links to the relevant documentation corresponding to the selected item.

- Access to ST tools

  > From STM32CubeMX project, the Tools tab allows the user to launch Tools directly or to access tools download pages on www.st.com.

- Video tutorials

  > STM32CubeMX allows the user to browse and play video tutorials. The video tutorial browser is accessible from the Help menu. The tutorials can be accessed through multiple locations, including the Help menu and the following areas:

1. STM32CubeMX Main Tabs: within the Pinout & Configuration, Clock Configuration, Project Manager, and Tools tabs.

2. MCU Finder Tabs within MPU/MCU Selector, Board Selector, Example Selector,

> Cross Selector

3. Embedded Software Package Manager window: specifically from any software expansion packages (X-CUBE packages) developed by STMicroelectronics, with an associated video tutorial

4. Specific IPs: directly from any peripheral (IP) with an associated video tutorial.

## 2.3 Rules and limitations