cancel
Showing results for 
Search instead for 
Did you mean: 

Difficulty porting Keil to CubeIDE, can't add a file

BTrem.1
Senior II

0693W000008xjhjQAA.jpgI have a STM32G431 project that was originally created with STM32CubeMX using HAL drivers. I need to port some of this code to another project that was originally built by CubeMX using LL Drivers by another engineer.

The specific problem I have is my initialization of Timer4 is not working in the new project.

I have narrowed this down to stm32g4xx_hal_msp.c is not in my IDE project. This causes __WEAK version of HAL_MspInit() to be called that does nothing, instead of my modified version in stm32g4xx_hal_msp.c.

When I try to add the file to my project using "import"->"General"->"File-System" and selecting the src directory and Application/User as the destination it shows up in the project listing but is greyed out with a line through the icon.

I can click on the file name and it opens but I can intentionally add code errors and the project builds with 0 errors, so the file is not being added to the build list. I've tried refresh and I've tried closing the project and reopening. The results are the same, it is not being build.

Thanks,

Brian

3 REPLIES 3
Tilen MAJERLE
ST Employee

To add a file to the compilation (source files only, no include header files) to the project, you can do drag-and-drop.

Find your files in your explorer window and drag-drop them to the eclipse folder. This folder must be source-folder. You can create new source folder in eclipse by right-click on the project name, add -> source folder.

Hi Tilen,

I did a drag & drop into the ..\Application\User folder where the other project C files are shown . The new file stm32g4xx_hal_msp.c still shows up with a line across the icon. If I add an intentional error in the file it compiles the project with 0 errors. If I click on the file properties I get what is shown below:

0693W000008xouEQAQ.pngThis is how it shows up in the ..\Application\User folder, it is greyed out:

0693W000008xovWQAQ.jpgNote also, since my initial post I upgraded the project to STM32CubeIDE 1.50 from V1.20.

BTrem.1
Senior II

I received an answer from my ST Apps Engineer, Nicolas Fillon, He suggested the file was excluded from the build and asked me to check under "properties->C/C++ build" and he was correct it was excluded.

I found some strange behavior with the "Exclude" button getting checked, as described below:

Oh! That's very interesting! I created a new file new_test.c by using "Add" new source. I then did a build with that file with nothing in it but C comments then adding some code garbage to create a build error. When I did this the project did get a build error. I verified the "Exclude from build" was NOT checked (I had not touched this). Next, I copied and pasted the contents of stm32g4xx_hal_msp.c into that file and renamed it stm32g4xx_hal_msp.c. When I renamed it the "Exclude from build" was now checked. Following your advice, I unchecked it and it now builds.

Also, I am now at V1.50.

My root problem was I did not verify the setting of "Exclude from build" and that option seems to be checked or not checked arbitrarily. Adding a file by either "import" or "drag & drop" should have worked if I then verified the "Exclude" button.

Thanks,

Brian