Skip to content

Latest commit

 

History

History
64 lines (39 loc) · 3.38 KB

File metadata and controls

64 lines (39 loc) · 3.38 KB

CubeMX Example

This csolution project shows the usage of STM32CubeMX which uses a generator import file to obtain the device configuration and HAL driver source files.

This project uses two different target-types to configure execution from Flash ROM or execution from RAM. It uses a variable to define the regions header file for each target in the file CubeMX.csolution.yml.

Prerequisites

Tools

Note

This example uses the Arm Compiler 6 (AC6). Using GCC Compiler explains how to configure it for a different compiler. A similar process also works for IAR.

Packs

Build Project

Build the Debug target set for the MyBoard_ROM target and download missing packs with:

> cbuild CubeMX.csolution.yml --active MyBoard_ROM@Debug --packs

Run CubeMX

To change the device configuration, start STM32CubeMX using the following command.

> csolution CubeMX.csolution.yml run --generator CubeMX --active MyBoard_ROM@Debug

For information about using CubeMX, refer to CMSIS-Toolbox > Configure STM32 Devices with CubeMX.

The source code generated by CubeMX is imported using the file STM32CubeMX<target-type>\CubeMX.cgen.yml. This allows you to create different settings for each target, for example evaluation board and custom hardware.

Note

Refer to the STM32U5xx_DFP pack overview for information on how to use an IDE workflow with CubeMX.

Execute Project

You may use the debugger of choice for executing this program.

Using GCC Compiler

By default, this project uses Arm Compiler 6 (AC6). It can be reconfigured for the GCC or IAR compiler using STM32CubeMX. To configure it for GCC, follow these steps:

  • In the file CubeMX.csolution.yml set compiler: GCC.

  • Launch the STM32CubeMX generator with this CMSIS-Toolbox command: csolution <solution_name>.csolution.yml run -g CubeMX -a <target-type>@<target-set>

  • In STM32CubeMX:

    • Open from the menu Project Manager - Project - Toolchain/IDE:
    • Select STM32CubeIDE and disable Generate Under Root.
    • Click GENERATE CODE to recreate the CubeMX generated files for the GCC compiler.
  • In the file CubeMX.cproject.yml, update the linker: node to reference the GCC linker script generated by CubeMX, typically found in the folder ./STM32CubeMX/<target-type>/STM32CubeMX/STM32CubeIDE. You may customize this linker script to meet your project's specific needs, but it should remain consistent with the CubeMX-generated startup and system files.

  • Rebuild the selected target set with cbuild CubeMX.csolution.yml --active <target-type>@<target-set> --rebuild.