2026-01-26 4:39 AM
I created a new project using CubeMX, and after that I plan to implement a framework for my firmware. I would like to better understand the best way to organize a clean and maintainable folder structure.
A colleague told me that all folders should be created inside the Core directory. I would like to understand whether using Core to contain my framework is the best approach, or if it is acceptable to create additional source folders outside of it.
Additionally, where can I find examples of STM32 firmware projects generated using CubeMX?
2026-01-26 4:56 AM
Hello @Vergnani_ElEn
A typical STM32CubeMX project looks like:
Project/
├─ Core/
│ ├─ Inc/
│ ├─ Src/
│ ├─ Startup/
│ └─ ...
├─ Drivers/
│ ├─ CMSIS/
│ └─ STM32xxxx_HAL_Driver/
├─ Middlewares/ (if you enable USB, FATFS, FreeRTOS, etc.)
├─ .project / .cproject / .mxproject / Makefile / etc.
└─ ...
CubeMX guarantees that it will regenerate or update files under:
Core/Inc,Src
Drivers/STM32xxxx_HAL_Driver
Middlewares/...
You don’t need to keep all your code under Core; you can structure it like this:
Project/
├─ Core/ # CubeMX-owned
│ ├─ Inc/
│ └─ Src/
├─ Drivers/ # ST/CMSIS
├─ Middlewares/ # Optional (FreeRTOS, USB, etc.)
├─ App/ # Your application logic
│ ├─ Inc/
│ └─ Src/
└─ Framework/ # Your reusable firmware framework
├─ Inc/
└─ Src/
Regarding the example : Each MCU family has a Cube package where you can find STM32CubeMX examples .
To install any firmware package In STM32CubeMX :Go to:
Help → Manage embedded software packages
Install the package for your MCU family (e.g. STM32F4, STM32H7)
After installation, the packages are typically stored in a path similar to:
C:\Users\<user>\STM32Cube\Repository\STM32Cube_FW_F4_Vx.x.x\
Inside this folder you will find example projects under Projects, for example:
Projects/STM32F4-Discovery/Examples/
Projects/NUCLEO-F401RE/Applications/
These contain ready-to-build projects that follow the same structure generated by STM32CubeMX.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2026-01-26 5:19 AM
@Ghofrane GSOURI wrote:You don’t need to keep all your code under Core.
Indeed.
@Vergnani_ElEn I would suggest that you keep all of your own code out of any folders maintained by CubeMX.
That way you can just leave CubeMX to do its own thing entirely in its own folder structure - so no risks of it affecting any of your own stuff, and no headaches if it decides to change its structure.
This also makes it easier to share code between projects.
See also: Project organisation in CubeIDE - how to go about libraries.