Skip to main content
EStei.3
Associate III
April 1, 2025
Question

CubeMX and C++

  • April 1, 2025
  • 3 replies
  • 545 views

Hi all,
once again I stumble across CubeMX being so inflexible in its code generation.
I use CubeMX to generate initialization code but I'm also using C++ and that's where CubeMX has major downsides.
For example it is still not possible to tell CubeMX to generate the MX_XXX_Init function calls anywhere but in main.
Further more an option to add a simple pointer to all HandleTypeDefs which is free to use would help a lot.
From my experience STM HAL drivers are actually working pretty much ok but sometimes the are based on assumptions that a either flawed or don't apply in the project context.
Hence you have to write your own driver.
Just a simple pointer so I can pass additional information together with the handle struct would make life much easier especially when trying to implement a driver as C++ class.

To any ST employee reading this:
Are there any plans to make CubeMX more flexible?

To all users of CubeMX:
What would you really like ST to change in CubeMX?

BR

This topic has been closed for replies.

3 replies

Andrew Neil
Super User
April 1, 2025

@EStei.3 wrote:

 it is still not possible to tell CubeMX to generate the MX_XXX_Init function calls anywhere but in main.


But you can tell it not to generate them at all.

Edit: https://community.st.com/t5/stm32cubemx-mcus/how-to-have-cubemx-configure-a-peripheral-but-not-enable-it/td-p/761643 

 


@EStei.3 wrote:

Just a simple pointer so I can pass additional information together with the handle struct would make life much easier especially when trying to implement a driver as C++ class.


Recent discussion about that:

https://community.st.com/t5/stm32-mcus-embedded-software/user-defined-context-in-hal-callbacks/m-p/783093

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
EStei.3
EStei.3Author
Associate III
April 1, 2025

@Andrew Neil wrote:
But you can tell it not to generate them at all.

Yeah, both options are not really useful.

 


@Andrew Neil wrote:
Recent discussion about that:
https://community.st.com/t5/stm32-mcus-embedded-software/user-defined-context-in-hal-callbacks/m-p/783093

 

 Thanks, couldn't find that one!

Pavel A.
April 1, 2025

>To all users of CubeMX:
>What would you really like ST to change in CubeMX?

Power it up with some AI engine already ))) And a cloud based workspace, like on Github, so we won't struggle with linux versions and updates.  But this isn't going to be free?

>  so inflexible

Other words for it are stable, classic, minimalist, old & proven... 

> Are there any plans to make CubeMX more flexible?

Just note that any added option will require more testing. Willing to sponsor this?