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

- Command-line modes
  - Interactive command-line mode
  - Script mode
  - Quiet script mode
- Command line summary
- Notes
- Example script

# Running STM32CubeMX in command-line mode

STM32CubeMX provides command-line modes to facilitate integration with other tools and automation workflows.

With the commands listed in the table below, it is possible to:

- load an MCU,

- load an existing configuration,

- save the current configuration,

- set project parameters and generate the corresponding code,

- generate user code from templates,

- load a board identified by its part number,

- refresh the list of embedded software packages and install or remove packages,

- select additional software pack components to add to the project.

## Command-line modes

Three command-line modes are available:

### Interactive command-line mode

In interactive mode, STM32CubeMX starts a command prompt where commands can be entered manually.

The prompt displayed is `MX>`, indicating that the application is ready to accept commands.

Windows:

    cd <STM32CubeMX installation path>
    jre\bin\java -jar --add-opens java.desktop/java.awt=ALL-UNNAMED -add-exports java.desktop/sun.awt=ALL-UNNAMED -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT STM32CubeMX.exe -i

Linux:

    cd <STM32CubeMX installation path>
    ./STM32CubeMX -i

macOS:

    cd <STM32CubeMX installation path>
    cd Contents/MacOs
    ./STM32CubeMX -i

### Script mode

In script mode, STM32CubeMX executes commands from a script file.

Windows:

    cd <STM32CubeMX installation path>
    jre\bin\java -jar STM32CubeMX.exe -s <script filename>

Linux and macOS:

    ./STM32CubeMX -s <script filename>

The script file must contain one command per line. Example:

    load STM32F417VETx
    project name MyFirstMXGeneratedProject
    project toolchain "MDK-ARM v4"
    project path C:\STM32CubeProjects\STM32F417VETx
    project generate
    exit

### Quiet script mode

In quiet mode, STM32CubeMX executes a script without UI interaction.

Windows:

    cd <STM32CubeMX installation path>
    jre\bin\java -jar STM32CubeMX.exe -q <script filename>

Linux and macOS:

    ./STM32CubeMX -q <script filename>

As in script mode, commands are provided in a text file. The `MX>` prompt is displayed when the application is ready to accept commands.

## Command line summary

STM32CubeMX command-line reference
Command line | Purpose | Example
--- | --- | ---
`help` | Displays the list of available commands. | `help`
`swmgr refresh` | Refreshes the list of embedded software package versions available for download. | `swmgr refresh`
`swmgr install stm32cube_<series>_<version> ask` | Installs the specified STM32Cube MCU package version. | `swmgr install stm32cube_f1_1.8.0 ask`
`swmgr remove stm32cube_<series>_<version>` | Removes the specified STM32Cube MCU package version. | `swmgr remove stm32cube_f1_1.8.0`
`swmgr install <packVendor>.<packName>.<packVersion> ask` | Installs the specified pack version. | `swmgr install STMicroelectronics.X-CUBE-NFC4.1.4.1 ask`
`swmgr remove <packVendor>.<packName>.<packVersion>` | Removes the specified pack version. | `swmgr remove STMicroelectronics.X-CUBE-BLE1.4.2.0`
`pack enable <vendor> <pack>[/bundle] <version> <class> <group>[/subgroup] [variant]` | Selects a software pack component to add to the project. | `pack enable STMicroelectronics "X-CUBE-BLE1/BlueNRG-MS" 1.0.0 "Wireless" "Controller"`
`pack validate` | Applies in the project all pack components enabled since the last `pack validate` command. | `pack validate`
`load <mcu>` | Loads the selected MCU. | `load STM32F101RCTx`
`load <board part number> <allmodes|nomode>` | Loads the selected board with all peripherals configured in default mode or with no configuration. | `loadboard NUCLEO-F030R8 allmodes`
`config load <filename>` | Loads a previously saved configuration. | `config load "C:\Cube\ccmram\ccmram.ioc"`
`config save <filename>` | Saves the current configuration. | `config save "C:\Cube\ccmram\ccmram.ioc"`
`config saveext <filename>` | Saves the current configuration with all parameters, including values kept at default. | `config saveext "C:\Cube\ccmram\ccmram.ioc"`
`config saveas <filename>` | Saves the current project under a new name. | `config saveas "C:\Cube\ccmram2\ccmram2.ioc"`
`csv pinout <filename>` | Exports the current pin configuration as a CSV file. | `csv pinout mypinout.csv`
`script <filename>` | Runs all commands in the script file. There must be one command per line. | `script myscript.txt`
`project couplefilesbyip <0|1>` | Chooses whether peripheral initializations are generated in the main file or in dedicated `.c/.h` files. | `project couplefilesbyip 1`
`setDriver <Peripheral Name> <HAL | LL>` | Selects HAL-or LL-based peripheral initialization code generation. | `setDriver ADC LL`
`generate code <path>` | Generates only the STM32CubeMX-generated code, not a complete project. | `generate code C:\mypath`
`set tpl_path <path>` | Sets the path to the source folder containing `.ftl` user template files. | `set tpl_path C:\myTemplates\`
`set dest_path <path>` | Sets the destination folder used for code generated from user templates. | `set dest_path C:\myMXProject\inc\`
`get tpl_path` | Retrieves the current user template source folder path. | `get tpl_path`
`get dest_path` | Retrieves the current user template destination folder path. | `get dest_path`
`SetStructure <Advanced/Basic>` | Selects the project structure to generate. | `SetStructure Basic`
`SetCopyLibrary <copy all / copy only / copy as reference>` | Selects how reference libraries are copied to the project. | `SetCopyLibrary "copy all"`
`project setCustomFWPath <CustomFwLocation>` | Specifies an alternative STM32Cube firmware library path. | `project SetCustomFWPath "F:/SharedRepository/STM32Cube_FW_F0_V1.11.0"`
`project toolchain <toolchain>` | Specifies the project toolchain. | `project toolchain STM32CubeIDE`
`project name <name>` | Specifies the project name. | `project name ccmram`
`project path <path>` | Specifies the path where the project is generated. | `project path C:\Cube\ccmram`
`project compiler <compiler/linker>` | Sets the compiler/linker. | `project compiler "GCC"`
`project generate` | Generates the full project. | `project generate`
`login <email_address> <password> <remember_me>` | Allows you to log in to download software packages. | `login john.smith@st.com mypassword y`
`exit` | Ends the STM32CubeMX process. | `exit`

## Notes

- Use the `login` command before commands that require downloading software packages.

- The available toolchains may include `EWARM`, `MDK-Arm`, `STM32CubeIDE`, `Makefile`, and `CMake`.

- For script files, ensure there is exactly one command per line.

## Example script

    load STM32F417VETx
    project name MyFirstMXGeneratedProject
    project toolchain "MDK-ARM v4"
    project path C:\STM32CubeProjects\STM32F417VETx
    project generate
    exit