Last edited 3 weeks ago

How to create STM32MPU projects with STM32CubeMX

Applicable for STM32MP15x lines, STM32MP13x lines, STM32MP21x lines, STM32MP23x lines, STM32MP25x lines

This article explains how to create an STM32 Arm® Cortex® MPUs More info.png projects with STM32CubeMX and how to import them in STM32CubeIDE.

Warning DB.png Important
In this article, project are created for specific ST boards. Nevertheless, similar procedure can be done for specific STM32 Arm® Cortex® MPUs More info.png device used on customer boards.

1. Prerequisites[edit | edit source]


2. Definitions on some generated folders and files[edit | edit source]

Complete definitions are available in the STM32CubeMX user manual. Here are given only the definitions of files and folders generated systematically whatever the STM32 Arm® Cortex® MPUs More info.png.

  • ".settings" folder : contains IDE preferences and settings, includes things like compiler settings, code formatting, and environment variables.
  • .ioc : STM32CubeMX configuration for hardware initialization and middleware setup.
  • manifest.prop : project manifest version and path to .dts mx for OSTL projects: KERNEL , OPTEE , TF-A and U-BOOT
  • .mxproject : stores STM32CubeMX-specific project information.
  • .project : contains IDE project metadata such as build configurations.
  • .ld : linker script defining memory layout for the Cortex-M33 application in RAM.
  • ".cproject" file: contains build settings and configurations specific to the C/C++ project.

3. Create an STM32MP13x lines More info.png project[edit | edit source]

For STM32MP13x lines More info.png, 2 distributions are possible:

3.1. Create a project for a specific board[edit | edit source]

The project is created for a specific ST board.

  • Launch STM32CubeMX.
  • Create a new project via the menu File > New Project
  • Select the board: in the tab Board Selector, type MP1 in Commercial Part Number, the list of possible boards is displayed. For this example, the selected board is STM32MP135F-DK.
  • then click on the button Start Project
  • for this example the generated code is the default one , for that approve the proposal to Initialize all peripherals with their default Mode
  • then select which software must be generated amongst the 2 possible solutions:
STM32CubeMX STM32MP13 OpenSTLinux Project

or

STM32CubeMX STM32MP13 Bare Metal Project

The project creation starts loading the IOC file

STM32CubeMX STM32MP13 project creation

ThenPinout & Configuration tab appears

STM32CubeMX STM32MP13 project creation

In Project manager tab:

  • define the name of the generated project in Project Name field,
  • select STM32CubeIDE in Toolchain/IDE field,
STM32CubeMX MP13 OSTL project manager
  • press GENERATE CODE button to generate the project.
STM32CubeMX MP13 OSTL code generation


Once project generation done, a new pop up Code Generation appears to indicate that the generation is done. The generated project is automatically save in the directory identified, previously, in Project Name field (as written in next picture)

This directory can be simply opened (identified as option1 later in the article ) or the project can be opened (identified as option2 later in the article) meaning, imported directly in the STM32CubeIDE.



Screenshots of the generation for Baremetal use case

STM32CubeMX MP13 BareMetal project manager


STM32CubeMX MP13 BareMetal code generation

3.1.1. Structure of STM32MP13 OpenSTLinux generated code[edit | edit source]

If MP13 OpenSTLinux has been selected during this step:

STM32CubeMX STM32MP13 OpenSTLinux Project

Generated code is :

  • .settings folder
  • Device tree folder: Each software component has its own folder under "DeviceTree/Project Name/" with relevant ".dts" and makefile files.
    • Linux kernel,
    • OP-TEE secure OS,
    • Trusted Firmware-A,
    • U-Boot.
  • .ioc
  • manifest.prop
  • .mxproject
  • .project: this file is used to make the import of the project generated by STM32CubeMX in STM32CubeIDE (Option1).

The picture below shows the project structure after import in STM32CubeIDE

STM32CubeMX STM32MP13 OpenSTLinux project structure

3.1.2. Structure of STM32MP13 Bare metal generated code[edit | edit source]

If MP13 Bare Metal has been selected during this step:

STM32CubeMX STM32MP13 Bare Metal Project

Generated code is :

  • .settings folder
  • Application folder: User-level application logic, features, and modules
    • Core folder :The Core folder contains the main application source and header files, startup assembly, and system initialization code.
    • Drivers bare-metal user application source code, include file, startup files, application-specific HAL drivers.
    • .cproject
    • .ld
  • Drivers folder:
    • CMSIS folder: CMSIS core files
    • STM32MP13xx_HAL_Driver folder: the STM32MP13 HAL driver library, providing low-level peripheral support.
  • .mxproject
  • .ioc
  • .project: this file is used to make the import of the project generated by STM32CubeMX in STM32CubeIDE (Option1).

The picture below shows the project structure after import in STM32CubeIDE

STM32CubeMX STM32MP13 project structure

4. Create an STM32MP15x lines More info.png project[edit | edit source]

4.1. Create a project for a specific board[edit | edit source]

The project is created for a specific ST board.

  • Launch STM32CubeMX.
  • Create a new project via the menu File > New Project
  • Select the board: in the tab Board Selector, type MP1 in Commercial Part Number, the list of possible boards is displayed. For this article, the selected board is STM32MP157D-DK1.
  • then click on the button Start Project
  • then for this example the generated code is the default one , for that approve the proposal to Initialize all peripherals with their default Mode
STM32CubeMX STM32MP15 project creation

The project creation starts loading the IOC file

STM32CubeMX STM32MP15 project creation

Then Pinout & Configuration tab appears

STM32CubeMX STM32MP15 project creation

In Project manager tab:

  • define the name of the generated project in Project Name field,
  • select the STM32CubeIDE in Toolchain/IDE field,
  • press GENERATE CODE button.
STM32CubeMX STM32MP15 project creation

Once project generation done, a new pop up Code Generation appears to indicate that the generation is done. The generated project is automatically saved in the directory identified, previously, in Project Name field (as written in next picture)

This directory can be simply opened (identified as option1 later in the article ) or the project can be opened (identified as option2 later in the article) meaning, imported directly in the STM32CubeIDE.

STM32CubeMX STM32MP15 project creation

4.2. Structure of generated code[edit | edit source]

  • .settings folder
  • CA7 folder: Software and configuration targeting the Cortex-A7.
  • CM4 folder: Software targeting the Cortex-M4, including RTOS applications and inter-core communication (OPENAMP).
  • Common, Drivers, Middlewares: Shared code and libraries.
  • .mxproject
  • .ioc
  • .project: this file is used to make the import of the project generated by STM32CubeMX in STM32CubeIDE (Option1).

The picture below shows the project structure after import in STM32CubeIDE

STM32CubeMX STM32MP15 project project structure

5. Create an STM32MP2 series project[edit | edit source]

5.1. Create a project for a specific board[edit | edit source]

The project is created for a specific ST board.

  • Launch STM32CubeMX.
  • Create a new project via the menu File > New Project
  • Select the board: in the tab Board Selector, type MP2 in Commercial Part Number, the list of possible boards is displayed. For this article, the selected board is STM32MP257F-EV1.
  • then click on the button Start Project
  • then for this example the generated code is the default one , for that approve the proposal to Initialize all peripherals with their default Mode
STM32CubeMX STM32MP25 project creation
  • Select the TD flavor and, for A35-TD flavor only, if the TrustedZone must be activated or not
STM32CubeMX STM32MP25 project creation

The project creation starts loading the IOC file

In Project manager tab:

  • define the name of the generated project in Project Name field,
  • select the STM32CubeIDE in Toolchain/IDE field,
  • press GENERATE CODE button.
STM32CubeMX STM32MP25 project Manager


Once project generation done, a new pop upCode Generation appears to indicate that the generation is done. The generated project is automatically saved in the directory identified, previously, in Project Name field (as written in next picture)

This directory can be simply opened (identified as option1 later in the article ) or the project can be opened (identified as option2 later in the article) meaning, imported directly in the STM32CubeIDE.

STM32CubeMX MP25 project creation

5.2. Structure of generated code for A35-TD flavor More info green.png[edit | edit source]

In next chapters, are described the structures generated into the folder ProjectName depending if TZ is activated or not

5.2.1. TZ activated[edit | edit source]

  • CA35 folder : software and configuration related to the Cortex-A35 cores (application processors).
    • DeviceTree folder: Device Tree source files (.dts and .dtsi) describing the hardware configuration for the Cortex-A35. These are used by the Linux kernel or bare-metal embedded software running on Cortex-A35.
    • manifest.prop
  • CM33 folder : software and configuration related to the Cortex-M33, typically used for real-time or secure processing.
    • DeviceTree folder:
      • TF-M folder: Device Tree Source files describing the hardware configuration for the CM33 core for TF-M
    • NonSecure folder:
      • Common folder : shared code, utilities, or libraries used by both cores or common to the entire project.
      • Core folder: Source code and headers for the Cortex-M33 application.
      • Drivers folder: Peripheral drivers used by the Cortex-M33.
      • STM32MP257FAIX_RAM.ld
      • .cproject
  • Common folder : shared code, utilities, or libraries used by both cores or common to the entire project.
  • Drivers folder : General peripheral drivers or libraries shared across cores or used globally.
  • .ioc
  • .project : this file is used to make the import of the project generated by STM32CubeMX in STM32CubeIDE (Option1).

The picture below shows the project structure after import in STM32CubeIDE

STM32CubeMX STM32MP25 project creation

5.2.2. TZ not activated[edit | edit source]

  • "CA35" folder :software and configuration related to the Cortex-A35 cores (application processors).
    • "DeviceTree" folder: Device Tree source files (.dts and .dtsi) describing the hardware configuration for the Cortex-A35. These are used by the Linux kernel or bare-metal embedded software running on Cortex-A35.
    • "manifest.prop"
  • "CM33" folder :software and configuration related to the Cortex-M33, typically used for real-time or secure processing.
    • "Core" folder: Source code and headers for the Cortex-M33 application.
    • "Drivers" folder:Peripheral drivers used by the Cortex-M33.
    • STM32MP257FAIX_RAM.ld:
    • ".cproject"
  • "Common" folder: shared code, utilities, or libraries used by both cores or common to the entire project.
  • "Drivers" folder : General peripheral drivers or libraries shared across cores or used globally.
  • ".project": this file is used to make the import of the project generated by STM32CubeMX in STM32CubeIDE (Option1).
  • ".ioc"

The picture below shows the project structure after import in STM32CubeIDE

STM32CubeMX MP15 project creation

5.3. Structure of generated projects for M33-TD flavor More info green.png[edit | edit source]

In next chapters, are described the structures generated into the folder "ProjectName" .

  • "CA35" folder : software and configuration related to the Cortex-A35 cores (application processors).
    • "DeviceTree" folder: Device Tree source files (.dts and .dtsi) describing the hardware configuration for the Cortex-A35. These are used by the Linux kernel or bare-metal embedded software running on Cortex-A35.
    • "manifest.prop" file: project manifest version and path to "mx" .dts for Kernel, OP-TEE, TF-A and U-BOOT
  • "CM33" folder : software and configuration related to the Cortex-M33, typically used for real-time or secure processing.
    • "DeviceTree" folder: Device Tree Source files describing the hardware configuration for the Cortex-M33 for TF-M and mcuboot configuration
      • "TF-M" folder: Device Tree Source files describing the hardware configuration for the Cortex-M33 for TF-M
      • "mcuboot" folder: Device Tree Source files describing the hardware configuration for the Cortex-M33 for mcuboot
    • "NonSecure" folder:
      • "Core" folder: Source code and headers for the Cortex-M33 application.
      • '"Drivers" folder: Peripheral drivers used by the Cortex-M33.
      • STM32MP257FAIX_RAM.ld: Linker script defining memory layout for the Cortex-M33 application in RAM.
      • ".cproject" file:contains build settings and configurations specific to the C/C++ project.
  • "Common" folder : shared code, utilities, or libraries used by both cores or common to the entire project.
  • "Drivers" folder : General peripheral drivers or libraries shared across cores or used globally.
  • " ExtMemLoader/DeviceTree" folder : device tree for CA35 flashloader (optee-os, TF-a, u-Boot) .
  • ".ioc"
  • ".inc"
  • ".project": this file is used to make the import of the project generated by STM32CubeMX in STM32CubeIDE (Option1).

The picture below shows the project structure after import in STM32CubeIDE

STM32CubeMX MP25 M33TD project on STM32CubeIDE project explorer

6. Import project generated by STM32CubeMX in STM32CubeIDE[edit | edit source]

visit How_to_import_STM32MPU_project_generated_by_STM32CubeMX_in_STM32CubeIDE


7. How to go further[edit | edit source]

For more details about MP1x families please refer to :