Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX: Feature request - Include a HAL driver, but don't configure it. (please)


I have a bootstrap in internal FLASH that configures the FMC driver to setup external FLASH and SDRAM. After setting them up it jumps to the application stored in external FLASH and executes it from there. The application also needs to use the FMC driver, but if it is included in the application project, the FMC clocks are initialised a second time - first in the bootstrap and then in the application. Initialising the FMC while executing using it causes bad juju.

I would like an option to include a HAL driver, but don't initialise it in any way, including the clocks.

The same goes for the MPU driver.



ST Employee

Just a workaround, but that could maybe help in your case. In STM32CubeMX, In Project Manager>Advanced Settings, you can disable the call to the init function.

In that case, the init function will still be generated and present in the main.c file, but without the call to them in the main().

And if not used at all, those functions will be removed during the build process and not present in the final binary.



Hi Herve,

Thank you for your reply. I think you might be on to something there. I had already disabled the FMC function call, but the problem was it still initialised the FMC clocks which crashed the app. Instead, what I could do is this:

  • include all the drivers the application needs in the bootstrap.
  • don't generate the Function Call so the bootstrap doesn't link the drivers in, but..
  • configure the clocks for all the drivers in the bootstrap.

Jump to the application:

  • include all the drivers in the application and do generate the init calls, except..
  • don't call the SystemClock_Config because it's already been done in the bootstrap.
  • call all the driver init functions.

Hopefully that will work, but I'll let you know how I get on.