Question
CubeMX does not correctly handle changing FW versions
CubeMX will not correctly re-generate code after changing STM firmware versions.
I want to be able to modify my project's version of STM firmware throughout the course of development. For example, to pickup any upcoming bug fixes, or to point to a patched version. I also want to include STM FW by reference in our projects to reduce code duplication.
Here are the steps to reproduce this issue:
- Create a project with these settings:


- Generate code
- Track output in version control
- Note that code must be generated a second time to pick-up these additional unexpected changes.
- Change to another firmware version (e.g. V1.24.1)

- Run code generation
- I expect that all V1.25.0 instances would be changed to V1.24.1, but there are leftover uses:
// test1.ioc
// I believe this represent's the greyed-out setting in CubeMX (above where we can specify a custom firmware path). So this doesn't seem to be cause for concern.
8:ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.0
// .cproject
// This appears to be the significant problem
214: <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1516957908" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.3 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.base.gnu-tools-for-stm32 || STM32F413ZHTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | /home/miles/STM32Cube/Repository/STM32Cube_FW_F4_V1.25.0/Drivers/STM32F4xx_HAL_Driver/Inc | /home/miles/STM32Cube/Repository/STM32Cube_FW_F4_V1.25.0/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | /home/miles/STM32Cube/Repository/STM32Cube_FW_F4_V1.25.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include | /home/miles/STM32Cube/Repository/STM32Cube_FW_F4_V1.25.0/Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F413xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F413ZHTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || " valueType="string"/>- Run code generation again. There should ideally not be any changes in output, but due to the idempotency bug, we expect only a few whitespace and reordering differences. There are actually a few more significant changes. In this case, it adds some lines pointing to the unwanted firmware version.
// .cproject
+ <listOptionValue builtIn="false" value="/home/miles/STM32Cube/Repository/STM32Cube_FW_F4_V1.25.0/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy"/>
+ <listOptionValue builtIn="false" value="/home/miles/STM32Cube/Repository/STM32Cube_FW_F4_V1.25.0/Drivers/STM32F4xx_HAL_Driver/Inc"/>System info:
- OS : Ubuntu 20.04
- STM32CubeMX version: 6.0.1
