on
2024-01-30
01:38 AM
- edited on
2024-06-18
12:55 AM
by
Laurids_PETERSE
This article covers how to create a custom build setup to allow users to customize, modify, and add specific build settings for each file, folder, or project.
Creating a custom build in STM32CubeIDE can be a powerful tool for developers looking to optimize their project's build process. Furthermore, to configure the build settings to meet specific needs and to improve project efficiency.
This feature is particularly useful when working on complex projects that require different build settings for various parts of the project. For example, a project may require different build settings for the firmware, bootloader, and application code. Using the “Manage Configurations” option, developers can easily create separate build configurations for each of these parts of the project. This makes it easier to manage and modify the build process options to specific projects, folders, or separate files.
In this article, we walk you through the steps to create a custom build in STM32CubeIDE and explore some of the benefits of this powerful feature.
So, let us get started and learn how to create a custom build in STM32CubeIDE!
The steps below specify how to create the new compilation settings:
The added build configuration might look like the following. Click OK and then “Apply and Close.”
After following the basic steps mentioned the user can, for example, exclude a file from building. This can be achieved by following the steps below.
The same steps can be replicated, so each selected build configuration only compiles the desired files.
A compilation symbol can be another extremely useful resource in the application code. Let us check a simple example using the custom build feature.
Add the code below:
while (1)
{
#ifdef BLINK_LED
HAL_GPIO_TogglePin(USER_LED_GPIO_Port, USER_LED_Pin);
#endif
#ifdef PRINTF
printf("Custom Build Message!");
#endif
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
In the "Project Properties", go to “C/C++ Build” > “Settings” > “MCU GCC Compiler” > “Preprocessor” > “Add New”
Note: Remember to specify the build configuration to be used, in this example, “Test.”
Add “PRINTF” and “BLINK_LED” Symbols:
After applying the changes, the code within the #ifdef statement will be compiled in this building configuration.
Creating different build artifact names can be useful for quickly identifying which project settings were used to create the given application. Each binary file created can have a custom name associated to its build configurations.
After building with “Test” build configuration active, the compilation files will appear as:
With the C/C++ Build option in “Project Properties”, users can perform a considerable set of configurations
Let us look at some of these options below:
In Project Properties > “C/C++ Build” > “Settings” > “MCU Post Build Outputs” > Check the boxes to generate the files after build.
In "Project Properties" > “C/C++ Build” > “Settings” > “MCU GCC Compiler” > “Optimization” > Select the desired “Optimization Level.”
Using the Custom Build feature, user can easily enable or disable the FPU for each build configuration, by just selecting the Build configuration, for example “Test,” and defining the FPU.
In conclusion, creating a custom build setup in STM32CubeIDE can greatly benefit developers looking to optimize their project's build process and improve project efficiency.
By following the steps outlined, developers can take advantage of this powerful feature and customize their build process to meet their specific needs.
This article has also provided some simple use cases for custom build, such as:
Hope this all helps to improve your project efficiency!
See you soon!