cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX package migration causes main.c file deletion

APari.2
Associate

I created and developed a project for more than 4 years, and changes in the project have always forced us to migrate to newer versions of CubeMX and also newer software packages. The project is for an STM32F407VGT6 microcontroller. The last stable version was with CubeMX 6.2.1 and software package 1.26.2. Now when I try to migrate to CubeMX 6.5.0 software pack 1.27.0, after clicking generate, CubeMX deletes the main.c file from the project. Restoring the backup main.c file is not a good idea, since the changes are not made in the older file. The main.c file is generated when the project is made from scratch, but with migrated project, it is deleted.

2 REPLIES 2
Paul1
Lead

What we do:

  • create main2.c
  • have main() immediately call main2() (nothing else done in main())
  • put all custom code in main2.c where its safe
  • manually move any required changes/updates from main to main2.c and main2(), including init code.
  • option: make it main2.cpp even if only C code. C++ has more checks than C, and you can set compile options/warnings separately for C vs C++ files allowing even stricter check which can reduce runtime bugs.

Paul

APari.2
Associate

Thank you for answering Paul.

Actually, I was repotting a bug, and not concerned with my self-written code, since I can copy it from an older version. The problem is that I wanted to add some peripherals to the code, and now the cube doesn't make main.c file. So if I do it your way, I have to copy-paste initialization and project settings and all that stuff as well. I realized that it's more efficient to make another project and copy-paste the custom code again.