2024-09-24 06:27 AM
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!
Solved! Go to Solution.
2024-09-25 12:58 AM
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.
2024-09-24 06:33 AM
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
2024-09-24 06:35 AM
Do you have this option checked?
If so, try un-checking it?
2024-09-24 06:50 AM
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:
Perhaps you could do something similar?
2024-09-24 08:47 AM
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.
2024-09-24 08:49 AM
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.
2024-09-24 08:51 AM
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.
2024-09-24 09:20 AM
@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?
2024-09-24 09:46 AM
The HAL driver files are stm32l4xx_hal_adc.c, etc.
2024-09-24 10:07 AM
Ah, right - so would this option help:
The wording seems a bit strange, so not sure