Adding files to STM32CubeMX project
Additional settings for project generation
STM32CubeMX allows users to specify additional project settings through the .extSettings
file. These settings will be applied for the specified project upon CubeMX code generation from.
The .extSettings
file must be placed in the same project folder and at the same level as the .ioc
file.
Entries and syntax
ProjectFiles Use the fields in the ProjectFiles section to specify additional include directories. Syntax:
HeaderPath = <include directory 1 path>;< include directory 2 path >
Groups Use the fields in the Groups section where to create new groups of files and/or add files to a group. Syntax:
<Group name> = <file pathname1>;< file pathname2>
Others Use the fields in the Others section where to enable HAL modules and/or specify preprocessor define statements. Syntax:
Define = <define1_name>;<define2_name>
Examples
The following example specifies additional settings for a STM32H735G-DK project:
.extSettings file for STM32H735G-DK
[ProjectFiles]
HeaderPath=../Drivers/BSP/Components/Common;../Drivers/BSP/STM32H735G-DK
[Groups]
Drivers/BSP/STM32H735G-DK=../Drivers/BSP/STM32H735G-DK/stm32h735g_discovery_ospi.c;../Drivers/BSP/STM32H735G-DK/stm32h735g_discovery_ts.c;../Drivers/BSP/STM32H735G-DK/stm32h735g_discovery_bus.c
Drivers/BSP/Components=../Drivers/BSP/Components/s70kl1281/s70kl1281.c;../Drivers/BSP/Components/mx25lm51245g/mx25lm51245g.c;../Drivers/BSP/Components/ft5336/ft5336.c;../Drivers/BSP/Components/ft5336/ft5336_reg.c
Application/User/TouchGFX/target=../TouchGFX/target/CortexMMCUInstrumentation.cpp
[Others]
Define=USE_STM32H735G_DK
HALModule=I2C
The following example specifies additional settings for a STM32H747I-DK project:
Tip
.extSettings file for STM32H747I-DISCO
[CortexM7:ProjectFiles]
HeaderPath=../Drivers/BSP/Components/Common;../Drivers/BSP/STM32H747I-Discovery
[CortexM7:Groups]
Application/User/CM7/TouchGFX/target=../CM7/TouchGFX/target/STM32H7Instrumentation.cpp
Drivers/BSP/Components=../Drivers/BSP/Components/otm8009a/otm8009a.c;../Drivers/BSP/Components/otm8009a/otm8009a_reg.c;../Drivers/BSP/Components/ft6x06/ft6x06.c;../Drivers/BSP/Components/ft6x06/ft6x06_reg.c;../Drivers/BSP/Components/mt25tl01g/mt25tl01g.c;../Drivers/BSP/Components/is42s32800j/is42s32800j.c
Drivers/BSP/STM32H747I-Discovery=../Drivers/BSP/STM32H747I-Discovery/stm32h747i_discovery_bus.c;../Drivers/BSP/STM32H747I-Discovery/stm32h747i_discovery_qspi.c;../Drivers/BSP/STM32H747I-Discovery/stm32h747i_discovery_sdram.c;../Drivers/BSP/STM32H747I-Discovery/stm32h747i_discovery_ts.c;
[CortexM7:Others]
Define=USE_STM32H747I_DISCO
HALModule=I2C
Impact on generated project
Upon project generation from CubeMX, the presence of this .extSettings
file triggers the update of:
- The IDE project
.project
file in STM32CubeIDE folder
Update of the project `.project` file (STM32CubeIDE IDE)
<link>
<name>Drivers/BSP/Components/ft5336.c</name>
<type>1</type>
<locationURI>$%7BPARENT-1-PROJECT_LOC%7D/Drivers/BSP/Components/ft5336/ft5336.c</locationURI>
</link>
<link>
<name>Drivers/BSP/Components/ft5336_reg.c</name>
<type>1</type>
<locationURI>$%7BPARENT-1-PROJECT_LOC%7D/Drivers/BSP/Components/ft5336/ft5336_reg.c</locationURI>
</link>
<link>
<name>Drivers/BSP/Components/mx25lm51245g.c</name>
<type>1</type>
<locationURI>$%7BPARENT-1-PROJECT_LOC%7D/Drivers/BSP/Components/mx25lm51245g/mx25lm51245g.c</locationURI>
</link>
<link>
<name>Drivers/BSP/Components/s70kl1281.c</name>
<type>1</type>
<locationURI>$%7BPARENT-1-PROJECT_LOC%7D/Drivers/BSP/Components/s70kl1281/s70kl1281.c</locationURI>
</link>
<link>
<name>Drivers/BSP/STM32H735G-DK/stm32h735g_discovery_bus.c</name>
<type>1</type>
<locationURI>$%7BPARENT-1-PROJECT_LOC%7D/Drivers/BSP/STM32H735G-DK/stm32h735g_discovery_bus.c</locationURI>
</link>
<link>
<name>Drivers/BSP/STM32H735G-DK/stm32h735g_discovery_ospi.c</name>
<type>1</type>
<locationURI>$%7BPARENT-1-PROJECT_LOC%7D/Drivers/BSP/STM32H735G-DK/stm32h735g_discovery_ospi.c</locationURI>
</link>
<link>
<name>Drivers/BSP/STM32H735G-DK/stm32h735g_discovery_ts.c</name>
<type>1</type>
<locationURI>$%7BPARENT-1-PROJECT_LOC%7D/Drivers/BSP/STM32H735G-DK/stm32h735g_discovery_ts.c</locationURI>
</link>
...
<link>
<name>Application/User/TouchGFX/target/CortexMMCUInstrumentation.cpp</name>
<type>1</type>
<locationURI>$%7BPARENT-1-PROJECT_LOC%7D/TouchGFX/target/CortexMMCUInstrumentation.cpp</locationURI>
</link>
- The
stm32h7xx_hal_conf.h
file in the projectInc
(include) folder due to the presence of the I2C module in the.extsettings
file.
Update of stm32h7xx_hal_conf.h file to enable selected HAL modules (I2C)
/* #define HAL_PSSI_MODULE_ENABLED */
/* #define HAL_DTS_MODULE_ENABLED */
#define HAL_GPIO_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_MDMA_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_I2C_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED
/* #define HAL_HSEM_MODULE_ENABLED */
- The project view within
STM32CubeIDE
user interface as shown in the below figures.
Note
For the above STM32H735G-DK example the file CortexMMCUInstrumentation.cpp should be present inside its indicated location /TouchGFX/target/CortexMMCUInstrumentation.cpp