cancel
Showing results for 
Search instead for 
Did you mean: 

New STM32 VSCode extension V2.0.0 released

Nawres GHARBI
ST Employee

Changelog

  • V2.0.0 implies a breaking change: CMake project generation has been moved from VS Code to STM32CubeMX v6.11.0 (and later).
    • VS Code solution no longer has dependency on STM32CubeIDE (.cproject-files)
    • VS Code solution no longer relies on STM32CubeIDE provided toolchains and debugger tools
    • VS Code solution no longer has dependency on vcpkg,
  • Added support to import STM32CubeMX v6.11.0 CMake projects and bootstrap edit/compile/debug in VS Code
  • Added support to create empty projects
  • Depends on STM32CubeCLT v1.15.0 for empty project creation, build and debug tools
  • Documentation update: The User Guide has increased coverage
  • Better OS platform support

 

https://marketplace.visualstudio.com/items?itemName=stmicroelectronics.stm32-vscode-extension

23 REPLIES 23

There is actually a way in which you may be able to do port your project from CubeIDE to use the CMake support in MX. 

Note1: In this approach you will no longer be able to use CubeIDE on this project.
Note2: You will instead use CubeMX stand-alone tool + CMake, and VS Code if you want, or any other editor...

This procedure is a bit experimental. It took me 5min to test this out with a satisfying result. But I just had a plain MX project without much added application code that I wrote myself. This porting is where the tool does not help you.
Anyway, you can try this approach:

  1. Download and install CubeMX stand-alone software equivalent to the CubeIDE version you are using
    1. If you are unsure about which version of MX is inside a specific version of CubeIDE, then please read the CubeIDE release note.
  2. Make a copy/back-up of your project. We don't want to take any risks of you losing data...
  3. Launch CubeMX stand-alone load the back-up/copy of your CubeIDE project.
    1. File > Load Project... > Go to your CubeIDE project and load the ioc-file...
    2. Inside CubeMX > Project ManagerToolchain/IDE > Select CMake
    3. GENERATE CODE
      1. Your .cproject/.project files used by CubeIDE are now renamed to .project.bak/.cproject.bak. May sounds ***, but this is because we actually want VS Code users to be able to use the CubeIDE elf-file debugger feature (section: "Import STM32 Cortex®-M executable") in combination with VS Code. And that feature will otherwise overwrite the .project-file.
  4. Inside VS Code...
    1. Click on STM32 in the left-side activity bar > Import CMake project
    2. If you to build your project at this stage it will probably fail, assuming have added your own sources files, include paths, defines and other compiler options... The conversion done in step "3.2" would only cover what MX is aware of, and it does not know your application code...
  5. Merging build settings from CubeIDE to CMake structure
    1. Open CubeIDE on the original project and go into Project Settings > C/C++ Build > Settings > Tool Settings
    2. Copy all settings you have added yourself into the CMakeLists.txt in the root of the new project...
    3. Maybe you have a working build result after that?
    4. As extra step I would compare the build console output produced when compiling main.c with CubeIDE with the one you find in your new CMake project under $(Project_name)/build/Debug/compile_commands.json
      1. Is the build performed in the same way, or do you need to make additional CMake fixes?

 

This list of steps may sounds quite long and terrifying, but, assuming you are not using too much exotic post-build steps and similar this procedure should be quite easy.

Good luck and let us know if it worked or not?! :)

Southbranch
Senior II

I like the VS Code extension a lot, but here here are a couple of things I miss from the STM32CubeIDE:

Run Without Debugging

In order to execute this from the VS Code top menu, I currently need to do these steps:

  1. Stop the current MCU from running using Shift + F5 (if it is running)
  2. After compiling and flashing with "Run Without Debugging, manually reset the device on the hardware in order to start executing.

It all works but is a bit irritating since both these two steps works seamless in CubeIDE.

Is this a bug or just some settings that needs to be fixed?

 

“Clean Build” on the Run menu

There is no such thing on the Run menu which is a bit annoying.

Also, a simple “Build” would be nice to have in the Run menu.

 


@Southbranch wrote:

...

Run Without Debugging

...

It all works but is a bit irritating since both these two steps works seamless in CubeIDE.

Is this a bug or just some settings that needs to be fixed?

It is more of embracing a philosophical change. In VS Code you work more with keyboard shortcuts then with using your mouse to click on GUI buttons. Many developers would argue that this is more ergonomic / efficient. But the down-side is getting used to this and to learn the keyboard shortcuts... To make a complete answer on this topic for anyone reading this thread:

Today our VS Code extensions generates a tasks.json file (unless it already exist in your project, then we don't want to overwrite your stuff...) which provides a "task" labeled STM32: CubeProg: Flash project (SWD)

mattiasnorlander_0-1718716561654.png

This is just a template we provide, feel free to modify to your needs!

To perform a "flash and reset" you can execute this task.
Executing this task can be done by "clicks" or by keyboard shortcuts.
If you choose the "click approach", then there will be several clicks since there is no dedicated button... 

  • Option1: By "clicking": Terminal > Run Task... > CubeProg: Flash Project (SWD)
    mattiasnorlander_0-1719471642446.png

 

  • Option2 via Run Task keyboard shortcut:
    • CTRL + P
    • Type: "Task CubePro..." <-- You will notice that the menu auto-suggests tasks matching your pattern.

 

  • Option3: Pre-installed keyboard shortcut:
    • CTRL+ALT+F <-- This will immediately execute the same task


Also please notice that their are tasks named "Clean project" and "Build project". Option3 is the most efficient...
The other options require more than 1 user interactions.

lexcibien
Associate

Hi there!

Having some problems with the off box VS Code Extension,

i have to install ninja build, since the program won't compile, cant't say it's my case or the program doesn't install itself.

Next on my STM32F411CEUx_FLASH.ld i receive errors on this archive, which GPT help me notice where it says that it's missing RAM parameters, which i highlighted where it lacks.

The archive is annexed down.

Then it compiles and debug correctly.