Skip to main content
Visitor
September 12, 2026
Question

Observations: CubeMX2 1.1.1 will not restore deleted main.c (different behavior compared to CubeMX6)

  • September 12, 2026
  • 0 replies
  • 7 views

Software version: STM32CubeMX2 1.1.1 Target MCU: STM32C542RCT6

Steps I followed:

  1. Created a new project and generated the CMake‑based IDE project to a target folder.
  2. Closed CubeMX2, then manually deleted Core/Src/main.c via file explorer.
  3. Opened the original .mx2 project file again, kept using the same output directory, and clicked Generate IDE project.

Observed behavior: After code generation finishes, main.c is still missing from the folder. There is no warning message or popup to notify me the main entry‑point file is absent. Consequence: CMake build fails with undefined reference to main.

In legacy CubeMX6, when main.c was removed, code‑generation would recreate this template file automatically. This does not happen in CubeMX2 1.1.1.

Current workaround: I have to generate project files into a brand‑new empty folder to get a fresh copy of main.c, then copy this file back to my original project directory.

Analysis: It seems CubeMX2 treats main.c as a user‑modified file and skips regeneration. However it does not handle the scenario where the file has been manually deleted from disk. Developers coming from CubeMX6 may not expect this difference in behavior and can run into build issues. It would be helpful to add a warning if main.c is missing.