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 ¶
|
Command line |
Purpose |
Example |
|---|---|---|
|
|
Displays the list of available commands. |
|
|
|
Refreshes the list of embedded software package versions available for download. |
|
|
|
Installs the specified STM32Cube MCU package version. |
|
|
|
Removes the specified STM32Cube MCU package version. |
|
|
|
Installs the specified pack version. |
|
|
|
Removes the specified pack version. |
|
|
|
Selects a software pack component to add to the project. |
|
|
|
Applies in the project all pack components enabled since the last
|
|
|
|
Loads the selected MCU. |
|
|
|
Loads the selected board with all peripherals configured in default mode or with no configuration. |
|
|
|
Loads a previously saved configuration. |
|
|
|
Saves the current configuration. |
|
|
|
Saves the current configuration with all parameters, including values kept at default. |
|
|
|
Saves the current project under a new name. |
|
|
|
Exports the current pin configuration as a CSV file. |
|
|
|
Runs all commands in the script file. There must be one command per line. |
|
|
|
Chooses whether peripheral initializations are generated in the main file or in dedicated
|
|
|
|
Selects HAL-or LL-based peripheral initialization code generation. |
|
|
|
Generates only the STM32CubeMX-generated code, not a complete project. |
|
|
|
Sets the path to the source folder containing
|
|
|
|
Sets the destination folder used for code generated from user templates. |
|
|
|
Retrieves the current user template source folder path. |
|
|
|
Retrieves the current user template destination folder path. |
|
|
|
Selects the project structure to generate. |
|
|
|
Selects how reference libraries are copied to the project. |
|
|
|
Specifies an alternative STM32Cube firmware library path. |
|
|
|
Specifies the project toolchain. |
|
|
|
Specifies the project name. |
|
|
|
Specifies the path where the project is generated. |
|
|
|
Sets the compiler/linker. |
|
|
|
Generates the full project. |
|
|
|
Allows you to log in to download software packages. |
|
|
|
Ends the STM32CubeMX process. |
|
Notes ¶
Use the
logincommand before commands that require downloading software packages.The available toolchains may include
EWARM,MDK-Arm,STM32CubeIDE,Makefile, andCMake.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