cancel
Showing results for 
Search instead for 
Did you mean: 

How to add user source files to STM32CubeMX project?

Jim Seymour
Senior
Posted on August 23, 2016 at 19:58

I created a project with STM32CubeMX, generated the source code (for MDK-ARM5), then expanded my code by adding a couple of new source files.

Later, I went back to tweak my original Cube project and when I regenerated the source code, it deleted my new source files and created a new Keil project that didn't know about my new sources.

Is there a trick to doing what I want here?  My workaround so far is to store my new code in a separate folder - but I still have to re-add them to my project if I ever re-generate the source code.

Thanks.

4 REPLIES 4
Walid FTITI_O
Senior II
Posted on August 24, 2016 at 14:18

Hi seymour.jim, 

First, be sure that you are using the last version of CubeMx (4.16.0 now)

For the option ''Keep user code when generating'' ( in “Project setting� -> “Code generator�), it is checked by default but also you can verify it

.

Try to copy and paste the files that you want to add in source folder of your generated project ->  add the files in workspace –> regenerate project.

-Hannibal-

Jim Seymour
Senior
Posted on August 24, 2016 at 18:32

Thanks.  I am using the latest version and that option was selected.

But now I'm having trouble duplicating the original bug, so I'm not 100% sure about it anymore.

I still have to manually add my custom source files to the project when I do a regenerate, but the files themselves didn't get deleted the last couple of times I tried this.

Weird.

Walid FTITI_O
Senior II
Posted on August 25, 2016 at 16:16

Hi seymour.jim,

So it's OK. It seems that the first time you were not adding the files to the generated project's repository.

-Hannibal-

Jim Seymour
Senior
Posted on August 25, 2016 at 17:32

I am fairly confident that I can reproduce the problem, so I don't think it's ''OK''.  But it clearly does not happen all the time, so it's not the big, scary bug I thought it was.