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

17 REPLIES 17

I've updated STM32CubeCLT_1.20.0 to 1.21.0 and they both report the same version

C:\Users\karl.yamashita>cmake --version
cmake version 3.28.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

C:\Users\karl.yamashita>where cmake
C:\ST\STM32CubeCLT_1.21.0\CMake\bin\cmake.exe

 

I'm not familiar with cmsis_Scanner?

 

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 


Actually, you need to check the version of Cube Bundle CMake using the command "cube cmake --version" and not "cmake --version".

To make sure all the VS Code Cube bundles are up to date and compatible, run the command "cube bundle update"
in the VS Code terminal.

Please let me know if it works

Regarding STM32CubeMX2, it also uses cmsis_scanner as a resource in background processes. That’s why the version and compatibility are very important and help us investigate the issue more effectively.


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 ran the following

PS C:\Users\karl.yamashita\STM32CubeIDE\workspace_2\Nucleo-C562RE_Test_cmake> cube cmake --version
cmake version 4.0.1

Then ran the update

PS C:\Users\karl.yamashita\STM32CubeIDE\workspace_2\Nucleo-C562RE_Test_cmake> cube bundle update
Do you want to install the following bundles: ["stlink-server@2.1.1+st.8", "st-arm-clangd@21.1.0+st.2", "st-arm-clang-hybrid-21_1_1-description@1.0.0+st.1", "st-arm-clang-hybrid@21.1.1+st.2", "st-arm-clang-21_1_1-description@1.0.1+st.1", "st-arm-clang@21.1.1+st.6", "pack-manager-snapshot@2026.2.27", "ninja@1.13.2+st.1", "gnu-tools-for-stm32-14_3_1-description@1.0.1+st.2", "gnu-tools-for-stm32@14.3.1+st.2", "gnu-gdb-for-stm32@14.3.1+st.2", "cmake@4.2.3+st.1"] (yes, no, show)?

After the update

PS C:\Users\karl.yamashita\STM32CubeIDE\workspace_2\Nucleo-C562RE_Test_cmake> cube cmake --version
cmake version 4.2.3

I tried building again on a 4th project and I get the same error

[main] Building folder: C:/Users/karl.yamashita/STM32CubeIDE/workspace_2/Nucleo-C562RE_Test_cmake/build/debug_GCC_NUCLEO-C562RE 
[main] Configuring project: Nucleo-C562RE_Test_cmake 
[driver] NOTE: You are configuring with preset debug_GCC_NUCLEO-C562RE, but there are some overrides being applied from your VS Code settings.
[proc] Executing command: C:\ST\STM32CubeCLT_1.21.0\CMake\bin\cmake.EXE -DCMAKE_BUILD_TYPE=debug_GCC_NUCLEO-C562RE -DTOOLCHAIN_FILE=GCC.14.3.1.cmake -S C:/Users/karl.yamashita/STM32CubeIDE/workspace_2/Nucleo-C562RE_Test_cmake -B C:/Users/karl.yamashita/STM32CubeIDE/workspace_2/Nucleo-C562RE_Test_cmake/build/debug_GCC_NUCLEO-C562RE -G Ninja
[cmake] -- Configuring done (11.7s)
[cmake] CMake Error at cmake/components.cmake:43 (target_link_libraries):
[cmake]   Error evaluating generator expression:
[cmake] 
[cmake]     $<QUOTE>
[cmake] 
[cmake]   Expression did not evaluate to a known generator expression
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:15 (include)
[cmake] 
[cmake] 
[cmake] CMake Error at cmake/components.cmake:43 (target_link_libraries):
[cmake]   Error evaluating generator expression:
[cmake] 
[cmake]     $<QUOTE>
[cmake] 
[cmake]   Expression did not evaluate to a known generator expression
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:15 (include)
[cmake] 
[cmake] 
[cmake] -- Generating done (0.4s)
[cmake] CMake Generate step failed.  Build files cannot be regenerated correctly.
[proc] The command: C:\ST\STM32CubeCLT_1.21.0\CMake\bin\cmake.EXE -DCMAKE_BUILD_TYPE=debug_GCC_NUCLEO-C562RE -DTOOLCHAIN_FILE=GCC.14.3.1.cmake -S C:/Users/karl.yamashita/STM32CubeIDE/workspace_2/Nucleo-C562RE_Test_cmake -B C:/Users/karl.yamashita/STM32CubeIDE/workspace_2/Nucleo-C562RE_Test_cmake/build/debug_GCC_NUCLEO-C562RE -G Ninja exited with code: 1

 

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

Per our private conversation on exporting with Issue Reporter and not being able to attach a zip file in the private message, I am attaching the zip file here.

 

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 
Thanks for sharing !!

Regarding the issue with the missing main.c/h files when creating a project from scratch:

just to make it easier to understand what’s going wrong if these issues happen again, it would be great if you could start STM32CubeMX2 in debug mode from now on, using:

  • cube mx start --log-level debug

Then, once you manage to reproduce issues, please send me the latest log files from:

  • C:\Users\<user>\AppData\Roaming\stm32cube\logs\STM32CubeMX2

Those logs with debug mode should give more clues about what’s happening and help investigate the problems further.


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.
Oussama_TROUDI
ST Employee

Hi @Karl Yamashita 

Yes, for the Cube bundle, all bundles are now up to date.
What you need to do is check the CMake path in the VS Code settings and set it to "cube-cmake" as shown:

Screenshot.png


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 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

Hi @Karl Yamashita 

Nice, to hear it’s working now and that the issue is fixed!

Thanks for sharing what you did too, this will be useful for others who hit the same problem. 


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.