STM32CubeIDE on Windows
Last updated
Last updated
STM32CubeIDE projects are generating Makefiles that can then be used using the strategy defined in , with a few extra configuration steps.
STM32CubeIDE projects works the following way to compile a project:
Generation of Makefiles
Instrumentation of the PATH variable to make use of the right tools (make command, compiler, linker, etc)
Execution of the make
command.
This method conflicts with the method used by below-make-intercept
to generate a compilation database. Because of this, the below-make-intercept
must be run after PATH variable instrumentation, which must be replicated.
To do that, the user must:
Generate the Makefiles (using STM32CubeIDE directly, by running at least one build).
Find the paths used by STM32CubeIDE for:
The make
command
The compiler invokations
Inject these paths
Call below-make-intercept
directly on the make
command.
This section details how to do that, taking the STM32CubeIDE example project 53L1A2_MultiSensorRanging, targeting NUCLEO-F401RE (Cortex-M4), on Windows.
The project is possible to setup quickly by clicking on File -> New -> STM32 Project.
There, on tab Example selector, select project 53L1A2_MultiSensorRanging for NUCLEO-F401RE.
On the newly imported project, set Release target active.
Then, build the project. This will generate the build files, hence the Makefiles. Then, clean the project to be in a clean state.
Let's now build the project from a terminal instead of STM32CubeIDE. Open Release directory in the system explorer, and then open a PowerShell terminal from Release directory.
Now, the objective is to make the command make all
work in this terminal. To do that, we must setup the environment so make
command and arm-none-eabi-gcc
are recognized.
To find the required environment, in STM32CubeIDE, go to project properties, in C/C++ Build -> Environment and check the content of the PATH variable, so you can identify where the commands are. In general, both are in different directories. On a classical installation of STM32CubeIDE, the directory containing the make
command is something like:
The directory containing the arm-none-eabi-gcc
command is something like:
In the PowerShell terminal, we may now inject these paths and build the project.
The best thing to do here is to create a PowerShell script with the following content:
Now, calling this script directly in the Configure script in beLow will generate the required compilation database.
If you don't wish to modify your global environment, you may also create a clean and a build script.
Therefore, the typical commands setup in beLow would be the following ones.
For Configure section, enter:
Script content:
Script execution path: In the target directory
Shell: Pwsh
For Clean section, enter:
Script content:
Script execution path: In the target directory
Shell: Pwsh
For Build section, enter:
Script content:
Script execution path: In the target directory
Shell: Pwsh
The project compiles! Now, from the same terminal, we can generate a compilation database by using below-make-intercept
tool, as descripted in .