cancel
Showing results for 
Search instead for 
Did you mean: 

Code generation deletes HAL Drivers

DN19
Associate

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!

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

18 REPLIES 18
TDK
Guru

No, that's just how STM32CubeMX is set up to work when generating code for STM32CubeIDE. It only copies what is necessary and deletes the rest. For other toolchains, you can have it copy all files.

Solved: "Copy all used libraries into the project folder" ... - STMicroelectronics Community

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

Do you have this option checked?

AndrewNeil_0-1727184863495.png

If so, try un-checking it?

 

 

Andrew Neil
Evangelist III

Not entirely clear what you're doing here, nor how you're currently trying to achieve it.

But CubeIDE basically works on the basis of having exactly one .ioc file per project - so I don't think it's really going to support what you're trying to do, I'm afraid.

 

I described here how I manage have multiple Projects (ie, multiple hardware configurations) sharing common code:

https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/same-touchgfx-project-for-multiple-cubemx-files-in-the-same/m-p/672534/highlight/true#M37503

Perhaps you could do something similar?

Ok thanks for your quick answer.

I mean.... It is a necessary driver for my project. But I understand that CubeMX thinks that its not necessary, because no specific pin is enabled in the .ioc file for this peripheral.

If that is the case I may consider not using the .ioc file and CubeMX at all. I don't want to copy the driver files every time I generate the code. An option to select necessary drivers would be a good feature for CubeMX then.

You certainly are not tied to the IOC. If you're not using the pre-generated stuff, it makes sense to keep the IOC and the code separate.

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

Thanks for your suggestion. I already disabled this option.

The adc.c and adc.h files are not deleted due to this checkbox. But unfortunately the necessary HAL drivers are removed when generating the code.


@DN19 wrote:

The adc.c and adc.h files are not deleted due to this checkbox. But unfortunately the necessary HAL drivers are removed when generating the code.


Not sure what you mean by that?

The adc.c and adc.h files remain, but there is no driver code within them?

The HAL driver files are stm32l4xx_hal_adc.c, etc.

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

Ah, right - so would this option help:

AndrewNeil_0-1727197588885.png

The wording seems a bit strange, so not sure