In the past two days, I have tried to build the stm32 development environment of eclipse + GNU arm Eclipse plug-in + sourcery g ++ Lite Edition for ARM + opencd + jlink, I also use Keil very well, mainly because I recently worked on a project to make it impossible to use a commercial environment. I searched almost all the information on the Internet and found that there was very little information. I sorted out some of my accumulated information and hoped to discuss it with you.
There should be no problem with the solution. I tried the commercial version of sourcery g ++, which is slightly different from Keil and can also be used with jlink for debugging, the following is how to use eclipse and sourcery g ++ Lite to implement the functions of its commercial version.
In order to make it easier for the following descriptions to have no images, the attachment should be detailed. The following is only a part of it. I will continue to organize the rest. You are welcome to discuss it.
Click here to download ourdev_599568t57dyi.rar (file size: 1.10 MB) (original file name: Environment details. rar)
1. Establish the environment
1.1 download and install eclipse
Eclipse is an open-source and Java-based scalable development platform. In itself, it is only a framework and a set of services, used to build a development environment through plug-in components. Because eclipse is only an IDE, you need to use other plug-ins and software to build a complete development environment, which is precisely because eclipse has great flexibility.
Therefore, first download and install eclipse ,:
Http://www.eclipse.org/downloads/
Download Page 1.1.
Figure 1.1 eclipse Download Page
Because it is developed for C, download the Eclipse IDE for C/C ++ developers version, which has integrated the CDT plug-in for C language development.
1.2 download and install JRE
The downloaded eclipse is a green software that does not need to be installed. You can run it directly by double-clicking it. However, because eclipse is developed based on Java, JDK or JRE must be installed in the system. Here, JRE is used, as follows:
Http://www.oracle.com/technetwork/java/javase/downloads/index.html
If you find it troublesome to download the official website, you can download it here:
Http://www.skycn.com/soft/27213.html
Java download interface 1.2.
Figure 1.2 Java Download Page
JDK is a Java Development Kit Used by developers. It provides a Java development environment and runtime environment. JRE is the Java runtime enviroment, which refers to the Java Runtime Environment and is intended for Java program users rather than developers. Therefore, you only need to install JRE. Because the Java Virtual Machine must be run in the background when running eclipse, the memory and CPU usage is large, and sometimes the comparison is slow.
1.3 download and install GNU arm Eclipse plug-in.
To build a development environment for arm, you also need to download the plug-in for ARM development so that you can create a project for ARM development. The GNU arm Eclipse plug-in is used here, as shown below:
Http://sourceforge.net/projects/gnuarmeclipse/
The download page is shown in Figure 1.3.
Figure 1.3 GNU arm Eclipse plug-in Download Page
After installing the plug-in by installing eclipse, you can create a new project to view the arm project, as shown in Figure 1.4.
Figure 1.4 create a project after installing the plug-in
1.4 download and install sourcery g ++ Lite
You have installed a tool before. To complete arm development, you also need to install a complete software development environment. for the support of the GNU arm Eclipse plug-in, see Figure 4, he supports four types of winarm, sourcery g ++ lite, yagarto, and devkitpro. The first two are more famous, winavr in the previous design of AVR and other Microcontroller has been used a lot, but also very convenient, but many versions before winarm does not support stm32 cortex-M3 kernel, although winarm_20080331_testing is supported, it is troublesome during testing. The supported version is not very good and the update has been stopped. Therefore, this solution is abandoned. Sourcery g ++ is a complete software development environment based on the GNU tool chain. It is still being updated. Compare and select sourcery g ++ as the development environment, sourcery g ++ is paid, but sourcery g ++ Lite is free. We use the free version. As follows:
Http://www.codesourcery.com/sgpp/lite/arm/portal/subscription? @ Template = Lite
The download page is shown in Figure 1.5.
Figure 1.5 software download page
On the download page, we can know that sourcery g ++ lite has a version of 4, where Eabi is developed for the underlying layer, that is, it does not contain any system. We will use this version. Sourcery g ++ lite uses the installation package. Compared with cygwin, which was previously used, it is very convenient to install it. You only need to click Next. After installation, eclipse can find it by yourself, you do not need to manually add environment variables.
This is a basic development environment. For stm32, we use the official Firmware Library of St, which can reduce the concern for the underlying hardware and shorten the development cycle, at the same time, it is conducive to the stability and standardization of the program. Therefore, we compile the Firmware Library in the established development environment. There are many versions of the St Firmware Library, and the differences between versions are also large, we are using version 3.1, which is relatively new, and St has been releasing new versions ,:
Http://www.st.com/stonline/products/support/micro/files
The development interface 1.6 contains the Firmware Library.
Figure 1.6 complete development environment interface
2. Engineering Configuration
2.1 create a project
Create a project using the configured development environment, as shown in figure 2.1.
Figure 2.1 create a project
After creating a new project, click Finish to enter the project interface. if the environment is correctly configured, the project automatically contains related files, as shown in figure 2.2. The file should be the installation directory of sourcery g ++ lite.
Figure 2.2 contains files after a new project is created
Next, prepare related files. For better development of stm32, I can use the Firmware Library provided by St to download it from the Internet. Now I am using the latest version 3.4, other versions may be similar.
The file name of the Firmware Library is stm32f10x_stdperiph_lib_v3.4.0. First, copy the stm32f10x_stdperiph_lib_v3.4.0/libraries folder to the directory of the created project file. This is the Firmware Library that needs to be called during compilation.
2.2 link and Startup File
Next, you need to find the LD file required by linker. Because st provides some compiler engineering templates in the Firmware Library, you can use the configuration file in the template. The folder truestudio contains several folders. Truestudio is the official st compiler and GCC, So it uses the configuration file in its template. Open stm32f10x_stdperiph_lib_v3.4.0/project/stm32f10x_stdperiph_template/truestudio and you can see that there are several folders in the directory, because I am using stm32f103zet6 so I select cmd_flash.ld under the STM3210E-EVAL file and open it through notepad, some content is excerpted as follows:
** File: pai_flash.ld
** Abstract: Linker script for stm32f103ze device
** 512 Kbyte flash, 64 Kbyte Ram
** Set heap size, stack size, and stack location according
** To application requirements.
** Set memory bank area and size if external memory is used.
I guess this is what I was looking for. copy the file to the project root directory.
Next, find the project Startup File. Like the linker file, open the directory as follows:
Workspace/gcctest/libraries/cmsis/cm3/devicesupport/ST/stm32f10x/startup/truestudio
There are also a lot of files in it, because I used the file stm32f103zet6, so I chose the file startup_stm32f10x_hd.s. I guess it corresponds to the large capacity of stm32, which should be consistent, note: Replace the extension with "S" and copy it to the "Startup" directory to delete all other unnecessary files.
2.3 other files
Create a new user folder in the root directory of the project and copy a routine to the file. Many routines are provided in the Firmware Library. I copied stm32f10x_stdperiph_lib_v3.4.0/project/stm32f10x_stdperiph_examples/gpio/iotoggle, copy all the files under iotoggle to the user folder. In this way, all the files are ready.
2.4 configuration project
Return to the eclipse interface and press F5 to refresh the current working directory. The file you just added will be displayed in the project window, as shown in 2.3.
Figure 2.3 project window after adding a file
If compilation is performed directly at this time, it is certain that an error occurs. Therefore, we need to set the project. Next, set the project, right-click the project, and select the "properties" menu. Click C/C ++ build-settings, as shown in Figure 2.4.
Figure 2.4 Setting page
Click target processor select all processor select cortex-m3, as shown in 2.5.
Figure 2.5 processor Selection
As shown in Figure 2.6, add two pre-defined libraries: stm32f10x_hd and use_stdperiph_driver. Stm32f10x_hd corresponds to the preceding link to the Startup File, indicating that it is a large capacity period (I guess ). Use_stdperiph_driver indicates that the firmware is used.
Figure 2.6 Add a pre-defined Compilation
Next, add the file inclusion path. In order to prevent the project from finding the corresponding header file, you need to add the corresponding path. The method is similar to the above. Click the Add button and select workspace on the path, in turn, the folders with header files under the project directory are included. 2.7.
Figure 2.7 Add a file inclusion path
Next, add the link file, as shown in Figure 2.8. Add the prepared link file.
Figure 2.8 add a link file
Http://www.ourdev.cn/bbs/bbs_content.jsp? Bbs_sn = 4406987 & bbs_page_no = 8 & bbs_id = 9999