cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX - Generated files vs copied files

Korporal
Senior

I'm new to CubeMX and I've read over the documentation a couple of times (speed reading) but can't quite find an answer.

My question is what files exactly are generated by the tool and what files are simply copied?

Is it the case that all files we find under the Drivers folder are copied files? copied from the installed HAL reference files?

Is it the case that ONLY truly generated files are put into the Src/Inc folders (that is the Src/Inc folders in the project root).

For example I see a file named stm32f4xx_hal_msp.c in the project root Src folder, if this was generated by CubeMX why does it not have some kind of comment block saying "generated by CubeMX v x.y.x on March 8 2020 at 1:01 pm as part of project ABC..." and so on? Or is it a copy of a HAL file that was customized in some way by CubeMX as part of the code generation phase?

I'm trying hard to figure what code is generated for a project and what code is simply consumed as is.

Thx

1 REPLY 1
Pavel A.
Evangelist III

Basically it works this way:

  • All library files installed in %USERPROFILE%\STM32Cube\Repository\STM32Cube_FWxx_yy are constant and not mutable.
  • They can be copied to the generated project, either to have the project self-contained (so you can zip it and take away), or if you want to modify these library files.
  • Or the project can be created so that it refers to the library files in their original location. You may want this when you have more than a few projects for same chip/board.
  • Cube copies some library files always, even if copying is not selected in generation options. For example the .s startup file - because these files are likely to be customized. If you don't want to change these, you can delete them from the project and link to their originals in the Cube repository.

So if you specify to link the library files rather than copy, almost all files found in the project directory are generated.

> For example I see a file named stm32f4xx_hal_msp.c in the project root Src folder, if this was generated by CubeMX why does it not have some kind of comment block saying "generated by CubeMX v x.y.x on March 8 2020 at 1:01 pm as part of project ABC..." and so on?

Because the generated files are meant to be customized (note the user sections marked by special comments).

Some people would hate extra noise in generated files.

Use a version control system to track changes in all project files, including generated ones.

-- pa