Import to ST project to Visual Studio Code
Author:Long development road Time:2022.09.04
In the world of ARM processors, there are many semiconductor manufacturers, one of which is ST. ST has a large number of product models, which have a variety of functions and for their corresponding development boards. ST also provides a development environment STM32Cubeide for development on ST devices. In addition, they also provide a configuration tool STM32CUBEMX, which is used to configure the equipment attribute and generate the configuration information of the project.
If you have participated in ST -based projects, I will not tell you any new content. You may not know what we do to enable embedded developers in Visual Studio Code. This embedded experience depends on the new VCPKG Artifacts features to help obtain the tool chain and configuration development environment. In order to make developers using ST devices more easily using Visual Studio Code, we have been working with ST to implement the introduction of the STM32Cubeide project.
We can achieve this by generating CMAKE projects from the ST project. ST provides many examples in its product portfolio. We have used this mechanism to verify the construction in ST's example projects, of which more than 3,000 are. At present, our pass rate has reached 94%, and we are constantly improving it. This makes us believe that our method will be successfully introduced into your own ST project. Our embedded tool extension also supports the equipment firmware burning and debugging through the importer, but please note that we only verify this on our existing test hardware.
This article will introduce how this project importer function is combined with VCPKG and ST tools.
Developing ST projects in Visual Studio Code This article is assumed that you are familiar with ST devices, development tools and embedded development basic knowledge. If you need some background knowledge, you can read the two entry documents written by Shawn Hymel below. > INTRODUCTION to Stm32Cubeide> Introiduction to Frertos
We rely on VCPKG to manage CMAKE and Ninja dependencies, including obtaining them and making them for your development environment. You can learn more about how we VCPKG can be understood in our Visual Studio Code Embedded Development Overview, and use the following commands to install it.
Linux/macOS system#. <(Curlhttps://aka.ms/vcpkg -init.sh -L)
PowerShell# iex (IWR -USEB https://aka.ms/vcpkg -init.ps1))
Please note that you need to install an embedded tool extension version 0.3.0 or higher version in Visual Studio Code to use ST project importer.
Our importer requires you to install STM32Cubeide software on the default location of the platform. We have been using STM32Cubeide 1.9.0 and STM32CUBEMX 6.5.0 to test this function. If you install multiple instances, we will not be able to control which one.
In addition, you also need to get a board -level support package for your device in STM32CUIDE. In this way, we can use the compilers and support applications provided by ST in Visual Studio Code.
ST will provide a lighter package in the future. We plan to obtain dependencies through VCPKG here. After installing our prerequisites, the command tray in the Visual Studio Code runs the "Create Project from the ST project".
Navigation to the location where your St .cProject was located and select it. You can then choose to debug or publish the configuration. You can now choose Build to use CMAKE to compile device firmware. To debug, select debug view, and then select the start button. This will run the STM32 programmer to write the firmware brush on the device and use GDB to connect. From here, you can use all our embedded development views (serial, RTOS and peripheral equipment).
If your project has a .IOC file, you can open the context menu and open STM32Cubemx for your project.
If you change the project in STM32CUBEMX, they will be recognized and CMAKE cache will be renewed.
After closing the Visual Studio Code for the next session of your project, you will need to start Visual Studio Code from activating VCPKG prompts. To this end, navigate to the project folder containing VCPKG-configuration.json, run VCPKG Activate, and run Code. In the future version, this will no longer be needed and activated will occur automatically.
Learn CMAKE interaction
You can see the simple cmakelists.txt generated under the root directory of the .cproject. This depends on the cmake file generated in the CMAKE directory. There are some path settings in these files to find the foundation of the ST compiler on your machine. If you intend to migrate from the ST project format to CMAKE, we recommend that you adjust these files as needed, especially in teams with different paths.
Another thing to note is that sometimes in the STM32CUBEIDE example, the project may be located in the sub -directory of the source code. If you don't see the project file in the file view, this may be the reason. Choose the CMAKE target view, you should see that Cmake is used to generate all the content.
According to the above point of view, we recommend that when using STM32CUBEMX to generate projects, reserve the default option for "Generate Under Root" in the project manager. This will save your .cProject in the root directory of the folder containing the generated source file. This is also the way STM32Cubeide generates the project by default.
If the project is opened in STM32Cubeide again, you need to exclude the construction directory used by the CMAKE from the project. Right -click to build a directory and select resource configuration> Eliminate from the construction.
Then select "Debug" and "Release" in the "Elimination in the Construction" dialog box.
Summarize
I remembered that I used Keil C to write STM32 code to control the car in the large factory. Harmful! The past is really unbearable. Let's not talk about it.
at last
The blog of the Microsoft Visual C ++ team is one of my favorite blogs. There are many knowledge and latest development progress about Visual C ++. Big waves, if you are still so interested in the ancient technology of Visual C ++, you can often go to them (or me). This article comes from: "Importing St Projects Into Visual Studio Code"
- END -
The new achievement of Chang'e 5 reveals the distribution characteristics of the moon table water in the landing area
On June 15, 2022, Beijing time, Nature Communications released an important resear...
Water and land use millimeter -level robots are available, or it can be used for minimally invasive medical diagnosis
Science Fiction Network June 15 (Wang Ziyu) Recently, the British Nature · Commun...