cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE config for multiple projects sharing a HAL-like layer?

spectator
Associate II

Greetings. I'm trying to use the IDE to have builds of a common app for several of the L0/G0 lines, both to leverage my code from an older other-party SoC as well as compare STM32 low-power solutions against one another.

E.g. allow the IDE/MX to continue generating the Core/Driver/ThirdParty tree for each STM32 chip and have the main() user "while(1) {}" become "app_init(); app_main();" for all of them (ideally.) With some one-time #defines and path additions as part of each chip's project, I think this is not unusal.

From what I have learned so far, this would be straightforward if the shared/common code could compile into a shared library, but what I want to do requires compile-time access to each chip's Core/Inc world. I can't trick Eclipse into "reaching up and over" during compile, and I hope it's only my ignorance that's stopping me.

I am not strong in Eclipse, so forgive me if this is a direct application of resources that I have not yet grasped. Any simple example, wiki, GitHub showing this arrangement will be a wonderful tutorial for me.

1 REPLY 1
Pavel A.
Evangelist III

Sorry it's not obvious what you mean by sharing.

Do you refer to the behavior of Cube project generator, that it copies all the HAL files into the project?

Then, it has an option to create links to all the HAL files in the Cube libraries "repository" instead, so that several projects can share these HAL files.

Several .h files in each project contain #defines to configure the shared files (stm32..._hal_conf.h and so on).

> I am not strong in Eclipse, so forgive me if this is a direct application of resources that I have not yet grasped.

Yep. Please google for use of "linked resources" (files, directories) in Eclipse. And read on Eclipse CDT in general.

>  this would be straightforward if the shared/common code could compile into a shared library

Yes, compiling common files to a library would be straightforward and can save compile time - but ST leaves this as exercise to the users. The library format is specific to compiler, there are too many compilers to support, each with their own optimization and other options... do this at your own discretion.

One of my coworkers uses ccache, it greatly accelerates compile time.

-- pa