Teach you to use Clion to develop STM32 elegantly from scratch (1) software installation and environment configuration

Teach you to use Clion to develop STM32 from scratch

(1) Software installation and environment configuration

(2) Transplant project files to other chips

(3) Necessary plug-ins for Clion embedded development


foreword

Some time ago, Mr. Zhihui used Clion to develop STM32 , such an elegant degree deeply attracted me! ! ! So referring to Zhihui Jun’s blog post, I also started to build the Clion configuration environment , consulted a lot of information about Clion’s development of STM32, and summarized a set of simple Clion development process of STM32 configuration environment .

This series of articles will teach you how to develop STM32 with Clion from scratch, from environment construction to code burning . I hope my series of articles can help you. Next, I will lead you to be an elegant embedded Type software development engineer! ! ! Due to my limited knowledge, if there are some mistakes, I hope everyone can help me point them out, and we will learn and progress together! ! !


1. Installation of relevant software

1) Prepare documents

Configure the software and environment packages required for the development environment:

  1. Clion software
  2. STM32Cubmx software
  3. gcc-arm-none-eabi
  4. openocd
  5. mingw64

You can search the above software and environment packages on the Internet by yourself. Later, I will package all the software and installation packages involved in this article and put them in the comment area. Friends who need them can pick them up by themselves .

2) Installation of software and environment packages

Due to space limitations, you can search online for tutorials on the installation of Clion software and STM32Cubmx software. I won’t go into details here, but focus on the installation of gcc-arm-none-eabi, openocd, and mingw64 ;

installation steps:

1) Install Clion software;

2) Install STM32Cubmx software;

3) Unzip the gcc-arm-none-eabi installation package to the specified path, and add the bin folder under the specified path to the environment variable;

4) Unzip the openocd installation package to the specified path, and add the bin folder under the specified path to the environment variable;

5) Unzip the mingw64 installation package to the specified path, and add the bin folder under the specified path to the environment variable;

Figure 1 Add the environment package path to the environment variable

TIPS:

1) The decompression path must not contain Chinese characters;

2) It is better not to have spaces in the decompression path, for example: "C:\Program Files";


2. Development environment configuration and burning to the development board

After going through the above steps, you can choose to use STM32Cubmx to generate the configuration file of SW4STM32 corresponding to the chip , and then open it with the Clion compiler , but there may be other complex situations such as not recognizing the configuration environment, compiling errors, and file loss... ...

You can refer to Zhihui Jun - "Configuring CLion for STM32 Development [Elegant Embedded Development]" https://zhuanlan.zhihu.com/p/145801160

In order to avoid this situation, so that everyone can easily and conveniently use Clion to develop STM32 without worrying about complicated configuration methods, I will directly give you the configured project files! The project file will be placed in the comment area later.....

The development platform I use is STM32F103VETx , which is the chip used by the Wildfire Guide development board. If you have this chip on hand, you can do the next operation with me. It doesn’t matter if it’s not this chip . The second section will bring you how to transplant project files to other chips, so stay tuned! !


 installation steps

a) Unzip the project file, and use the Clion compiler to open it under the decompression path ;

b) After opening, select Trial for 30 days, and click Continue , and in the subsequent window, select to trust this project ;

c) At this time, check whether the path of Mingw64 is correct . If the following three green ticks do not appear, it means that the installation is not successful. You need to check the path or reconfigure the environment variables. Click OK to enter the next step;

d) Follow the steps to click to the page as shown in the figure. If the small hammer in box 3 is gray, please wait patiently for the project file to be completely imported . If it still does not turn green, it means that there is a problem with the Mingw configuration. Then, click the green hammer to compile the file . If there is no accident, it should be 100% passed. At this time, we are only one step away from the successful construction, that is, the burning operation ;

e) Before burning, you must add the downloader configuration file. The following is the burning file of DAP-link . You can modify it according to the parameters of the downloader on hand, and save it in the format of xxxlink.cfg , and put it in the project directory In the config folder ;

# choose st-link/j-link/dap-link etc.
source [find interface/cmsis-dap.cfg]
transport select swd
# 0x10000 = 64K Flash Size
# 0x80000 = 512K Flash Size
set FLASH_SIZE 0x80000
source [find target/stm32f1x.cfg]
# download speed = 10MHz
adapter speed 10000
reset_config srst_only
#reset_config none

f) Follow the steps shown in the figure, select the correct cfg file , connect the downloader, and click on the burning program. If the pop-up window in the figure pops up, it means that the program burning is successful! At this point, you can use Clion to develop STM32 elegantly! ! !


Summarize

The prerequisite for developing STM32 with the Clion environment above is that you use the HAL library for embedded development . If you want to use the standard library for Clion development, there are currently Internet experts who have adapted it. You can search for more information. I believe you will succeed! ! ! If you have any questions, you can leave a message directly in the comment area, and I will summarize them and reply to everyone later! ! !

Guess you like

Origin blog.csdn.net/qq_35953617/article/details/129403383