Skip to main content
ADovn.1
Associate II
April 3, 2020
Solved

Is it possible to have CubeIDE project with multiple main functions?

  • April 3, 2020
  • 2 replies
  • 3905 views

I have a project which uses multiple identical boards and needs them to have slightly different firmware. So I thought that having a folder for each firmware with its own main function in one project will be efficient because all boards will use the same libraries and I won't need to maintain multiple projects at one time. 

So is it possible to set up a project with multiple main functions in Cube IDE? If yes, how I can do it?

This topic has been closed for replies.
Best answer by berendi

You can create multiple configurations under Project / Build Configurations / Manage. Each configuration has its own set of project settings, so you can e.g. define preprocessor symbols to activate some #ifdef in the code, or exclude entire files or directories from build.

Another way is to create sub-projects within a project. Create the main project without a target, new projects for each configuration inside the main project folder, and additional directories for common code. CubeMX uses this approach to manage dual core MCUs, you might want to create a dummy project for a STM32H745 to see how does it look like.

2 replies

berendi
berendiAnswer
Principal
April 3, 2020

You can create multiple configurations under Project / Build Configurations / Manage. Each configuration has its own set of project settings, so you can e.g. define preprocessor symbols to activate some #ifdef in the code, or exclude entire files or directories from build.

Another way is to create sub-projects within a project. Create the main project without a target, new projects for each configuration inside the main project folder, and additional directories for common code. CubeMX uses this approach to manage dual core MCUs, you might want to create a dummy project for a STM32H745 to see how does it look like.

ADovn.1
ADovn.1Author
Associate II
April 3, 2020

Thanks a lot, I tried the first method, it is working as I desired.