cancel
Showing results for 
Search instead for 
Did you mean: 

Suggestion: Change the name of the generated code directories and main.c

Posted on May 20, 2015 at 06:12

Dear ST,

I'd like to give a bit of feedback now that I've worked with STM32CubeMX for a while.

Since CubeMX is really generating HAL code, what do you think of having CubeMX put the generated code into a directory called hal instead of src?

Also, since I want to have control over what is in my main.c file, could CubeMX put the startup code into something like cube_init.c? Or something else, but not main.c.

It's small, but I'd rather use my 35 years of experience to determine the structure of my directories (I put MY source into a directory called src these days, and I put bible code that isn't linted for MISRA compliance, into a separate directory). MY code starts at main() according to C, your code gets called since it is library code.

It would be nice if the directories didn't have to be generated where the ioc file lives. The ioc file is more of a hardware file and EEs would like to throw them in with their Altium files instead of the software files.

It's kinda like having your code fit in to my/our way of working rather than me/us fitting into your code structure.

That's what I've noticed, a couple of sharp edges that get in the way.

Just a thought.

Thanks,

Andrei from The Great White North
3 REPLIES 3
hbarta
Associate II
Posted on May 20, 2015 at 13:30

Hi Andrei,

I agree that dumping the generated files in .../src is not the best choice.  I would suggest .../cube or .../MX since strictly speaking, it is not HAL library code but rather generated code that uses HAL. .../src/MX or .../src/cube (or similar) would also be acceptable to me.

Location of the .ioc file has not been an issue for me because the H/W engineer did not produce it. Had he done so, it would (or should) have been in the source management system and the location and an alternate code location would have been convenient. The project settings show the project path but it seems not to be editable.

stm32cube-t
Senior III
Posted on June 04, 2015 at 18:28

Hello,

As you know MX generates either the peripheral initialization in the main.c or in dedicated files (that is an option under project settings). It generates also msp and interrupt service routine files. All these files are generated according to user configuration via MX UI. On top, they come with ''user sections'' for the user to insert his code. So we consider these files to be user files.

Posted on June 11, 2015 at 00:22

Please try and understand this, main.c is MY file, in fact with my chosen RTOS my entrypoint is called Init() and there is no main(). Your code is support library code and should be encapsulated from my code.

A more appropriate structure is for you to supply something like InitCube(). I can call that from my startup code, much like FatFS does.