cancel
Showing results for 
Search instead for 
Did you mean: 

Code generation deletes HAL Drivers

DN19
Associate II

Hi everyone,

I recently started programming STM Microcontrollers. I'm using STM32CubeIDE 1.13.2 to setup my project.

I want to build a modular software, where some necessary peripherals are initialized from beginning and others are initialized dependend on my build variables.

I was using STM32CubeIDE to setup the project and initialize the peripherals in the .ioc file. That worked well!

The reason I want to build a modular SW is because I also have a modular HW. Sometimes I want to use the same pins for different purposes dependent on my build variables. That is why I want to reset every pin I do not necessarily need from the begining. My problem is occuring when generating the code. The code generation does not only add or delete some code as I configure. It does also delete the HAL drivers if a module is not used. For example if I deactivate ADC it deletes the HAL drivers for adc even if I define them as enabled in the user code space of "stm32l4xx_hal_conf.h". How can I prevent the code generation process from deleting those drivers? I do not want to copy the folder manually or via script every time from my repository.

Is there any solution to keep the driver files?

Thank you very much!

Best regards!

18 REPLIES 18

@DN19 wrote:

I don't want to copy the driver files every time I generate the code. 


You could automate it as a User Action?

AndrewNeil_0-1727197784971.png

 

The adc.c and adc.h in Project/Core/Src and Project/Core/Include persist, but the HAL drivers are deleted. That was what I meant. Please excuse my unclear description.

Maybe, I don't know. I never used this box before, because its disabled. Nevertheless I would love to try it.

Thanks a lot for this suggestion. I recently had a look at that post, but this will not fit for my solution. I sometimes also change some common settings in the ioc file (clock or some common GPIOs). And if I adopt this solution, I would have to edit every existing ioc file if I understand it right.

Yeah, the whole CubeMX/IOC file thing really doesn't support that.

I think you're just going to have to do it manually.

You can always use CubeMX to get you started, but then manage changes manually in the generated code - rather than trying to re-generate.

DN19
Associate II

Thanks for your answer. So I think my solution to go is just to use the ioc file to set up some new hardware components and afterwards just refreshing the drivers folder manually.


@DN19 wrote:

I never used this box before, because its disabled. Nevertheless I would love to try it.


Apparently it's only disabled within CubeIDE - it should be available if you use the standalone CubeMX:

https://community.st.com/t5/stm32cubemx-mcus/quot-copy-all-used-libraries-into-the-project-folder-quot-option/td-p/152793

 

It is disabled when creating code for STM32CubeIDE even in the standalone STM32CubeMX.

If you feel a post has answered your question, please click "Accept as Solution".

Oh well - I guess that must've changed since 2021, then?

Why is it still there if it's never enabled?!