cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicate system_stm32g0xx.c file after regenerating

CTapp.1
Senior II

I've got a project that has the following files in the tree view:

CTapp1_1-1745333196183.png

All is well if I clean and build, but if I open the .ioc and "Generate Code", the tree changes to:

CTapp1_2-1745333269644.png

and the project then fails to build due to a duplicate system_stm32g0xx.c file.

Why is this getting added and how do I stop it?

I am using STM32CubeIDE V1.18.1.

1 ACCEPTED SOLUTION

Accepted Solutions
CTapp.1
Senior II

@Ghofrane GSOURI

I have created a new workspace and recreated the project from the .ioc file, and it looks like everything is back to normal.

I guess that means something in the workspace's metadata was not valid?

View solution in original post

10 REPLIES 10
Ghofrane GSOURI
ST Employee

Hello @CTapp.1 

First let me thank you for posting.

Could you please provide your IOC.

I 'will be waiting for your feedback.

THX

Ghofrane

CTapp.1
Senior II

Thanks for the quick response - file is attached.

Hello @CTapp.1 

I used your IOC to generate the code multiple times and each time the build finished without any errors or warnings, and your project architecture did not change.

GhofraneGSOURI_0-1745335969962.png

Let's try to close STM32CubeIDE and STM32CubeMX and go under C:\Users\XXXXXX then delete .stm32cubeide and .stm32cubemx.

THX

Ghofrane 

 

Thanks - I've tried that, but the results are the same.

CTapp.1
Senior II

I've just uninstalled and reinstalled CubeIDE (V.1.18.1), but that has also made no difference.

Hello @CTapp.1 

Try to use STM32CubeMX 6.14.1 standalone : this is the LINK to download it .

Open your IOC using STM32CubeMX 6.14.1 standalone then generate the code using STM32CubeIDE as shown 

GhofraneGSOURI_0-1745392514667.png

I will be waiting for your feedback.

THX

Ghofrane

CTapp.1
Senior II

Hi @Ghofrane GSOURI

The code is generated as expected when using the standalone MX 6.14.1 - the second system_stm32g0xx.c is not generated in the templates folder, and the code builds successfully.

Does this mean there is an issue with the integrated MX in IDE V1.18.1?

Edited to add:

When using the internal MX, an mx.scratch file is left in the project after code generation.

Hello @CTapp.1 

Even with the integrated MX in IDE V1.18.1, everything is working correctly. After multiple generation of the code, the build finished with success. There were no changes in the structure of your project and no duplicate files.

GhofraneGSOURI_0-1745400715189.png

It could be an issue related to your environment.

THX

Ghofrane

Ok, but how do I find out where the problem is so that I can fix it?