Use Eclipse to build STM32 embedded development environment

1. Installation of Eclipse software and related tools

When using Eclipse to develop embedded software projects such as STM32, the software or tools that need to be installed are:

  • The Eclipse software itself, eclipse-inst-jre-win64.exe
  • Cross-compilation toolchain, gcc-arm-none-eabi-10.3-2021.10-win32
  • make build tool for automatically generating makefiles
  • openocd debugging tool for downloading or debugging code
  • J-Link driver (if there is no need to install)

The following describes the installation of these tools one by one.

1.1 Install Eclipse

Eclipse is an open source, Java-based, extensible development platform. It is just a framework and a set of services. It builds a development environment by adding various plug-ins (this is a bit like VS Code), so as long as you add development plug-ins for C/C++ and other languages, it can be used as a tool for other languages ​​such as C/C++. development environment.

For embedded development, the version we downloaded is Eclipse IDE for Embedded C/C++ Developers, which can be downloaded through the link below:

https://www.eclipse.org/downloads/packages/release/2020-12/r/eclipse-ide-embedded-cc-developers

After the download is complete, we double-click to open the software. The following is an introduction to the installation process:

1. Double-click to open the eclipse-inst-jre-win64.exe program, and then select the Eclipse IDE for Embedded C/C++ Developers version to install.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-LyjR0GEq-1668914120056)(../picture/image-20221119103834701.png)]

2. Select the installation path and click Install.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-29JTNrmy-1668914120057)(../picture/image-20221119104643295.png)]

3. After the installation is complete, click Launch to start Eclipse for the first time.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-dqRm3e18-1668914120058)(../picture/image-20221119110422938.png)]

4. The interface selection after the first startup:

When you start Eclipse for the first time, the following interface will appear:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-aE47DBjQ-1668914120058)(../picture/image-20221119111428897.png)]

  1. Let us choose the Eclipse workspace path here, and the projects created with Eclipse in the future will be automatically created under this folder. The default path is in the user directory of the C drive, here I am modifying it to the D drive for storage.
  2. Use this as the ... This option box is not checked, so that we don't need to waste time to change the folder where the workspace is located in the future
  3. Finally, click Launch to open the Eclipse interface.

5. After the first startup, the interface is as follows, and a welcome interface will pop up, we can close it directly.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-yHW8fcKB-1668914120058)(../picture/image-20221119112342501.png)]

1.2 Install the cross-compilation toolchain

The cross-compilation toolchain can be directly downloaded from the ARM official website. The download link is as follows:

https://developer.arm.com/downloads/-/gnu-rm

Open the official website and scroll down to see the software you need to download, including windows, linux, and mac os. We choose the first one:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-kP1eTVm4-1668914120059)(../picture/image-20221119143223613.png)]

Note: Of course, you can download the .exe executable program or the .zip compressed package, and the same is true for decompressing the compressed package.

After downloading, we can unzip or install it to a certain directory (it is best to install or unzip all the tools used by Eclipse in one directory, which is convenient for management and search). Then you need to specify the environment variable so that Eclipse can recognize the path to the cross-compilation toolchain.

1.3 Install the make build tool

The main function of the make tool is to automatically generate makefiles. Of course, the make tool embedded in CDT can also be implemented, but it is recommended to use an external make tool to compile faster.

Make tool official website:

https://xpack.github.io/windows-build-tools/

download link:

https://github.com/xpack-dev-tools/windows-build-tools-xpack/releases/

Open the download URL and click the version below to download:

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-cwH49k7A-1668914120059)(../picture/image-20221119142250187.png)]

After downloading, the make tool is actually a compressed package. We unzip it to the same directory as the cross-compilation toolchain for backup (you need to specify the make tool path when creating a project later).

1.4 Install the debugging tool openocd

openocd, Open On-Chip Debugger , is actually an open source GDB debugging tool, which is the tool we need to use when debugging code. It can support many debugging tools (ST-LINK, JLINK, DAP-LINK, etc.) online debugging.

We can go to his official website to download.

https://openocd.org/pages/getting-openocd.html

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-tAAIAsyR-1668914120059)(../picture/image-20221119233751689.png)]

Then click the jumped github interface to download:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-O4XxDYgp-1668914120060)(../picture/image-20221120094842188.png)]

After downloading, it is actually a compressed package, unzip it to the same folder as the above tool, so that it can be used later when creating an Eclipse STM32 project.

1.5 J-Link driver installation

If you are using the J-Link debugger, you need to install the J-Link driver. You can go to J-Link official website to download:

https://www.segger.com/downloads/jlink/

The genuine J-Link debugger is relatively expensive. The latest version of the J-Link driver can identify whether the debugger we use is a pirated version, and then a warning dialog box will pop up every time we debug, which is very troublesome.

insert image description here

So you can choose a relatively old version of the J-Link driver.

After downloading, install all the way by default.

At this point, the software and some necessary tools are all ready.

2. Eclipse creates a new STM32 project and configures the environment

2.1 Create a new STM32 project

1. New construction

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-LY918uLE-1668914120060)(../picture/image-20221120101643582.png)]

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-Ti2NM9B4-1668914120060)(../picture/image-20221120101759329.png)]

2. Select the chip project type, compilation tool, etc.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-UduUS6wZ-1668914120060)(../picture/image-20221120102330465.png)]

3. Configure chip information, Flash size, board external crystal oscillator frequency, etc. These information are used to automatically generate corresponding link script files, as well as some configuration macro definitions.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-QJiodIiC-1668914120061)(../picture/image-20221120103011277.png)]

4. Define the project folder, the default is fine here, but don’t worry.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-KHnd4qBQ-1668914120061)(../picture/image-20221120103221252.png)]

5. Specify the cross-compilation toolchain path of this project.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-HtUAryYJ-1668914120061)(../picture/image-20221120103652123.png)]

Finally, click Finish to create the Eclipse STM32 project. At this time, some codes will be automatically generated.

2.2 Eclipse environment configuration

At this time, if we compile the newly created project, we will prompt some guarantees and report errors, saying that we don’t like the make tool very much. This is because some necessary environment configurations have not been performed yet.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-7um7BgBY-1668914120062)(../picture/image-20221120104337567.png)]

Next, some environment configuration is required.

1. Enter the attribute configuration interface.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-dyM7hVpP-1668914120062)(../picture/image-20221120104555604.png)]

2. Enable multi-threaded compilation.

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-jUOkNVes-1668914120062)(../picture/image-20221120105012931.png)]

3. Use the external make build tool, and specify the path of the tool.

Generally speaking, the external make build tool is used by default, so we only need to specify the make tool path.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-Y1ICFfQc-1668914120063)(../picture/image-20221120105250356.png)]

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-SbusdRh3-1668914120063)(../picture/image-20221120105545602.png)]

If it is an internal build tool, then select CDT Internal Builder. The above two options are generally selected by default as external build tools, so let’s check if something is right.

Next, you need to specify the path of the external make tool, and specify it in the bin directory.

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-4actnjYv-1668914120063)(../picture/image-20221120105918491.png)]

3. Compile the Eclipse STM32 project

After the above configuration is done, if there are no errors, it can generally be compiled and passed.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-tUEQ24IL-1668914120064)(../picture/image-20221120110355144.png)]

Then click the hammer to compile the project, the result is as follows:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-4foPtTtR-1668914120064)(../picture/image-20221120110450970.png)]

The prompt has been compiled successfully, but there is a warning, which is the warning output from the code automatically generated by Eclipse to create the STM32 project.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-3mZrMVoy-1668914120064)(../picture/image-20221120110616834.png)]

If we check that there is no problem with the system clock configuration, we can comment it out.

At this point, the creation of the Eclipse STM32 project has been completed. So how do we use Eclipse to debug and download programs to STM32? Isn't the openocd tool we downloaded earlier not used yet?

The following article then introduces how to use openocd to debug and download programs to STM32.

Guess you like

Origin blog.csdn.net/luobeihai/article/details/127946814