cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX2 code generation issues

Karl Yamashita
Principal

Yesterday I was able to generate a cmake project which included main.c/h files. I opened the project in VS Code but had errors trying to build. I had VS code fix the errors so now I am able to build the project.

  • Today, I generated another project but the main.c/h files are missing as seen in the screen shot.
  • I've timed the project generation and it takes 3 minutes to generate a project. Why so long?
  • Why are the IOC files created outside of the project folder?

 

Screenshot 2026-03-18 140335.png

 

 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
CAN Jammer an open source CAN bus hacking tool
CANableV3 Open Source

1 ACCEPTED SOLUTION

Accepted Solutions

I checked the path and it was set for "cmake" instead of "cube-cmake", so updated it. 

When building the project i got different errors

[cmakeExecutable] CMake executable not found in cache. Checking again.
[proc] Executing command: cube-cmake --version
[proc] The command: cube-cmake --version failed with error: Error: spawn cube-cmake ENOENT
[proc] Executing command: cube-cmake -E capabilities
[proc] The command: cube-cmake -E capabilities failed with error: Error: spawn cube-cmake ENOENT
[main] Building folder: Nucleo-C562RE_Test_cmake 
[cmakeExecutable] CMake executable not found in cache. Checking again.
[proc] Executing command: cube-cmake --version
[proc] The command: cube-cmake --version failed with error: Error: spawn cube-cmake ENOENT
[proc] Executing command: cube-cmake -E capabilities
[proc] The command: cube-cmake -E capabilities failed with error: Error: spawn cube-cmake ENOENT
[rollbar] Unhandled exception: Unhandled Promise rejection: build Error: Build failed: Unable to configure the project {}

I had the VS Code agent fix it. It added a wrapper "cube-cmake.cmd" which created this text

@Echo off
"%~dp0cube.exe" cmake %*

But it still had the same build error. Then I had the agent try to fix again and it create a settings.json file and added a path.

Screenshot 2026-03-27 121253.png

So now I am able to build the project with zero errors.

 

 

 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
CAN Jammer an open source CAN bus hacking tool
CANableV3 Open Source

View solution in original post

17 REPLIES 17
Oussama_TROUDI
ST Employee

Hi @Karl Yamashita 


With VS Code no need to open the folder with the .ioc2 file, just open the '_cmake' project folder.

Can you please share the cmake_project folder and .zip issue reporter so we can check the error?


In order 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.

Well the problem is when I want to create a repository for the cmake project folder, the IOC file is not included. 

 

I've attached the zip file and included the IOC file

 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
CAN Jammer an open source CAN bus hacking tool
CANableV3 Open Source

Hi @Karl Yamashita 

How did you create the attached IOC2? 
Could you please open pack manager and send me a screenshot displaying the "Up To date" packs?


In order 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.

I started a board project in CubeMX2, then it generated the IOC2 file. It then asked if i wanted to open the project, which i did. In the GUI, i enabled some peripherals and the System Tick. Then i had it generate the cmake project. But the main.c/h and files were missing.

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
CAN Jammer an open source CAN bus hacking tool
CANableV3 Open Source

Hi @Karl Yamashita 

It looks like main.c/h are missing because the pack 'stm32cubemx2_templates_no_os_stm32c5' is not installed in the Pack Manager.

and in the attached project, I didn't see the 'stm32cubemx2_templates_no_os_stm32c5' pack which is responsible of generating those files and the startup component.

It contains only 10 packs while a project created from  board contains 12 packs.Screenshot 2026-03-20 025236.png

we need to check whether the template pack is already installed 'up to date" in Pack Manager.
Could you please open pack manager and share a screenshot of the "Up To date" packs?


In order 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.

Yes, I looked at the project and only 10 packs are there for that project.

 

The 1st project i created has 12 packs. That project had errors building in VS Code. I had VS code fix it so it would build. I can't remember what it did.

 

The 2nd project is the one I attached prior that has the missing main.c/h.

 

I created a 3rd project. It has 12 packs and it created main.c/h files. However, it has build errors like the 1st project. I've attached the cmake project, IOC and the output.

  

 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
CAN Jammer an open source CAN bus hacking tool
CANableV3 Open Source

Hi  @Karl Yamashita 


So, for 2nd project is the one you attached that has the missing main.c/h. I suspect that VS Code might be impacting the issue.
Could you please check the cmsis-scanner bundle version used by VS Code under AppData/Local/stm32cube/bundles?


Also, regarding the CMake issue: you should use latest version of STM32CubeIDE for VS Code or for STM32CubeIDE (Eclipse) that we delivered. to ensure that you are using a compatible CMake version (CMake version ≥ 3.30).

To check the CMake version from the VS Code terminal, run the following command: "cube cmake --version"

 

Could you please check the versions of the cmsis-scanner bundle and CMake, and let me know both?


In order 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.

So, for 2nd project is the one you attached that has the missing main.c/h. I suspect that VS Code might be impacting the issue.

How would VS Code have prevented CubeMX2 from generating the missing files? 

I think the 2nd project was just a one time fluke with the 10 packs and missing files.

I created 4th project and the main.c/h files are there. But this has build errors just like the 1st and 3rd projects.

Have you taken a look at the 3rd project that i attached to see if you get the same build error?

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
CAN Jammer an open source CAN bus hacking tool
CANableV3 Open Source

Yes, it works fine on my side.

For that, I suggested you to check the versions of CMake and the cmsis_Scanner on your side to verify which versions you are using.


In order 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.